示例#1
0
 public bool insertSalesDetailFrist(string SalesOrderID, string SalesOutID)
 {
     try
     {
         List <VSalesDetail> list = new List <VSalesDetail>();
         SalesOutDetailDAL   ldal = new SalesOutDetailDAL();
         list = new SalesDetailDAL().getBySalesOrderID(SalesOrderID);
         for (int i = 0; i < list.Count; i++)
         {
             SalesOutDetail b       = new SalesOutDetail();
             VSalesDetail   detail2 = list[i];
             b.ProductsID   = detail2.ProductsID;
             b.Quantity     = detail2.Quantity;
             b.SalesOutID   = SalesOutID;
             b.DiscountRate = detail2.DiscountRate;
             b.Description  = detail2.Description;
             b.Price        = detail2.Price;
             ldal.insertNewEitity(b);
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#2
0
        public bool AuditingSalesOutOrder(string SalesOutID)
        {
            bool flag = false;

            try
            {
                VSalesOut @out = new VSalesOut();
                List <VSalesOutDetail> list = new List <VSalesOutDetail>();
                ProductsStockDAL       kdal = new ProductsStockDAL();
                @out = new SalesOutDAL().getByID(SalesOutID);
                list = new SalesOutDetailDAL().getBySalesOutID(SalesOutID);
                for (int i = 0; i < list.Count; i++)
                {
                    ProductsStock  stock;
                    SalesOutDetail detail = list[i];
                    if (kdal.isHaveEitity(detail.HouseDetailID, detail.ProductsID))
                    {
                        stock = new ProductsStock();
                        stock.HouseDetailID = detail.HouseDetailID;
                        stock.ProductsID    = detail.ProductsID;
                        stock.Num           = detail.Quantity;
                        kdal.updateCutNum(stock);
                    }
                    else
                    {
                        stock = new ProductsStock();
                        stock.HouseDetailID = detail.HouseDetailID;
                        stock.ProductsID    = detail.ProductsID;
                        stock.Num           = -detail.Quantity;
                        kdal.insertNewEitity(stock);
                    }
                }
                flag = true;
            }
            catch
            {
            }
            return(flag);
        }
示例#3
0
    /// <summary>
    /// 根据SalesOrderID 快速生成
    /// </summary>
    /// <param name="SalesOrderID"></param>

    private void buildNode(string SalesOrderID, int DeliveryID)
    {
        bool result = true;

        VSalesOrder vo = Leyp.SQLServerDAL.Sales.Factory.getSalesOrderDAL().getByID(SalesOrderID);

        if (vo == null)
        {
            Response.Write("订单号:" + SalesOrderID + " 有误<br>");
            return;
        }
        if (vo.State != 1)//订单没有审核
        {
            Response.Write("订单号:" + SalesOrderID + " 没有审核或已经处理<br>");
            return;
        }

        string SalesOutID = getSalesOutID();
        // int DeliveryID = Leyp.SQLServerDAL.Factory.getDeliveryDAL().getDefaultEitity().DeliveryID;//得到默认得
        SalesOut s = new SalesOut();

        s.Consignee    = "未知";
        s.CreateDate   = DateTime.Now.ToString("yyyy-MM-dd");
        s.DeliveryID   = DeliveryID;
        s.TradeDate    = DateTime.Now.ToString("yyyy-MM-dd");
        s.Deposits     = float.Parse("0.00");
        s.Description  = "无";
        s.UserName     = getUserName();
        s.State        = 0;
        s.SalesOutID   = SalesOutID;
        s.SalesOrderID = SalesOrderID;
        s.AccountsID   = "无";


        Leyp.SQLServerDAL.Sales.Factory.getSalesOutDAL().insertSalesDetailFrist(SalesOrderID, SalesOutID);//临时添加详细

        List <VSalesOutDetail> list = Leyp.SQLServerDAL.Sales.Factory.getSalesOutDetailDAL().getBySalesOutIDinit(SalesOutID);

        for (int i = 0; i < list.Count; i++)
        {
            if (result == false)
            {
                break;
            }



            VSalesOutDetail       v          = list[i];
            int                   ProductsID = v.ProductsID;
            List <VProductsStock> list0      = Leyp.SQLServerDAL.Factory.getProductsStockDAL().getStockList(ProductsID); //寻找库存

            if (list0 == null || list0.Count == 0)                                                                       //没有库存
            {
                result = false;
                break;
            }

            VProductsStock vp = null;

            for (int j = 0; j < list0.Count; j++)
            {
                VProductsStock vps = list0[j];
                if (vps.Num >= v.Quantity)//有库存 并且数量合理
                {
                    vp = vps;
                    break;
                }
            }

            if (vp == null)//没有库存 失败!
            {
                result = false;
                break;
            }


            SalesOutDetail d = new SalesOutDetail();
            d.SalesOutID    = v.SalesOutID;
            d.ProductsID    = v.ProductsID;
            d.Price         = v.Price;
            d.Quantity      = v.Quantity;
            d.DiscountRate  = v.DiscountRate;
            d.Description   = v.Description;
            d.DetailID      = v.DetailID;
            d.StoreHouseID  = vp.HouseID;
            d.HouseDetailID = vp.HouseDetailID;
            Leyp.SQLServerDAL.Sales.Factory.getSalesOutDetailDAL().updateEitity(d);
        }

        if (result == true)
        {
            if (Leyp.SQLServerDAL.Sales.Factory.getSalesOutDAL().insertNewEntity(s))
            {
                Response.Write("单号:" + SalesOrderID + "  --生成成功<br>");
            }
        }
        else
        {
            Response.Write("订单号:" + SalesOrderID + "  不能生成,可能库存不足<br>");
        }
    }
    protected void init()
    {
        string action = Request.Form["action"].ToString();

        if (action.Equals("addDetail"))//明细添加
        {
            string str0 = Request.Form["SalesOutID"].ToString();
            string str1 = Request.Form["ProductsID"].ToString();
            string str2 = Request.Form["Price"].ToString();
            string str3 = Request.Form["Quantity"].ToString();
            string str4 = Request.Form["DiscountRate"].ToString();
            string str5 = Request.Form["Descriptions"].ToString();

            SalesOutDetail d = new SalesOutDetail();
            d.SalesOutID   = str0;
            d.ProductsID   = int.Parse(str1);
            d.Price        = float.Parse(str2);
            d.Quantity     = int.Parse(str3);
            d.DiscountRate = float.Parse(str4);
            d.Description  = str5;
            Leyp.SQLServerDAL.Sales.Factory.getSalesOutDetailDAL().insertNewEitity(d);
            Response.Write("00");
            Response.End();
        }
        else if (action.Equals("LoadDetail"))//加载明细BY  SalesOrderID
        {
            string str0 = Request.Form["SalesOutID"].ToString();
            loadinit(str0);
        }
        else if (action.Equals("delDetail"))//delete
        {
            string str0 = Request.Form["DetailID"].ToString();
            Leyp.SQLServerDAL.Sales.Factory.getSalesOutDetailDAL().deleteEitity(int.Parse(str0));
            Response.Write("00");
            Response.End();
        }
        else if (action.Equals("getNode"))//得到编辑节点
        {
            getNode();
        }
        else if (action.Equals("editDetail"))//编辑节点
        {
            string str0 = Request.Form["SalesOutID"].ToString();
            string str1 = Request.Form["ProductsID"].ToString();
            string str2 = Request.Form["Price"].ToString();
            string str3 = Request.Form["Quantity"].ToString();
            string str4 = Request.Form["DiscountRate"].ToString();
            string str5 = Request.Form["Descriptions"].ToString();
            string str6 = Request.Form["DetailID"].ToString();

            string str7 = Request.Form["StoreHouseID"].ToString();
            string str8 = Request.Form["HouseDetailID"].ToString();

            SalesOutDetail d = new SalesOutDetail();
            d.SalesOutID    = str0;
            d.ProductsID    = int.Parse(str1);
            d.Price         = float.Parse(str2);
            d.Quantity      = int.Parse(str3);
            d.DiscountRate  = float.Parse(str4);
            d.Description   = str5;
            d.DetailID      = int.Parse(str6);
            d.StoreHouseID  = int.Parse(str7);
            d.HouseDetailID = int.Parse(str8);
            Leyp.SQLServerDAL.Sales.Factory.getSalesOutDetailDAL().updateEitity(d);
            Response.Write("00");
            Response.End();
        }
        else if (action.Equals("LoadDetailEdit"))//编辑节点
        {
            string str0 = Request.Form["SalesOutID"].ToString();
            loadinitEdit(str0);
        }
        else if (action.Equals("checkEdit"))//检查仓库编辑完成了没有
        {
            string str0 = Request.Form["SalesOutID"].ToString();
            checkEdit(str0);
        }
        else if (action.Equals("LoadDetailPrint"))//快递单打印
        {
            string str0 = Request.Form["SalesOutID"].ToString();
            LoadDetailPrint(str0);
        }
        else if (action.Equals("checkProductsNum"))//得到一个库区一个商品数量
        {
            string PID = Request.Form["ProductsID"].ToString();
            string HID = Request.Form["HouseDetailID"].ToString();
            Response.Clear();
            checkProductsNum(int.Parse(HID), int.Parse(PID));
        }
    }