/// <summary> /// 编辑情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="planId"></param> /// <param name="model"></param> private void EditPurchasePlanSqlString(List<SysSQLString> listSql, string planId, tb_parts_purchase_plan model, string HandleType) { try { SysSQLString sysStringSql = new SysSQLString(); sysStringSql.cmdType = CommandType.Text; int plan_counts = 0; int finish_counts = 0; GetBuessinessCount(ref plan_counts, ref finish_counts); ddtorder_date.Value = Convert.ToDateTime(ddtorder_date.Value.ToShortDateString() + " 23:59:59"); ddtplan_start_time.Value = Convert.ToDateTime(ddtplan_start_time.Value.ToShortDateString() + " 00:00:00"); ddtplan_end_time.Value = Convert.ToDateTime(ddtplan_end_time.Value.ToShortDateString() + " 23:59:59"); Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数 CommonFuncCall.SetModelObjectValue(this, model); 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.plan_counts = plan_counts; model.finish_counts = finish_counts; model.is_suspend = chkis_suspend.Checked ? "0" : "1";//选中(中止):0,未选中(不中止):1 model.import_status = "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(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(" Update tb_parts_purchase_plan 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 plan_id='" + planId + "';"); sysStringSql.sqlString = sb.ToString(); sysStringSql.Param = dicParam; listSql.Add(sysStringSql); } } catch (Exception ex) { } }
/// <summary> 添加情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="planId"></param> private void AddPurchasePlanSqlString(List<SysSQLString> listSql, string planId, string HandleType) { try { SysSQLString sysStringSql = new SysSQLString(); sysStringSql.cmdType = CommandType.Text; Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数 decimal plan_counts = 0; decimal finish_counts = 0; GetBuessinessCount(ref plan_counts, ref finish_counts); ddtorder_date.Value = Convert.ToDateTime(ddtorder_date.Value.ToShortDateString() + " 23:59:59"); ddtplan_start_time.Value = Convert.ToDateTime(ddtplan_start_time.Value.ToShortDateString() + " 00:00:00"); ddtplan_end_time.Value = Convert.ToDateTime(ddtplan_end_time.Value.ToShortDateString() + " 23:59:59"); tb_parts_purchase_plan model = new tb_parts_purchase_plan(); CommonFuncCall.SetModelObjectValue(this, model); model.plan_id = planId; model.com_id = GlobalStaticObj.CurrUserCom_Id;//公司ID model.com_code = GlobalStaticObj.CurrUserCom_Code;//公司编码 model.com_name = GlobalStaticObj.CurrUserCom_Name;//公司名称 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.plan_counts = plan_counts; model.finish_counts = finish_counts; model.import_status = "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(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_purchase_plan( "); 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); } } catch (Exception ex) { } }