/// <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_receipt stockReceiptEntity, string StockReceiptId, 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, ReceiptBillEntity); stockReceiptEntity.handle = GlobalStaticObj.UserID; stockReceiptEntity.operators = GlobalStaticObj.UserID; stockReceiptEntity.enable_flag = NoDelFlag; if (HandleType == Save) { stockReceiptEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); stockReceiptEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); } else if (HandleType == Submit) { stockReceiptEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.SUBMIT).ToString(); stockReceiptEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT, true); } if (ReceiptBillEntity != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Update tb_parts_stock_receipt Set "); bool isFirstValue = true; foreach (PropertyInfo info in stockReceiptEntity.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stockReceiptEntity, 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_receipt_id='" + StockReceiptId + "';"); 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 AddReceiptBillSql(List<SysSQLString> listSql, tb_parts_stock_receipt stockReceiptEntity, string StockReceiptId, 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, stockReceiptEntity); stockReceiptEntity.stock_receipt_id = StockReceiptId; stockReceiptEntity.update_by = GlobalStaticObj.UserID; stockReceiptEntity.operators = GlobalStaticObj.UserID; stockReceiptEntity.enable_flag = NoDelFlag; if (HandleType == Save) { stockReceiptEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); stockReceiptEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); } else if (HandleType == Submit) { stockReceiptEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.SUBMIT).ToString(); stockReceiptEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT, true); } if (stockReceiptEntity != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Insert Into tb_parts_stock_receipt( "); StringBuilder sb_PrValue = new StringBuilder(); StringBuilder sb_PrName = new StringBuilder(); foreach (PropertyInfo info in stockReceiptEntity.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stockReceiptEntity, 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); } }