Exemple #1
0
        public PurchaseOrderDetailsBO countTotalPodId()
        {
            var query = (from pod in context.PurchaseOrderDetails
                         orderby pod.PODetailsID descending
                         select new { pod.PODetailsID }).First();
            PurchaseOrderDetailsBO pbo = new PurchaseOrderDetailsBO();

            pbo.PoDetailsId = query.PODetailsID;
            return(pbo);
        }
Exemple #2
0
        public PurchaseOrderDetail convertPurchaseOrderDetails(PurchaseOrderDetailsBO pobo)
        {
            PurchaseOrderDetail pod = new PurchaseOrderDetail();

            pod.PODetailsID = pobo.PoDetailsId;
            pod.POID        = pobo.PoId;
            pod.SupplierID  = pobo.SupplierId;
            pod.ItemNumber  = pobo.ItemNumber;
            pod.Quantity    = pobo.Quantity;
            return(pod);
        }
Exemple #3
0
 public Boolean createPurchaseOrderDetails(PurchaseOrderDetailsBO pod)
 {
     poda = new PurchaseOrderDA();
     return(poda.createPODetails(convertPurchaseOrderDetails(pod)));
 }
Exemple #4
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");
            }
        }