diff --git a/DSWeb/Areas/Account/Controllers/Chfee_invoiceapplicationController.cs b/DSWeb/Areas/Account/Controllers/Chfee_invoiceapplicationController.cs index 927a1b06..eaf03ace 100644 --- a/DSWeb/Areas/Account/Controllers/Chfee_invoiceapplicationController.cs +++ b/DSWeb/Areas/Account/Controllers/Chfee_invoiceapplicationController.cs @@ -310,7 +310,9 @@ namespace DSWeb.Areas.Account.Controllers result= modb.Save(headData); }; - if (result.Success == true) { } + if (result.Success == true) { + ChinvoiceapplicationDAL.SetSALECORP(headData.BILLNO); + } else { MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); diff --git a/DSWeb/Areas/Account/Controllers/Chfee_payapplicationController.cs b/DSWeb/Areas/Account/Controllers/Chfee_payapplicationController.cs index 0640f990..08547289 100644 --- a/DSWeb/Areas/Account/Controllers/Chfee_payapplicationController.cs +++ b/DSWeb/Areas/Account/Controllers/Chfee_payapplicationController.cs @@ -317,7 +317,7 @@ namespace DSWeb.Areas.Account.Controllers if (result.Success == true) { ChpayapplicationDAL.p_update_Amount(headData.BILLNO); - + ChpayapplicationDAL.SetSALECORP(headData.BILLNO); } else { @@ -382,7 +382,8 @@ namespace DSWeb.Areas.Account.Controllers var CHPAYMSG = MsSysParamSetDAL.GetData("PARAMNAME='CHPAYMSG'").PARAMVALUE; var modb = new ModelObjectDB(); - var _r = ChpayapplicationDAL.SetSALECORP(bill, bodyList, Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"])); + var bsnoList = bodyList.Select(s => s.BSNO).Distinct().ToList(); + var _r = ChpayapplicationDAL.SetSALECORP(bill, bsnoList); if (!_r.Success) { return BasicDataRefDAL.GetContentResult(_r); diff --git a/DSWeb/Areas/Account/Controllers/Chfee_recvapplicationController.cs b/DSWeb/Areas/Account/Controllers/Chfee_recvapplicationController.cs index 93f61817..11a8418f 100644 --- a/DSWeb/Areas/Account/Controllers/Chfee_recvapplicationController.cs +++ b/DSWeb/Areas/Account/Controllers/Chfee_recvapplicationController.cs @@ -153,9 +153,8 @@ namespace DSWeb.Areas.Account.Controllers public ContentResult Save(string opstatus, string data) { - - - var headData = JsonConvert.Deserialize(data); + + var headData = JsonConvert.Deserialize(data); if (opstatus == "add") { @@ -181,7 +180,6 @@ namespace DSWeb.Areas.Account.Controllers else headData.BILLNO = PubSysDAL.GetBillNo("0307"); } - } else if (opstatus == "edit") { @@ -207,7 +205,10 @@ namespace DSWeb.Areas.Account.Controllers var BILLNO = headData.BILLNO; var modb = new ModelObjectDB(); DBResult result = modb.Save(headData); - if (result.Success == true) { } + if (result.Success == true) { + //保存后处理 + ChrecvapplicationDAL.SetSALECORP(headData.BILLNO); + } else { MsSysBillNoSetDAL.DeleteBsNo(headData.BILLNO); @@ -234,7 +235,7 @@ namespace DSWeb.Areas.Account.Controllers //如果头表所属分部为空 将其设置为所选业务的销售人员所属的公司 并保存; //如果头表所属分部不为空 判断所属分部与所选业务的销售人员所属的公司是否相同 如否则返回错误; var bsnoList = bodyList.Select(s => s.BSNO).Distinct().ToList(); - var _r = ChrecvapplicationDAL.SetSALECORP(bill, bsnoList, "", Convert.ToString(Session["COMPANYID"]), Convert.ToString(Session["USERID"])); + var _r = ChrecvapplicationDAL.SetSALECORP(bill, bsnoList); if (!_r.Success) { diff --git a/DSWeb/Areas/Account/DAL/Chfee_ForeignPay/Chfee_ForeignPayDAL.cs b/DSWeb/Areas/Account/DAL/Chfee_ForeignPay/Chfee_ForeignPayDAL.cs index b7287321..ce1d5b92 100644 --- a/DSWeb/Areas/Account/DAL/Chfee_ForeignPay/Chfee_ForeignPayDAL.cs +++ b/DSWeb/Areas/Account/DAL/Chfee_ForeignPay/Chfee_ForeignPayDAL.cs @@ -1880,9 +1880,10 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Payapplication else if (visiblerange == "2") { var rangeDa = new RangeDA(); - var deptname = rangeDa.GetDEPTNAME(userid); - str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') and APPLICANT in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"; - + //var deptname = rangeDa.GetDEPTNAME(userid); + //str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') and APPLICANT in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"; + var deptgid = rangeDa.GetDEPTGID(userid); + str = " APPLICANT in (select USERID from vw_user where deptgid='" + deptgid + "') "; } else if (visiblerange == "1") { diff --git a/DSWeb/Areas/Account/DAL/Chfee_Invoicehexiao/Chfee_InvoicehexiaoDAL.cs b/DSWeb/Areas/Account/DAL/Chfee_Invoicehexiao/Chfee_InvoicehexiaoDAL.cs index 9c841b46..c2bdbf7c 100644 --- a/DSWeb/Areas/Account/DAL/Chfee_Invoicehexiao/Chfee_InvoicehexiaoDAL.cs +++ b/DSWeb/Areas/Account/DAL/Chfee_Invoicehexiao/Chfee_InvoicehexiaoDAL.cs @@ -2548,13 +2548,14 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoicehexiao else if (visiblerange == "2") { var rangeDa = new RangeDA(); - var deptname = rangeDa.GetDEPTNAME(userid); - str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') and APPLICANT in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"; - - } + //var deptname = rangeDa.GetDEPTNAME(userid); + //str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') and APPLICANT in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"; + var deptgid = rangeDa.GetDEPTGID(userid); + str = " APPLICANT in (select USERID from vw_user where deptgid='" + deptgid + "') "; + } else if (visiblerange == "1") { - str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "')"; + str = " SALECORPID='"+ companyid + "' or APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "')"; } else if (visiblerange == "0") { @@ -2642,13 +2643,14 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoicehexiao str = ""; while (reader.Read()) { + var _corpid = Convert.ToString(reader["COMPANYID"]); if (str == "") { - str = " (OP in (select showname from vw_user where COMPANYID='" + companyid + "') "; + str = " (OP in (select showname from vw_user where COMPANYID='" + _corpid + "') "; } else { - str = str + " or OP in (select showname from vw_user where COMPANYID='" + companyid + "')"; + str = str + " or OP in (select showname from vw_user where COMPANYID='" + _corpid + "')"; }; } str = str + ")"; diff --git a/DSWeb/Areas/Account/DAL/Chfee_invoice/Chfee_InvoiceDAL.cs b/DSWeb/Areas/Account/DAL/Chfee_invoice/Chfee_InvoiceDAL.cs index f80584c6..580e7f10 100644 --- a/DSWeb/Areas/Account/DAL/Chfee_invoice/Chfee_InvoiceDAL.cs +++ b/DSWeb/Areas/Account/DAL/Chfee_invoice/Chfee_InvoiceDAL.cs @@ -4563,13 +4563,14 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice str = ""; while (reader.Read()) { + var _corpid = Convert.ToString(reader["COMPANYID"]); if (str == "") { - str += " (CREATEUSER='"+ userid + "' or COMPANYID='" + companyid + "' "; + str += " (CREATEUSER='"+ userid + "' or COMPANYID='" + _corpid + "' "; } else { - str += " or COMPANYID='" + companyid + "' "; + str += " or COMPANYID='" + _corpid + "' "; }; } str = str + ")"; diff --git a/DSWeb/Areas/Account/DAL/Chfee_invoice_HangXin/Chfee_InvoiceDAL.cs b/DSWeb/Areas/Account/DAL/Chfee_invoice_HangXin/Chfee_InvoiceDAL.cs index 8485841e..38c3a971 100644 --- a/DSWeb/Areas/Account/DAL/Chfee_invoice_HangXin/Chfee_InvoiceDAL.cs +++ b/DSWeb/Areas/Account/DAL/Chfee_invoice_HangXin/Chfee_InvoiceDAL.cs @@ -4559,7 +4559,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin } else if (visiblerange == "1") { - str = " COMPANYID='" + companyid + "' "; + str = " COMPANYID='" + companyid + "' or SALECORPID='"+ companyid + "' "; } else if (visiblerange == "5") { @@ -4572,13 +4572,14 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoice_HangXin str = ""; while (reader.Read()) { + var _corpid = Convert.ToString(reader["COMPANYID"]); if (str == "") { - str = " (CREATEUSER in (select USERID from user_company where COMPANYID='" + companyid + "') "; + str = $" (CREATEUSER='{userid}' or SALECORPID='" + _corpid + "' "; } else { - str = str + " or CREATEUSER in (select USERID from user_company where COMPANYID='" + companyid + "')"; + str = str + $" or SALECORPID='" + _corpid + "'"; }; } str = str + ")"; diff --git a/DSWeb/Areas/Account/DAL/Chfee_invoiceapplication/Chfee_InvoiceapplicationDAL.cs b/DSWeb/Areas/Account/DAL/Chfee_invoiceapplication/Chfee_InvoiceapplicationDAL.cs index ecdddcd7..28961ff8 100644 --- a/DSWeb/Areas/Account/DAL/Chfee_invoiceapplication/Chfee_InvoiceapplicationDAL.cs +++ b/DSWeb/Areas/Account/DAL/Chfee_invoiceapplication/Chfee_InvoiceapplicationDAL.cs @@ -1688,6 +1688,14 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoiceapplication return SetSALECORP(billno, bsnolist); } + public static DBResult SetSALECORP(string billno) + { + var cdc = new CommonDataContext(); + //var head = cdc.ch_fee_invoiceapplication.FirstOrDefault(x => x.BILLNO == billno); + var body = cdc.ch_fee_do.Where(x => x.BILLNO == billno).ToList(); + var bsnoList = body.Select(s => s.BSNO).Distinct().ToList(); + return SetSALECORP(billno, bsnoList); + } public static DBResult AddDetail(string billno, List bodyList, string curr, string companyid,bool isList,string GID,ChInvoiceapplication headdata) { var result = new DBResult(); @@ -3182,9 +3190,10 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Invoiceapplication else if (visiblerange == "2") { var rangeDa = new RangeDA(); - var deptname = rangeDa.GetDEPTNAME(userid); - str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') and APPLICANT in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"; - + //var deptname = rangeDa.GetDEPTNAME(userid); + //str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') and APPLICANT in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')"; + var deptgid = rangeDa.GetDEPTGID(userid); + str = " APPLICANT in (select USERID from vw_user where deptgid='" + deptgid + "') "; } else if (visiblerange == "5") { diff --git a/DSWeb/Areas/Account/DAL/Chfee_payapplication/Chfee_PayapplicationDAL.cs b/DSWeb/Areas/Account/DAL/Chfee_payapplication/Chfee_PayapplicationDAL.cs index eb41f759..8f9e8007 100644 --- a/DSWeb/Areas/Account/DAL/Chfee_payapplication/Chfee_PayapplicationDAL.cs +++ b/DSWeb/Areas/Account/DAL/Chfee_payapplication/Chfee_PayapplicationDAL.cs @@ -1951,11 +1951,11 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Payapplication /// /// /// - public static DBResult SetSALECORP(string billno, List feelist, string companyid, string userid, bool custgroup = false) + public static DBResult SetSALECORP(string billno, List bsnoList) { var result = new DBResult(); result.OK(); - var bsnoList = feelist.Select(s => s.BSNO).Distinct().ToList(); + //var bsnoList = feelist.Select(s => s.BSNO).Distinct().ToList(); var cdc = new CommonDataContext(); @@ -1998,10 +1998,18 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Payapplication if (!custgroup) feesql = feesql + " AND CUSTOMERNAME='" + billcust + "'"; var feelist = GetFeeDetailList(feesql, userid, userid, companyid); - - return SetSALECORP(billno, feelist, companyid, userid, custgroup); + var bsnoList = feelist.Select(s => s.BSNO).Distinct().ToList(); + return SetSALECORP(billno, bsnoList); } + public static DBResult SetSALECORP(string billno) + { + var cdc = new CommonDataContext(); + //var head = cdc.ch_fee_payapplication.FirstOrDefault(x => x.BILLNO == billno); + var body = cdc.ch_fee_do.Where(x => x.BILLNO == billno).ToList(); + var bsnoList = body.Select(s => s.BSNO).Distinct().ToList(); + return SetSALECORP(billno, bsnoList); + } public static DBResult AddDetail(string billno, List bodyList, string curr, string companyid,string salecorp) { @@ -3857,7 +3865,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Payapplication } else if (visiblerange == "1") { - str = " APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "')"; + str = " SALECORPID='"+ companyid + "' or APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "')"; } else if (visiblerange == "5") { diff --git a/DSWeb/Areas/Account/DAL/Chfee_recvapplication/Chfee_RecvapplicationDAL.cs b/DSWeb/Areas/Account/DAL/Chfee_recvapplication/Chfee_RecvapplicationDAL.cs index 19561a9f..e5abc856 100644 --- a/DSWeb/Areas/Account/DAL/Chfee_recvapplication/Chfee_RecvapplicationDAL.cs +++ b/DSWeb/Areas/Account/DAL/Chfee_recvapplication/Chfee_RecvapplicationDAL.cs @@ -931,7 +931,7 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Recvapplication /// /// /// - public static DBResult SetSALECORP(string billno, List bsnoList, string billcust, string companyid, string userid, bool custgroup = false) + public static DBResult SetSALECORP(string billno, List bsnoList) { var result = new DBResult(); @@ -986,7 +986,16 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Recvapplication var bsnoList = feelist.Select(s => s.BSNO).Distinct().ToList(); - return SetSALECORP(billno, bsnoList, billcust, companyid, userid, custgroup); + return SetSALECORP(billno, bsnoList); + } + + public static DBResult SetSALECORP(string billno) + { + var cdc = new CommonDataContext(); + //var head = cdc.ch_fee_recvapplication.FirstOrDefault(x => x.BILLNO == billno); + var body = cdc.ch_fee_do.Where(x => x.BILLNO == billno).ToList(); + var bsnoList = body.Select(s => s.BSNO).Distinct().ToList(); + return SetSALECORP(billno, bsnoList); } public static DBResult AddBill(string billno, string billcust, string billcurr, string feesql, List exratelist, string companyid,string userid, bool custgroup = false) diff --git a/DSWeb/Areas/Account/DAL/Chfee_settlement/Chfee_SettlementDAL.cs b/DSWeb/Areas/Account/DAL/Chfee_settlement/Chfee_SettlementDAL.cs index a5155150..7122fc55 100644 --- a/DSWeb/Areas/Account/DAL/Chfee_settlement/Chfee_SettlementDAL.cs +++ b/DSWeb/Areas/Account/DAL/Chfee_settlement/Chfee_SettlementDAL.cs @@ -4334,7 +4334,8 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement if (OPLISTNOCANCEL.PARAMVALUE == "1") { strSql.Append(" FROM ch_fee_recvapplication cm where BILLSTATUS IN (0,4,5) "); - } else strSql.Append(" FROM ch_fee_recvapplication cm where BILLSTATUS IN (0,2,4,5) "); + } else + strSql.Append(" FROM ch_fee_recvapplication cm where BILLSTATUS IN (0,2,4,5) "); if (!string.IsNullOrEmpty(strCondition)) { @@ -7043,26 +7044,27 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement else if (visiblerange == "5") { - var userstr = new StringBuilder(); - userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); - Database userdb = DatabaseFactory.CreateDatabase(); - using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) + var userstr = new StringBuilder(); + userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); + Database userdb = DatabaseFactory.CreateDatabase(); + using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) + { + str = ""; + while (reader.Read()) { - str = ""; - while (reader.Read()) + var _corpid = Convert.ToString(reader["COMPANYID"]); + if (str == "") { - if (str == "") - { - str = " (APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') "; - } - else - { - str = str + " or APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "')"; - }; + str = " (SALECORPID='" + _corpid + "' "; } - str = str + ")"; - reader.Close(); + else + { + str = str + " or SALECORPID='" + _corpid + "' "; + }; } + str = str + ")"; + reader.Close(); + } } @@ -7172,26 +7174,27 @@ namespace DSWeb.Areas.Account.DAL.Chfee_Settlement else if (visiblerange == "5") { - var userstr = new StringBuilder(); - userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); - Database userdb = DatabaseFactory.CreateDatabase(); - using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) + var userstr = new StringBuilder(); + userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1"); + Database userdb = DatabaseFactory.CreateDatabase(); + using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString())) + { + str = ""; + while (reader.Read()) { - str = ""; - while (reader.Read()) + var _corpid= Convert.ToString(reader["COMPANYID"]); + if (str == "") { - if (str == "") - { - str = " (APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "') "; - } - else - { - str = str + " or APPLICANT in (select USERID from user_company where COMPANYID='" + companyid + "')" ; - }; + str = " (SALECORPID='"+ _corpid + "' "; } - str = str + ")"; - reader.Close(); + else + { + str = str + " or SALECORPID='"+ _corpid + "' " ; + }; } + str = str + ")"; + reader.Close(); + } }