/// <summary> /// 编辑情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="purchase_billing_id"></param> /// <param name="model"></param> private void EditReceiptBillSql(List <SysSQLString> listSql, tb_parts_stock_shipping stockShippingEntity, string StockShippingtId, string HandleType) { try { const string NoDelFlag = "1"; //默认删除标记,1表示未删除,0表示删除 string Save = DataSources.GetDescription(DataSources.EnumOperateType.save, true); //保存操作 string Submit = DataSources.GetDescription(DataSources.EnumOperateType.submit, true); //提交操作 SysSQLString sysStrSql = new SysSQLString(); sysStrSql.cmdType = CommandType.Text; //sql字符串语句执行函数 Dictionary <string, string> dicParam = new Dictionary <string, string>(); //参数 CommonFuncCall.FillEntityByControls(this, ShippingBillEntity); stockShippingEntity.handle = GlobalStaticObj.UserID; stockShippingEntity.operators = GlobalStaticObj.UserID; stockShippingEntity.enable_flag = NoDelFlag; if (HandleType == Save) { stockShippingEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); stockShippingEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); } else if (HandleType == Submit) { stockShippingEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.SUBMIT).ToString(); stockShippingEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT, true); } if (ShippingBillEntity != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Update tb_parts_stock_shipping Set "); bool isFirstValue = true; foreach (PropertyInfo info in stockShippingEntity.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stockShippingEntity, 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 stock_shipping_id='" + StockShippingtId + "';"); sysStrSql.sqlString = sb.ToString(); sysStrSql.Param = dicParam; listSql.Add(sysStrSql);//完成SQL语句的拼装 } } catch (Exception ex) { MessageBoxEx.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } }
/// <summary> /// 添加情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="purchase_billing_id"></param> private void AddShippingBillSql(List <SysSQLString> listSql, tb_parts_stock_shipping stockShippingEntity, string StockShippingId, string HandleType) { try { const string NoDelFlag = "1"; //默认删除标记1表示未删除,0表示删除 string Save = DataSources.GetDescription(DataSources.EnumOperateType.save, true); //保存操作 string Submit = DataSources.GetDescription(DataSources.EnumOperateType.submit, true); //提交操作 //SQL语句拼装操作 SysSQLString sysStringSql = new SysSQLString(); sysStringSql.cmdType = CommandType.Text; Dictionary <string, string> dicParam = new Dictionary <string, string>();//保存SQL语句参数值 CommonFuncCall.FillEntityByControls(this, stockShippingEntity); stockShippingEntity.stock_shipping_id = StockShippingId; stockShippingEntity.update_by = GlobalStaticObj.UserID; stockShippingEntity.operators = GlobalStaticObj.UserID; stockShippingEntity.enable_flag = NoDelFlag; if (HandleType == Save) { stockShippingEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); stockShippingEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); } else if (HandleType == Submit) { stockShippingEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.SUBMIT).ToString(); stockShippingEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT, true); } if (stockShippingEntity != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Insert Into tb_parts_stock_shipping( "); StringBuilder sb_PrValue = new StringBuilder(); StringBuilder sb_PrName = new StringBuilder(); foreach (PropertyInfo info in stockShippingEntity.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stockShippingEntity, null); sb_PrName.Append("," + name); //数据表字段名 sb_PrValue.Append(",@" + name); //数据表字段值 dicParam.Add(name, value == null ? "" : value.ToString()); } sb.Append(sb_PrName.ToString().Substring(1, sb_PrName.ToString().Length - 1) + ") Values ("); //追加字段名 sb.Append(sb_PrValue.ToString().Substring(1, sb_PrValue.ToString().Length - 1) + ");"); //追加字段值 //完成SQL语句的拼装 sysStringSql.sqlString = sb.ToString(); sysStringSql.Param = dicParam; listSql.Add(sysStringSql); } } catch (Exception ex) { MessageBoxEx.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } }