protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int rowindex = Convert.ToInt32(e.CommandArgument);
            int adjid    = Int32.Parse(((Label)GridView2.Rows[rowindex].FindControl("Label1")).Text);

            using (LastADEntities entities = new LastADEntities())
            {
                AdjVoucher abc = entities.AdjVouchers.Where(p => p.AdjVoucherId == adjid).First();
                if (e.CommandName == "Issue Voucher")
                {
                    abc.ApprovedDate = DateTime.Now;
                    //abc.ApprovalEmpNum = ...
                    abc.Status = "Authorised";
                    entities.SaveChanges();



                    Transaction trans    = new Transaction();
                    string      itemname = ((Label)GridView2.Rows[rowindex].FindControl("Label3")).Text;
                    string      ItemId   = Business.Finditemidbyname(itemname);
                    trans.ItemId = ItemId;
                    int Quantity = Int32.Parse(((Label)GridView2.Rows[rowindex].FindControl("Label4")).Text);
                    trans.Quantity = Quantity;
                    ItemList i       = entities.ItemLists.Find(ItemId);
                    int      stock   = (int)i.Stock;
                    int      Balance = stock + (Quantity);
                    trans.Balance = Balance;

                    trans.AdjVoucherId = adjid;
                    trans.EntryDate    = DateTime.Now;
                    entities.Transactions.Add(trans);
                    entities.SaveChanges();

                    GridView2.DataBind();

                    ItemList xyz = entities.ItemLists.Where(p => p.ItemId == ItemId).First();
                    xyz.Stock = Balance;
                    entities.SaveChanges();

                    Response.Redirect("~/6StoreSupervisor/SupervisorAdjVoucher.aspx");
                }


                else if (e.CommandName == "Inform Manager")
                {
                    abc.Status = "PendingDHAuthorisation";

                    entities.SaveChanges();
                    Response.Redirect("~/6StoreSupervisor/SupervisorAdjVoucher.aspx");
                }
            }
        }
示例#2
0
        public String UpdateAdjVoucher(WCF_AdjVoucher AdjV)
        {
            LastADEntities entities = new LastADEntities();
            AdjVoucher     adj      = new AdjVoucher();

            adj.ItemId        = AdjV.ItemId;
            adj.QuantityAdj   = Int32.Parse(AdjV.QuantityAdj);
            adj.Reason        = AdjV.Reason;
            adj.RequestEmpNum = Int32.Parse(AdjV.RequestEmpNum);
            adj.SubmitDate    = DateTime.Now;
            adj.Status        = "Pending Authorisation";
            entities.AdjVouchers.Add(adj);
            entities.SaveChanges();
            return("Successfully");
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            //Clicking this button will generate a new Adjustment voucher. Those values displayed in the gridview
            //wil be added into the adjustment voucher accordingly. This adjustment voucher will be added into the database

            LastADEntities entities = new LastADEntities();

            for (int i = 0; i < list3.Rows.Count; i++)
            {
                AdjVoucher adj = new AdjVoucher();
                adj.ItemId      = (list3.Rows[i][0].ToString());
                adj.QuantityAdj = Int32.Parse(list3.Rows[i][1].ToString());
                adj.Reason      = list3.Rows[i][2].ToString();
                if (Session["EmpId"] != null)
                {
                    adj.RequestEmpNum = Int32.Parse(Session["EmpId"].ToString());
                }
                adj.SubmitDate = DateTime.Now;
                adj.Status     = "Pending Authorisation";
                entities.AdjVouchers.Add(adj);
                entities.SaveChanges();
            }
            //An email will be sent to the supervisor for approval.

            string bossmail = "*****@*****.**";

            Business.sendemail();
            MailMessage mm = new MailMessage("*****@*****.**",
                                             bossmail);

            mm.Subject = "The new Adjustment voucher has been send to you, please help us check and review";

            mm.Body = "There are" + list3.Rows.Count.ToString() + " item need to be issued";
            Business.sendemail().Send(mm);

            Response.Redirect("DiscrepancyListSubmitted.aspx");
        }