using System; using System.Data; using System.Collections.Generic; using System.Text; using DSWeb.MvcShipping.Models.MsOp_InternalTrade; using Microsoft.Practices.EnterpriseLibrary.Data; using DSWeb.Areas.CommMng.Models; using HcUtility.Comm; using System.Web.Mvc;//ContentResult using DSWeb.TruckMng.Helper.Repository;//ModelObjectRepository using DSWeb.MvcShipping.Helper; using DSWeb.Areas.CommMng.DAL;//使用获取权限子句 using DSWeb.Areas.SysMng.DAL.SysTask; using DSWeb.Common.DB; using System.Linq; namespace DSWeb.Areas.MvcShipping.DAL.DJYORDER_CONTRACTNO { public class DJYORDER_CONTRACTNODAL { #region 大简云订舱 船公司合约 头表 查询 const string HeadSql = " SELECT * FROM DJYORDER_CONTRACTNO where 1=1 "; public static List GetDataList(int start, int limit, string sort, string condition, VW_user_md userinfo, ref int count) { //range var rangestr = GetRangDAStr(userinfo); //condition var strCondition = condition; var sortstring = DatasetSort.Getsortstring(sort); ; var param = new BasicDataRefDAL.PagedQuaryParam(); param.strSql = HeadSql; param.strCondition = strCondition; param.rangestr = rangestr; param.sortstring = sortstring; param.defaultsortstr = "CREATETIME desc"; param.start = start; param.limit = limit; var strSql = BasicDataRefDAL.PagedQuaryStr(param); count = BasicDataRefDAL.PagedCount(param); return SetData(strSql); } public static string GetDataListStr(string condition, VW_user_md userinfo) { //range var rangestr = GetRangDAStr(userinfo); //condition var strCondition = ""; var sortstring = ""; var param = new BasicDataRefDAL.PagedQuaryParam(); param.strSql = HeadSql; param.strCondition = strCondition; param.rangestr = rangestr; param.sortstring = sortstring; param.defaultsortstr = "ETA desc"; param.start = 0; param.limit = 9999; var strSql = BasicDataRefDAL.PagedQuaryStr(param); return strSql.ToString(); } private static List SetData(System.Text.StringBuilder strSql) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { DJYORDER_CONTRACTNO_md data = new DJYORDER_CONTRACTNO_md(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.CORPID = Convert.ToString(reader["CORPID"]); data.CARRIER = Convert.ToString(reader["CARRIER"]); data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]); data.ShipperName = Convert.ToString(reader["ShipperName"]); data.ShipperAddress = Convert.ToString(reader["ShipperAddress"]); data.ShipperCountry = Convert.ToString(reader["ShipperCountry"]); data.ShipperProvince = Convert.ToString(reader["ShipperProvince"]); data.ShipperCity = Convert.ToString(reader["ShipperCity"]); data.ShipperCounty = Convert.ToString(reader["ShipperCounty"]); data.ShipperPostCode = Convert.ToString(reader["ShipperPostCode"]); data.ShipperFirstName = Convert.ToString(reader["ShipperFirstName"]); data.ShipperLastName = Convert.ToString(reader["ShipperLastName"]); data.ShipperPhoneCountryCode = Convert.ToString(reader["ShipperPhoneCountryCode"]); data.ShipperPhoneCode = Convert.ToString(reader["ShipperPhoneCode"]); data.ShipperPhone = Convert.ToString(reader["ShipperPhone"]); data.REMARK = Convert.ToString(reader["REMARK"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } public static string GetRangDAStr(VW_user_md userinfo) { string str = ""; var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL "); strSql.Append(" from VW_User_Authority "); strSql.Append(" where [NAME]='modDJYORDER_CONTRACTNO' and USERID='" + userinfo.USERID + "' and ISDELETE=0"); string visiblerange = "4"; string operaterange = "4"; string AUTHORITYID = ""; string VSSQL = ""; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { visiblerange = Convert.ToString(reader["VISIBLERANGE"]); operaterange = Convert.ToString(reader["OPERATERANGE"]); AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]); VSSQL = Convert.ToString(reader["VSSQL"]); break; } reader.Close(); } if (visiblerange == "3" || visiblerange == "2"|| visiblerange == "5"|| visiblerange == "6") { visiblerange = "1"; } if (visiblerange == "4") { str = "1=2"; } //else if (visiblerange == "3") //{ // str = " (INPUTBY='" + userinfo.SHOWNAME + "' OR SALE='" + userinfo.SHOWNAME + "' )"; //} //else if (visiblerange == "2") //{ // str = $" (DEPT='{userinfo.deptgid}' or SALEDEPT='{userinfo.deptgid}') "; //} else if (visiblerange == "1") { str = $" UPPER(CORPID)='{userinfo.COMPANYID}' "; } else if (visiblerange == "5") { var userstr = new StringBuilder(); userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userinfo.USERID + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { str = ""; while (reader.Read()) { if (str == "") { str = $" (Corpid='{userinfo.COMPANYID}' "; } else { str = str + $" or Corpid='{userinfo.COMPANYID}' "; }; } str = str + ")"; reader.Close(); } } return str; } #endregion } public class DJYORDER_ACCOUNTINFODAL { #region 大简云订舱 船公司账号密码 头表 查询 const string HeadSql = " SELECT * FROM DJYORDER_ACCOUNTINFO where 1=1 "; public static List GetDataList(int start, int limit, string sort, string condition, VW_user_md userinfo, ref int count) { //range var rangestr = GetRangDAStr(userinfo); //condition var strCondition = condition; var sortstring = DatasetSort.Getsortstring(sort); ; var param = new BasicDataRefDAL.PagedQuaryParam(); param.strSql = HeadSql; param.strCondition = strCondition; param.rangestr = rangestr; param.sortstring = sortstring; param.defaultsortstr = "CREATETIME desc"; param.start = start; param.limit = limit; var strSql = BasicDataRefDAL.PagedQuaryStr(param); count = BasicDataRefDAL.PagedCount(param); return SetData(strSql); } public static string GetDataListStr(string condition, VW_user_md userinfo) { //range var rangestr = GetRangDAStr(userinfo); //condition var strCondition = ""; var sortstring = ""; var param = new BasicDataRefDAL.PagedQuaryParam(); param.strSql = HeadSql; param.strCondition = strCondition; param.rangestr = rangestr; param.sortstring = sortstring; param.defaultsortstr = "CREATETIME desc"; param.start = 0; param.limit = 9999; var strSql = BasicDataRefDAL.PagedQuaryStr(param); return strSql.ToString(); } private static List SetData(System.Text.StringBuilder strSql) { var bodyList = new List(); Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { DJYORDER_ACCOUNTINFO_md data = new DJYORDER_ACCOUNTINFO_md(); #region Set DB data to Object data.GID = Convert.ToString(reader["GID"]); data.CORPID = Convert.ToString(reader["CORPID"]); data.CARRIER = Convert.ToString(reader["CARRIER"]); data.ACCOUNT = Convert.ToString(reader["ACCOUNT"]); data.ACCOUNTPSW = Convert.ToString(reader["ACCOUNTPSW"]); data.BookingName = Convert.ToString(reader["BookingName"]); data.BookingAddress = Convert.ToString(reader["BookingAddress"]); data.BookingCountry = Convert.ToString(reader["BookingCountry"]); data.BookingProvince = Convert.ToString(reader["BookingProvince"]); data.BookingCity = Convert.ToString(reader["BookingCity"]); data.BookingCounty = Convert.ToString(reader["BookingCounty"]); data.BookingPostCode = Convert.ToString(reader["BookingPostCode"]); data.BookingFirstName = Convert.ToString(reader["BookingFirstName"]); data.BookingLastName = Convert.ToString(reader["BookingLastName"]); data.BookingPhoneCountryCode = Convert.ToString(reader["BookingPhoneCountryCode"]); data.BookingPhoneCode = Convert.ToString(reader["BookingPhoneCode"]); data.BookingPhone = Convert.ToString(reader["BookingPhone"]); data.REMARK = Convert.ToString(reader["REMARK"]); #endregion bodyList.Add(data); } reader.Close(); } return bodyList; } public static string GetRangDAStr(VW_user_md userinfo) { string str = ""; var strSql = new StringBuilder(); strSql.Append("SELECT "); strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID,VSSQL "); strSql.Append(" from VW_User_Authority "); strSql.Append(" where [NAME]='modDJYORDER_ACCOUNTINFO' and USERID='" + userinfo.USERID + "' and ISDELETE=0"); string visiblerange = "4"; string operaterange = "4"; string AUTHORITYID = ""; string VSSQL = ""; Database db = DatabaseFactory.CreateDatabase(); using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString())) { while (reader.Read()) { visiblerange = Convert.ToString(reader["VISIBLERANGE"]); operaterange = Convert.ToString(reader["OPERATERANGE"]); AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]); VSSQL = Convert.ToString(reader["VSSQL"]); break; } reader.Close(); } if (visiblerange == "3" || visiblerange == "2" || visiblerange == "5" || visiblerange == "6") { visiblerange = "1"; } if (visiblerange == "4") { str = "1=2"; } //else if (visiblerange == "3") //{ // str = " (INPUTBY='" + userinfo.SHOWNAME + "' OR SALE='" + userinfo.SHOWNAME + "' )"; //} //else if (visiblerange == "2") //{ // str = $" (DEPT='{userinfo.deptgid}' or SALEDEPT='{userinfo.deptgid}') "; //} else if (visiblerange == "1") { str = $" UPPER(CORPID)='{userinfo.COMPANYID}' "; } else if (visiblerange == "5") { var userstr = new StringBuilder(); userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userinfo.USERID + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); Database userdb = DatabaseFactory.CreateDatabase(); using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) { str = ""; while (reader.Read()) { if (str == "") { str = $" (Corpid='{userinfo.COMPANYID}' "; } else { str = str + $" or Corpid='{userinfo.COMPANYID}' "; }; } str = str + ")"; reader.Close(); } } return str; } #endregion } }