/// <summary> 当金额不为0,审核通过时,自动生产预/应收单、预/应付单 /// </summary> void AddBillPayReceive(List<string> listField) { if (listField.Count > 0) { for (int i = 0; i < listField.Count; i++) { DataTable dt = DBHelper.GetTable("", "tb_parts_sale_order", "*", string.Format("sale_order_id='{0}'", listField[i]), "", ""); if (dt != null && dt.Rows.Count > 0) { tb_parts_sale_order model = new tb_parts_sale_order(); CommonFuncCall.SetModlByDataTable(model, dt); if (model.advance_money > 0) { tb_bill_receivable a = new tb_bill_receivable(); tb_balance_documents b = new tb_balance_documents(); tb_payment_detail c = new tb_payment_detail(); a.cust_id = model.cust_id;//客户ID a.order_num = CommonUtility.GetNewNo(DataSources.EnumProjectType.RECEIVABLE);//订单号 a.order_type = (int)DataSources.EnumOrderType.RECEIVABLE; a.payment_type = (int)DataSources.EnumReceivableType.ADVANCES; a.org_id = model.org_id; b.billing_money = model.advance_money;//开单金额 b.documents_date = model.order_date;//单据日期 b.documents_id = model.sale_order_id;//单据ID b.documents_name = "销售订单";//单据名称 b.documents_num = model.order_num;//单据编码 c.money = model.advance_money;//金额 c.balance_way = model.closing_way;//结算方式 //c.check_number = model.check_number;//票号 DBOperation.AddBillReceivable(a, b, c); } } } } }
/// <summary> 添加情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="sale_order_id"></param> private void AddPurchaseOrderSqlString(List<SysSQLString> listSql, string sale_order_id, string HandleType) { SysSQLString sysStringSql = new SysSQLString(); sysStringSql.cmdType = CommandType.Text; Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数 int business_count = 0; decimal payment = 0; decimal tax = 0; decimal valorem_together = 0; GetBuesinessMoney(ref business_count, ref payment, ref tax, ref valorem_together); ddtorder_date.Value = Convert.ToDateTime(ddtorder_date.Value.ToShortDateString() + " 23:59:59"); ddtvalid_till.Value = Convert.ToDateTime(ddtvalid_till.Value.ToShortDateString() + " 23:59:59"); //ddldelivery_time.Value = Convert.ToDateTime(ddldelivery_time.Value.ToShortDateString() + " 23:59:59"); tb_parts_sale_order model = new tb_parts_sale_order(); CommonFuncCall.SetModelObjectValue(this, model); model.cust_id = cust_id; model.valid_till = Common.LocalDateTimeToUtcLong(Convert.ToDateTime(ddldelivery_time.Value.ToShortDateString() + " 23:59:59")); model.cust_code = txtcust_code1.Text.Trim(); model.cust_name = txtcust_name.Caption.Trim(); model.closing_unit = txtclosing_unit1.Text; model.sale_order_id = sale_order_id; model.create_by = GlobalStaticObj.UserID; model.create_name = GlobalStaticObj.UserName; model.create_time = Common.LocalDateTimeToUtcLong(DateTime.Now); model.operators = GlobalStaticObj.UserID; model.operator_name = GlobalStaticObj.UserName; model.is_suspend = chkis_suspend.Checked ? "0" : "1";//选中(中止):0,未选中(不中止):1 model.suspend_reason = txtsuspend_reason.Caption.Trim();//中止原因 model.com_id = GlobalStaticObj.CurrUserCom_Id;//公司ID model.com_code = GlobalStaticObj.CurrUserCom_Code;//公司编码 model.com_name = GlobalStaticObj.CurrUserCom_Name;//公司名称 model.order_quantity = business_count;//订货数量 model.payment = payment;//货款 model.tax = tax;//税款 model.money = valorem_together;//金额 model.is_occupy = "0"; model.is_lock = "0"; model.enable_flag = "1"; if (HandleType == "保存") { model.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); model.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); } else if (HandleType == "提交") { model.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.SUBMIT).ToString(); model.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT, true); } if (!string.IsNullOrEmpty(ddltrans_way.SelectedValue.ToString())) { model.trans_way = ddltrans_way.SelectedValue.ToString(); model.trans_way_name = ddltrans_way.SelectedItem.ToString(); } if (!string.IsNullOrEmpty(ddlclosing_way.SelectedValue.ToString())) { model.closing_way = ddlclosing_way.SelectedValue.ToString(); model.closing_way_name = ddlclosing_way.SelectedItem.ToString(); } if (!string.IsNullOrEmpty(ddlorg_id.SelectedValue.ToString())) { model.org_id = ddlorg_id.SelectedValue.ToString(); model.org_name = ddlorg_id.SelectedItem.ToString(); } if (!string.IsNullOrEmpty(ddlhandle.SelectedValue.ToString())) { model.handle = ddlhandle.SelectedValue.ToString(); model.handle_name = ddlhandle.SelectedItem.ToString(); } if (model != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Insert Into tb_parts_sale_order( "); StringBuilder sp = new StringBuilder(); StringBuilder sb_prame = new StringBuilder(); foreach (PropertyInfo info in model.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(model, null); sb_prame.Append("," + name); sp.Append(",@" + name); dicParam.Add(name, value == null ? "" : value.ToString()); } sb.Append(sb_prame.ToString().Substring(1, sb_prame.ToString().Length - 1) + ") Values ("); sb.Append(sp.ToString().Substring(1, sp.ToString().Length - 1) + ")").Append(";"); sysStringSql.sqlString = sb.ToString(); sysStringSql.Param = dicParam; listSql.Add(sysStringSql); } }