コード例 #1
0
        public void SendEmailApproveReject(string poId, int value)
        {
            purchaseOrderBL = new PurchaseOrderBL();
            PurchaseOrderBO po          = purchaseOrderBL.getStatusAndOrderDateDetails(poId);
            string          requestorId = po.RequestorId;
            EmployeeBO      emp         = purchaseOrderBL.getRequestorName(requestorId);
            SendEmail       se          = new SendEmail();
            string          subject     = "";
            string          body        = "";

            if (value == 1)
            {
                subject = "Purchase Order Approved";
                body    = "Dear " + emp.EmployeeName + ", \n"
                          + "\n" + "The Purchase Order with ID: " + poId + " requested by you has been approved."
                          + "\n" + "(This is an auto-generated email, please do not reply.)"
                          + "\n\n\n" + "Regards,"
                          + "\n" + "Admin";
            }
            else
            {
                subject = "Purchase Order Rejected";
                body    = "Dear " + emp.EmployeeName + ", \n"
                          + "\n" + "The Purchase Order with ID: " + poId + " requested by you has been rejected. Please contact your supervisor for further information"
                          + "\n" + "(This is an auto-generated email, please do not reply.)"
                          + "\n\n\n" + "Regards,"
                          + "\n" + "Admin";
            }
            se.sendCPEmail(subject, body, emp.EmployeeEmail);
        }
コード例 #2
0
        public ActionResult Index()
        {
            try
            {
                CustomIdentity customIdentity = null;
                if (ControllerContext.HttpContext.User.Identity.IsAuthenticated)
                {
                    customIdentity = (CustomIdentity)ControllerContext.HttpContext.User.Identity;
                }
                string username = string.Empty;
                if (customIdentity != null)
                {
                    username = customIdentity.Name;
                }

                IPurchaseOrder purchaseOrderBO = new PurchaseOrderBO(username);


                List <PurchaseOrder> list = purchaseOrderBO.GetPurchaseOrderbyCustomerId(customIdentity.Id);



                return(View(list));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #3
0
        public void doProcess()
        {
            if (Session["employee"] != null)
            {
                EmployeeBO ebo           = (EmployeeBO)Session["employee"];
                string     title         = ebo.EmployeeTitle;
                int        delegateValue = ebo.Delegate;
                poId            = Request.QueryString["poId"];
                lblPOID.Text    = poId;
                lblName.Text    = ebo.EmployeeName;
                purchaseOrderBL = new PurchaseOrderBL();
                PurchaseOrderBO pbo = purchaseOrderBL.getStatusAndOrderDateDetails(poId);
                lblOrderDate.Text         = String.Format("{0:dd/MMM/yyyy}", pbo.DateOfOrder);
                lblStatus.Text            = pbo.Status;
                tbClerkComments.Text      = pbo.CommentByClerk;
                tbSupervisorComments.Text = pbo.CommentBySupervisor;

                if (title.Equals("Supervisor") && (lblStatus.Text.Equals("Pending")))
                {
                    btnResubmit.Visible = false;
                    this.gvPurchaseOrderList.Columns[7].Visible = false;
                    tbClerkComments.Enabled = false;
                }
                else if (title.Equals("Manager") && (lblStatus.Text.Equals("Pending")) && delegateValue == 1)
                {
                    btnResubmit.Visible = false;
                    this.gvPurchaseOrderList.Columns[7].Visible = false;
                    tbClerkComments.Enabled = false;
                }
                else if (title.Equals("Clerk") && lblStatus.Text.Equals("Pending"))
                {
                    btnResubmit.Enabled          = true;
                    tbSupervisorComments.Enabled = false;
                    this.gvPurchaseOrderList.Columns[7].Visible = true;
                    btnApprove.Visible = false;
                    btnReject.Visible  = false;
                }
                else
                {
                    this.gvPurchaseOrderList.Columns[7].Visible = false;
                    tbClerkComments.Enabled      = false;
                    tbSupervisorComments.Enabled = false;
                    btnResubmit.Visible          = false;
                    btnApprove.Visible           = false;
                    btnReject.Visible            = false;
                }
                List <PurchaseOrderDetailsJoinBO> poDetailList = purchaseOrderBL.getPurchaseOrderDetailsList(poId);

                if (poDetailList.Count != 0)
                {
                    gvPurchaseOrderList.DataSource = poDetailList;
                    gvPurchaseOrderList.DataBind();
                    footableSettings();
                }
            }
            else
            {
                Console.WriteLine("Something is wrong!!!!!!");
            }
        }
コード例 #4
0
        public Boolean createPurchaseOrder(PurchaseOrderBO pobo)
        {
            poda = new PurchaseOrderDA();
            PurchaseOrder po = convertPurchaseOrder(pobo);

            return(poda.createPO(po));
        }
コード例 #5
0
        // GET: PurchaseOrder/Details/5
        public ActionResult Details(int id)
        {
            try
            {
                CustomIdentity customIdentity = null;
                if (ControllerContext.HttpContext.User.Identity.IsAuthenticated)
                {
                    customIdentity = (CustomIdentity)ControllerContext.HttpContext.User.Identity;
                }
                string username = string.Empty;
                if (customIdentity != null)
                {
                    username = customIdentity.Name;
                }

                IPurchaseOrder purchaseOrderBO = new PurchaseOrderBO(username);


                PurchaseOrderDetail purchaseOrderDetail = purchaseOrderBO.GetPurchaseOrderDetailById(id);



                return(View(purchaseOrderDetail));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #6
0
        public PurchaseOrderBO countTotalPoId()
        {
            var query = (from po in context.PurchaseOrders
                         orderby po.POID descending
                         select new { po.POID }).First();
            PurchaseOrderBO pob = new PurchaseOrderBO();

            pob.PoId = query.POID;
            return(pob);
        }
コード例 #7
0
 public PurchaseOrderBO convertPurchaseOrderBO(PurchaseOrder po)
 {
     pobo                = new PurchaseOrderBO();
     pobo.PoId           = po.POID;
     pobo.DeliveryDate   = po.DeliveryDate;
     pobo.DateOfOrder    = po.DateOfOrder;
     pobo.RequestorId    = po.RequestorID;
     pobo.CommentByClerk = po.CommentByClerk;
     pobo.ApproverId     = po.ApproverID;
     pobo.ApprovalDate   = po.ApprovalDate;
     pobo.Status         = po.Status;
     return(pobo);
 }
コード例 #8
0
        public PurchaseOrder convertPurchaseOrder(PurchaseOrderBO pobo)
        {
            PurchaseOrder po = new PurchaseOrder();

            po.POID                 = pobo.PoId;
            po.DeliveryDate         = pobo.DeliveryDate;
            po.DateOfOrder          = pobo.DateOfOrder;
            po.RequestorID          = pobo.RequestorId;
            po.CommentByClerk       = pobo.CommentByClerk;
            po.ApproverID           = pobo.ApproverId;
            po.Status               = pobo.Status;
            po.CommentsBySupervisor = pobo.CommentBySupervisor;
            return(po);
        }
コード例 #9
0
        public PurchaseOrderBO getStatusAndOrderDateById(string poId)
        {
            var query = (from po in context.PurchaseOrders
                         where po.POID == poId
                         select new { po.DateOfOrder, po.Status, po.CommentByClerk, po.CommentsBySupervisor, po.RequestorID });
            PurchaseOrderBO obj = new PurchaseOrderBO();

            foreach (var q in query)
            {
                obj.DateOfOrder         = q.DateOfOrder;
                obj.Status              = q.Status;
                obj.CommentByClerk      = q.CommentByClerk;
                obj.CommentBySupervisor = q.CommentsBySupervisor;
                obj.RequestorId         = q.RequestorID;
            }
            return(obj);
        }
コード例 #10
0
        public List <PurchaseOrderBO> getPurchaseOrderAll()
        {
            var query = (from po in context.PurchaseOrders
                         orderby po.Status descending, po.DateOfOrder descending
                         select new { po.POID, po.DeliveryDate, po.DateOfOrder, po.Status, po.ApprovalDate });

            List <PurchaseOrderBO> list = new List <PurchaseOrderBO>();

            foreach (var q in query)
            {
                PurchaseOrderBO obj = new PurchaseOrderBO();
                obj.PoId         = q.POID;
                obj.DeliveryDate = q.DeliveryDate;
                obj.DateOfOrder  = q.DateOfOrder;
                obj.Status       = q.Status;
                obj.ApprovalDate = q.ApprovalDate;
                list.Add(obj);
            }
            return(list);
        }
コード例 #11
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            DataTable datatbl = new DataTable();

            if (Session["createPO"] != null && Convert.ToInt32(Session["gvCount"]) == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(),
                                                    "alert",
                                                    "alert('Please select item's criteria first');window.location ='CreatePO.aspx';",
                                                    true);
                Session["count"] = 0;
            }
            else
            {
                EmployeeBO ebo = (EmployeeBO)Session["employee"];
                datatbl         = (DataTable)Session["createPO"];
                purchaseOrderBL = new PurchaseOrderBL();
                PurchaseOrderBO poLastValue = new PurchaseOrderBO();
                PurchaseOrderBO pobo        = new PurchaseOrderBO();
                poLastValue = purchaseOrderBL.countTotalPO();
                string idSeperator = poLastValue.PoId.ToString().Substring(2);//gets the last PurchaseOrder ID from database
                int    valuePod    = Convert.ToInt32(idSeperator);
                if (valuePod < 100)
                {
                    valuePod   = valuePod + 1;
                    poCountStr = "PO0" + valuePod;
                }
                else
                {
                    valuePod   = valuePod + 1;
                    poCountStr = "PO" + valuePod;
                }
                pobo.PoId = poCountStr;
                string   date = tbDeliveryDate.Text;
                DateTime dt   = DateTime.Parse(tbDeliveryDate.Text);
                pobo.DeliveryDate = dt;
                pobo.DateOfOrder  = DateTime.Today;
                string eId = ebo.EmployeeId;
                pobo.RequestorId    = eId;
                pobo.CommentByClerk = Request.Form["tbClerkComments"];
                EmployeeBO empBo = purchaseOrderBL.getSupervisorId();//get supervisor ID of the logged in employee
                pobo.ApproverId = empBo.EmployeeId;
                pobo.Status     = "Pending";
                Boolean flagPO  = purchaseOrderBL.createPurchaseOrder(pobo);
                Boolean flagPOD = false;
                foreach (DataRow dr in datatbl.Rows)
                {
                    PurchaseOrderDetailsBO pod = new PurchaseOrderDetailsBO();
                    pod.PoId = poCountStr;
                    PurchaseOrderDetailsBO podLastValue = new PurchaseOrderDetailsBO();
                    podLastValue = purchaseOrderBL.countTotalPODId();
                    string idSeperate = podLastValue.PoDetailsId.ToString().Substring(2);//gets the last PurchaseOrderDetails ID from database
                    int    valuePoId  = Convert.ToInt32(idSeperate);
                    if (valuePoId < 100)
                    {
                        valuePoId     = valuePoId + 1;
                        podIdCountStr = "PD0" + valuePoId;
                    }
                    else
                    {
                        valuePoId     = valuePoId + 1;
                        podIdCountStr = "PD" + valuePoId;
                    }
                    pod.PoDetailsId = podIdCountStr;
                    pod.SupplierId  = ddlSupplier.SelectedItem.Text;
                    string itemName = purchaseOrderBL.getItemNumberByName(dr["ItemName"].ToString());
                    pod.ItemNumber = itemName;

                    pod.Quantity = Convert.ToInt32(dr["Quantity"]);
                    flagPOD      = purchaseOrderBL.createPurchaseOrderDetails(pod);
                }
                if (flagPO && flagPOD)//checks if both PurchaseOrder and PurchaseOrderDetails are updated to database. if so, send an email to the supervisor
                {
                    SendEmailSubmit(poCountStr);
                }
                else
                {
                    string script = "alert('There is some issue in sending email. We apologize for this!');";
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script, true);
                }

                Response.Redirect("~/Store/POList.aspx");
            }
        }
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                //For only show the
                PurchaseOrderBO obj = new PurchaseOrderBO();
                PurchaseItemBL  bl  = new PurchaseItemBL();

                //Get the item list from session
                purlst              = (List <PurchaseOrderBO>)Session["purchase"];
                obj.ItemID          = bl.getItemIDByNumber(txtItemNumber.Text);
                obj.ItemNo          = txtItemNumber.Text;
                obj.SupplierID      = Convert.ToInt32(ddlSupplier.SelectedValue);
                obj.SupplierName    = bl.getSupplier(Convert.ToInt32(ddlSupplier.SelectedValue));
                obj.ItemDescription = txtDescription.Text;
                obj.Quantity        = int.Parse(txtQuantity.Text);
                obj.Price           = bl.getPrice(obj.ItemID, obj.SupplierID);
                obj.Amount          = (decimal)obj.Quantity * (decimal)obj.Price;
                //added new tell to jane
                obj.SupplierID       = int.Parse(ddlSupplier.SelectedValue);
                obj.ExpectedDelivery = DateTime.Parse(txtExpectedDeliveryDate.Text);

                //Add object to the lists sessionlist
                int index = isExiting(obj.ItemID, obj.SupplierID);
                if (index == -1)
                {
                    purlst.Add(obj);
                    total += obj.Amount;
                    Session["purchase"] = purlst;
                }
                else
                {
                    purlst[index].Amount   += obj.Amount;
                    purlst[index].Quantity += obj.Quantity;
                    total += obj.Amount;
                    Session["purchase"] = purlst;
                }



                //Bind the data list to gridview
                GridView1.DataSource = purlst;
                GridView1.DataBind();

                //Show Button
                btnPurchase.Visible = true;
                GridView1.FooterRow.Cells[1].HorizontalAlign = HorizontalAlign.Left;
                GridView1.FooterRow.Cells[2].HorizontalAlign = HorizontalAlign.Right;
                GridView1.FooterRow.Cells[3].HorizontalAlign = HorizontalAlign.Right;
                GridView1.FooterRow.Cells[4].HorizontalAlign = HorizontalAlign.Right;
                GridView1.FooterRow.Cells[5].HorizontalAlign = HorizontalAlign.Left;
                GridView1.FooterRow.Cells[5].Text            = total.ToString();

                txtItemNumber.Text     = txtDescription.Text = txtQuantity.Text = "";
                ddlSupplier.DataSource = "";
                ddlSupplier.DataBind();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }