/// <summary> /// 插入销售订单 /// </summary> /// <param name="parem">合同参数列表,返回DataTable:ID,CODE</param> /// <returns></returns> public DataTable InsertSaleOrder(List <string> parem) { //初始化DataTable DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(string)); //主键 dt.Columns.Add("CODE", typeof(string)); //单据号 Dal_TMO_CON tmo_con = new Dal_TMO_CON(); Dal_TMO_CONDETAILS tmo_condetails = new Dal_TMO_CONDETAILS(); ArrayList strSql = new ArrayList(); if (parem.Count > 0) { for (int i = 0; i < parem.Count; i++) { Mod_TMO_CON modCon = tmo_con.GetModel(parem[i]); Mod_TMO_SALEORDER modSale = new Mod_TMO_SALEORDER(); #region //销售订单主表 string pk_mainid = Guid.NewGuid().ToString("N"); //主键ID string code = Dal_RandomNumber.GetSaleCode(); //销售单据号 dt.Rows.Add(new object[] { pk_mainid, code }); StringBuilder cmdText = new StringBuilder(); cmdText.Append("insert into TMO_SALEORDER("); cmdText.Append("C_ID,C_CODE,C_CONNO,C_INITIALIZE_ID,C_BIZTYPE,D_BILLDATE,C_CUSTOMERID,C_DEPTID,C_EMPLOYEEID,C_OPERATORID,C_SALECORPID,C_RECEIPTCUSTOMERID,C_RECEIVEADDRESS,C_RECEIPTCORPID,C_TRANSMODEID,D_MAKEDATE,C_APPROVEID,D_APPROVEDATE)"); cmdText.Append(" values ("); cmdText.Append("'" + pk_mainid + "',"); //主键ID cmdText.Append("'" + code + "',"); //销售单据号 cmdText.Append("'" + modCon.C_CON_NO + "',"); //合同号 cmdText.Append("'',"); //方案表主键 cmdText.Append("'" + modCon.C_BIZTYPE + "',"); //业务类型ID cmdText.Append("to_date('" + DateTime.Now + "','yyyy-mm-dd hh24:mi:ss'),"); //单据日期 cmdText.Append("'" + modCon.C_CUSTOMERID + "',"); //客户ID-NC客商管理档案主键 cmdText.Append("'" + modCon.C_DEPTID + "',"); //部门ID cmdText.Append("'" + modCon.C_EMPLOYEEID + "',"); //业务员ID cmdText.Append("'" + modCon.C_COPERATORID + "',"); //制单人ID cmdText.Append("'" + modCon.C_SALECORPID + "',"); //销售组织ID cmdText.Append("'" + modCon.C_CRECEIPTCUSTOMERID + "',"); //收货单位 cmdText.Append("'" + modCon.C_ADDRESS + "',"); //收货地址 cmdText.Append("'" + modCon.C_CRECEIPTAREAID + "',"); //开票单位ID-来源与客户档案信息 cmdText.Append("'" + modCon.C_TRANSMODEID + "',"); //发运方式ID cmdText.Append("to_date('" + modCon.D_DMAKEDATE + "','yyyy-mm-dd hh24:mi:ss'),"); //制单日期 cmdText.Append("'" + modCon.C_APPROVEID + "',"); //审批人 cmdText.Append("to_date('" + modCon.D_APPROVEDATE + "','yyyy-mm-dd hh24:mi:ss')"); //审批日期 cmdText.Append(")"); strSql.Add(cmdText.ToString()); #endregion DataTable dtOrder = tmo_condetails.GetConOrderList(parem[i], "").Tables[0]; if (dtOrder.Rows.Count > 0) { for (int k = 0; k < dtOrder.Rows.Count; k++) { #region //插入销售订单子表 Mod_TMO_CONDETAILS modOrder = tmo_condetails.GetModel(dtOrder.Rows[k]["C_NO"].ToString()); string pk_itemid = Guid.NewGuid().ToString("N"); //主键 StringBuilder cmdText2 = new StringBuilder(); cmdText2.Append("insert into TMO_SALEORDERITEM("); cmdText2.Append("C_ID,C_BILLID,C_ORDERNO,C_CONNO,C_INVBASDOCID,C_INVENTORYID,C_UNITID,C_FUNITID,N_NUMBER,D_CONSIGNDATE,D_DELIVERDATE,C_CURRENCYTYPEID,N_TAXRATE,N_ORIGINALCURPRICE,N_ORIGINALCURTAXPRICE,N_ORIGINALCURTAXMNY,N_ORIGINALCURMNY,N_ORIGINALCURSUMMNY,C_RECEIPTAREAID,C_RECEIVEADDRESS,C_RECEIPTCORPID,C_VFREE1,C_VFREE2,C_VFREE3,C_VDEF1)"); cmdText2.Append(" values ("); cmdText2.Append("'" + pk_itemid + "',"); //主键 cmdText2.Append("'" + pk_mainid + "',"); //来源销售主表ID cmdText2.Append("'" + modOrder.C_NO + "',"); //订单号 cmdText2.Append("'" + modOrder.C_CON_NO + "',"); //合同号 cmdText2.Append("'" + modOrder.C_INVBASDOCID + "',"); //存货档案主键 cmdText2.Append("'" + modOrder.C_INVENTORYID + "',"); //存货管理档案主键 cmdText2.Append("'" + modOrder.C_UNITID + "',"); //主计量单位 cmdText2.Append("'" + modOrder.C_PACKUNITID + "',"); //辅单位 cmdText2.Append("" + modOrder.N_WGT + ","); //数量 cmdText2.Append("to_date('" + modOrder.D_DELIVERY_DT + "','yyyy-mm-dd hh24:mi:ss'),"); //发货日期 cmdText2.Append("to_date('" + modOrder.D_DELIVERY_DT + "','yyyy-mm-dd hh24:mi:ss'),"); //交货日期 cmdText2.Append("'" + modOrder.C_CURRENCYTYPEID + "',"); //货币 cmdText2.Append("" + modOrder.N_TAXRATE + ","); //税率 cmdText2.Append("" + modOrder.N_ORIGINALCURPRICE + ","); //原币无税单价 cmdText2.Append("" + modOrder.N_ORIGINALCURTAXPRICE + ","); //原币含税单价 cmdText2.Append("" + modOrder.N_ORIGINALCURTAXMNY + ","); //原币税额 cmdText2.Append("" + modOrder.N_ORIGINALCURMNY + ","); //原币无税金额 cmdText2.Append("" + modOrder.N_ORIGINALCURSUMMNY + ","); //原币价税合计 cmdText2.Append("'" + modCon.C_CRECEIPTAREAID + "',"); //收货地区 cmdText2.Append("'" + modCon.C_ADDRESS + "',"); //收货地址 cmdText2.Append("'" + modCon.C_CRECEIPTCORPID + "',"); //收货单位 cmdText2.Append("'" + modOrder.C_FREE_TERM + "',"); //自由项1 cmdText2.Append("'" + modOrder.C_FREE_TERM2 + "',"); //自由项2 cmdText2.Append("'" + modOrder.C_PACK + "',"); //包装要求 cmdText2.Append("'" + modOrder.C_VDEF1 + "'"); //质量等级 cmdText2.Append(")"); strSql.Add(cmdText2.ToString()); #endregion #region //日计划 string dayCode = Dal_RandomNumber.GetDayPlanCode(); //日计划单据号 StringBuilder cmdText3 = new StringBuilder(); cmdText3.Append("insert into TMP_DAYPLAN("); cmdText3.Append(@"C_PLCODE, C_PKBILLB, C_PKBILLH, C_CONNO, C_ORDERNO, C_PKINV, C_PKASSISTMEASURE, N_ASSISTNUM, N_NUM, N_UNITPRICE, N_MONEY, D_PLANDATE, D_ORDSNDATE, D_REQUIREDATE, D_SNDDATE, C_PKCUST, C_PKSENDTYPE, C_PKSALEORG, C_PKOPERATOR, C_PKOPRDEPART, C_PKPLANPERSON, C_PKAPPRPERSON, D_APPRDATE, C_PKARRIVEAREA, C_DESTADDRESS, C_RECEIPTCORPID, C_BIZTYPE, C_UNITID, C_VFREE1, C_VFREE2, C_VFREE3, C_VFREE4, C_SALECODE)"); cmdText3.Append(" values ("); cmdText3.Append("'" + dayCode + "',"); //日计划单据号 cmdText3.Append("'" + pk_itemid + "',"); //来源销售订单子表ID cmdText3.Append("'" + pk_mainid + "',"); //来源销售订单主表ID cmdText3.Append("'" + modOrder.C_CON_NO + "',"); //合同号 cmdText3.Append("'" + modOrder.C_NO + "',"); //订单号 cmdText3.Append("'" + modOrder.C_INVENTORYID + "',"); //存货主键 cmdText3.Append("'" + modOrder.C_PACKUNITID + "',"); //辅计量单位ID cmdText3.Append("" + modOrder.N_FNUM + ","); //辅数量 cmdText3.Append("" + modOrder.N_WGT + ","); //主数量 cmdText3.Append("" + modOrder.N_ORIGINALCURTAXPRICE + ","); //单价 cmdText3.Append("" + modOrder.N_ORIGINALCURSUMMNY + ","); //订单金额 cmdText3.Append("to_date('" + modOrder.D_DT + "','yyyy-mm-dd hh24:mi:ss'),"); //日计划日期 cmdText3.Append("to_date('" + modOrder.D_DELIVERY_DT + "','yyyy-mm-dd hh24:mi:ss'),"); //定单要求发货日期 cmdText3.Append("to_date('" + modOrder.D_DELIVERY_DT + "','yyyy-mm-dd hh24:mi:ss'),"); //定单要求到货日期 cmdText3.Append("to_date('" + modOrder.D_DELIVERY_DT + "','yyyy-mm-dd hh24:mi:ss'),"); //实际发货日期 cmdText3.Append("'" + modOrder.C_RECEIPTCORPID + "',"); //客户ID cmdText3.Append("'" + modCon.C_TRANSMODEID + "',"); //发运方式ID cmdText3.Append("'" + modCon.C_SALECORPID + "',"); //销售组织ID cmdText3.Append("'" + modCon.C_EMPLOYEEID + "',"); //业务员ID cmdText3.Append("'" + modCon.C_DEPTID + "',"); //业务部门ID cmdText3.Append("'" + modCon.C_COPERATORID + "',"); //计划人ID cmdText3.Append("'" + modCon.C_APPROVEID + "',"); //审批人ID cmdText3.Append("to_date('" + modCon.D_APPROVEDATE + "','yyyy-mm-dd hh24:mi:ss'),"); //审批日期 cmdText3.Append("'" + modCon.C_CRECEIPTAREAID + "',"); //到货地区ID cmdText3.Append("'" + modCon.C_ADDRESS + "',"); //到货地址 cmdText3.Append("'" + modCon.C_CRECEIPTCUSTOMERID + "',"); //收货单位ID cmdText3.Append("'" + modCon.C_BIZTYPE + "',"); //业务类型ID cmdText3.Append("'" + modOrder.C_UNITID + "',"); //计量单位ID cmdText3.Append("'" + modOrder.C_FREE_TERM + "',"); //自由项1 cmdText3.Append("'" + modOrder.C_FREE_TERM2 + "',"); //自由项2 cmdText3.Append("'" + modOrder.C_PACK + "',"); //包装要求 cmdText3.Append("'" + modOrder.C_VDEF1 + "',"); //质量等级 cmdText3.Append("'" + code + "'"); //销售单据号 cmdText3.Append(")"); strSql.Add(cmdText3); #endregion } } } DbHelperOra.ExecuteSqlTran(strSql); } return(dt); }
/// <summary> /// 得到一个对象实体 /// </summary> public Mod_TMO_CONDETAILS GetModel(string C_NO) { return(dal.GetModel(C_NO)); }