private void buttonEx1_Click(object sender, EventArgs e) { try { List <string> listField = GetTestRecord(); if (listField.Count > 0) { if (listField.Count == 0) { MessageBoxEx.Show("请选择要发送的销售开单审核数据!"); return; } partsale partsalemodel = new partsale(); tb_parts_sale_billing sale_bill_model = new tb_parts_sale_billing(); DataTable dt_test = DBHelper.GetTable("查看一条销售开发订单信息", "tb_parts_sale_billing", "*", " sale_billing_id='" + listField[0] + "'", "", ""); CommonFuncCall.SetModlByDataTable(sale_bill_model, dt_test, 0); partsalemodel.sale_date = DateTime.Now.ToString(); partsalemodel.cust_name = sale_bill_model.contacts; partsalemodel.cust_phone = sale_bill_model.contacts_tel; partsalemodel.turner = string.Empty; partsalemodel.license_plate = string.Empty; partsalemodel.amount = sale_bill_model.allmoney.ToString(); partsalemodel.remark = sale_bill_model.remark; DataTable dt_parts_test = DBHelper.GetTable("查看一条销售开发订单的配件信息", "tb_parts_sale_billing_p", "*", " sale_billing_id='" + listField[0] + "'", "", ""); if (dt_parts_test != null && dt_parts_test.Rows.Count > 0) { partDetail partDetailmodel = new partDetail(); partsalemodel.partDetails = new partDetail[dt_parts_test.Rows.Count]; tb_parts_sale_billing_p sale_bill_p_model = new tb_parts_sale_billing_p(); for (int i = 0; i < dt_parts_test.Rows.Count; i++) { partDetailmodel = new partDetail(); sale_bill_p_model = new tb_parts_sale_billing_p(); CommonFuncCall.SetModlByDataTable(sale_bill_p_model, dt_parts_test, i); partDetailmodel.wh_code = sale_bill_p_model.wh_code; partDetailmodel.car_parts_code = sale_bill_p_model.car_factory_code; partDetailmodel.remark = sale_bill_p_model.remark; partDetailmodel.business_count = sale_bill_p_model.business_count.ToString(); partDetailmodel.business_price = sale_bill_p_model.business_price.ToString(); partDetailmodel.amount = sale_bill_p_model.valorem_together.ToString(); partDetailmodel.parts_remark = sale_bill_p_model.remark; partsalemodel.partDetails[i] = partDetailmodel; } } string mess = DBHelper.WebServHandler("调用销售开发订单信息", SYSModel.EnumWebServFunName.UpLoadPartSale, partsalemodel); if (!string.IsNullOrEmpty(mess)) { mess = "操作成功!"; } MessageBoxEx.Show(mess); } } catch (Exception ex) { } }
/// <summary> 创建出入库单 /// </summary> /// <param name="ordertype">单据类型</param> /// <param name="bill_model">采购开单信息</param> bool CreateIntoStock(string ordertype, tb_parts_sale_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.SaleBilling).ToString(); stoct_inout_model.billing_type_name = Convert.ToInt32(DataSources.EnumAllocationBillingType.SaleBilling).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_sale_billing", "*", string.Format("sale_billing_id='{0}'", listField[i]), "", ""); if (dt != null && dt.Rows.Count > 0) { tb_parts_sale_billing model = new tb_parts_sale_billing(); CommonFuncCall.SetModlByDataTable(model, dt); #region 当金额大于0时,自动生成预收款单 if (model.current_collect > 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.cust_id; //客户ID a.order_num = CommonUtility.GetNewNo(DataSources.EnumProjectType.RECEIVABLE); //订单号 a.order_type = (int)DataSources.EnumOrderType.RECEIVABLE; a.payment_type = (int)DataSources.EnumReceivableType.RECEIVABLE; a.org_id = model.org_id; b.billing_money = model.current_collect; //开单金额 b.documents_date = model.order_date; //单据日期 b.documents_id = model.org_id; //单据ID b.documents_name = "销售开单"; //单据名称 b.documents_num = model.order_num; //单据编码 c.money = model.current_collect; //金额 c.balance_way = model.balance_way; //结算方式 c.check_number = model.check_number; //票号 DBOperation.AddBillReceivable(a, b, c); } #endregion #region 自动生产出入库单 //1:销售开单-->自动生成出库单 if (model.order_type == DataSources.EnumSaleOrderType.SaleBill.ToString()) { string stock_inout_id = string.Empty; //1.生成出库单 if (CreateIntoStock("出库单", model, ref stock_inout_id)) { //2.查询配件信息,生成配件信息出库单 DataTable dt_parts = DBHelper.GetTable("查询销售开单配件信息表", "tb_parts_sale_billing_p", "*", " sale_billing_id='" + model.sale_billing_id + "'", "", ""); if (dt_parts != null && dt_parts.Rows.Count > 0) { for (int a = 0; a < dt_parts.Rows.Count; a++) { tb_parts_sale_billing_p bill_p_model = new tb_parts_sale_billing_p(); CommonFuncCall.SetModlByDataTable(bill_p_model, dt_parts, a); CreateIntoPartsStock(stock_inout_id, bill_p_model); } } } } //2:销售退货-->自动生成入库单 else if (model.order_type == DataSources.EnumSaleOrderType.SaleBack.ToString()) { string stock_inout_id = string.Empty; //1.生成入库单 if (CreateIntoStock("入库单", model, ref stock_inout_id)) { //2.查询配件信息,生成配件信息入库单 DataTable dt_parts = DBHelper.GetTable("查询销售开单配件信息表", "tb_parts_sale_billing_p", "*", " sale_billing_id='" + model.sale_billing_id + "'", "", ""); if (dt_parts != null && dt_parts.Rows.Count > 0) { for (int a = 0; a < dt_parts.Rows.Count; a++) { tb_parts_sale_billing_p bill_p_model = new tb_parts_sale_billing_p(); CommonFuncCall.SetModlByDataTable(bill_p_model, dt_parts, a); CreateIntoPartsStock(stock_inout_id, bill_p_model); } } } } //3:销售换货-->自动生成出、入库单(数量大于0是出库,小于0是入库) else if (model.order_type == DataSources.EnumSaleOrderType.SaleExchange.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_sale_billing_p", "*", " sale_billing_id='" + model.sale_billing_id + "' and library_count<0 ", "", ""); if (dt_parts != null && dt_parts.Rows.Count > 0) { for (int a = 0; a < dt_parts.Rows.Count; a++) { tb_parts_sale_billing_p bill_p_model = new tb_parts_sale_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_sale_billing_p", "*", " sale_billing_id='" + model.sale_billing_id + "' and library_count>0 ", "", ""); if (dt_parts != null && dt_parts.Rows.Count > 0) { for (int a = 0; a < dt_parts.Rows.Count; a++) { tb_parts_sale_billing_p bill_p_model = new tb_parts_sale_billing_p(); CommonFuncCall.SetModlByDataTable(bill_p_model, dt_parts, a); CreateIntoPartsStock(stock_out_id, bill_p_model); } } } } #endregion } } } }