protected void btnReceive_Click(object sender, EventArgs e)
        {
            if (orderDetailslist.Count > 0)
            {
                Order o1 = new Order();
                o1 = ios.FindOrderById(poNumber);
                if (o1.Status != "Delivered")
                {
                    int p = o1.PoNumber;
                    o1.DateDelivery = DateTime.Today;
                    o1.Status       = "Delivered";
                    ios.UpdateOrder(o1);
                    for (int i = 0; i < orderDetailslist.Count(); i++)
                    {
                        Stationery      s0  = new Stationery();
                        StockManagement sm0 = new StockManagement();
                        s0 = iss.FindStationeryById(orderDetailslist.ElementAt(i).ItemCode);
                        s0.QuantityInStock = s0.QuantityInStock + orderDetailslist.ElementAt(i).Quantity;

                        sm0.Date         = DateTime.Today;
                        sm0.ItemCode     = orderDetailslist.ElementAt(i).ItemCode;
                        sm0.StoreClerkId = (int)Session["employeeId"];
                        sm0.Source       = "ORD";
                        sm0.SourceId     = p;
                        sm0.QtyAdjusted  = orderDetailslist.ElementAt(i).Quantity;
                        sm0.Balance      = s0.QuantityInStock;
                        ism.AddStockManagement(sm0);

                        iss.UpdateStationery(s0);
                        Iod.UpdateOrderDetail(orderDetailslist.ElementAt(i));
                    }
                }
                else
                {
                    for (int i = 0; i < orderDetailslist.Count(); i++)
                    {
                        Iod.UpdateOrderDetail(orderDetailslist.ElementAt(i));
                    }
                }
                Response.Redirect("~/Store/RaisePurchaseOrder_OrderList.aspx");
            }
            else
            {
                Response.Write("<script>alert('No item to receive!');</script>");
                Response.Write("<script language=javascript>history.go(-1);</script>");
            }
        }
Example #2
0
        public void ApproveAdjustmentList(List <int> listAdjustmentId, string remarks, int approvedByEmployeeId)
        {
            // Generate voucherNumber
            int newVoucherNumber = saService.FindLastVoucherNumber() + 1;

            foreach (int id in listAdjustmentId)
            {
                // 1. ADJUSTMENT
                StockAdjustment s = saService.FindAdjustmentById(id); // Associated adjustment object

                // Check if negative adjustments exceeded stock quantity
                // Modify adjusted quantity and add remarks for user
                int currentQty = FindCurrentQuantityByItemCode(s.ItemCode);

                if ((currentQty + s.QuantityAdjusted) < 0)
                {
                    s.QuantityAdjusted = -currentQty;
                    remarks           += "SYSTEM GENERATED-As user input negative adjustment exceeded " +
                                         "current quantity, adjusted quantity has been modified to reduce current quantity to zero.";
                }

                s.ApproverRemarks      = remarks;
                s.DateApproved         = DateTime.Today;
                s.ApprovedByEmployeeId = approvedByEmployeeId;
                s.VoucherNumber        = newVoucherNumber;

                // 2. STATIONERY
                Stationery sta = stService.FindStationeryById(s.ItemCode);
                sta.QuantityInStock += s.QuantityAdjusted;

                // 3. STOCK MANAGEMENT
                StockManagement smt = new StockManagement();
                smt.Date         = (DateTime)s.DateApproved;
                smt.ItemCode     = s.ItemCode;
                smt.StoreClerkId = s.ClerkEmployeeId;
                smt.Source       = "ADJ";
                smt.SourceId     = s.AdjustmentId;
                smt.QtyAdjusted  = s.QuantityAdjusted;
                smt.Balance      = sta.QuantityInStock;

                // 3. ALL
                saService.ApproveAdjustment(s);
                stService.UpdateStationery(sta);
                smService.AddStockManagement(smt);
            }
        }
 public int AddNewStockManagement(StockManagement tm)
 {
     return(stServ.AddStockManagement(tm));
 }