public async Task <IActionResult> Edit(int id, [Bind("PoId,ResellerId,CustomerId,OrderReference,ProductId,Price")] Purchase_Order purchase_Order)
        {
            if (id != purchase_Order.PoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(purchase_Order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!Purchase_OrderExists(purchase_Order.PoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"]  = new SelectList(_context.Product, "ProductId", "Name", purchase_Order.ProductId);
            ViewData["ResellerId"] = new SelectList(_context.Product, "ResellerId", "TradingName");
            ViewData["CustomerId"] = new SelectList(_context.Product, "CustomerId", "TradingName");
            return(View(purchase_Order));
        }
        protected void ReceiveOrder(object sender, EventArgs e)
        {
            Purchase_Order p = context.Purchase_Order.Where(x => x.order_id == orderId).First();

            Session["suppliername"] = p.Supplier.name;

            Response.Redirect("~/Views/StoreClerk/ReceiveOrder.aspx");
        }
        public ActionResult deletePurchaseOrder(int id)
        {
            Purchase_Order so = db.Purchase_Order.Find(id);

            so.is_active = "N";
            db.SaveChanges();
            List <Purchase_Order> list = db.Purchase_Order.Where(x => x.is_active == "Y").ToList();

            return(PartialView("UpdatedPurchaseOrderList", list));
        }
        public ActionResult CreatePurchaseOrder(int id)
        {
            try
            {
                Temporary_Orders temp      = tempServices.findTempOrderById(id);
                int account_id             = temp.Account_Id;
                TransactionAccount account = transactionService.findTransactionAccount(account_id);
                Purchase_Order     s_order = new Purchase_Order();

                s_order.bags              = temp.bags;
                s_order.broker_name       = temp.broker_name;
                s_order.brokers_commision = temp.brokers_commision;

                s_order.company_sign = temp.company_sign;
                s_order.created_at_  = temp.created_at_;
                s_order.is_active    = temp.is_active;
                s_order.vendor_sign  = temp.vendor_sign;
                s_order.item         = temp.item;
                s_order.party_name   = account.name;

                s_order.po_number   = temp.order_number;
                s_order.terms       = temp.terms;
                s_order.uptdated_at = temp.created_at_;
                s_order.weight      = temp.weight;
                s_order.rate        = temp.rate;
                s_order.prepared_by = temp.prepared_by;
                s_order.approved_by = Session["username"].ToString();
                s_order.checked_by  = temp.checked_by;
                s_order.Account_Id  = account.id;
                service.addPO(s_order);
                service.save();
                Temporary_Orders TO = db.Temporary_Orders.Find(id);
                TO.is_active = "N";
                db.SaveChanges();
                db.SaveChanges();
                return(RedirectToAction("listOfTempOrders", "SaleOrder"));
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}",
                                               validationErrors.Entry.Entity.GetType().FullName,
                                               validationError.PropertyName,
                                               validationError.ErrorMessage);
                    }
                }

                return(RedirectToAction("listOfTempOrders", "SaleOrder"));
            }
        }
        public async Task <IActionResult> Create([Bind("PoId,ResellerId,CustomerId,OrderReference,ProductId,Price")] Purchase_Order purchase_Order)
        {
            if (ModelState.IsValid)
            {
                _context.Add(purchase_Order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"]  = new SelectList(_context.Product, "ProductId", "Name", purchase_Order.ProductId);
            ViewData["ResellerId"] = new SelectList(_context.Product, "ResellerId", "TradingName");
            ViewData["CustomerId"] = new SelectList(_context.Product, "CustomerId", "TradingName");
            return(View(purchase_Order));
        }
        protected void Delete_Order(object sender, EventArgs e)
        {
            Button      btn = (Button)sender;
            GridViewRow gvr = (GridViewRow)btn.NamingContainer;

            int orderId = Convert.ToInt32(((Label)gvr.FindControl("Label_OrderId")).Text);

            Purchase_Order order = s.Purchase_Order.Where(x => x.order_id == orderId).First();

            order.deleted = "Y";

            s.SaveChanges();

            Response.Redirect("~/Views/StoreClerk/ViewPendingOrder.aspx");
        }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow            row        = GridView1.SelectedRow;
        String                 item       = row.Cells[2].Text;
        String                 supplierid = row.Cells[1].Text;
        Purchase_Order_Details update     = model.Purchase_Order_Details.Where(x => x.Order_ID == order_ID && x.Item_Number == item).First();

        if (update != null)
        {
            update.Supplier_ID = supplierid;
            update.Status      = "Pending";
            model.SaveChanges();
        }
        Purchase_Order order = model.Purchase_Order.Where(x => x.Order_ID == order_ID).First();
        var            date  = order.Order_Date;
        var            user  = order.User_ID;

        Response.Redirect("Store_ChangePurchaseOrderDetails.aspx?Order_ID=" + order_ID + "&Order_Date=" + date + "&user_id=" + user);
    }
        public Purchase_Order[] Get()
        {
            var collection = JsonConvert.DeserializeObject <List <Purchase_Order> >(File.ReadAllText("C:/Users/Arthur/source/repos/src/Challenge/data/purchase_orders.json")); //Deserializando json em objetos do tipo correto
            List <Purchase_Order> aux_collection = new List <Purchase_Order>();                                                                                                //Lista auxiliar para armazenar a quantia certa do array para retornar.

            for (int i = 0; i < collection.Count; i++)
            {
                if (collection[i].MaterialName.Contains(Search.GetInstance().query)) //Condições de busca
                {
                    aux_collection.Add(collection[i]);
                }
            }

            Purchase_Order[] purchase_orderArray = new Purchase_Order[aux_collection.Count]; //Criando array de valores para retornar

            for (int i = 0; i < aux_collection.Count; i++)
            {
                purchase_orderArray[i] = aux_collection[i]; //Atribuindo todos os valores da lista auxiliar ao array de retorno.
            }

            return(purchase_orderArray); //Retornando json
        }
Exemple #9
0
        public Purchase_Order[] Get()
        {
            var collection = JsonConvert.DeserializeObject <List <Purchase_Order> >(File.ReadAllText("C:/xampp/htdocs/dashboard/src/Controllers/purchase_orders.json"));
            List <Purchase_Order> aux_collection = new List <Purchase_Order>();

            for (int i = 0; i < collection.Count; i++)
            {
                if (collection[i].MaterialName.Contains(Search.GetInstance().query))
                {
                    aux_collection.Add(collection[i]);
                }
            }

            Purchase_Order[] purchase_orderArray = new Purchase_Order[aux_collection.Count];

            for (int i = 0; i < aux_collection.Count; i++)
            {
                purchase_orderArray[i] = aux_collection[i];
            }

            return(purchase_orderArray);
        }
Exemple #10
0
    // Make Order
    protected void Button3_Click(object sender, EventArgs e)
    {
        DateTime time = DateTime.Now;

        Purchase_Order po        = new Purchase_Order();
        LoginDetails   logininfo = User.Identity as LoginDetails;

        po.User_ID                = Int32.Parse(logininfo.UserId);
        po.Order_Date             = time;
        po.Purchase_Order_Details = addPurchaseDetailsItem();
        model.Purchase_Order.Add(po);
        model.SaveChanges();

        Button3.Visible = false;

        Session.Clear();
        Session.Abandon();


        ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Order Successfully');window.location ='Store_MakePurchaseOrder.aspx';", true);

        //ShowMessage("Order Successfully", MessageType.Success);
    }
Exemple #11
0
 public void addPO(Purchase_Order obj)
 {
     db.Purchase_Order.Add(obj);
 }
        public ActionResult AddSaleVoucher(int id)
        {
            if (service.checkID() == false)
            {
                return(Content("IDS Conflict Error Occured While Procsesing Request"));
            }



            TemporaryReport temp      = service.findTemporaryReport(id);
            int             nextID    = id + 1;
            TemporaryReport tempTo    = service.findTemporaryReport(nextID);
            string          from      = temp.from_account;
            string          to        = temp.to_account;
            int             fromID    = (int)temp.tax;
            double          rate      = 0;
            int             idForRate = 0;
            float           unitPrice = 0;

            if (temp.voucher_type == "UPSV" || temp.voucher_type == "UPPV")
            {
                try
                {
                    float checkingUnit = float.Parse(temp.unit_price);
                }
                catch (Exception)
                {
                    if (temp.builty_no_ != null)
                    {
                        return(RedirectToAction("unitPriceSV", "SaleVoucher"));
                    }
                    else
                    {
                        return(RedirectToAction("unitPricePV", "SaleVoucher"));
                    }
                }
            }
            try
            {
                int checking = (int)temp.builty_no_;
            }
            catch (Exception)
            {
                if (temp.voucher_type == "SV")
                {
                    return(RedirectToAction("Index", "SaleVoucher"));
                }
                else
                {
                    return(RedirectToAction("unitPriceSV", "SaleVoucher"));
                }
            }


            int builty = Convert.ToInt32(temp.builty_no_);

            try
            {
                String             session   = Session["name"].ToString();
                TransactionAccount transFrom = new TransactionAccount();
                TransactionAccount trans_to  = new TransactionAccount();

                Good good = service.findGood(fromID);
                if (temp.voucher_type == "UPPV" || temp.voucher_type == "PV")
                {
                    transFrom = service.findJvTransaction(from);
                    trans_to  = good.TransactionAccount;
                    idForRate = transFrom.id;
                }
                else if (temp.voucher_type == "SV" || temp.voucher_type == "UPSV")
                {
                    transFrom = good.TransactionAccount;
                    trans_to  = service.findJvTransaction(to);
                    idForRate = trans_to.id;
                }
                Transaction tr      = new Transaction();
                Transaction transTo = new Transaction();
                if (temp.voucher_type == "UPSV" || temp.voucher_type == "UPPV")
                {
                    unitPrice = float.Parse(temp.unit_price);
                    rate      = unitPrice;
                }

                else
                {
                    try
                    {
                        rate = service.findRate(idForRate, good.good_Name);
                    }

                    catch (Exception)
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('Invalid Rate !');</script>"));
                    }
                }
                int amount = 0;

                tr.truck        = temp.truck;
                tr.builty_no_   = temp.builty_no_;
                tr.weight_empty = temp.weight_empty;
                tr.weight_load  = temp.weight_load;
                tr.net_weight   = temp.net_weight;
                tr.quantity     = tr.net_weight.ToString();
                tr.good_        = good.good_Name;

                amount = Convert.ToInt32(rate * tr.net_weight);

                tr.bags        = temp.bags;
                tr.created_at  = temp.created_at;
                tr.updated_at  = tr.created_at;
                tr.is_active   = "Y";
                tr.code        = transFrom.id;
                tr.description = temp.description;
                tr.cr          = 0;
                tr.dr          = amount;
                tr.balance     = (transFrom.balance - amount);



                tr.from_account = from;
                tr.to_account   = to;
                //transFrom.dr_ = amount;

                if (temp.voucher_type == "SV" || temp.voucher_type == "UPSV")
                {
                    if (temp.voucher_type == "SV")
                    {
                        tr.status       = "Sale voucher added";
                        tr.voucher_type = "SV";
                        //   tr.voucher_code = "SV111";
                    }
                    else
                    {
                        tr.status       = "Unit Price Sale Voucher Added";
                        tr.voucher_type = "UPSV";
                        //     tr.voucher_code = "UPSV111";
                    }
                }
                else
                {
                    if (temp.voucher_type == "PV")
                    {
                        tr.status = "Purchase Voucher added";
                        //     tr.voucher_code = "PV111";
                        tr.voucher_type = "PV";
                        tr.grn          = temp.grn;
                        tr.deduction    = temp.deduction;
                    }
                    else
                    {
                        tr.status = "Unit Price Purchase Voucher added";
                        //     tr.voucher_code = "UPPV111";
                        tr.voucher_type = "UPPV";
                        tr.grn          = temp.grn;
                        tr.deduction    = temp.deduction;
                    }
                }
                tr.trans_acc_id = transFrom.id;
                if (session != "Admin")
                {
                    string username = Session["username"].ToString();
                    User   user     = service.findUser(username);
                    ViewBag.userName = user.name;
                    tr.supervisor    = user.name;
                }
                else
                {
                    ViewBag.userName = Session["username"].ToString();
                    tr.supervisor    = Session["username"].ToString();
                }


                tr.user_id  = temp.user_id;
                tr.admin_id = temp.admin_id;


                tr.voucher_code = temp.voucher_code;
                tr.unit_price   = temp.unit_price;
                service.addTransaction(tr);
                transFrom.balance = tr.balance;
                tr.unique_key     = transFrom.id;
                temp.is_active    = "N";



                transTo.truck        = tempTo.truck;
                transTo.builty_no_   = tempTo.builty_no_;
                transTo.weight_empty = tempTo.weight_empty;
                transTo.weight_load  = tempTo.weight_load;
                transTo.net_weight   = tempTo.net_weight;
                transTo.bags         = tempTo.bags;
                transTo.created_at   = tempTo.created_at;
                transTo.updated_at   = tr.created_at;
                transTo.is_active    = "Y";
                transTo.quantity     = tr.quantity;
                transTo.good_        = good.good_Name;


                transTo.code        = trans_to.id;
                transTo.description = tempTo.description;
                transTo.dr          = 0;
                transTo.cr          = amount;
                transTo.balance     = (trans_to.balance + amount);



                transTo.from_account = from;
                transTo.to_account   = to;
                if (temp.voucher_type == "SV" || temp.voucher_type == "UPSV")
                {
                    if (temp.voucher_type == "SV")
                    {
                        transTo.status       = "Sale voucher added";
                        transTo.voucher_type = "SV";
                        transTo.voucher_code = "SV111";
                    }
                    else
                    {
                        transTo.status       = "Unit Price Sale Voucher Added";
                        transTo.voucher_type = "UPSV";
                        transTo.voucher_code = "UPSV111";
                    }
                }
                else
                {
                    if (temp.voucher_type == "PV")
                    {
                        transTo.status       = "Purchase Voucher added";
                        transTo.voucher_code = "PV111";
                        transTo.voucher_type = "PV";
                        transTo.grn          = tempTo.grn;
                        transTo.deduction    = tempTo.deduction;
                    }
                    else
                    {
                        transTo.status       = "Unit Price Purchase Voucher added";
                        transTo.voucher_code = "UPPV111";
                        transTo.voucher_type = "UPPV";
                        transTo.grn          = tempTo.grn;
                        transTo.deduction    = tempTo.deduction;
                    }
                }
                transTo.trans_acc_id = trans_to.id;
                //trans_to.cr_ = amount;
                if (session != "Admin")
                {
                    string username = Session["username"].ToString();
                    User   user     = service.findUser(username);
                    ViewBag.userName   = user.name;
                    transTo.supervisor = user.name;
                }
                else
                {
                    ViewBag.userName   = Session["username"].ToString();
                    transTo.supervisor = Session["username"].ToString();
                }


                transTo.user_id  = temp.user_id;
                transTo.admin_id = temp.admin_id;


                // End //
                transTo.voucher_code = temp.voucher_code;
                transTo.unit_price   = tr.unit_price;
                service.addTransaction(transTo);
                trans_to.balance      = transTo.balance;
                transTo.unique_key    = tr.unique_key;
                tempTo.is_active      = "N";
                trans_to.updated_at_  = tr.updated_at;
                transFrom.updated_at_ = tr.updated_at;

                // for Weight maintenece //

                //if (tr.voucher_type == "PV" || tr.voucher_type != "UPPV")


                //    if (transFrom.WEIGHT != null)
                //    {
                //        int weight = Convert.ToInt32(transFrom.WEIGHT);
                //        weight = (int)(weight - temp.net_weight);
                //        transFrom.WEIGHT = weight.ToString();
                //    }

                //    if (trans_to.WEIGHT != null)
                //    {
                //        int weight = Convert.ToInt32(trans_to.WEIGHT);
                //        weight = (int)(weight + temp.net_weight);
                //        trans_to.WEIGHT = weight.ToString();
                //    }



                //////////////////////////

                tr.Last_Edit      = "None";
                transTo.Last_Edit = "None";



                service.save();



                #region Sale and Purchase order


                if (temp.order_number != 0 && temp.order_number != -1 && temp.order_number != null)
                {
                    Database1Entities1 db = new Database1Entities1();
                    if (temp.order_code == "SO")
                    {
                        Sale_Order so = db.Sale_Order.Find(temp.order_number);
                        so.weight = (int)(so.weight - temp.net_weight);
                        if (so.weight <= 0)
                        {
                            so.is_active = "N";
                        }
                    }
                    else if (temp.order_code == "PO")
                    {
                        Purchase_Order po = db.Purchase_Order.Find(temp.order_number);
                        po.weight = (int)(po.weight - temp.net_weight);
                        if (po.weight <= 0)
                        {
                            po.is_active = "N";
                        }
                    }
                    db.SaveChanges();
                }

                #endregion

                service.balanceUpdation(transFrom.id, trans_to.id);


                //////////////////////////////////////////////////////////
                //////////////////////////////////////////////////////////

                if (tr.voucher_type == "SV" || tr.voucher_type == "UPSV")
                {
                    Transaction        transaction   = new Transaction();
                    Transaction        transactionTo = new Transaction();
                    TransactionAccount newTr         = new TransactionAccount();
                    try{
                        newTr = service.findSaleAccount(transFrom.sale_account_id);
                    }
                    catch (Exception)
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('Link sale Account not Found !');</script>"));
                    }

                    transaction.truck        = tr.truck;
                    transaction.builty_no_   = tr.builty_no_;
                    transaction.weight_empty = tr.weight_empty;
                    transaction.weight_load  = tr.weight_load;
                    transaction.net_weight   = tr.net_weight;

                    transaction.quantity = tr.quantity;
                    tr.good_             = good.good_Name;

                    amount = Convert.ToInt32(rate * tr.net_weight);

                    transaction.bags        = tr.bags;
                    transaction.created_at  = tr.created_at;
                    transaction.updated_at  = tr.created_at;
                    transaction.is_active   = "Y";
                    transaction.code        = transFrom.id;
                    transaction.description = tr.description;
                    transaction.cr          = 0;
                    transaction.dr          = amount;
                    transaction.balance     = (transFrom.balance - amount);



                    transaction.from_account = transFrom.name;
                    transaction.to_account   = trans_to.name;
                    //transFrom.dr_ = amount;
                    transaction.status       = "Sale voucher added";
                    transaction.voucher_type = "SV";
                    transaction.voucher_code = tr.voucher_code;
                    transaction.trans_acc_id = transFrom.id;

                    if (session != "Admin")
                    {
                        string username = Session["username"].ToString();
                        User   user     = service.findUser(username);
                        ViewBag.userName       = user.name;
                        transaction.supervisor = user.name;
                    }
                    else
                    {
                        ViewBag.userName       = Session["username"].ToString();
                        transaction.supervisor = Session["username"].ToString();
                    }


                    transaction.user_id  = temp.user_id;
                    transaction.admin_id = temp.admin_id;


                    transaction.from_account = transFrom.name;
                    transaction.to_account   = newTr.name;
                    transaction.voucher_code = tr.voucher_code;
                    transaction.unique_key   = good.Id;
                    transaction.Last_Edit    = tr.Last_Edit;
                    service.addTransaction(transaction);

                    transactionTo.truck        = tr.truck;
                    transactionTo.builty_no_   = tr.builty_no_;
                    transactionTo.weight_empty = tr.weight_empty;
                    transactionTo.weight_load  = tr.weight_load;
                    transactionTo.net_weight   = tr.net_weight;
                    transactionTo.bags         = tr.bags;
                    transactionTo.created_at   = tr.created_at;
                    transactionTo.updated_at   = tr.created_at;
                    transactionTo.is_active    = "Y";
                    transactionTo.quantity     = tr.quantity;
                    transactionTo.good_        = tr.good_;
                    transactionTo.code         = newTr.id;
                    transactionTo.description  = tr.description;
                    transactionTo.dr           = 0;
                    transactionTo.cr           = amount;
                    transactionTo.balance      = (trans_to.balance + amount);
                    transactionTo.from_account = transFrom.name;

                    transaction.to_account     = newTr.name;
                    transactionTo.status       = "Sale voucher added";
                    transactionTo.voucher_type = "SV";
                    transactionTo.trans_acc_id = newTr.id;
                    //newTr.cr_ = amount;

                    if (session != "Admin")
                    {
                        string username = Session["username"].ToString();
                        User   user     = service.findUser(username);
                        ViewBag.userName         = user.name;
                        transactionTo.supervisor = user.name;
                    }
                    else
                    {
                        ViewBag.userName         = Session["username"].ToString();
                        transactionTo.supervisor = Session["username"].ToString();
                    }


                    transactionTo.user_id  = temp.user_id;
                    transactionTo.admin_id = temp.admin_id;


                    transactionTo.from_account = transFrom.name;
                    transactionTo.to_account   = newTr.name;

                    transactionTo.Last_Edit = tr.Last_Edit;

                    service.addTransaction(transactionTo);
                    newTr.balance     = newTr.balance + amount;
                    newTr.updated_at_ = tr.updated_at;
                    //newTr.dr_ = newTr.dr_ + amount;
                    int weight    = Convert.ToInt32(newTr.WEIGHT);
                    int newWieght = (int)(weight + tr.net_weight);
                    newTr.WEIGHT = newWieght.ToString();
                    transactionTo.voucher_code = tr.voucher_code;

                    transaction.extra   = "Sale"; // for dicriminate sale accounts //
                    transactionTo.extra = "Sale";

                    service.save();


                    service.balanceUpdation(transFrom.id, newTr.id);
                }


                ////////////////////////////////////////////////////////////////////////////
                return(RedirectToAction("Supervision", "USER_CRUD"));
            }

            catch
            {
                if (temp.voucher_type == "SV" || temp.voucher_type == "UPSV")
                {
                    if (unitPrice == 0)
                    {
                        return(RedirectToAction("Supervision", "USER_CRUD"));
                        //return RedirectToAction("Index");
                    }
                    else
                    {
                        return(RedirectToAction("Supervision", "USER_CRUD"));
                        //return RedirectToAction("unitPriceSV");
                    }
                }
                else
                {
                    if (unitPrice == 0)
                    {
                        return(RedirectToAction("purchaseVoucher"));
                    }
                    else
                    {
                        return(RedirectToAction("unitPricePV"));
                    }
                }
            }
        }
Exemple #13
0
        protected void MakeOrder(object sender, EventArgs e)
        {
            HashSet <OrderDetailsView> orderList = (HashSet <OrderDetailsView>)Session["tender"];

            IEnumerable <IGrouping <string, OrderDetailsView> > groups = orderList.GroupBy(k => k.SupplierId);

            // Create new Order


            foreach (var o in groups)
            {
                Purchase_Order po = new Purchase_Order();
                po.supplier_id     = o.Key;
                po.clerk_user      = User.Identity.Name;
                po.delivery_by     = DateTime.Parse(deliverydate.Text);
                po.order_date      = DateTime.Today;
                po.deliver_address = "1 University Road, #01-00 Store Warehouse, Singapore 786541";
                po.deleted         = "N";
                s.Purchase_Order.Add(po);
                s.SaveChanges();


                // Get OrderID
                Purchase_Order createdorder = s.Purchase_Order.Where(x => x.clerk_user == User.Identity.Name).OrderBy(x => x.order_id).ToList().Last();



                foreach (var item in o)
                {
                    Purchase_Order_Details orderDetail = new Purchase_Order_Details();
                    orderDetail.order_id  = createdorder.order_id;
                    orderDetail.tender_id = item.TenderId;
                    orderDetail.quantity  = item.Quantity;
                    orderDetail.status    = "Pending";
                    orderDetail.cancelled = "N";
                    orderDetail.deleted   = "N";
                    s.Purchase_Order_Details.Add(orderDetail);
                    s.SaveChanges();
                }
            }

            UserModel currentUserModel = new UserModel(User.Identity.Name);

            /* Email logic */
            string    fromEmail = currentUserModel.Email;
            string    fromName  = currentUserModel.Fullname;
            UserModel deptHead  = currentUserModel.FindDelegateOrDeptHead();
            string    toEmail   = deptHead.Email;
            string    toName    = deptHead.Fullname;

            string        subject = string.Format("Your purchase order confirmation, {0}", fromName);
            StringBuilder sb      = new StringBuilder();

            sb.AppendLine("Dear " + fromName + ",");
            sb.AppendLine("<br />");
            sb.AppendLine("<br />");
            sb.AppendLine(string.Format("You have sent a purchase order."));
            sb.AppendLine("<br />");
            sb.AppendLine("<br />");
            sb.AppendLine(string.Format("Please <a href=\"{0}\">follow this link to view the request</a>.", "https://rebrand.ly/ssis-store-receiveorder"));
            sb.AppendLine("<br />");
            sb.AppendLine("<br />");
            sb.AppendLine("Thank you.");
            sb.AppendLine("<br />");
            sb.AppendLine("<br />");
            sb.AppendLine("<i>This message was auto-generated by the Stationery Store Inventory System.</i>");

            string body = sb.ToString();

            new Emailer(fromEmail, fromName).SendEmail(fromEmail, fromName, subject, body);
            /* End of email logic */


            Session["tender"] = null;
            Session["item"]   = null;

            Response.Redirect("~/Views/StoreClerk/PurchaseOrderSuccess.aspx");
        }