コード例 #1
0
ファイル: PurchaseController.cs プロジェクト: arizarm/Test11
 public void AddPurchaseOrder(Dictionary <PurchaseOrder, List <Item_PurchaseOrder> > orderItems)
 {
     try
     {
         EFBroker_PurchaseOrder.AddPurchaseOrder(orderItems);
         string supervisorEmail = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Supervisor")[0].Email;
         Utility.sendMail(supervisorEmail, "Purchase order", "There  is a new purchase order created. Please review");
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
コード例 #2
0
 private void DiscrepancyMailNotification()
 {
     try
     {
         if (informSupervisor)
         {
             string supervisorEmail = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Supervisor")[0].Email;
             if (Session["monthly"] != null)
             {
                 if ((bool)Session["monthly"] == true)
                 {
                     Utility.sendMail(supervisorEmail, "Monthly Inventory Check Discrepancies Notification " + DateTime.Now.ToString(), "A monthly inventory check has been performed and new item discrepancies have been submitted. Please log in to the system to review them. Thank you.");
                 }
                 else
                 {
                     Utility.sendMail(supervisorEmail, "New Discrepancies Notification " + DateTime.Now.ToString(), "New item discrepancies have been submitted. Please log in to the system to review them. Thank you.");
                 }
             }
             else
             {
                 Utility.sendMail(supervisorEmail, "New Discrepancies Notification " + DateTime.Now.ToString(), "New item discrepancies have been submitted. Please log in to the system to review them. Thank you.");
             }
         }
         if (informManager)
         {
             string managerEmail = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Manager")[0].Email;
             if (Session["monthly"] != null)
             {
                 if ((bool)Session["monthly"] == true)
                 {
                     Utility.sendMail(managerEmail, "Monthly Inventory Check Discrepancies Notification " + DateTime.Now.ToString(), "A monthly inventory check has been performed and new item discrepancies (worth at least $250) have been submitted. Please log in to the system to review them. Thank you.");
                 }
                 else
                 {
                     Utility.sendMail(managerEmail, "New Discrepancies Notification " + DateTime.Now.ToString(), "New item discrepancies (worth at least $250) have been submitted. Please log in to the system to review them. Thank you.");
                 }
             }
             else
             {
                 Utility.sendMail(managerEmail, "New Discrepancies Notification " + DateTime.Now.ToString(), "New item discrepancies (worth at least $250) have been submitted. Please log in to the system to review them. Thank you.");
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #3
0
ファイル: DiscrepancyService.cs プロジェクト: arizarm/Test11
    public bool SubmitDiscrepanciesWithItemUpdate(List <WCFDiscrepancy> wdList)
    {
        List <Discrepency> dList = new List <Discrepency>();
        bool informSupervisor    = false;
        bool informManager       = false;

        foreach (WCFDiscrepancy wd in wdList)
        {
            Discrepency d = new Discrepency();
            d.ItemCode      = wd.ItemCode;
            d.RequestedBy   = Int32.Parse(wd.RequestedBy);
            d.AdjustmentQty = Int32.Parse(wd.AdjustmentQty);
            d.Remarks       = wd.Remarks;
            d.Status        = wd.Status;
            d.Date          = DateTime.Now;

            //Code to determine the discrepancy amount
            List <PriceList> plHistory  = EFBroker_PriceList.GetPriceListByItemCode(d.ItemCode);
            List <PriceList> itemPrices = new List <PriceList>();

            foreach (PriceList pl in plHistory)
            {    //Get only currently active suppliers for an item
                if (pl.TenderYear == DateTime.Now.Year.ToString())
                {
                    itemPrices.Add(pl);
                }
            }

            decimal totalPrice = 0;

            foreach (PriceList pl in itemPrices)
            {
                totalPrice += (decimal)pl.Price;
            }

            decimal averageUnitPrice = totalPrice / itemPrices.Count;
            d.TotalDiscrepencyAmount = d.AdjustmentQty * averageUnitPrice;

            //Set the approver based on discrepancy amount, and email notify them
            if (Math.Abs((decimal)d.TotalDiscrepencyAmount) < 250)
            {
                if (d.TotalDiscrepencyAmount < 250)
                {
                    d.ApprovedBy     = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Supervisor")[0].EmpID;
                    informSupervisor = true;
                }
                else
                {
                    d.ApprovedBy  = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Manager")[0].EmpID;
                    informManager = true;
                }
            }
            dList.Add(d);
        }
        bool successfullySent = sendDiscrepanciesToDatabaseWithItemUpdates(dList);

        if (successfullySent)
        {
            if (informSupervisor)
            {
                string supervisorEmail = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Supervisor")[0].Email;
                Utility.sendMail(supervisorEmail, "New Discrepancies Notification " + DateTime.Now.ToString(), "New item discrepancies have been submitted. Please log in to the system to review them. Thank you.");
            }
            if (informManager)
            {
                string managerEmail = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Manager")[0].Email;
                Utility.sendMail(managerEmail, "New Discrepancies Notification " + DateTime.Now.ToString(), "New item discrepancies (worth at least $250) have been submitted. Please log in to the system to review them. Thank you.");
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }
コード例 #4
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        List <Discrepency> dList = new List <Discrepency>();
        bool complete            = true;
        bool monthly             = false;

        foreach (GridViewRow row in gvDiscrepancies.Rows)
        {
            string itemCode = (row.FindControl("lblItemCode") as Label).Text;
            string stock    = (row.FindControl("lblStock") as Label).Text;
            string actual   = (row.FindControl("lblActual") as Label).Text;
            int    adj      = Int32.Parse(actual) - Int32.Parse(stock);
            string remarks  = (row.FindControl("txtRemarks") as TextBox).Text;
            if (!ValidatorUtil.isEmpty(remarks))
            {
                if (remarks.Length <= maxChars)
                {
                    //update item table if any adjustment at disubrsement point
                    if (Session["ItemToUpdate"] != null)
                    {
                        if ((bool)Session["ItemToUpdate"])
                        {
                            Item i = EFBroker_Item.GetItembyItemCode(itemCode);
                            i.BalanceQty = (adj * -1) + i.BalanceQty;
                            EFBroker_Item.UpdateItem(i);
                        }
                    }

                    List <PriceList> plHistory  = EFBroker_PriceList.GetPriceListByItemCode(itemCode);
                    List <PriceList> itemPrices = new List <PriceList>();

                    foreach (PriceList pl in plHistory)
                    {    //Get only currently active suppliers for an item
                        if (pl.TenderYear == DateTime.Now.Year.ToString())
                        {
                            itemPrices.Add(pl);
                        }
                    }

                    decimal totalPrice = 0;

                    foreach (PriceList pl in itemPrices)
                    {
                        totalPrice += (decimal)pl.Price;
                    }

                    decimal averageUnitPrice = totalPrice / itemPrices.Count;

                    Discrepency d = new Discrepency();
                    d.ItemCode = itemCode;
                    if (Session["empID"] != null)
                    {
                        int empID = (int)Session["empID"];
                        d.RequestedBy = empID;
                    }
                    else
                    {
                        Utility.logout();
                    }
                    d.AdjustmentQty = adj;
                    d.Remarks       = remarks;
                    d.Date          = DateTime.Now;
                    if (Session["monthly"] != null)
                    {
                        if ((bool)Session["monthly"] == true)
                        {
                            d.Status = "Monthly";
                            monthly  = true;
                        }
                        else
                        {
                            d.Status = "Pending";
                            monthly  = false;
                        }
                    }
                    else
                    {
                        d.Status = "Pending";
                    }
                    d.TotalDiscrepencyAmount = adj * averageUnitPrice;
                    if (d.TotalDiscrepencyAmount < 250)
                    {
                        d.ApprovedBy = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Supervisor")[0].EmpID;
                    }
                    else
                    {
                        d.ApprovedBy = EFBroker_DeptEmployee.GetEmployeeListByRole("Store Manager")[0].EmpID;
                    }
                    dList.Add(d);
                }
                else
                {
                    lblErrorCharLimit.Text = "Make sure all remarks are under 100 characters long";
                    row.BackColor          = Color.Yellow;
                    complete = false;
                    break;
                }
            }
            else
            {
                lblRequired.Text = "Please state the cause of discrepancies for all items in Remarks";
                complete         = false;
                break;
            }
        }

        if (complete)
        {
            if (monthly)
            {
                EFBroker_Discrepancy.MonthlyInventoryCheck(dList);
            }
            else
            {
                EFBroker_Discrepancy.SaveDiscrepencies(dList);
            }


            //bool informSupervisor = false;
            //bool informManager = false;
            informSupervisor = false;
            informManager    = false;
            foreach (Discrepency d in dList)
            {
                if (Math.Abs((decimal)d.TotalDiscrepencyAmount) < 250)
                {
                    informSupervisor = true;
                }
                else
                {
                    informManager = true;
                }
            }



            Session["discrepancyList"]            = null;
            Session["discrepancyDisplay"]         = null;
            Session["RetrievalShortfallItemList"] = null;
            Session["RetrievalID"] = null;

            Session["monthly"]      = null;
            Session["ItemToUpdate"] = null;


            ThreadStart emailThreadStart = new ThreadStart(DiscrepancyMailNotification);
            Thread      emailThread      = new Thread(emailThreadStart);
            emailThread.Start();

            string destination = "";

            if (Session["empRole"] != null)
            {
                string role = (string)Session["empRole"];
                if (role == "Store Supervisor" || role == "Store Manager")
                {
                    destination = "PurchaseOrderList.aspx";
                }
                else if (role == "Store Clerk")
                {
                    destination = "RequisitionListClerk.aspx";
                }
                else
                {
                    Utility.logout();
                }
            }
            else
            {
                Utility.logout();
            }

            Utility.AlertMessageThenRedirect("Discrepancies successfully reported", destination);
        }
    }
コード例 #5
0
ファイル: PurchaseController.cs プロジェクト: arizarm/Test11
 public List <Employee> GetSupervisorList()
 {
     return(EFBroker_DeptEmployee.GetEmployeeListByRole("Store Supervisor"));
 }