/// <summary> /// 添加情况下组装sql的方法 /// </summary> /// <param name="listSql"></param> /// <param name="purchase_billing_id"></param> private void AddLossBillSql(List<SysSQLString> listSql, tb_parts_stock_loss stockLossEntity, string StockLossId, 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, stockLossEntity); stockLossEntity.stock_loss_id = StockLossId; stockLossEntity.update_by = GlobalStaticObj.UserID; stockLossEntity.operators = GlobalStaticObj.UserID; stockLossEntity.enable_flag = NoDelFlag; if (HandleType == Save) { stockLossEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); stockLossEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); } else if (HandleType == Submit) { stockLossEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.SUBMIT).ToString(); stockLossEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT, true); } if (stockLossEntity != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Insert Into tb_parts_stock_loss( "); StringBuilder sb_PrValue = new StringBuilder(); StringBuilder sb_PrName = new StringBuilder(); foreach (PropertyInfo info in stockLossEntity.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stockLossEntity, 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); } }
/// <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_loss stockLossEntity, string StockLosstId, 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, LossBillEntity); stockLossEntity.handle = GlobalStaticObj.UserID; stockLossEntity.operators = GlobalStaticObj.UserID; stockLossEntity.enable_flag = NoDelFlag; if (HandleType == Save) { stockLossEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.DRAFT).ToString(); stockLossEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.DRAFT, true); } else if (HandleType == Submit) { stockLossEntity.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.SUBMIT).ToString(); stockLossEntity.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.SUBMIT, true); } if (LossBillEntity != null) { StringBuilder sb = new StringBuilder(); sb.Append(" Update tb_parts_stock_loss Set "); bool isFirstValue = true; foreach (PropertyInfo info in stockLossEntity.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stockLossEntity, 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_loss_id='" + StockLosstId + "';"); 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> /// <param name="stock_loss_id"></param> /// <returns></returns> bool CreateIntoLoss(tb_parts_sale_billing bill_model, ref string stock_loss_id) { tb_parts_stock_loss stock_loss_model = new tb_parts_stock_loss(); Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数 stock_loss_model.stock_loss_id = Guid.NewGuid().ToString(); stock_loss_id = stock_loss_model.stock_loss_id; stock_loss_model.order_num = CommonUtility.GetNewNo(DataSources.EnumProjectType.LossBill);//获取报损单编号 stock_loss_model.order_date = Common.LocalDateTimeToUtcLong(Convert.ToDateTime(DateTime.Now.ToShortDateString())); stock_loss_model.order_status = Convert.ToInt32(DataSources.EnumAuditStatus.AUDIT).ToString(); stock_loss_model.order_status_name = DataSources.GetDescription(DataSources.EnumAuditStatus.AUDIT, true); stock_loss_model.out_wh_type_name = DataSources.GetDescription(DataSources.EnumOtherInoutType.Scrap, true); stock_loss_model.com_id = GlobalStaticObj.CurrUserCom_Id; stock_loss_model.com_name = GlobalStaticObj.CurrUserCom_Name; stock_loss_model.org_id = bill_model.org_id; stock_loss_model.org_name = bill_model.org_name; stock_loss_model.handle = bill_model.handle; stock_loss_model.handle_name = bill_model.handle_name; stock_loss_model.operators = bill_model.operators; stock_loss_model.operator_name = bill_model.operator_name; stock_loss_model.create_by = GlobalStaticObj.UserID; stock_loss_model.create_name = GlobalStaticObj.UserName; stock_loss_model.create_time = Common.LocalDateTimeToUtcLong(DateTime.Now); stock_loss_model.update_by = GlobalStaticObj.UserID; stock_loss_model.update_name = GlobalStaticObj.UserName; stock_loss_model.update_time = Common.LocalDateTimeToUtcLong(DateTime.Now); stock_loss_model.remark = "由单号为【" + bill_model.order_num + "】的销售开单生成"; stock_loss_model.enable_flag = "1"; foreach (PropertyInfo info in stock_loss_model.GetType().GetProperties()) { string name = info.Name; object value = info.GetValue(stock_loss_model, null); dicParam.Add(name, value == null ? "" : value.ToString()); } return DBHelper.Submit_AddOrEdit("根据销售开单生成报损单信息", "tb_parts_stock_loss", "stock_loss_id", "", dicParam); }