/// <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(); stoct_inout_model.order_date = Common.LocalDateTimeToUtcLong(DateTime.Now); 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 = Convert.ToInt32(DataSources.EnumAllocationBillType.Storage).ToString(); } 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 = Convert.ToInt32(DataSources.EnumAllocationBillType.OutboundOrder).ToString(); } stoct_inout_model.billing_type = Convert.ToInt32(DataSources.EnumAllocationBillingType.PurchaseBilling).ToString(); stoct_inout_model.billing_type_name = Convert.ToInt32(DataSources.EnumAllocationBillingType.PurchaseBilling).ToString(); 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 = ""; 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> /// 审核通过后需要自动生成的单子的方法 /// </summary> void CreateBill(List <string> listField) { if (listField.Count > 0) { for (int i = 0; i < listField.Count; i++) { DataTable dt = DBHelper.GetTable("", "tb_parts_purchase_billing", "*", string.Format("purchase_billing_id='{0}'", listField[i]), "", ""); if (dt != null && dt.Rows.Count > 0) { tb_parts_purchase_billing model = new tb_parts_purchase_billing(); CommonFuncCall.SetModlByDataTable(model, dt); #region 当金额大于0时,自动生成预付款单 if (model.this_payment > 0) { tb_bill_receivable a = new tb_bill_receivable(); tb_balance_documents b = new tb_balance_documents(); tb_payment_detail c = new tb_payment_detail(); a.cust_id = model.sup_id; //供应商ID a.order_num = CommonUtility.GetNewNo(DataSources.EnumProjectType.PAYMENT); //订单号 a.order_type = (int)DataSources.EnumOrderType.PAYMENT; a.payment_type = (int)DataSources.EnumPaymentType.PAYMENT; a.org_id = model.org_id; b.billing_money = model.this_payment; //开单金额 b.documents_date = model.order_date; //单据日期 b.documents_id = model.purchase_billing_id; //单据ID b.documents_name = "采购开单"; //单据名称 b.documents_num = model.order_num; //单据编码 c.money = model.this_payment; //金额 c.balance_way = model.balance_way; //结算方式 c.check_number = model.check_number; //票号 DBOperation.AddBillReceivable(a, b, c); } #endregion #region 自动生产出入库单 #region 一:采购收货单-->自动生成入库单 if (model.order_type == DataSources.EnumPurchaseOrderType.PurchaseReceive.ToString()) { string stock_inout_id = string.Empty; //1.生成入库单 if (CreateIntoStock("入库单", model, ref stock_inout_id)) { //2.查询配件信息,生成配件信息入库单 DataTable dt_parts = DBHelper.GetTable("查询采购开单配件信息表", "tb_parts_purchase_billing_p", "*", " purchase_billing_id='" + model.purchase_billing_id + "'", "", ""); if (dt_parts != null && dt_parts.Rows.Count > 0) { for (int a = 0; a < dt_parts.Rows.Count; a++) { tb_parts_purchase_billing_p bill_p_model = new tb_parts_purchase_billing_p(); CommonFuncCall.SetModlByDataTable(bill_p_model, dt_parts, a); CreateIntoPartsStock(stock_inout_id, bill_p_model); } } } } #endregion #region 二:采购退货-->自动生成出库单 else if (model.order_type == DataSources.EnumPurchaseOrderType.PurchaseBack.ToString()) { string stock_inout_id = string.Empty; //1.生成出库单 if (CreateIntoStock("出库单", model, ref stock_inout_id)) { //2.查询配件信息,生成配件信息出库单 DataTable dt_parts = DBHelper.GetTable("查询采购开单配件信息表", "tb_parts_purchase_billing_p", "*", " purchase_billing_id='" + model.purchase_billing_id + "'", "", ""); if (dt_parts != null && dt_parts.Rows.Count > 0) { for (int a = 0; a < dt_parts.Rows.Count; a++) { tb_parts_purchase_billing_p bill_p_model = new tb_parts_purchase_billing_p(); CommonFuncCall.SetModlByDataTable(bill_p_model, dt_parts, a); CreateIntoPartsStock(stock_inout_id, bill_p_model); } } } } #endregion #region :采购换货-->自动生成出、入库单(数量大于0是入库,小于0是出库) else if (model.order_type == DataSources.EnumPurchaseOrderType.PurchaseExchange.ToString()) { string stock_in_id = string.Empty; string stock_out_id = string.Empty; //1.生成入库单 if (CreateIntoStock("入库单", model, ref stock_in_id)) { //2.查询配件入库数量大于0的,生成配件信息入库单 DataTable dt_parts = DBHelper.GetTable("查询采购开单配件信息表", "tb_parts_purchase_billing_p", "*", " purchase_billing_id='" + model.purchase_billing_id + "' and storage_count>0 ", "", ""); if (dt_parts != null && dt_parts.Rows.Count > 0) { for (int a = 0; a < dt_parts.Rows.Count; a++) { tb_parts_purchase_billing_p bill_p_model = new tb_parts_purchase_billing_p(); CommonFuncCall.SetModlByDataTable(bill_p_model, dt_parts, a); CreateIntoPartsStock(stock_in_id, bill_p_model); } } } //3.生成出库单 if (CreateIntoStock("出库单", model, ref stock_out_id)) { //4.查询配件入库数量小于0的,生成配件信息出库单 DataTable dt_parts = DBHelper.GetTable("查询采购开单配件信息表", "tb_parts_purchase_billing_p", "*", " purchase_billing_id='" + model.purchase_billing_id + "' and storage_count<0 ", "", ""); if (dt_parts != null && dt_parts.Rows.Count > 0) { for (int a = 0; a < dt_parts.Rows.Count; a++) { tb_parts_purchase_billing_p bill_p_model = new tb_parts_purchase_billing_p(); CommonFuncCall.SetModlByDataTable(bill_p_model, dt_parts, a); CreateIntoPartsStock(stock_out_id, bill_p_model); } } } } #endregion #endregion #region 向宇通发送配送单号 if (!string.IsNullOrEmpty(model.ration_send_code)) { //DBHelper.WebServHandler("审核通过入库时发送配送单号到宇通系统", EnumWebServFunName.UpLoadPartPutStore, model.ration_send_code); DBHelper.WebServHandler("", EnumWebServFunName.LoadPartInStore, model.ration_send_code); } #endregion } } } }