/// <summary> /// 编辑情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="purchase_billing_id"></param> /// <param name="model"></param> private void EditAllocBillSql(List<SysSQLString> listSql, tb_parts_stock_inout stockInoutEntity, string StockInoutId, 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, AllocationBillEntity); stockInoutEntity.handle = GlobalStaticObj.UserID; stockInoutEntity.operators = GlobalStaticObj.UserID; stockInoutEntity.update_name = GlobalStaticObj.UserName; stockInoutEntity.update_time = Common.LocalDateTimeToUtcLong(Convert.ToDateTime(DateTime.Now.ToShortDateString())); stockInoutEntity.enable_flag = NoDelFlag; if (HandleType == Save) { stockInoutEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); stockInoutEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); } else if (HandleType == Submit) { stockInoutEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.SUBMIT).ToString(); stockInoutEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT, true); } if (AllocationBillEntity != null) { StringBuilder sb = new StringBuilder(); sb.Append(" update tb_parts_stock_inout Set "); bool isFirstValue = true; foreach (PropertyInfo info in stockInoutEntity.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stockInoutEntity, 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_inout_id='" + StockInoutId + "';"); sysStrSql.sqlString = sb.ToString(); sysStrSql.Param = dicParam; listSql.Add(sysStrSql);//完成SQL语句的拼装 } } catch (Exception ex) { MessageBoxEx.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } }
/// <summary> 创建出入库单 /// </summary> /// <param name="ordertype">单据类型</param> /// <param name="bill_model">采购开单信息</param> bool CreateIntoStock(string ordertype, tb_parts_purchase_billing bill_model, ref string stock_inout_id) { tb_parts_stock_inout stoct_inout_model = new tb_parts_stock_inout(); Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数 stoct_inout_model.stock_inout_id = Guid.NewGuid().ToString(); stock_inout_id = stoct_inout_model.stock_inout_id; stoct_inout_model.order_date = Common.LocalDateTimeToUtcLong(Convert.ToDateTime(DateTime.Now.ToShortDateString())); stoct_inout_model.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); stoct_inout_model.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); if (ordertype == "入库单") { //stoct_inout_model.order_num = CommonUtility.GetNewNo(DataSources.EnumProjectType.InBill);//获取入库单编号 stoct_inout_model.order_type = Convert.ToInt32(DataSources.EnumAllocationBillType.Storage).ToString();//入库单类型编号 stoct_inout_model.order_type_name = DataSources.GetDescription(DataSources.EnumAllocationBillType.Storage, true);//入库单类型名称 } else if (ordertype == "出库单") { //stoct_inout_model.order_num = CommonUtility.GetNewNo(DataSources.EnumProjectType.OutBill);//获取出库单编号 stoct_inout_model.order_type = Convert.ToInt32(DataSources.EnumAllocationBillType.OutboundOrder).ToString();//出库单类型编号 stoct_inout_model.order_type_name = DataSources.GetDescription(DataSources.EnumAllocationBillType.OutboundOrder, true);//出库单类型名称 } stoct_inout_model.billing_type = Convert.ToInt32(DataSources.EnumAllocationBillingType.PurchaseBilling).ToString();//开单类型编号 stoct_inout_model.billing_type_name = DataSources.GetDescription(DataSources.EnumAllocationBillingType.PurchaseBilling, true);//开单类型名称 stoct_inout_model.arrival_place = bill_model.delivery_address; stoct_inout_model.bussiness_units = ""; stoct_inout_model.com_id = GlobalStaticObj.CurrUserCom_Id; stoct_inout_model.com_name = GlobalStaticObj.CurrUserCom_Name; stoct_inout_model.org_id = bill_model.org_id; stoct_inout_model.org_name = bill_model.org_name; stoct_inout_model.handle = bill_model.handle; stoct_inout_model.handle_name = bill_model.handle_name; stoct_inout_model.operators = bill_model.operators; stoct_inout_model.operator_name = bill_model.operator_name; stoct_inout_model.create_by = GlobalStaticObj.UserID; stoct_inout_model.create_name = GlobalStaticObj.UserName; stoct_inout_model.create_time = Common.LocalDateTimeToUtcLong(DateTime.Now); stoct_inout_model.remark = "由单号为【" + bill_model.order_num + "】的采购开单生成"; stoct_inout_model.enable_flag = "1"; foreach (PropertyInfo info in stoct_inout_model.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stoct_inout_model, null); dicParam.Add(name, value == null ? "" : value.ToString()); } return DBHelper.Submit_AddOrEdit("出入库单表添加信息", "tb_parts_stock_inout", "stock_inout_id", "", dicParam); }
/// <summary> /// 添加情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="purchase_billing_id"></param> private void AddAllocBillSql(List<SysSQLString> listSql, tb_parts_stock_inout stockInoutEntity, string StockInoutId, 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 StrSqlObj = new SysSQLString(); StrSqlObj.cmdType = CommandType.Text; Dictionary<string, string> dicParam = new Dictionary<string, string>();//保存SQL语句参数值 CommonFuncCall.FillEntityByControls(this, stockInoutEntity); stockInoutEntity.stock_inout_id = StockInoutId; stockInoutEntity.update_by = GlobalStaticObj.UserID; stockInoutEntity.operators = GlobalStaticObj.UserID; stockInoutEntity.create_by = GlobalStaticObj.UserID; stockInoutEntity.update_name = GlobalStaticObj.UserName; stockInoutEntity.create_name = GlobalStaticObj.UserName; stockInoutEntity.operator_name = GlobalStaticObj.UserName; stockInoutEntity.create_time =Common.LocalDateTimeToUtcLong(Convert.ToDateTime(DateTime.Now.ToShortDateString())); stockInoutEntity.enable_flag = NoDelFlag; if (HandleType == Save) { stockInoutEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); stockInoutEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); } else if (HandleType == Submit) { stockInoutEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.SUBMIT).ToString(); stockInoutEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT, true); } if (stockInoutEntity != null) { StringBuilder sb = new StringBuilder(); sb.Append(" insert into tb_parts_stock_inout ( "); StringBuilder sb_PrValue = new StringBuilder(); StringBuilder sb_PrName = new StringBuilder(); foreach (PropertyInfo info in stockInoutEntity.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stockInoutEntity, 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语句的拼装 StrSqlObj.sqlString = sb.ToString(); StrSqlObj.Param = dicParam; listSql.Add(StrSqlObj); } } catch (Exception ex) { MessageBoxEx.Show(ex.Message, "异常提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } }