Esempio n. 1
0
        public ActionResult StockDeleting(int stockID)
        {
            try
            {
                StockModel sModel = new StockModel();
                sModel.STOCK_ID = stockID;

                Database db   = new Database();
                StockDAO sDAO = new StockDAO(db);
                sDAO.Delete(sModel);
                db.Close();

                return(Redirect("~/Stock"));
            }
            catch
            {
                return(RedirectToAction("alert", "Stock", new { link = "", massage = "มีรายการที่อ้างถึงข้อมูลนี้อยู่ ไม่สามารถลบได้" }));
            }
        }
Esempio n. 2
0
        public void UpdateKitchenStockForSendOut(Stock aStock)
        {
            Stock    stock = new Stock();
            StockDAO aDao  = new StockDAO();

            stock = aDao.GetStockByItemidFrominventory_kitchen_stock(aStock.Item.ItemId);
            if (stock.StockId == 0)
            {
                aDao.InsertStock(aStock);
            }
            else if (stock.StockId > 0)
            {
                double totalStocks = stock.Stocks - aStock.Stocks;
                // double totalPrice = priceNow + pricePrevious;
                stock.Stocks  = totalStocks;
                stock.StockId = stock.StockId;
                aDao.UpdateKitchenStock(stock);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 删除出库单数据
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool DeleteOutWarehouseBill(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        //如果出库单是由出仓单自动生成的,则不允许手工删除
                        OutWarehouseBill bill = dao.LoadOutWarehouseBill(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }
                        if (bill.ShipmentBillId > 0)
                        {
                            strErrText = InnoSoft.LS.Resources.Strings.CanNotDeleteOutWarehouseBillCreateByShipmentBill;
                            return(false);
                        }

                        //删除出库单数据
                        if (!dao.DeleteOutWarehouseBill(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出库单货物数据
                        if (!dao.DeleteOutWarehouseBillAllGoods(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Esempio n. 4
0
        public ActionResult StockUpdating(int partsID, string stockInfo, int unit, int price, int stockID)
        {
            System.Diagnostics.Debug.WriteLine("StockUpdating :" + stockID + " partsID" + partsID + " stockInfo" + stockInfo + " unit" + unit + " price" + price);
            StockModel sModel = new StockModel();

            sModel.STOCK_ID     = stockID;
            sModel.PART         = new PartsModel();
            sModel.PART.PART_ID = partsID;
            sModel.STOCK_INFO   = stockInfo;
            sModel.UNIT         = unit;
            sModel.PRICE        = price;

            Database db   = new Database();
            StockDAO sDAO = new StockDAO(db);

            sDAO.Update(sModel);
            db.Close();

            return(Redirect("~/Stock"));
        }
Esempio n. 5
0
        public static bool DoMovement(Movement m, Window w)
        {
            //Si no hay stock suficiente, anular el movimiento
            if (m.Article.Stock.CurrentStock < m.Ammount)
            {
                DialogHelper.ShowDialog("Error de stock", "Stock insuficiente\n" +
                                        "Stock actual: " + m.Article.Stock.CurrentStock, w,
                                        DialogFlags.Modal | DialogFlags.DestroyWithParent, "Volver", ResponseType.Close);
                return(false);
            }
            //Si después del movimiento quedan menos del mínimo
            if ((m.Article.Stock.CurrentStock - m.Ammount) < m.Article.Stock.MinStock &&
                m.Type.Equals(Movement.M_OUT))
            {
                DialogHelper.ShowDialog("Advertencia de stock", "El stock actual de " +
                                        m.Article.Name + " \nha alcanzado el mínimo establecido", w,
                                        DialogFlags.Modal | DialogFlags.DestroyWithParent, "Aceptar", ResponseType.Close);
            }
            //Si después del movimiento el stock sobrepasa el límite máximo
            if ((m.Article.Stock.CurrentStock + m.Ammount) > m.Article.Stock.MaxStock &&
                m.Type.Equals(Movement.M_IN))
            {
                DialogHelper.ShowDialog("Aviso de stock", "El stock actual de " +
                                        m.Article.Name + " \nha superado el máximo establecido", w,
                                        DialogFlags.Modal | DialogFlags.DestroyWithParent, "Aceptar", ResponseType.Close);
            }

            switch (m.Type)
            {
            case Movement.M_IN:
                m.Article.Stock.CurrentStock += m.Ammount;
                break;

            case Movement.M_OUT:
                m.Article.Stock.CurrentStock -= m.Ammount;
                break;
            }
            StockDAO.Update(m.Article.Stock);
            MovementDAO.Save(m);
            return(true);
        }
Esempio n. 6
0
        public static void ClosePurchaseOrder(PurchaseOrder order, List <long> itemIds, List <int> itemQuantities)
        {
            PurchaseOrderDAO.ClosePurchaseOrder(order.OrderNumber);

            int totalQuantity = itemQuantities.Sum(m => m);

            //if no more items in Purchase Order, to remove record from Purchase Order and Purchase Order Details
            if (totalQuantity == 0)
            {
                PurchaseOrderDAO.DeleteAllPurchaseOrderDetails(order.OrderId);
                PurchaseOrderDAO.DeletePurchaseOrder(order.OrderId);
            }
            else
            {
                //Update quantities(if any)
                for (int i = 0; i < itemIds.Count; i++)
                {
                    if (itemQuantities[i] == 0)
                    {
                        PurchaseOrderDAO.DeleteItemFromPurchaseOrder(order.OrderId, itemIds[i]);
                    }
                    else
                    {
                        PurchaseOrderDAO.UpdatePurchaseOrderItemQuantity(order.OrderId, itemIds[i], itemQuantities[i]);
                    }
                }
            }

            //Updated inventory stock level
            PurchaseOrder          updatedOrder    = GetOrderDetails(order.OrderNumber);
            Dictionary <long, int> itemAndNewStock = new Dictionary <long, int>();

            foreach (var item in updatedOrder.ItemDetails)
            {
                itemAndNewStock[item.ItemId] = item.Quantity + item.Item.StockLevel;
            }

            //Update stock level for items in Purchase Order to be closed
            StockDAO.UpdateInventoryStock(itemAndNewStock);
        }
Esempio n. 7
0
        /// <summary>
        /// 新增移库记录
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public long InsertMoveWarehouseBill(MoveWarehouseBill bill, List <MoveWarehouseBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            long nMoveWarehouseBillId = 0;

            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        //新增移库单数据
                        nMoveWarehouseBillId = dao.InsertMoveWarehouseBill(bill, nOpStaffId, strOpStaffName, out strErrText);
                        if (nMoveWarehouseBillId <= 0)
                        {
                            return(0);
                        }

                        //新增移库货物数据
                        foreach (MoveWarehouseBillGoods goods in listGoods)
                        {
                            goods.MoveWarehouseBillId = nMoveWarehouseBillId;

                            if (!dao.InsertMoveWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(0);
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(nMoveWarehouseBillId);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(0);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// 删除移库单数据
 /// </summary>
 /// <param name="bill"></param>
 /// <param name="listGoods"></param>
 /// <param name="nOpStaffId"></param>
 /// <param name="strOpStaffName"></param>
 /// <param name="strErrText"></param>
 /// <returns></returns>
 public bool DeleteMoveWarehouseBill(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
 {
     try
     {
         using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
         {
             using (StockDAO dao = new StockDAO())
             {
                 if (!dao.DeleteMoveWarehouseBill(nId, nOpStaffId, strOpStaffName, out strErrText))
                 {
                     return(false);
                 }
             }
             transScope.Complete();
         }
         return(true);
     }
     catch (Exception e)
     {
         strErrText = e.Message;
         return(false);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// 根据综合条件读取仓储力支费结算数据
        /// </summary>
        /// <param name="strStartTime"></param>
        /// <param name="strEndTime"></param>
        /// <param name="strInvoiceNo"></param>
        /// <param name="strCustomerName"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public List <CustomerStorageAndForceFeeSettlement> LoadCustomerStorageAndForceFeeSettlementsByConditions(string strStartTime, string strEndTime, string strInvoiceNo, string strCustomerName, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                List <CustomerStorageAndForceFeeSettlement> dataResult = null;
                strErrText = String.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        dataResult = dao.LoadCustomerStorageAndForceFeeSettlementsByConditions(strStartTime, strEndTime, strInvoiceNo, strCustomerName, nOpStaffId, strOpStaffName, out strErrText);
                    }
                    transScope.Complete();
                }
                return(dataResult);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 读取库存尾差数据
        /// </summary>
        /// <param name="strCustomerName"></param>
        /// <param name="strGoodsId"></param>
        /// <param name="strWarehouse"></param>
        /// <param name="strIsConsigning"></param>
        /// <param name="strConsignedDeliveryNo"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public List <Stock> LoadStockEndDifferencesByConditions(string strCustomerName, string strGoodsId, string strWarehouse, string strIsConsigning, string strConsignedDeliveryNo, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                List <Stock> dataResult = null;
                strErrText = String.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        dataResult = dao.LoadStockEndDifferencesByConditions(strCustomerName, strGoodsId, strWarehouse, strIsConsigning, strConsignedDeliveryNo, nOpStaffId, strOpStaffName, out strErrText);
                    }
                    transScope.Complete();
                }
                return(dataResult);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(null);
            }
        }
Esempio n. 11
0
    public static void LoadPurchaseRecords()
    {
        // Load stocks if not loaded
        if (Stocks.Count == 0)
        {
            StockDAO dao = new StockDAO();
            Stocks.AddRange(dao.RetrieveStocks());
        }

        purchaseRecords.Clear();

        List <StockPurchaseRecord> stockPurchaseRecords;

        foreach (Player player in GameStore.Players)
        {
            stockPurchaseRecords = new List <StockPurchaseRecord>();
            foreach (Stock stock in Stocks)
            {
                stockPurchaseRecords.Add(new StockPurchaseRecord(stock.Name));
            }

            purchaseRecords.Add(player.Name, stockPurchaseRecords);
        }
    }
Esempio n. 12
0
        // SELECT
        public static StockDAO SelectStockById(string id)
        {
            var stockDao = new StockDAO();
            // Selectionne la stock a partir de l'id
            var query =
                "SELECT * FROM public.stock a where a.\"idStock\"=:idStockParam";
            var cmd = new NpgsqlCommand(query, DALconnection.OpenConnection());

            cmd.Parameters.AddWithValue("idStockParam", id);

            var reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                // récup les paramètres principaux
                var idStock   = (string)reader["idStock"];
                var adresseId = (string)reader["adresseId"];

                stockDao = new StockDAO(idStock, adresseId);
            }

            reader.Close();
            return(stockDao);
        }
Esempio n. 13
0
        public async static Task <List <Inventory> > GetAllItemsOrdered()
        {
            List <Inventory> items = StockDAO.GetAllItemsOrdered();

            //Contact Python API to get predicted re-order amount and level for item with code 'P021' and 'P030'
            string data;

            string[] preds = new string[] { };

            foreach (var item in items)
            {
                if (item.ItemCode == "P021" || item.ItemCode == "P030")
                {
                    data = await AnalyticsService.GetRequest("http://127.0.0.1:5000/reorder/" + item.ItemCode);

                    preds             = data.Split(new char[] { ',', '[', ']' }, StringSplitOptions.RemoveEmptyEntries);
                    item.ReorderQty   = (int)Math.Round(double.Parse(preds[0]));
                    item.ReorderLevel = (int)Math.Round(double.Parse(preds[1]));
                }
            }
            //Using Comparable to sort by (stockLevel - reorderLevel)
            items.Sort();
            return(items);
        }
Esempio n. 14
0
        /// <summary>
        /// 修改出库单数据
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateOutWarehouseBill(OutWarehouseBill bill, List <OutWarehouseBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        //修改出库单数据
                        if (!dao.UpdateOutWarehouseBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //修改出库货物数据
                        foreach (OutWarehouseBillGoods goods in listGoods)
                        {
                            if (!dao.UpdateOutWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    using (CustomerDAO dao = new CustomerDAO())
                    {
                        //修改上力支费价格数据
                        List <CustomerForceFeePrice> listForceFeePrice = dao.LoadCustomerForceFeePricesByCustomerId(bill.CustomerId, nOpStaffId, strOpStaffName, out strErrText);
                        if (listForceFeePrice.Count == 0)
                        {
                            //新增力支费价格数据
                            CustomerForceFeePrice data = new CustomerForceFeePrice();
                            data.CustomerId             = bill.CustomerId;
                            data.StartTime              = bill.CreateTime;
                            data.EndTime                = DateTime.Parse("9999-12-31");
                            data.LoadingForceFeePrice   = bill.LoadingForceFeePrice;
                            data.UnloadingForceFeePrice = 0;

                            if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            int i = 0;
                            while (i < listForceFeePrice.Count)
                            {
                                if (bill.CreateTime.Date >= listForceFeePrice[i].StartTime.Date && bill.CreateTime.Date <= listForceFeePrice[i].EndTime.Date)
                                {
                                    break;
                                }
                                i++;
                            }
                            if (i < listForceFeePrice.Count)
                            {
                                //修改力支费价格数据
                                listForceFeePrice[i].LoadingForceFeePrice = bill.LoadingForceFeePrice;

                                if (!dao.UpdateCustomerForceFeePrice(listForceFeePrice[i], nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                //新增力支费价格数据
                                CustomerForceFeePrice data = new CustomerForceFeePrice();
                                data.CustomerId             = bill.CustomerId;
                                data.StartTime              = bill.CreateTime;
                                data.LoadingForceFeePrice   = bill.LoadingForceFeePrice;
                                data.UnloadingForceFeePrice = 0;

                                //计算截止时间
                                i = 0;
                                while (i < listForceFeePrice.Count)
                                {
                                    if (bill.CreateTime.Date < listForceFeePrice[i].StartTime.Date)
                                    {
                                        break;
                                    }
                                    i++;
                                }
                                if (i < listForceFeePrice.Count)
                                {
                                    data.EndTime = listForceFeePrice[i].StartTime.Date.AddDays(-1);
                                }
                                else
                                {
                                    data.EndTime = DateTime.Parse("9999-12-31");
                                }

                                if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 修改入库单数据
        /// </summary>
        /// <param name="bill"></param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateEnterWarehouseBill(EnterWarehouseBill bill, List <EnterWarehouseBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (StockDAO dao = new StockDAO())
                    {
                        //读取原入库单货物数据
                        List <EnterWarehouseBillGoods> listOldGoods = dao.LoadEnterWarehouseBillAllGoods(bill.Id, nOpStaffId, strOpStaffName, out strErrText);
                        if (listOldGoods == null)
                        {
                            return(false);
                        }

                        //如果划拨计划所产生的入库单,则修改前必须检查新旧货物的数量
                        if (bill.PlanId > 0)
                        {
                            //检查每个品种数据
                            var grpOldGoods = listOldGoods.GroupBy(g => new { g.GoodsNo, g.BatchNo, g.Packing, g.ProductionDate, g.EnterWarehouseBillId });
                            foreach (var grpOld in grpOldGoods)
                            {
                                string  strGoodsNo            = grpOld.Key.GoodsNo;
                                string  strBatchNo            = grpOld.Key.BatchNo;
                                string  strPacking            = grpOld.Key.Packing;
                                string  strProductionDate     = grpOld.Key.ProductionDate;
                                long    nEnterWarehouseBillId = grpOld.Key.EnterWarehouseBillId;
                                int     nOldTotalPackages     = grpOld.Sum(s => s.Packages);
                                decimal decOldTotalTunnages   = grpOld.Sum(s => s.Tunnages);

                                List <EnterWarehouseBillGoods> listNew = listGoods.Where(g => g.GoodsNo == strGoodsNo && g.BatchNo == strBatchNo && (g.Packing ?? string.Empty) == strPacking && g.ProductionDate == strProductionDate && g.EnterWarehouseBillId == nEnterWarehouseBillId).ToList();
                                if (nOldTotalPackages != listNew.Sum(g => g.Packages) || decOldTotalTunnages != listNew.Sum(g => g.Tunnages))
                                {
                                    strErrText = string.Format(InnoSoft.LS.Resources.Strings.GoodsModifyBeforeAndAfterPackagesOrTunnagesNotEqual, strGoodsNo, strBatchNo, strPacking, strProductionDate);
                                    return(false);
                                }
                            }

                            //检查总数量
                            if (listGoods.Sum(g => g.Packages) != listOldGoods.Sum(g => g.Packages) || listGoods.Sum(g => g.Tunnages) != listOldGoods.Sum(g => g.Tunnages))
                            {
                                strErrText = InnoSoft.LS.Resources.Strings.GoodsModifyBeforeAndAfterTotalPackagesOrTotalTunnagesNotEqual;
                                return(false);
                            }
                        }

                        //新增入库货物数据
                        foreach (EnterWarehouseBillGoods goods in listGoods)
                        {
                            if (goods.Id == 0)
                            {
                                if (!dao.InsertEnterWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }

                        //修改入库货物数据
                        foreach (EnterWarehouseBillGoods goods in listGoods)
                        {
                            if (goods.Id > 0)
                            {
                                if (!dao.UpdateEnterWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }

                        //删除入库单货物数据
                        foreach (EnterWarehouseBillGoods o in listOldGoods)
                        {
                            if (listGoods.FindAll(delegate(EnterWarehouseBillGoods g) { return(g.Id == o.Id); }).Count == 0)
                            {
                                if (!dao.DeleteEnterWarehouseBillGoods(o.Id, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }

                        //修改入库单数据
                        if (!dao.UpdateEnterWarehouseBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    using (CustomerDAO dao = new CustomerDAO())
                    {
                        //修改下力支费价格数据
                        List <CustomerForceFeePrice> listForceFeePrice = dao.LoadCustomerForceFeePricesByCustomerId(bill.CustomerId, nOpStaffId, strOpStaffName, out strErrText);
                        if (listForceFeePrice.Count == 0)
                        {
                            //新增力支费价格数据
                            CustomerForceFeePrice data = new CustomerForceFeePrice();
                            data.CustomerId             = bill.CustomerId;
                            data.StartTime              = bill.CreateTime;
                            data.EndTime                = DateTime.Parse("9999-12-31");
                            data.LoadingForceFeePrice   = 0;
                            data.UnloadingForceFeePrice = bill.UnloadingForceFeePrice;

                            if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            int i = 0;
                            while (i < listForceFeePrice.Count)
                            {
                                if (bill.CreateTime.Date >= listForceFeePrice[i].StartTime.Date && bill.CreateTime.Date <= listForceFeePrice[i].EndTime.Date)
                                {
                                    break;
                                }
                                i++;
                            }
                            if (i < listForceFeePrice.Count)
                            {
                                //修改力支费价格数据
                                listForceFeePrice[i].UnloadingForceFeePrice = bill.UnloadingForceFeePrice;

                                if (!dao.UpdateCustomerForceFeePrice(listForceFeePrice[i], nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                //新增力支费价格数据
                                CustomerForceFeePrice data = new CustomerForceFeePrice();
                                data.CustomerId             = bill.CustomerId;
                                data.StartTime              = bill.CreateTime;
                                data.LoadingForceFeePrice   = 0;
                                data.UnloadingForceFeePrice = bill.UnloadingForceFeePrice;

                                //计算截止时间
                                i = 0;
                                while (i < listForceFeePrice.Count)
                                {
                                    if (bill.CreateTime.Date < listForceFeePrice[i].StartTime.Date)
                                    {
                                        break;
                                    }
                                    i++;
                                }
                                if (i < listForceFeePrice.Count)
                                {
                                    data.EndTime = listForceFeePrice[i].StartTime.Date.AddDays(-1);
                                }
                                else
                                {
                                    data.EndTime = DateTime.Parse("9999-12-31");
                                }

                                if (!dao.InsertCustomerForceFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }

                        //修改仓储费价格数据
                        List <CustomerStorageFeePrice> listStorageFeePrice = dao.LoadCustomerStorageFeePricesByCustomerId(bill.CustomerId, nOpStaffId, strOpStaffName, out strErrText);
                        if (listStorageFeePrice.Count == 0)
                        {
                            //新增仓储费价格数据
                            CustomerStorageFeePrice data = new CustomerStorageFeePrice();
                            data.CustomerId      = bill.CustomerId;
                            data.StartTime       = bill.CreateTime;
                            data.EndTime         = DateTime.Parse("9999-12-31");
                            data.StorageFeePrice = bill.StorageFeePrice;

                            if (!dao.InsertCustomerStorageFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            int i = 0;
                            while (i < listStorageFeePrice.Count)
                            {
                                if (bill.CreateTime.Date >= listStorageFeePrice[i].StartTime.Date && bill.CreateTime.Date <= listStorageFeePrice[i].EndTime.Date)
                                {
                                    break;
                                }
                                i++;
                            }
                            if (i < listStorageFeePrice.Count)
                            {
                                //修改仓储费价格数据
                                listStorageFeePrice[i].StorageFeePrice = bill.StorageFeePrice;

                                if (!dao.UpdateCustomerStorageFeePrice(listStorageFeePrice[i], nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                //新增仓储费价格数据
                                CustomerStorageFeePrice data = new CustomerStorageFeePrice();
                                data.CustomerId      = bill.CustomerId;
                                data.StartTime       = bill.CreateTime;
                                data.StorageFeePrice = bill.StorageFeePrice;

                                //计算截止时间
                                i = 0;
                                while (i < listStorageFeePrice.Count)
                                {
                                    if (bill.CreateTime.Date < listStorageFeePrice[i].StartTime.Date)
                                    {
                                        break;
                                    }
                                    i++;
                                }
                                if (i < listStorageFeePrice.Count)
                                {
                                    data.EndTime = listStorageFeePrice[i].StartTime.Date.AddDays(-1);
                                }
                                else
                                {
                                    data.EndTime = DateTime.Parse("9999-12-31");
                                }

                                if (!dao.InsertCustomerStorageFeePrice(data, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Esempio n. 16
0
        private void TransactionWhenProfessionalPackageIsActive()
        {
            InventoryItem aItem = new InventoryItem();

            aItem = (InventoryItem)itemNamecomboBox.SelectedItem;
            InventoryCategory aInventoryCategory = new InventoryCategory();

            aInventoryCategory = (InventoryCategory)categoryNamecomboBox.SelectedItem;


            Stock       aStock          = new Stock();
            StockBLL    aStockBll       = new StockBLL();
            string      transactiontype = transactionTypecomboBox.SelectedItem.ToString();
            Transaction aTransaction    = new Transaction();

            aTransaction.TransactionDate = DateTime.Now;
            aTransaction.Item            = aItem;
            aTransaction.Category        = aInventoryCategory;
            aTransaction.TransactionType = transactiontype;
            CUserInfo aUserInfo = new CUserInfo();

            aUserInfo.UserName    = RMSGlobal.LogInUserName;
            aTransaction.UserInfo = aUserInfo;
            string sr = string.Empty;

            if (transactiontype == "Damage_in_Stock")
            {
                if (danmagetextBox.Text.Length > 0)
                {
                    aStock = aStockBll.GetStockByItemid(aItem.ItemId);

                    if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) &&
                        (Convert.ToDouble(quantitytextBox.Text) != 0))
                    {
                        aStock.Stocks             = Convert.ToDouble(quantitytextBox.Text);
                        aStock.Item               = aItem;
                        aStock.Category           = aInventoryCategory;
                        aTransaction.Stock        = aStock;
                        aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''");

                        TransactionBLL aBll = new TransactionBLL();
                        sr = aBll.DamageInStock(aTransaction);
                        ShowAndClear(sr);
                    }
                    else
                    {
                        MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to  " + aStock.Stocks + " " +
                                        unittypelabel.Text);
                    }
                }
                else
                {
                    MessageBox.Show("Please Check Your Damage Report Field It's Never Empty");
                }
            }

            if (transactiontype == "Send_to_Kitchen")
            {
                aStock = aStockBll.GetStockByItemid(aItem.ItemId);

                if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) && (Convert.ToDouble(quantitytextBox.Text) != 0))
                {
                    aStock.Stocks      = Convert.ToDouble(quantitytextBox.Text);
                    aStock.Item        = aItem;
                    aStock.Category    = aInventoryCategory;
                    aTransaction.Stock = aStock;
                    TransactionBLL aBll = new TransactionBLL();
                    sr = aBll.SendToKitchen(aTransaction);
                    ShowAndClear(sr);
                }
                else
                {
                    MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to " + aStock.Stocks + " " + unittypelabel.Text);
                }
            }

            //aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);
            if (transactiontype == "Return_from_Kitchen")
            {
                aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);

                if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) && (Convert.ToDouble(quantitytextBox.Text) != 0))
                {
                    aStock.Stocks      = Convert.ToDouble(quantitytextBox.Text);
                    aStock.Item        = aItem;
                    aStock.Category    = aInventoryCategory;
                    aTransaction.Stock = aStock;
                    TransactionBLL aBll = new TransactionBLL();
                    sr = aBll.ReturnFromKitchen(aTransaction);
                    ShowAndClear(sr);
                }
                else
                {
                    MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to " + aStock.Stocks + " " + unittypelabel.Text);
                }
            }

            if (transactiontype == "Damage_in_kitchen")
            {
                if (danmagetextBox.Text.Length > 0)
                {
                    aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);

                    if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) &&
                        (Convert.ToDouble(quantitytextBox.Text) != 0))
                    {
                        aStock.Stocks             = Convert.ToDouble(quantitytextBox.Text);
                        aStock.Item               = aItem;
                        aStock.Category           = aInventoryCategory;
                        aTransaction.Stock        = aStock;
                        aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''");

                        TransactionBLL aBll = new TransactionBLL();
                        sr = aBll.DamageInKitchen(aTransaction);
                        ShowAndClear(sr);
                    }
                    else
                    {
                        MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to  " + aStock.Stocks + " " +
                                        unittypelabel.Text);
                    }
                }
                else
                {
                    MessageBox.Show("Please Check Your Damage Report Field It's Never Empty");
                }
            }

            if (transactiontype == "Stock_Out_In_Kitchen")
            {
                if (danmagetextBox.Text.Length > 0)
                {
                    aStock = aStockBll.GetStockByItemidFrominventory_kitchen_stock(aItem);

                    if ((aStock.Stocks >= Convert.ToDouble(quantitytextBox.Text)) &&
                        (Convert.ToDouble(quantitytextBox.Text) != 0))
                    {
                        aStock.Stocks             = Convert.ToDouble(quantitytextBox.Text);
                        aStock.Item               = aItem;
                        aStock.Category           = aInventoryCategory;
                        aTransaction.Stock        = aStock;
                        aTransaction.DamageReport = danmagetextBox.Text.Replace("'", "''");

                        TransactionBLL aBll = new TransactionBLL();
                        sr = aBll.SendOutInKitchen(aTransaction);

                        StockDAO aStockDao = new StockDAO();
                        aStockDao.InsertOrUpdateSaleRawmaterialsReport(aTransaction.Item.ItemId, Convert.ToDouble(quantitytextBox.Text), aStock.UnitPrice);
                        ShowAndClear(sr);
                    }
                    else
                    {
                        MessageBox.Show("Your Quantity Must be Greater than 0 and  less than or equal to  " + aStock.Stocks + " " +
                                        unittypelabel.Text);
                    }
                }
                else
                {
                    MessageBox.Show("Please Check Your Damage Report Field It's Never Empty");
                }
            }
        }
Esempio n. 17
0
 public static void UpdateInventoryStockById(long itemId, int stock)
 {
     StockDAO.UpdateInventoryStockById(itemId, stock);
 }
Esempio n. 18
0
 public static List <Inventory> GetPendingOrderQuantities(List <Inventory> items)
 {
     return(StockDAO.GetPendingOrderQuantities(items));
 }
Esempio n. 19
0
 public static long GetItemId(string itemCode)
 {
     return(StockDAO.GetItemId(itemCode));
 }
Esempio n. 20
0
        /// <summary>
        /// 修改综合查询数据
        /// </summary>
        /// <param name="nPlanId"></param>
        /// <param name="strShipmentNo"></param>
        /// <param name="strDeliveryNo"></param>
        /// <param name="nPayerId"></param>
        /// <param name="strPayerName"></param>
        /// <param name="nContractId"></param>
        /// <param name="strOriginalContractNo"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool SyntheticalSearchModifyData(long nPlanId, string strShipmentNo, string strDeliveryNo, long nPayerId, string strPayerName, long nContractId, string strOriginalContractNo, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    //修改发货计划
                    using (PlanDAO dao = new PlanDAO())
                    {
                        DeliverPlan data = dao.LoadDeliverPlan(nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                        if (data == null)
                        {
                            return(false);
                        }
                        data.ShipmentNo = strShipmentNo;
                        data.DeliveryNo = strDeliveryNo;
                        data.PayerId    = nPayerId;
                        data.PayerName  = strPayerName;
                        if (!dao.UpdateDeliverPlan(data, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    //修改出仓单和送货单数据
                    using (DeliverDAO dao = new DeliverDAO())
                    {
                        List <ShipmentBill> listShipmentBill = dao.LoadShipmentBillsByPlanId(nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                        foreach (ShipmentBill data in listShipmentBill)
                        {
                            if (!dao.UpdateShipmentBillDeliveryNo(data.Id, strDeliveryNo, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }

                        List <DeliverBill> listDeliverBill = dao.LoadDeliverBillsByPlanId(nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                        foreach (DeliverBill data in listDeliverBill)
                        {
                            if (!dao.UpdateDeliverBillDeliveryNo(data.Id, strDeliveryNo, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    //修改出库单、入库单和库存数据
                    using (StockDAO dao = new StockDAO())
                    {
                        List <OutWarehouseBill> listOutWarehouseBill = dao.LoadOutWarehouseBillsByPlanId(nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                        foreach (OutWarehouseBill data in listOutWarehouseBill)
                        {
                            data.DeliveryNo = strDeliveryNo;
                            data.PayerId    = nPayerId;
                            data.PayerName  = strPayerName;
                            if (!dao.UpdateOutWarehouseBill(data, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    //修改合同数据
                    using (ContractDAO dao = new ContractDAO())
                    {
                        if (nContractId > 0)
                        {
                            Contract data = dao.LoadContract(nContractId, nOpStaffId, strOpStaffName, out strErrText);
                            if (data == null)
                            {
                                return(false);
                            }
                            data.OriginalContractNo = strOriginalContractNo;
                            if (!dao.UpdateContract(data, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Esempio n. 21
0
 public Stock()
 {
     lStockDAO = new StockDAO();
 }
Esempio n. 22
0
        /// <summary>
        /// 取消送货单数据
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool CancelDeliverBill(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                strErrText = string.Empty;
                long nShipmentBillId = 0;
                long nDispatchBillId = 0;
                long nPlanId         = 0;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    using (DeliverDAO dao = new DeliverDAO())
                    {
                        //读取送货单数据
                        DeliverBill bill = dao.LoadDeliverBill(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }
                        nShipmentBillId = bill.ShipmentBillId;
                        nDispatchBillId = bill.DispatchBillId;
                        nPlanId         = bill.PlanId;

                        //删除送货单数据
                        if (!dao.DeleteDeliverBill(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除送货单货物数据
                        if (!dao.DeleteDeliverBillAllGoods(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出仓单数据
                        if (!dao.DeleteShipmentBill(nShipmentBillId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出仓单货物数据
                        if (!dao.DeleteShipmentBillAllGoods(nShipmentBillId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    using (StockDAO dao = new StockDAO())
                    {
                        //读取出库单数据
                        OutWarehouseBill bill = dao.LoadOutWarehouseBillByShipmentBillId(nShipmentBillId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }

                        //删除出库单数据
                        if (!dao.DeleteOutWarehouseBill(bill.Id, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出库单货物数据
                        if (!dao.DeleteOutWarehouseBillAllGoods(bill.Id, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    using (DispatchDAO dao = new DispatchDAO())
                    {
                        //读取调度单计划数据
                        DispatchBillDeliverPlan plan = dao.LoadDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                        if (plan == null)
                        {
                            return(false);
                        }

                        //读取调度单数据
                        DispatchBill bill = dao.LoadDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }

                        //修改或删除调度单数据
                        bill.TotalPackages         = bill.TotalPackages - plan.Packages;
                        bill.TotalTunnages         = bill.TotalTunnages - plan.Tunnages;
                        bill.TotalPiles            = bill.TotalPiles - plan.Piles;
                        bill.TotalTenThousands     = bill.TotalTenThousands - plan.TenThousands;
                        bill.TotalTransportCharges = bill.TotalTransportCharges - plan.TransportCharges;

                        if (bill.TotalPackages == 0 && bill.TotalTunnages == 0 && bill.TotalPiles == 0 && bill.TotalTenThousands == 0)
                        {
                            if (!dao.DeleteDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            if (!dao.UpdateDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }

                        //删除调度单计划数据
                        if (!dao.DeleteDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除调度计划货物数据
                        if (!dao.DeleteDispatchBillDeliverPlanAllGoods(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //校验调度单数据
                        if (bill.TotalPackages != 0 || bill.TotalTunnages != 0 || bill.TotalPiles != 0 || bill.TotalTenThousands != 0)
                        {
                            if (!dao.CheckDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Esempio n. 23
0
        // อัพเดทเมื่อสถานะเป็น allow ให่้หักสต็อกเลย
        public ActionResult Approbation_popupUpdate(string approve, int reqID, int repID)
        {
            RequisitionModel reqModel = new RequisitionModel();

            // ค้นเอา stock_id จากการเบิก
            Database       db     = new Database();
            RequisitionDAO reqDAO = new RequisitionDAO(db);

            reqModel = new RequisitionModel();
            reqModel = reqDAO.FindById(reqID);
            db.Close();

            // แล้วเอามาค้นเอาข้อมูลสต๊อก
            db = new Database();
            StockDAO   sDAO   = new StockDAO(db);
            StockModel sModel = sDAO.FindById(reqModel.STOCK_NO.STOCK_ID);

            db.Close();

            RequisitionModel rqModel = new RequisitionModel();

            rqModel.REQ_ID = reqID;
            rqModel.APROVE = approve;

            db     = new Database();
            reqDAO = new RequisitionDAO(db);
            int ap = reqDAO.Approbation(rqModel);

            db.Close();

            if (approve.Equals("allow") && !reqModel.APROVE.Equals("allow"))
            {
                if (ap > 0)
                {
                    // ของที่เบิก ต้องมีจำนวน น้อยกว่าเท่ากับของที่อยู่ในสต๊อก
                    if (reqModel.REQ_UNIT <= sModel.UNIT)
                    {
                        int stkMinus = sModel.UNIT - reqModel.REQ_UNIT;

                        // รับค่าที่ทำการหักสต๊อกแล้ว
                        sModel          = new StockModel();
                        sModel.STOCK_ID = reqModel.STOCK_NO.STOCK_ID;
                        sModel.UNIT     = stkMinus;

                        System.Diagnostics.Debug.WriteLine("sModel.STOCK_ID :" + sModel.STOCK_ID);

                        db   = new Database();
                        sDAO = new StockDAO(db);
                        sDAO.StockDeduction(sModel);
                        db.Close();
                    }
                    else
                    {
                        return(RedirectToAction("Alert", "Requisition", new { link = "../Requisition/approbationManagement", massage = "ไม่สามารถเบิกมากกว่าจำนวนของที่มีในคลังได้" }));
                    }
                }
            }
            else if ((approve.Equals("wait") || approve.Equals("not")) && reqModel.APROVE.Equals("allow"))
            {
                int stkMinus = sModel.UNIT + reqModel.REQ_UNIT;

                // รับค่าที่ทำการหักสต๊อกแล้ว
                sModel          = new StockModel();
                sModel.STOCK_ID = reqModel.STOCK_NO.STOCK_ID;
                sModel.UNIT     = stkMinus;

                db   = new Database();
                sDAO = new StockDAO(db);
                sDAO.StockDeduction(sModel);
                db.Close();
            }


            RepairModel rModel = new RepairModel();

            rModel.REPAIR_NO    = repID;
            rModel.ALERT_STATUS = "1";

            db = new Database();
            RepairDAO rDAO = new RepairDAO(db);

            rDAO.AlertStatus(rModel);
            db.Close();

            return(Redirect("~/Requisition/approbationManagement"));
        }
Esempio n. 24
0
        /// <summary>
        /// 取消出仓单
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool CancelShipmentBill(long nId, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                strErrText = string.Empty;
                long   nDispatchBillId = 0;
                long   nPlanId         = 0;
                string strOutType      = string.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    //删除出仓单数据
                    using (DeliverDAO dao = new DeliverDAO())
                    {
                        //读取出仓单数据
                        ShipmentBill bill = dao.LoadShipmentBill(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }
                        nDispatchBillId = bill.DispatchBillId;
                        nPlanId         = bill.PlanId;
                        strOutType      = bill.OutType;

                        //删除出仓单数据
                        if (!dao.DeleteShipmentBill(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出仓单货物数据
                        if (!dao.DeleteShipmentBillAllGoods(nId, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    //删除出库单数据
                    using (StockDAO dao = new StockDAO())
                    {
                        //读取出库单数据
                        OutWarehouseBill bill = dao.LoadOutWarehouseBillByShipmentBillId(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }

                        //删除出库单数据
                        if (!dao.DeleteOutWarehouseBill(bill.Id, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }

                        //删除出库单货物数据
                        if (!dao.DeleteOutWarehouseBillAllGoods(bill.Id, nOpStaffId, strOpStaffName, out strErrText))
                        {
                            return(false);
                        }
                    }

                    //如果是划拨出库,则删除入库单数据
                    if (strOutType == InnoSoft.LS.Resources.Options.AllocateGoods)
                    {
                        using (StockDAO dao = new StockDAO())
                        {
                            //读取入库单编码
                            EnterWarehouseBill bill = dao.LoadEnterWarehouseBillByPlanId(nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                            if (bill == null)
                            {
                                return(false);
                            }

                            //删除入库单货物数据
                            if (!dao.DeleteEnterWarehouseBillAllGoods(bill.Id, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }

                            //删除入库单数据
                            if (!dao.DeleteEnterWarehouseBill(bill.Id, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    //如果是发货出库,则修改调度记录数据
                    if (strOutType == InnoSoft.LS.Resources.Options.DeliverGoods)
                    {
                        using (DispatchDAO dao = new DispatchDAO())
                        {
                            //读取调度单计划数据
                            DispatchBillDeliverPlan plan = dao.LoadDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                            if (plan == null)
                            {
                                return(false);
                            }

                            //读取调度单数据
                            DispatchBill bill = dao.LoadDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText);
                            if (bill == null)
                            {
                                return(false);
                            }

                            //修改或删除调度单数据
                            bill.TotalPackages         = bill.TotalPackages - plan.Packages;
                            bill.TotalTunnages         = bill.TotalTunnages - plan.Tunnages;
                            bill.TotalPiles            = bill.TotalPiles - plan.Piles;
                            bill.TotalTenThousands     = bill.TotalTenThousands - plan.TenThousands;
                            bill.TotalTransportCharges = bill.TotalTransportCharges - plan.TransportCharges;

                            if (bill.TotalPackages == 0 && bill.TotalTunnages == 0 && bill.TotalPiles == 0 && bill.TotalTenThousands == 0)
                            {
                                if (!dao.DeleteDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                            else
                            {
                                if (!dao.UpdateDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }

                            //删除调度单计划数据
                            if (!dao.DeleteDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }

                            //删除调度计划货物数据
                            if (!dao.DeleteDispatchBillDeliverPlanAllGoods(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }

                            //校验调度单数据
                            if (bill.TotalPackages != 0 || bill.TotalTunnages != 0 || bill.TotalPiles != 0 || bill.TotalTenThousands != 0)
                            {
                                if (!dao.CheckDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                    }

                    //如果是划拨出库,则直接取消发货计划
                    if (strOutType == InnoSoft.LS.Resources.Options.AllocateGoods)
                    {
                        using (PlanDAO dao = new PlanDAO())
                        {
                            if (!dao.CancelDeliverPlan(nPlanId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Esempio n. 25
0
        private void UpdateChargeBack(long listId)
        {
            /* Move the following code to RestRepresentativeController*/
            ////Attention: DisbursementList can only disburse once, date for that list is not null

            ///*The following code is for ChargeBack table*/
            ////By the time disburse item, calculate the amount of this list, update ChargeBack table

            DisbursementList disbursementList = DisbursementListService.GetDisbursementListByListId(listId);
            List <DisbursementListDetails> disbursementListDetails = DisbursementListDetailsDAO.ViewDetails(listId);

            foreach (DisbursementListDetails details in disbursementListDetails)
            {
                PriceList priceList = PriceListService.GetPriceListByItemId(details.Item.ItemId);
                double    price     = 0;
                if (priceList != null)
                {
                    price = priceList.Supplier1UnitPrice;
                }

                double amount = price * details.Quantity;
                ChargeBackService.UpdateChargeBackData(amount, disbursementList);

                ///*The following code is for StockCard table*/
                ////By the time disburse item, update StockCard table with itemId, deptId and date, souceType = 2

                int balance = CatalogueService.GetCatalogueById(details.Item.ItemId).StockLevel - details.Quantity;
                StockCardService.CreateStockCardFromDisburse(details, disbursementList, balance);
                StockDAO.UpdateWithReduceInventoryStockById(details.Item.ItemId, details.Quantity);

                ////following code will update and close requisitions
                int disbursedAmount             = details.Quantity;
                List <Requisition> requisitions = RequisitionDAO.GetOutstandingRequisitionsAndDetailsByDeptIdAndItemId(disbursementList.Department.DeptId, details.Item.ItemId, listId); //will get those status assigned/partially completed(assigned)

                foreach (var requisition in requisitions)
                {
                    if (requisition.RequisitionDetail.Balance <= disbursedAmount)                                     // if the balance is less than what was disbursed
                    {
                        RequisitionDetailsDAO.UpdateBalanceAmount(requisition.ReqId, details.Item.ItemId, 0);         //change balance to 0

                        if (RequisitionDetailsDAO.GetRemainingRequisitionDetailsByReqId(requisition.ReqId).Count > 0) //will get those the remaining amounts !=0 if
                        {
                            RequisitionDAO.UpdateStatus(requisition.ReqId, "Partially Completed");
                        }
                        else
                        {
                            RequisitionDAO.UpdateStatus(requisition.ReqId, "Completed");
                        }
                        disbursedAmount -= requisition.RequisitionDetail.Balance; // minusing the balance from what was disbursed
                    }
                    else// when the balance amount is more than the remainder of the disbursed amount
                    {
                        RequisitionDetailsDAO.UpdateBalanceAmount(requisition.ReqId, details.Item.ItemId, disbursedAmount);// change balance to remainder of disbursed amount

                        RequisitionDAO.UpdateStatus(requisition.ReqId, "Partially Completed");

                        break;//break out of for loop when disbursed amount become 0
                    }
                }
            }
        }
Esempio n. 26
0
 public StockBUS()
 {
     _stockDAO = new StockDAO();
 }
Esempio n. 27
0
        /// <summary>
        /// 修改出仓单数据
        /// </summary>
        /// <param name="nId"></param>
        /// <param name="decTransportCharges">运费</param>
        /// <param name="listGoods"></param>
        /// <param name="nOpStaffId"></param>
        /// <param name="strOpStaffName"></param>
        /// <param name="strErrText"></param>
        /// <returns></returns>
        public bool UpdateShipmentBill(long nId, decimal decTransportCharges, List <ShipmentBillGoods> listGoods, long nOpStaffId, string strOpStaffName, out string strErrText)
        {
            try
            {
                strErrText = string.Empty;
                long   nDispatchBillId = 0;
                long   nPlanId         = 0;
                string strOutType      = string.Empty;

                using (TransactionScope transScope = new TransactionScope(TransactionScopeOption.Required, new TimeSpan(2, 0, 0)))
                {
                    //修改出仓单货物数据
                    using (DeliverDAO dao = new DeliverDAO())
                    {
                        ShipmentBill bill = dao.LoadShipmentBill(nId, nOpStaffId, strOpStaffName, out strErrText);
                        if (bill == null)
                        {
                            return(false);
                        }
                        nDispatchBillId = bill.DispatchBillId;
                        nPlanId         = bill.PlanId;
                        strOutType      = bill.OutType;

                        foreach (ShipmentBillGoods goods in listGoods)
                        {
                            if (!dao.UpdateShipmentBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }

                    //如果是划拨出库,则需要修改入库单
                    if (strOutType == InnoSoft.LS.Resources.Options.AllocateGoods)
                    {
                        using (StockDAO dao = new StockDAO())
                        {
                            //读取入库单编码
                            EnterWarehouseBill bill = dao.LoadEnterWarehouseBillByPlanId(nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                            if (bill == null)
                            {
                                return(false);
                            }
                            long nEnterWarehouseBillId = bill.Id;

                            //读取入库单货物数据
                            List <EnterWarehouseBillGoods> listEnterWarehouseBillGoods = dao.LoadEnterWarehouseBillAllGoods(nEnterWarehouseBillId, nOpStaffId, strOpStaffName, out strErrText);
                            if (listEnterWarehouseBillGoods == null)
                            {
                                return(false);
                            }
                            foreach (EnterWarehouseBillGoods goods in listEnterWarehouseBillGoods)
                            {
                                int     nNewPackages       = 0;
                                decimal decNewTunnages     = 0;
                                decimal decNewPiles        = 0;
                                decimal decNewTenThousands = 0;

                                string[] strShipmentBillGoodsIds = goods.ShipmentBillGoodsIds.Split(',');
                                foreach (string strShipmentBillGoodsId in strShipmentBillGoodsIds)
                                {
                                    ShipmentBillGoods goods1 = listGoods.Find(delegate(ShipmentBillGoods g) { return(g.Id == long.Parse(strShipmentBillGoodsId)); });
                                    if (goods1 == null)
                                    {
                                        strErrText = InnoSoft.LS.Resources.Strings.NotFoundShipmentBillGoodsForEnterWarehouseBill;
                                        return(false);
                                    }
                                    nNewPackages       += goods1.Packages;
                                    decNewTunnages     += goods1.Tunnages;
                                    decNewPiles        += goods1.Piles;
                                    decNewTenThousands += goods1.TenThousands;
                                }
                                goods.Packages     = nNewPackages;
                                goods.Tunnages     = decNewTunnages;
                                goods.Piles        = decNewPiles;
                                goods.TenThousands = decNewTenThousands;

                                if (!dao.UpdateEnterWarehouseBillGoods(goods, nOpStaffId, strOpStaffName, out strErrText))
                                {
                                    return(false);
                                }
                            }
                        }
                    }

                    //如果是发货出库,则需要修改调度记录数据
                    if (strOutType == InnoSoft.LS.Resources.Options.DeliverGoods)
                    {
                        using (DispatchDAO dao = new DispatchDAO())
                        {
                            //读取调度单计划数据
                            DispatchBillDeliverPlan plan = dao.LoadDispatchBillDeliverPlan(nDispatchBillId, nPlanId, nOpStaffId, strOpStaffName, out strErrText);
                            if (plan == null)
                            {
                                return(false);
                            }
                            decimal decOldTransportCharges = plan.TransportCharges;

                            //修改调度单计划数据
                            plan.TransportCharges = decTransportCharges;
                            if (!dao.UpdateDispatchBillDeliverPlan(plan, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }

                            //读取调度单数据
                            DispatchBill bill = dao.LoadDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText);
                            if (bill == null)
                            {
                                return(false);
                            }

                            //修改调度单数据
                            bill.TotalTransportCharges = bill.TotalTransportCharges - decOldTransportCharges + decTransportCharges;
                            if (!dao.UpdateDispatchBill(bill, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }

                            //校验调度单数据
                            if (!dao.CheckDispatchBill(nDispatchBillId, nOpStaffId, strOpStaffName, out strErrText))
                            {
                                return(false);
                            }
                        }
                    }
                    transScope.Complete();
                }
                return(true);
            }
            catch (Exception e)
            {
                strErrText = e.Message;
                return(false);
            }
        }
Esempio n. 28
0
 public static List <long> GetItemsFirstSupplierIds(List <long> itemIds)
 {
     return(StockDAO.GetItemsFirstSupplierIds(itemIds));
 }
Esempio n. 29
0
        public void UpdateKitchenStockByStockId(Stock cStock)
        {
            StockDAO aDao = new StockDAO();

            aDao.UpdateKitchenStockByStockId(cStock);
        }
Esempio n. 30
0
 public ArtigoRN()
 {
     daoProduct = new ArtigoDAO();
     daoStock   = new StockDAO();
 }