/// <summary> /// 编辑情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="sale_billing_id"></param> /// <param name="model"></param> private void EditSaleOrderSqlString(List<SysSQLString> listSql, string sale_billing_id, tb_parts_sale_billing model, string HandleType) { decimal allmoney = 0; SysSQLString sysStringSql = new SysSQLString(); sysStringSql.cmdType = CommandType.Text; Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数 ddtorder_date.Value = Convert.ToDateTime(ddtorder_date.Value.ToShortDateString() + " 23:59:59"); ddtreceivables_date.Value = Convert.ToDateTime(ddtreceivables_date.Value.ToShortDateString() + " 23:59:59"); CommonFuncCall.SetModelObjectValue(this, model); GetAllMoney(ref allmoney); model.cust_id = cust_id; model.cust_code = cust_code; model.cust_name = txtcust_name.Text; //单据类型 if (!string.IsNullOrEmpty(ddlorder_type.SelectedValue.ToString())) { model.order_type_name = ddlorder_type.SelectedItem.ToString(); } //发票类型 if (!string.IsNullOrEmpty(ddlreceipt_type.SelectedValue.ToString())) { model.receipt_type_name = ddlreceipt_type.SelectedItem.ToString(); } //运输方式 if (!string.IsNullOrEmpty(ddltrans_way.SelectedValue.ToString())) { model.trans_way_name = ddltrans_way.SelectedItem.ToString(); } //结算方式 if (!string.IsNullOrEmpty(ddlbalance_way.SelectedValue.ToString())) { model.balance_way_name = ddlbalance_way.SelectedItem.ToString(); } //结算账户 if (!string.IsNullOrEmpty(ddlbalance_account.SelectedValue.ToString())) { model.balance_account_name = ddlbalance_account.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(); } model.balance_unit = balance_unit; model.balance_unit_name = txtbalance_unit.Text.Trim(); model.update_by = GlobalStaticObj.UserID; model.update_name = GlobalStaticObj.UserName; model.update_time = Common.LocalDateTimeToUtcLong(DateTime.Now); model.operators = GlobalStaticObj.UserID; model.operator_name = GlobalStaticObj.UserName; model.allmoney = allmoney; 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 (model != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Update tb_parts_sale_billing Set "); bool isFirstValue = true; foreach (PropertyInfo info in model.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(model, null); if (isFirstValue) { isFirstValue = false; sb.Append(name); sb.Append("="); sb.Append("@" + name); } else { sb.Append("," + name); sb.Append("="); sb.Append("@" + name); } dicParam.Add(name, value == null ? "" : value.ToString()); } sb.Append(" where sale_billing_id='" + sale_billing_id + "';"); sysStringSql.sqlString = sb.ToString(); sysStringSql.Param = dicParam; listSql.Add(sysStringSql); } }
/// <summary> /// 添加情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="sale_billing_id"></param> private void AddSaleOrderSqlString(List<SysSQLString> listSql, string sale_billing_id, string HandleType) { decimal allmoney = 0; SysSQLString sysStringSql = new SysSQLString(); sysStringSql.cmdType = CommandType.Text; Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数 ddtorder_date.Value = Convert.ToDateTime(ddtorder_date.Value.ToShortDateString() + " 23:59:59"); ddtreceivables_date.Value = Convert.ToDateTime(ddtreceivables_date.Value.ToShortDateString() + " 23:59:59"); tb_parts_sale_billing model = new tb_parts_sale_billing(); CommonFuncCall.SetModelObjectValue(this, model); GetAllMoney(ref allmoney); model.sale_billing_id = sale_billing_id; model.cust_id = cust_id; model.cust_code = cust_code; model.cust_name = txtcust_name.Text; //单据类型 if (!string.IsNullOrEmpty(ddlorder_type.SelectedValue.ToString())) { model.order_type_name = ddlorder_type.SelectedItem.ToString(); } //发票类型 if (!string.IsNullOrEmpty(ddlreceipt_type.SelectedValue.ToString())) { model.receipt_type_name = ddlreceipt_type.SelectedItem.ToString(); } //运输方式 if (!string.IsNullOrEmpty(ddltrans_way.SelectedValue.ToString())) { model.trans_way_name = ddltrans_way.SelectedItem.ToString(); } //结算方式 if (!string.IsNullOrEmpty(ddlbalance_way.SelectedValue.ToString())) { model.balance_way_name = ddlbalance_way.SelectedItem.ToString(); } //结算账户 if (!string.IsNullOrEmpty(ddlbalance_account.SelectedValue.ToString())) { model.balance_account_name = ddlbalance_account.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(); } model.balance_unit = balance_unit; model.balance_unit_name = txtbalance_unit.Text.Trim(); 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.com_id = GlobalStaticObj.CurrUserCom_Id;//公司ID model.com_code = GlobalStaticObj.CurrUserCom_Code;//公司编码 model.com_name = GlobalStaticObj.CurrUserCom_Name;//公司名称 model.allmoney = allmoney; 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 (model != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Insert Into tb_parts_sale_billing( "); 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); } }