public AjaxResult ConAdd([FromBody] dynamic Json) { #region 参数 string ZCCode = Json.ZCCode == null ? "01" : Json.ZCCode; //政策编码 string ConName = Json.ConName; //合同名称 string ConType = Json.ConType; //合同类型ID string Currency = Json.Currency; //货币类型ID string ConsingDT = Json.ConsingDT; //签署日期 string ConeffeDT = Json.ConeffeDT; //计划有效日期 string ConinvalidDT = Json.ConinvalidDT; //计划失效日期 string ShipVia = Json.ShipVia; //发运方式ID string Remark = Json.Remark; //备注 string CGID = Json.CGID; //收货单位 string STATION = Json.STATION; //站点 string SalesEmpID = Json.SalesEmpID; //业务员ID string Addr = Json.Addr; //收货地址 string OTCID = Json.OTCID; //开票单位 string CustID = Json.CustID; //客户 #endregion #region //数据操作 AjaxResult result = new AjaxResult(); List <Mod_TMO_ORDER> orderList = new List <Mod_TMO_ORDER>(); DataTable dt = ts_user.GetSaleDept(SalesEmpID).Tables[0]; Mod_TS_USER modUser = GetUserID(); Mod_TMO_CON mod = new Mod_TMO_CON(); string conNo = randomnumber.CreateConNo(ZCCode); //合同号 mod.C_CON_XH = conNo; //合同序号 mod.C_CON_NO = conNo; //合同号 mod.C_CON_NAME = ConName; //合同名称 mod.C_CONTYPEID = ConType; //合同类型ID mod.C_CURRENCYTYPEID = Currency; //货币类型ID mod.D_CONSING_DT = Convert.ToDateTime(ConsingDT); //签署日期 mod.D_CONEFFE_DT = Convert.ToDateTime(ConeffeDT); //计划有效日期 mod.D_CONINVALID_DT = Convert.ToDateTime(ConinvalidDT); //计划失效日期 //mod.D_NEED_DT = Convert.ToDateTime(ConinvalidDT).AddDays(-30);//需求日期 mod.C_TRANSMODEID = ShipVia; //发运方式ID mod.C_AREA = dt.Rows[0]["AREA"].ToString(); //合同区域 mod.C_REAMRK = Remark; //备注 mod.C_CRECEIPTCUSTOMERID = CGID; //收货单位ID mod.C_CRECEIPTCORPID = OTCID; //开票单位ID mod.C_STATION = STATION; //站点 mod.C_EMPLOYEEID = SalesEmpID; //业务员ID mod.C_DEPTID = dt.Rows[0]["C_DEPTID"].ToString(); //业务部门 if (!string.IsNullOrEmpty(CGID)) { Mod_TS_CUSTFILE modCust = ts_custfile.GetCustModel(CGID); mod.C_ADDRESS = Addr; //收货地址 mod.C_CRECEIPTAREAID = modCust.C_AREATYPE; //收货地区 } Mod_TS_CUSTFILE modCustfile = CustID == "" ? ts_custfile.GetModel(modUser.C_CUST_ID) : ts_custfile.GetCustModel(CustID); mod.C_CUSTOMERID = modCustfile.C_NC_M_ID; //NCID mod.C_CUSTNAME = modCustfile.C_NAME; mod.C_CUST_NO = modCustfile.C_NO; //客户编码 mod.C_COPERATORID = SalesEmpID; //制单人 mod.C_EMP_ID = modUser.C_ID; mod.C_EMP_NAME = modUser.C_NAME; mod.N_CUST_LEV = modCustfile.N_LEVEL; mod.N_CHANGENUM = 0;//变更次数默认0 if (tmo_con.InsertConOrder(mod, orderList)) { result.Code = DoResult.Success; result.Result = conNo; } else { result.Code = DoResult.Failed; result.Result = "提交失败"; } #endregion return(result); }
/// <summary> /// 新增合同 /// </summary> /// <param name="N_STATUS">合同状态</param> /// <returns></returns> private bool Add(int N_STATUS) { bool result = true; List <Mod_TMO_ORDER> orderList = new List <Mod_TMO_ORDER>(); #region //添加合同基本信息 Mod_TMO_CON modCon = new Mod_TMO_CON(); Mod_TS_DEPT modDept = ts_dept.GetModel(hiddeptid.Value); string areaCode = dropConPolicyArea.SelectedItem.Value == "" ? "01" : dropConPolicyArea.SelectedItem.Value; conNo = randomnumber.CreateConNo(areaCode); //合同号 modCon.C_CON_XH = conNo; modCon.C_CON_NO = conNo; //合同号 modCon.C_CON_NAME = txtConName.Text; //合同名称 modCon.C_CONTYPEID = dropConType.SelectedItem.Value; //合同类型 modCon.C_CUSTOMERID = hidCustID.Value; //客户ID modCon.C_CUSTNAME = txtCustName.Text; //客户名称 modCon.C_CUST_NO = hidCustNO.Value; //客户客户编码 modCon.C_EMPLOYEEID = hidsaleempid.Value; //业务员ID modCon.C_DEPTID = hiddeptid.Value; //业务部门 if (!string.IsNullOrEmpty(hiddeptid.Value)) { Mod_TS_DEPT moddept = ts_dept.GetModel(hiddeptid.Value); modCon.C_AREA = moddept.C_NAME; //部门 } modCon.C_CURRENCYTYPEID = dropCurrType.SelectedValue; //货币 modCon.D_CONSING_DT = Convert.ToDateTime(txtDate.Value); //签署日期 modCon.D_CONEFFE_DT = Convert.ToDateTime(txtStart.Value); //计划生效日期 modCon.D_CONINVALID_DT = Convert.ToDateTime(txtEnd.Value); //计划失效日期 modCon.C_TRANSMODEID = dropShipVia.SelectedValue; //发运方式 modCon.N_STATUS = N_STATUS; modCon.C_EMP_ID = ltlC_EMP_ID.Text; modCon.C_EMP_NAME = ltlC_EMP_NAME.Text; modCon.N_CUST_LEV = Convert.ToDecimal(ltlCustLEV.Text);//客户等级 if (!string.IsNullOrEmpty(hidC_CGID.Value)) { Mod_TS_CUSTFILE modCust = ts_custfile.GetCustModel(hidC_CGID.Value); modCon.C_CRECEIPTCUSTOMERID = hidC_CGID.Value; //收货单位 modCon.C_ADDRESS = txtAddr.Value; //收货地址 modCon.C_CRECEIPTAREAID = modCust.C_AREATYPE; //收货地区 } modCon.C_CRECEIPTCORPID = hidC_OTCID.Value; //开票单位 modCon.C_STATION = txtC_STATION.Value; //站点 modCon.C_REAMRK = txtReamrk.Value; modCon.N_CHANGENUM = 0; //合同变更次数 #endregion #region//添加合同明细 for (int i = 0; i < rptList.Items.Count; i++) { Literal ltlC_ID = (Literal)rptList.Items[i].FindControl("ltlC_ID"); //物料ID Literal ltlC_TECH_PROT = (Literal)rptList.Items[i].FindControl("ltlC_TECH_PROT"); //客户协议号 Literal ltlC_STD_CODE = (Literal)rptList.Items[i].FindControl("ltlC_STD_CODE"); //执行标准 Literal ltlzyx1 = (Literal)rptList.Items[i].FindControl("ltlzyx1"); //自由项1 Literal ltlzyx2 = (Literal)rptList.Items[i].FindControl("ltlzyx2"); //自由项2 Literal ltlC_IS_BXG = (Literal)rptList.Items[i].FindControl("ltlC_IS_BXG"); //执行标准 TextBox txtPack_Code = (TextBox)rptList.Items[i].FindControl("txtPack_Code"); //包装要求 TextBox txtC_PRO_USE = (TextBox)rptList.Items[i].FindControl("txtC_PRO_USE"); //产品用途 TextBox txtC_CUST_SQ = (TextBox)rptList.Items[i].FindControl("txtC_CUST_SQ"); //特殊要求 DropDownList dropZL = (DropDownList)rptList.Items[i].FindControl("dropZL"); //质量 HtmlInputText txtWgt = (HtmlInputText)rptList.Items[i].FindControl("txtWgt"); //数量 HtmlInputText txtPrice = (HtmlInputText)rptList.Items[i].FindControl("txtPrice"); //含税单价 if (dropConPolicyArea.SelectedItem.Text != "钢坯") { if (string.IsNullOrEmpty(txtPack_Code.Text) && tqb_pack.Exists(txtPack_Code.Text)) { result = false; break; } } #region //合同明细 Mod_TB_MATRL_MAIN modMat = tb_matrl_main.GetModel(ltlC_ID.Text); Mod_TMO_ORDER modOrder = new Mod_TMO_ORDER(); //订单表 string order_no = randomnumber.CreateOrderNo(conNo); //订单号 modOrder.C_ORDER_NO = order_no; modOrder.C_CON_NO = modCon.C_CON_NO; //合同号 modOrder.C_CON_NAME = modCon.C_CON_NAME; //合同名称 modOrder.C_AREA = modCon.C_AREA; //区域 modOrder.C_INVBASDOCID = modMat.C_PK_INVBASDOC; //存货档案主键 modOrder.C_INVENTORYID = modMat.C_PK_INVMANDOC; //存货管理档案主键 modOrder.C_PROD_NAME = modMat.C_PROD_NAME; //品名 modOrder.C_PROD_KIND = modMat.C_PROD_KIND; //品种 modOrder.C_MAT_CODE = modMat.C_MAT_CODE; //物料编码 modOrder.C_MAT_NAME = modMat.C_MAT_NAME; //物料名称 modOrder.C_SPEC = modMat.C_SPEC; //规格 modOrder.C_STL_GRD = modMat.C_MAT_TYPE == "841" ? modMat.C_MAT_NAME : modMat.C_MAT_TYPE == "851" ? modMat.C_MAT_NAME : modMat.C_STL_GRD; //钢种 modOrder.C_FUNITID = modMat.C_FJLDW; //辅单位 modOrder.C_UNITID = modMat.C_PK_MEASDOC; //主计量单位 modOrder.D_DELIVERY_DT = modCon.D_CONINVALID_DT; //计划交货日期 modOrder.D_DT = modCon.D_CONSING_DT; //订单日期//签单日期 modOrder.C_VDEF1 = dropZL.SelectedItem.Value; //质量主键ID modOrder.C_SFPJ = "N"; modOrder.C_TECH_PROT = ltlC_TECH_PROT.Text; //客户协议号 modOrder.C_FREE1 = ltlzyx1.Text; //自由项1 modOrder.C_FREE2 = ltlzyx2.Text; //自由项2 modOrder.C_STD_CODE = ltlC_STD_CODE.Text; //执行标准 modOrder.C_BY4 = ltlC_IS_BXG.Text; //是否不锈钢 modOrder.N_TYPE = Convert.ToDecimal(modMat.C_MAT_TYPE); //订单类型 modOrder.C_PACK = txtPack_Code.Text.Trim(); //包装要求 Mod_TMB_TAXITEMS modTaxi = tmb_taxitems.GetModel(modMat.C_PK_TAXITEMS); decimal shuolv = Convert.ToDecimal(modTaxi.N_TAXRATIO) >= 1 ? Convert.ToDecimal(modTaxi.N_TAXRATIO) / 100 : Convert.ToDecimal(modTaxi.N_TAXRATIO); //税率 modOrder.N_TAXRATE = shuolv; //税率 decimal N_WGT = 0; if (!string.IsNullOrEmpty(txtWgt.Value)) { N_WGT = Convert.ToDecimal(txtWgt.Value); } modOrder.N_WGT = N_WGT; //数量 modOrder.N_HSL = modMat.N_HSL == null ? 0 : modMat.N_HSL; //换算率 modOrder.N_FNUM = modMat.N_HSL == null ? 1 : N_WGT / modMat.N_HSL; //辅数量 #region //获取钢种单价-税率 if (!string.IsNullOrEmpty(txtPrice.Value)) { decimal N_TAXRATE = Convert.ToDecimal(modOrder.N_TAXRATE) + 1; //税率 decimal N_ORIGINALCURPRICE = Convert.ToDecimal(txtPrice.Value) / N_TAXRATE; //原币无税单价 decimal N_ORIGINALCURTAXPRICE = Convert.ToDecimal(txtPrice.Value); //原币含税单价 decimal N_ORIGINALCURMNY = decimal.Round(N_WGT * N_ORIGINALCURPRICE, 2); //原币无税金额 decimal N_ORIGINALCURSUMMNY = N_WGT * N_ORIGINALCURTAXPRICE; //原币价税合计 decimal N_ORIGINALCURTAXMNY = decimal.Round(N_ORIGINALCURSUMMNY - N_ORIGINALCURMNY, 2); //原币税额 modOrder.N_ORIGINALCURPRICE = N_ORIGINALCURPRICE; //原币无税单价 modOrder.N_ORIGINALCURTAXPRICE = N_ORIGINALCURTAXPRICE; //原币含税单价 modOrder.N_ORIGINALCURTAXMNY = N_ORIGINALCURTAXMNY; //原币税额 modOrder.N_ORIGINALCURMNY = N_ORIGINALCURMNY; //原币无税金额 modOrder.N_ORIGINALCURSUMMNY = N_ORIGINALCURSUMMNY; //原币价税合计 } #endregion modOrder.C_RECEIPTAREAID = modCon.C_CRECEIPTAREAID; //收货地区 modOrder.C_RECEIVEADDRESS = modCon.C_ADDRESS; //收货地址 modOrder.C_RECEIPTCORPID = modCon.C_CRECEIPTCUSTOMERID; //收货单位 modOrder.C_CURRENCYTYPEID = modCon.C_CURRENCYTYPEID; //货币 modOrder.N_USER_LEV = modCon.N_CUST_LEV; //客户等级 modOrder.C_CUST_SQ = txtC_CUST_SQ.Text; //客户要求 modOrder.C_PRO_USE = txtC_PRO_USE.Text; //产品用途 modOrder.C_EMP_ID = modCon.C_EMP_ID; modOrder.C_EMP_NAME = modCon.C_EMP_NAME; modOrder.C_CUST_NO = hidCustNO.Value; modOrder.C_CUST_NAME = txtCustName.Text; modOrder.C_SALE_CHANNEL = ltlCustType.Text; modOrder.C_LEV = GetLev("STL_GRD_Lev"); //钢种等级 modOrder.C_ORDER_LEV = GetLev("Order_Lev"); //订单等级 modOrder.N_COST = 0; //成本 modOrder.C_TRANSMODE = dropShipVia.SelectedItem.Text; //发运方式 modOrder.C_TRANSMODEID = dropShipVia.SelectedItem.Value; //发运方式主键 modOrder.C_YWY = txtSaleUser.Value; //业务员姓名 modOrder.N_STATUS = N_STATUS; orderList.Add(modOrder); #endregion } #endregion return(result == true?tmo_con.InsertConOrder(modCon, orderList) : result); }