Esempio n. 1
0
 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)
     { }
 }
Esempio n. 2
0
        /// <summary> 创建出入库单配件信息
        /// </summary>
        /// <param name="stock_inout_id">出入库单ID</param>
        /// <param name="parts_model">采购开单配件信息</param>
        bool CreateIntoPartsStock(string stock_inout_id, tb_parts_sale_billing_p parts_model)
        {
            tb_parts_stock_inout_p PartsInoutModel = new tb_parts_stock_inout_p();
            Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数

            PartsInoutModel.stock_inout_parts_id = Guid.NewGuid().ToString();
            PartsInoutModel.stock_inout_id = stock_inout_id;
            PartsInoutModel.wh_id = parts_model.wh_id;
            PartsInoutModel.num = parts_model.num;
            PartsInoutModel.parts_num = parts_model.parts_code;
            PartsInoutModel.parts_name = parts_model.parts_name;
            PartsInoutModel.drawing_num = parts_model.drawing_num;
            PartsInoutModel.unit = parts_model.unit_id;
            PartsInoutModel.unit_name = parts_model.unit_name;
            PartsInoutModel.parts_brand = parts_model.parts_brand;
            PartsInoutModel.count = parts_model.library_count;//出库数量
            PartsInoutModel.is_gift = parts_model.is_gift;
            PartsInoutModel.remark = parts_model.remark;
            PartsInoutModel.create_by = GlobalStaticObj.UserID;
            PartsInoutModel.create_name = GlobalStaticObj.UserName;
            PartsInoutModel.create_time = Common.LocalDateTimeToUtcLong(DateTime.Now);

            foreach (PropertyInfo info in PartsInoutModel.GetType().GetProperties())
            {
                string name = info.Name;
                object value = info.GetValue(PartsInoutModel, null);
                dicParam.Add(name, value == null ? "" : value.ToString());
            }
            return DBHelper.Submit_AddOrEdit("出入库配件表添加信息", "tb_parts_stock_inout_p", "stock_inout_parts_id", "", dicParam);
        }
Esempio n. 3
0
        /// <summary> 创建出入库单配件信息
        /// </summary>
        /// <param name="stock_inout_id">出入库单ID</param>
        /// <param name="parts_model">采购开单配件信息</param>
        bool CreateIntoPartsStock(string stock_inout_id, tb_parts_sale_billing_p parts_model, string billid, string billno)
        {
            tb_parts_stock_inout_p PartsInoutModel = new tb_parts_stock_inout_p();
            Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数

            PartsInoutModel.stock_inout_parts_id = Guid.NewGuid().ToString();
            PartsInoutModel.stock_inout_id = stock_inout_id;
            if (!string.IsNullOrEmpty(parts_model.wh_id))
            {
                PartsInoutModel.wh_id = parts_model.wh_id;
                PartsInoutModel.wh_name = parts_model.wh_name;
            }
            PartsInoutModel.num = parts_model.num;
            PartsInoutModel.parts_code = parts_model.parts_code;
            PartsInoutModel.parts_name = parts_model.parts_name;
            PartsInoutModel.drawing_num = parts_model.drawing_num;
            if (!string.IsNullOrEmpty(parts_model.unit_id))
            {
                PartsInoutModel.unit = parts_model.unit_id;
                PartsInoutModel.unit_name = parts_model.unit_name;
            }
            PartsInoutModel.parts_brand = parts_model.parts_brand;
            PartsInoutModel.counts = parts_model.business_count;//业务数量
            PartsInoutModel.parts_barcode = parts_model.parts_barcode;//条码
            PartsInoutModel.car_parts_code = parts_model.car_factory_code;//车厂编码
            if (parts_model.make_date > 0)
            {
                PartsInoutModel.make_date = parts_model.make_date;//生产日期
            }
            if (parts_model.arrival_date > 0)
            {
                PartsInoutModel.validity_date = parts_model.arrival_date;//到期、有效日期
            }
            PartsInoutModel.is_gift = parts_model.is_gift;
            PartsInoutModel.remark = parts_model.remark;
            PartsInoutModel.create_by = GlobalStaticObj.UserID;
            PartsInoutModel.create_name = GlobalStaticObj.UserName;
            PartsInoutModel.create_time = Common.LocalDateTimeToUtcLong(DateTime.Now);
            PartsInoutModel.reference_billid = billid;
            PartsInoutModel.reference_billno = billno;
            PartsInoutModel.model = parts_model.model;

            foreach (PropertyInfo info in PartsInoutModel.GetType().GetProperties())
            {
                string name = info.Name;
                object value = info.GetValue(PartsInoutModel, null);
                dicParam.Add(name, value == null ? "" : value.ToString());
            }
            return DBHelper.Submit_AddOrEdit("出入库配件表添加信息", "tb_parts_stock_inout_p", "stock_inout_parts_id", "", dicParam);
        }
Esempio n. 4
0
        /// <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
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 审核通过后需要自动生成的单子的方法
        /// </summary>
        void CreateBill(List<string> listField)
        {
            if (listField.Count > 0)
            {
                List<SysSQLString> listSql = new List<SysSQLString>();
                DataTable TemplateTable = CommonFuncCall.CreatePartStatisticTable();//获取要填充的公用表
                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 开单审核通过后,更新配件的账面库存
                        string str_time = Common.UtcLongToLocalDateTime(model.order_date).ToShortDateString();
                        long long_time = Common.LocalDateTimeToUtcLong(Convert.ToDateTime(str_time));
                        DataTable IOPartTable = DBHelper.GetTable("", "tb_parts_sale_billing_p", "*", string.Format("sale_billing_id='{0}'", listField[i]), "", "");
                        if (IOPartTable != null && IOPartTable.Rows.Count > 0)
                        {
                            for (int a = 0; a < IOPartTable.Rows.Count; a++)
                            {
                                DataRow dr = TemplateTable.NewRow();//创建模版表行项
                                dr["OrderDate"] = long_time.ToString();//单据日期
                                dr["WareHouseID"] = CommonCtrl.IsNullToString(IOPartTable.Rows[a]["wh_id"]);//仓库ID
                                dr["WareHouseName"] = CommonCtrl.IsNullToString(IOPartTable.Rows[a]["wh_name"]);//仓库名称
                                dr["PartID"] = CommonCtrl.IsNullToString(IOPartTable.Rows[a]["parts_id"]);//配件ID
                                dr["PartCode"] = IOPartTable.Rows[a]["parts_code"].ToString();//配件编码
                                dr["PartName"] = IOPartTable.Rows[a]["parts_name"].ToString();//配件名称
                                dr["PartSpec"] = IOPartTable.Rows[a]["model"].ToString();//配件规格
                                dr["PartBarCode"] = IOPartTable.Rows[a]["parts_barcode"].ToString();//配件条码
                                dr["CarPartsCode"] = IOPartTable.Rows[a]["car_factory_code"].ToString();//车厂编码
                                dr["DrawNum"] = IOPartTable.Rows[a]["drawing_num"].ToString();//配件图号
                                dr["UnitName"] = IOPartTable.Rows[a]["unit_name"].ToString();//单位名称
                                //dr["PartCount"] = IOPartTable.Rows[a]["business_count"].ToString();//配件业务数量
                                dr["PartCount"] = Convert.ToDecimal(IOPartTable.Rows[a]["business_count"].ToString());//配件业务数量
                                dr["StatisticType"] = (int)DataSources.EnumStatisticType.PaperCount;//统计类型
                                TemplateTable.Rows.Add(dr);//添加新的数据行项
                            }
                        }
                        #endregion

                        #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 自动生产出入库单
                        #region 1:销售开单(业务数量大于0)-->自动生成出库单
                        if (model.order_type == Convert.ToInt32(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);
                                        bool ret = CreateIntoPartsStock(stock_inout_id, bill_p_model, model.sale_billing_id, model.order_num);
                                    }
                                }
                            }
                        } 
                        #endregion

                        #region 2:销售退货(业务数量小于0)-->自动生成入库单
                        else if (model.order_type == Convert.ToInt32(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);
                                        bool ret = CreateIntoPartsStock(stock_inout_id, bill_p_model, model.sale_billing_id, model.order_num);
                                    }
                                }
                            }

                            #region 当销售退货时,将勾选了报损的配件信息生成报损单
                            DataTable dt_loss_parts = DBHelper.GetTable("查询销售开单配件信息表", "tb_parts_sale_billing_p", "*", " is_loss='1' and sale_billing_id='" + model.sale_billing_id + "'", "", "");
                            if (dt_loss_parts != null && dt_loss_parts.Rows.Count > 0)
                            {
                                string stock_loss_id = string.Empty;
                                if (CreateIntoLoss(model, ref stock_loss_id))
                                {
                                    for (int a = 0; a < dt_loss_parts.Rows.Count; a++)
                                    {
                                        tb_parts_sale_billing_p bill_p_model = new tb_parts_sale_billing_p();
                                        CommonFuncCall.SetModlByDataTable(bill_p_model, dt_loss_parts, a);
                                        bool ret = CreateIntoPartsLoss(stock_loss_id, bill_p_model, model.sale_billing_id, model.order_num);
                                    }
                                }
                            }
                            #endregion
                        }
                        #endregion

                        #region 3:销售换货-->自动生成出、入库单(数量大于0是出库,小于0是入库)
                        else if (model.order_type == Convert.ToInt32(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 isnull(business_count,0)<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);
                                        bool ret = CreateIntoPartsStock(stock_in_id, bill_p_model, model.sale_billing_id, model.order_num);
                                    }
                                }
                            }

                            //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 isnull(business_count,0)>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);
                                        bool ret = CreateIntoPartsStock(stock_out_id, bill_p_model, model.sale_billing_id, model.order_num);
                                    }
                                }
                            }
                        } 
                        #endregion
                        #endregion

                        #region 审核通过时,将本次现收更新到已结算金额中
                        if (model.current_collect > 0)
                        {
                            SysSQLString sysStringSql = new SysSQLString();
                            sysStringSql.cmdType = CommandType.Text;
                            Dictionary<string, string> dicParam = new Dictionary<string, string>();//参数
                            dicParam.Add("balance_money", model.current_collect.ToString());
                            dicParam.Add("sale_billing_id", listField[i]);
                            StringBuilder sb = new StringBuilder();
                            sb.Append(" Update tb_parts_sale_billing Set balance_money=@balance_money where sale_billing_id=@sale_billing_id");
                            sysStringSql.Param = dicParam;
                            sysStringSql.sqlString = sb.ToString();
                            listSql.Add(sysStringSql);
                        }
                        #endregion
                    }
                }
                CommonFuncCall.StatisticStock(TemplateTable, "销售开单审核通过后更新配件的账面库存");
                //审核通过时,将本次现收更新到已结算金额中
                if (listSql.Count > 0)
                {
                    DBHelper.BatchExeSQLStringMultiByTrans("采购销售审核通过时,将本次现收更新到已结算金额中", listSql);
                }
            }
        }