Beispiel #1
0
        /// <summary>
        /// 星创销售订单导入
        /// </summary>
        /// <param name="dt"></param>
        private bool InsertSaleBill_XC(DataTable dt)
        {
            DataTable tmpdt = FilterData(dt, "数量 > 0");

            //CustomDesktopAlert.H2(tmpdt.Rows.Count.ToString());

            if (tmpdt.Rows.Count > 0)
            {
                Huali.EDI2.DAL.SEOutStock dSale = new EDI2.DAL.SEOutStock();
                int    interId      = dSale.GetMaxFInterID();
                string billNo       = dSale.GetMaxFBillNo();
                string sourceBillNo = tmpdt.Rows[0]["订单号"].ToString();
                //已经翻译到名店编号列
                int    custId      = int.Parse(tmpdt.Rows[0]["购货单位代码"].ToString());
                int    storeId     = int.Parse(tmpdt.Rows[0]["门店代码"].ToString());
                string productName = tmpdt.Rows[0]["收货方部门"].ToString();
                //string explanation = string.Format("补货 {0}", productName);
                string explanation = string.Format("{0}", productName);
                int    empId       = dSale.GetEmpIDByStoreID(storeId);
                Huali.EDI2.Models.SEOutStock mSale = BuildSaleModel(interId, billNo, storeId, explanation, sourceBillNo, custId, 20302, null, 15322, empId);
                try
                {
                    if (dSale.InsertBill(mSale) == true)
                    {
                        //CustomDesktopAlert.H2("写主表成功!");

                        //写子表
                        int succ = 0;
                        for (int i = 0; i < tmpdt.Rows.Count; i++)
                        {
                            Huali.EDI2.DAL.SEOutStockEntry dSaleEnrty = new EDI2.DAL.SEOutStockEntry();
                            int itemId  = int.Parse(tmpdt.Rows[i]["SKU"].ToString());
                            int entryId = i + 1;
                            int stockId = int.Parse(tmpdt.Rows[i]["仓库"].ToString());
                            int qty     = int.Parse(tmpdt.Rows[i]["数量"].ToString());
                            //int cxType = int.Parse(tmpdt.Rows[i]["促销类别"].ToString());
                            Huali.EDI2.DAL.T_ICItem dicitem = new EDI2.DAL.T_ICItem();
                            //decimal price = dicitem.GetSalePriceByFItemID(itemId);
                            decimal price  = 0;
                            int     unitid = dicitem.GetUnitIDByitemID(itemId);

                            Huali.EDI2.Models.SEOutStockEntry mSaleEntry = BuildSaleEntryModel(interId, entryId, itemId, stockId, qty, price, 0, 0, 0, 0, 0, 0, 40384, 40470, unitid);

                            if (dSaleEnrty.InsertBillEntry(mSaleEntry))
                            {
                                succ += 1;
                            }
                        }
                        if (succ == tmpdt.Rows.Count)
                        {
                            CustomDesktopAlert.H2("单据号 " + billNo + " :" + succ + " 条记录导入成功!</h2>");
                            return(true);
                        }
                        else
                        {
                            CustomDesktopAlert.H2(billNo + "写子表失败!");
                            return(false);
                        }
                    }
                    else
                    {
                        CustomDesktopAlert.H2("写主数据表失败");
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return(false);
                }
            }
            else
            {
                CustomDesktopAlert.H2("没有可用的数据!");
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        private bool CheckData_XC(DataTable dt)
        {
            bool retVal = true;

            foreach (DataRow dr in dt.Rows)
            {
                //检查产品代码
                Huali.EDI2.DAL.T_ICItem dICItem = new EDI2.DAL.T_ICItem();
                string rowNum    = dr["序号"].ToString();
                string sku       = dr["SKU"].ToString();
                int    productId = dICItem.GetItemIDBySKU(sku);
                if (productId == 0)
                {
                    CustomDesktopAlert.H2("第" + rowNum + "行产品编号不能识别!");
                    retVal = false;
                }
                else
                {
                    dr["SKU"] = productId.ToString();
                }

                //检查门店ID
                string storeNumber = dr["门店代码"].ToString();
                int    storeId     = dICItem.GetCustIDByFnumber(storeNumber);
                if (storeId == 0)
                {
                    CustomDesktopAlert.H2("第" + rowNum + "行门店代码不能识别!");
                    //总店编号检查
                    storeNumber = storeNumber.Substring(0, storeNumber.Length - 3) + "001";
                    storeId     = dICItem.GetCustIDByFnumber(storeNumber);
                    if (storeId == 0)
                    {
                        CustomDesktopAlert.H2("第" + rowNum + "行总店编号不能识别!");
                        return(false);
                    }
                    else
                    {
                        dr["门店代码"] = storeId.ToString();
                    }
                }
                else
                {
                    dr["门店代码"] = storeId.ToString();
                }

                //检查客户ID
                string customNumber = dr["购货单位代码"].ToString();
                int    customId     = dICItem.GetCustIDByFnumber(customNumber);
                if (customId == 0)
                {
                    CustomDesktopAlert.H2("第" + rowNum + "行客户编号不能识别!");
                    return(false);
                }
                else
                {
                    dr["购货单位代码"] = customId.ToString();
                }

                //仓库编号
                string stockName = dr["仓库"].ToString();
                int    stockId   = dICItem.GetStockIDByFName(stockName);
                if (stockId == 0)
                {
                    CustomDesktopAlert.H2("第" + rowNum + "行仓库编号不能识别!");
                    return(false);
                }
                else
                {
                    dr["仓库"] = stockId.ToString();
                }

                //促销类别
                string cuxiaoType = dr["促销类别"].ToString();
                Huali.EDI2.DAL.SEOutStockEntry dEntry = new EDI2.DAL.SEOutStockEntry();
                int cxType = dEntry.GetInterIDByFName(cuxiaoType);
                dr["促销类别"] = cxType.ToString();
            }
            return(retVal);
        }
Beispiel #3
0
        /// <summary>
        /// 将一张订单的数据写入数据库
        /// </summary>
        /// <param name="dt">一张订单的数据</param>
        private bool InsertSaleBill_RL(DataTable dt)
        {
            Huali.EDI2.DAL.SEOutStock dSale = new EDI2.DAL.SEOutStock();
            int    interId      = dSale.GetMaxFInterID();
            string billNo       = dSale.GetMaxFBillNo();
            string sourceBillNo = dt.Rows[0]["订单号"].ToString();
            //已经翻译到名店编号列
            int    custId      = int.Parse(dt.Rows[0]["客户编号"].ToString());
            int    storeId     = int.Parse(dt.Rows[0]["门店编号"].ToString());
            string productName = dt.Rows[0]["补货产品名称"].ToString();
            string explanation = string.Format("免费品 {0} 2+1+1", productName);
            int    empId       = dSale.GetEmpIDByStoreID(storeId);

            Huali.EDI2.Models.SEOutStock mSale = BuildSaleModel(interId, billNo, storeId, explanation, sourceBillNo, custId, 20303, 40394, 15326, empId);
            try
            {
                if (dSale.InsertBill(mSale) == true)
                {
                    //CustomDesktopAlert.H2("写主表成功!");

                    //写子表
                    int succ = 0;
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Huali.EDI2.DAL.SEOutStockEntry dSaleEnrty = new EDI2.DAL.SEOutStockEntry();
                        int itemId  = int.Parse(dt.Rows[i]["补货产品编号"].ToString());
                        int entryId = i + 1;
                        int stockId = 526;//CSW
                        int qty     = int.Parse(dt.Rows[i]["补货数量"].ToString());
                        Huali.EDI2.DAL.T_ICItem dicitem = new EDI2.DAL.T_ICItem();
                        decimal price = dicitem.GetSalePriceByFItemID(itemId);

                        //Huali.EDI2.Models.SEOutStockEntry mSaleEntry = BuildSaleEntryModel(interId, entryId, itemId, stockId, qty, price, 0, 0, qty, qty, 0, 0,40311,40635, 255);
                        Huali.EDI2.Models.SEOutStockEntry mSaleEntry = BuildSaleEntryModel(interId, entryId, itemId, stockId, qty, price, 0, 0, 0, 0, 0, 0, 40311, 40635, 255);

                        if (dSaleEnrty.InsertBillEntry(mSaleEntry))
                        {
                            succ += 1;
                        }
                    }
                    if (succ == dt.Rows.Count)
                    {
                        CustomDesktopAlert.H2("单据号 " + billNo + " :" + succ + " 条记录导入成功!");
                        return(true);
                    }
                    else
                    {
                        CustomDesktopAlert.H2(billNo + "写子表失败!");
                        return(false);
                    }
                }
                else
                {
                    CustomDesktopAlert.H2("写主数据表失败");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }