Beispiel #1
0
        public void UpdateMonthlyCheck(List <MonthlyCheckModel> list, string username)
        {
            Inventory_Adjustment inventoryAdjMan = new Inventory_Adjustment();

            inventoryAdjMan.clerk_user  = username;
            inventoryAdjMan.deleted     = "N";
            inventoryAdjMan.status      = "Pending";
            inventoryAdjMan.date        = DateTime.Today;
            inventoryAdjMan.status_date = DateTime.Today;

            Inventory_Adjustment inventoryAdjSup = new Inventory_Adjustment();

            inventoryAdjMan.clerk_user  = username;
            inventoryAdjMan.deleted     = "N";
            inventoryAdjMan.status      = "Pending";
            inventoryAdjMan.date        = DateTime.Today;
            inventoryAdjMan.status_date = DateTime.Today;

            foreach (MonthlyCheckModel i in list)
            {
                int adjusted = i.CurrentQuantity - i.ActualQuantity;

                Stock_Inventory   inventory = context.Stock_Inventory.Where(x => x.item_code == i.ItemCode).ToList().First();
                MonthlyCheckModel itemModel = new MonthlyCheckModel(inventory);
                double            cost      = Math.Abs(adjusted) * itemModel.AveragePrice;

                Adjustment_Details adjustmentDetail = new Adjustment_Details();
                adjustmentDetail.item_code         = i.ItemCode;
                adjustmentDetail.quantity_adjusted = adjusted;
                adjustmentDetail.reason            = i.Reason;
                adjustmentDetail.deleted           = "N";


                if (cost >= 250)
                {
                    inventoryAdjMan.Adjustment_Details.Add(adjustmentDetail);
                }
                else if (cost < 250)
                {
                    inventoryAdjSup.Adjustment_Details.Add(adjustmentDetail);
                }
                context.Adjustment_Details.Add(adjustmentDetail);
            }

            if (inventoryAdjMan.Adjustment_Details.Count != 0)
            {
                context.Inventory_Adjustment.Add(inventoryAdjMan);
                context.SaveChanges();
            }
            if (inventoryAdjSup.Adjustment_Details.Count != 0)
            {
                context.Inventory_Adjustment.Add(inventoryAdjSup);
                context.SaveChanges();
            }
        }
        public bool CheckRepeatAdjustment(Adjustment_Details detail, List <Adjustment_Details> adjDetails)
        {
            List <Adjustment_Details> adjDetail = (List <Adjustment_Details>)Session["Adjustment"];

            foreach (Adjustment_Details i in adjDetails)
            {
                if (i.item_code == detail.item_code)
                {
                    i.quantity_adjusted += detail.quantity_adjusted;
                    return(true);
                }
            }
            return(false);
        }
Beispiel #3
0
        protected void ConfirmBtn_Click(object sender, EventArgs e)
        {
            List <MonthlyCheckModel> itemList = (List <MonthlyCheckModel>)Session["DisDetail"];

            if (itemList == null)
            {
                //Monthly_Check_Records checkRecord = new Monthly_Check_Records();
                //checkRecord.date_checked = DateTime.Today;
                //checkRecord.clerk_user = HttpContext.Current.User.Identity.Name;
                //checkRecord.deleted = "N";
                //checkRecord.discrepancy = "N";

                Response.Redirect("~/Default.aspx");
                Session["DisDetail"] = null;
                Session[PUBLIC_SESSION_DISCREPANCY_DICT] = null;
            }
            else
            {
                Inventory_Adjustment invAdjustmentSup = new Inventory_Adjustment();
                invAdjustmentSup.date        = DateTime.Today;
                invAdjustmentSup.clerk_user  = HttpContext.Current.User.Identity.Name;
                invAdjustmentSup.status      = "Pending";
                invAdjustmentSup.status_date = DateTime.Today;
                invAdjustmentSup.deleted     = "N";

                Inventory_Adjustment invAdjustmentMan = new Inventory_Adjustment();
                invAdjustmentMan.date        = DateTime.Today;
                invAdjustmentMan.clerk_user  = HttpContext.Current.User.Identity.Name;
                invAdjustmentMan.status      = "Pending";
                invAdjustmentMan.status_date = DateTime.Today;
                invAdjustmentMan.deleted     = "N";


                foreach (MonthlyCheckModel i in itemList)
                {
                    //get price of adjustment for MonthlyCheckModel
                    double priceAdj = i.AveragePrice * Math.Abs(i.ActualQuantity - i.CurrentQuantity);

                    Stock_Inventory inventory = context.Stock_Inventory.Where(x => x.item_code == i.ItemCode).ToList().First();
                    inventory.current_qty = i.ActualQuantity;

                    Adjustment_Details adjDetails = new Adjustment_Details();
                    adjDetails.deleted           = "N";
                    adjDetails.item_code         = i.ItemCode;
                    adjDetails.quantity_adjusted = i.ActualQuantity - i.CurrentQuantity;
                    adjDetails.reason            = i.Reason;

                    if (priceAdj < 250)
                    {
                        invAdjustmentSup.Adjustment_Details.Add(adjDetails);
                    }
                    else if (priceAdj >= 250)
                    {
                        invAdjustmentMan.Adjustment_Details.Add(adjDetails);
                    }

                    context.Adjustment_Details.Add(adjDetails);
                }

                if (invAdjustmentSup.Adjustment_Details.Count != 0)
                {
                    context.Inventory_Adjustment.Add(invAdjustmentSup);
                    context.SaveChanges();

                    MonthlyCheckConfirmation._sendEmail(User.Identity.Name, false);
                }
                if (invAdjustmentMan.Adjustment_Details.Count != 0)
                {
                    context.Inventory_Adjustment.Add(invAdjustmentMan);
                    context.SaveChanges();

                    MonthlyCheckConfirmation._sendEmail(User.Identity.Name, true);
                }
            }

            // Clear the session once done
            Session["DisDetail"] = null;
            Session[PUBLIC_SESSION_DISCREPANCY_DICT] = null;

            Response.Redirect("~/Default.aspx");
        }
Beispiel #4
0
        protected void confirmBtn_Click(object sender, EventArgs e)
        {
            //Inventory_Adjustment inventoryAdj = new Inventory_Adjustment();
            //foreach (Adjustment_Details i in adjDetails)
            //{
            //    inventoryAdj.Adjustment_Details.Add(i);
            //}
            //Label1.Text = inventoryAdj.Adjustment_Details.Count.ToString();
            List <MonthlyCheckModel> itemList    = (List <MonthlyCheckModel>)Session["Confirmation"];
            Monthly_Check_Records    checkRecord = new Monthly_Check_Records();

            if (itemList == null)
            {
                checkRecord.date_checked = DateTime.Today;
                checkRecord.clerk_user   = HttpContext.Current.User.Identity.Name;
                checkRecord.deleted      = "N";
                checkRecord.discrepancy  = "N";

                context.Monthly_Check_Records.Add(checkRecord);
                context.SaveChanges();

                Response.Redirect("~/Views/StoreClerk/Dashboard.aspx");
            }
            else
            {
                //UpdateMonthlyCheck(itemList, HttpContext.Current.User.Identity.Name);
                Inventory_Adjustment invAdjustmentSup = new Inventory_Adjustment();
                invAdjustmentSup.date        = DateTime.Today;
                invAdjustmentSup.clerk_user  = HttpContext.Current.User.Identity.Name;
                invAdjustmentSup.status      = "Pending";
                invAdjustmentSup.status_date = DateTime.Today;
                invAdjustmentSup.deleted     = "N";

                Inventory_Adjustment invAdjustmentMan = new Inventory_Adjustment();
                invAdjustmentMan.date        = DateTime.Today;
                invAdjustmentMan.clerk_user  = HttpContext.Current.User.Identity.Name;
                invAdjustmentMan.status      = "Pending";
                invAdjustmentMan.status_date = DateTime.Today;
                invAdjustmentMan.deleted     = "N";


                foreach (MonthlyCheckModel i in itemList)
                {
                    //get price of adjustment for MonthlyCheckModel

                    double priceAdj = i.AveragePrice * Math.Abs(i.ActualQuantity - i.CurrentQuantity);

                    Stock_Inventory inventory = context.Stock_Inventory.Where(x => x.item_code == i.ItemCode).ToList().First();
                    inventory.current_qty = i.ActualQuantity;

                    Adjustment_Details adjDetails = new Adjustment_Details();
                    adjDetails.deleted           = "N";
                    adjDetails.item_code         = i.ItemCode;
                    adjDetails.quantity_adjusted = i.ActualQuantity - i.CurrentQuantity;
                    adjDetails.reason            = i.Reason;

                    if (priceAdj < 250)
                    {
                        invAdjustmentSup.Adjustment_Details.Add(adjDetails);
                    }
                    else if (priceAdj >= 250)
                    {
                        invAdjustmentMan.Adjustment_Details.Add(adjDetails);
                    }

                    context.Adjustment_Details.Add(adjDetails);
                }



                checkRecord.date_checked = DateTime.Today;
                checkRecord.clerk_user   = HttpContext.Current.User.Identity.Name;
                checkRecord.deleted      = "N";
                checkRecord.discrepancy  = "Y";

                if (invAdjustmentSup.Adjustment_Details.Count != 0)
                {
                    context.Inventory_Adjustment.Add(invAdjustmentSup);
                    context.SaveChanges();

                    _sendEmail(User.Identity.Name, false);
                }
                if (invAdjustmentMan.Adjustment_Details.Count != 0)
                {
                    context.Inventory_Adjustment.Add(invAdjustmentMan);
                    context.SaveChanges();

                    _sendEmail(User.Identity.Name, true);
                }

                context.Monthly_Check_Records.Add(checkRecord);
                context.SaveChanges();
                Session["Confirmation"] = null;
                Session["Monthly"]      = null;
                Response.Redirect("~/Views/StoreClerk/Dashboard.aspx");
            }
        }