//to raise request protected void RaiseVouReqButton_Click(object sender, EventArgs e) { BindGrid(); if (RaiseVouReqGridView.Rows.Count != 0) { int EmpID = (int)HttpContext.Current.Session["EmpID"]; VoucherBizLogic.CreateVoucher(EmpID); //mail supervisor String from = "*****@*****.**"; List <String> toAddress = MailBizLogic.SupervisorEmail(); String subject = "[Auto Notification] New Voucher Request"; String body = String.Format("New Voucher Request has been raised by Employee {0}. Check website for further details." + "\n\nNote: This is an auto-generated email. Please do not reply to this email." + "\n\nThis email is confidential and may be privileged.If you are not the intended recipient, " + "please delete it and notify us immediately; you should not copy or use it for any purpose, " + "nor disclose its contents to any other person.\n\nThank you.", EmpID); foreach (String to in toAddress) { MailBizLogic.sendMail(from, to, subject, body); } Response.Redirect("~/Views/PendingVouchers.aspx"); } else { RaiseVouReqButton.Visible = false; Response.Write("<script>alert('No voucher items to add');</script>"); } }
protected void RaiseVouReqGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { RaiseVouReqGridView.DataSource = VoucherBizLogic.ListVoucherDetails((int)HttpContext.Current.Session["EmpID"]); // previously hardcoded as 1005 RaiseVouReqGridView.PageIndex = e.NewPageIndex; RaiseVouReqGridView.DataBind(); BindGrid(); }
protected void RaiseVouReqGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { int voucherDetailId = Convert.ToInt32(RaiseVouReqGridView.DataKeys[e.RowIndex].Values[0]); VoucherBizLogic.DeleteVoucherDetail(voucherDetailId); BindGrid(); }
/* Change: Added BindGrid(string stateOfRadioButton) */ private void BindGrid(string stateOfRadioButton) { if (stateOfRadioButton == "latest") { int EmpID = (int)HttpContext.Current.Session["EmpID"]; if (VoucherBizLogic.ListPendingVoucherRequests(EmpID).Any()) { List <PendingVoucherRequest> latestVoucherRequest = new List <PendingVoucherRequest>(); latestVoucherRequest.Add(VoucherBizLogic.ListPendingVoucherRequests(EmpID).Last()); PendingVouchersGridView.DataSource = latestVoucherRequest; // hardcoded employeeid for now, need to retrieve later PendingVouchersGridView.DataBind(); } else { Response.Write("<script>alert('No pending voucher !');</script>"); /* Changed 7-2-19 */ List <PendingVoucherRequest> emptyList = new List <PendingVoucherRequest>(); PendingVouchersGridView.DataSource = emptyList; PendingVouchersGridView.DataBind(); } } else if (stateOfRadioButton == "all") { int EmpID = (int)HttpContext.Current.Session["EmpID"]; PendingVouchersGridView.DataSource = VoucherBizLogic.ListPendingVoucherRequests(EmpID); // hardcoded employeeid for now, need to retrieve later PendingVouchersGridView.DataBind(); } }
private void BindGrid() { RaiseVouReqGridView.DataSource = VoucherBizLogic.ListVoucherDetails((int)HttpContext.Current.Session["EmpID"]); // previously hardcoded as 1005 RaiseVouReqGridView.DataBind(); if (RaiseVouReqGridView.Rows.Count == 0) { RaiseVouReqButton.Visible = false; } }
protected void PendingVouchersGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { int voucherId = Convert.ToInt32(PendingVouchersGridView.DataKeys[e.RowIndex].Values[0]); VoucherBizLogic.DeletePendingVoucher(voucherId); /* Changed: 7-2-19 */ Response.Write("<script>alert('Selected items have been deleted');</script>"); BindGridAuto(); }
/*Change: added PendingVouchersGridView_SelectedIndexChanged */ protected void PendingVouchersGridView_SelectedIndexChanged(object sender, EventArgs e) { int voucherId = Convert.ToInt32(PendingVouchersGridView.DataKeys[PendingVouchersGridView.SelectedRow.RowIndex].Values[0]); ViewState["vid"] = (int)voucherId; PendingVoucherItemsGridView.DataSource = VoucherBizLogic.ListVoucherDetails((int)HttpContext.Current.Session["EmpID"], voucherId); PendingVoucherItemsGridView.DataBind(); PendingVoucherItemsGridView.Visible = true; }
protected void PendingVoucherItemsGridView_PageIndexChanging(object sender, GridViewPageEventArgs e) { int voucherId = (int)ViewState["vid"]; PendingVoucherItemsGridView.DataSource = VoucherBizLogic.ListVoucherDetails((int)HttpContext.Current.Session["EmpID"], voucherId); PendingVoucherItemsGridView.PageIndex = e.NewPageIndex; PendingVoucherItemsGridView.Visible = true; PendingVoucherItemsGridView.DataBind(); }
protected void RaiseVouReqGridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = RaiseVouReqGridView.Rows[e.RowIndex]; int voucherDetailId = Convert.ToInt32(RaiseVouReqGridView.DataKeys[e.RowIndex].Values[0]); int adjustedQty = Convert.ToInt32((row.FindControl("TextBox1") as TextBox).Text); string remarks = (row.FindControl("TextBox2") as TextBox).Text; VoucherBizLogic.UpdateVoucherDetail(voucherDetailId, adjustedQty, remarks); RaiseVouReqGridView.EditIndex = -1; BindGrid(); }
protected void AddVouButton1_Click(object sender, EventArgs e) { if (Page.IsValid) // CustomValidator1.IsValid { // add voucher detail and retrieve list of voucher details not yet raised itemId = ItemCodeTextBox.Text; int adjustedQty = Convert.ToInt32(AdjQtyTextBox.Text); string Remarks = ReasonTextBox.Text; if (adjustedQty < 0) { if (Math.Abs(adjustedQty) > Convert.ToInt32(InventoryBizLogic.GetInventoryItemQty(itemId))) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Please input a valid adjusted qty');", true); this.Page_Load(null, null); // need this or else page won't add item the second time around } else { VoucherBizLogic.CreateVoucherDetail(itemId, adjustedQty, Remarks, (int)HttpContext.Current.Session["EmpID"]);// previously hardcoded employeeid as 1005; to retrieve employeeID from login later BindGrid(); /* Change: 6-2-19 */ ChangeControlsVisibility("Raise"); } } else { VoucherBizLogic.CreateVoucherDetail(itemId, adjustedQty, Remarks, (int)HttpContext.Current.Session["EmpID"]);// previously hardcoded employeeid as 1005; to retrieve employeeID from login later BindGrid(); /* Change 6/2/19 */ ChangeControlsVisibility("Raise"); } } }