/***********************this confirm button simulates the scene after scanning QRcode (only for Test)**********************************/ /**********************To confirm specified dept disbursement**************************************************************/ protected void Button3_Click(object sender, EventArgs e) { int disburseID = Convert.ToInt32(ViewState["disburseID"]); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('you are generate the Disbursement " + disburseID + " ?')", true); //here should send message box yes or no DisbursementDAO disDAO = new DisbursementDAO(); //disburList ConfirmBtn.Enabled = false; disDAO.updateDisbursementStatus(Convert.ToInt32(ViewState["disburseID"]), "Completed"); disburseGridView.SelectedIndex = -1; disburseBindGrid(); disburseUpdatePanel.Update(); disburseItemGridView.DataSource = null; disburseItemGridView.DataBind(); //send email and notification to rep SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities(); string repID = context.Departments.Where(x => x.deptID == deptid).Select(x => x.repStaffID).ToList().First(); string repName = context.DeptStaffs.Where(x => x.staffID == repID).Select(x => x.staffName).ToList().First(); string confirmDate = DateTime.Now.ToShortDateString(); NotificationDAO nDAO = new NotificationDAO(); nDAO.addDeptNotification(repID, "Disbursement " + disburseID + " is confirmed on " + confirmDate, DateTime.Now); Email email = new Email(); email.sendConfirmedDisbursementEmailToRep(repName, confirmDate, disburseID.ToString()); }
protected void btnUpdateRep_Click(object sender, EventArgs e) { //Update string newRepName = ddlEmp.SelectedValue; DeptStaff newRep = new DeptStaff(); if (newRepName != "---Select Name---") { newRep = deptStaffDAO.findStaffByName(newRepName); logInDept = newRep.deptID; Department dept = deptDAO.findByDeptId(logInDept); DeptStaff oldRep = deptStaffDAO.findDeptRep(logInDept); deptStaffDAO.updateRepName(newRep, oldRep); deptDAO.UpdateDeptRep(dept, newRep); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please Select Name First!')", true); return; } //send feedback email and notification to employee SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities(); string headID = Session["loginID"].ToString(); string headName = Session["loginName"].ToString(); string staffID = newRep.staffID; string staffName = newRepName; NotificationDAO nDAO = new NotificationDAO(); nDAO.addDeptNotification(staffID, headName + " chose you as representative. ", DateTime.Now); Email email = new Email(); email.sendRepNotificationToEmployee(staffName, headName); //Refesh display DisplayCurrentRep(logInDept); DisplayAvaliableEmp(logInDept); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('', 'Successful!');</script>"); }
protected void submit_button_Click(object sender, EventArgs e) { string selectedStaffId = employee_dropList.SelectedValue.ToString(); if (textBox_startDate.Text != "" || textBox_endDate.Text != "") { DateTime sDate = Convert.ToDateTime(textBox_startDate.Text); DateTime eDate = Convert.ToDateTime(textBox_endDate.Text); if (IsValidDate(sDate, eDate)) { delegateDAO.addDelegate(selectedStaffId, sDate, eDate); bindData(deptID); //send feedback email and notification to employee SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities(); string headID = Session["loginID"].ToString(); string headName = Session["loginName"].ToString(); string staffID = selectedStaffId; string staffName = context.DeptStaffs.Where(x => x.staffID == staffID).Select(x => x.staffName).ToList().First(); NotificationDAO nDAO = new NotificationDAO(); nDAO.addDeptNotification(staffID, headName + " delegate you as head from " + sDate + " to " + eDate, DateTime.Now); Email email = new Email(); email.sendDelegateEmailToEmployee(staffName, headName, sDate.ToShortDateString(), eDate.ToShortDateString()); ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Delegated succussfully!');</script>"); } else { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Please select valid date!');</script>"); } } else { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Please select valid date!');</script>"); } }
protected void NotifyButton_Click(object sender, EventArgs e) { NotifyButton.Enabled = false; //send email and notification to rep Label s = disburseGridView.SelectedRow.FindControl("disburseIDLabel") as Label; string a = s.Text; int disburseID = Convert.ToInt32(a); SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities(); Disbursement disbursement = disDAO.getDisbursmentbyId(disburseID); string deptid = disbursement.deptID; string repID = context.Departments.Where(x => x.deptID == deptid).Select(x => x.repStaffID).ToList().First(); string repName = context.DeptStaffs.Where(x => x.staffID == repID).Select(x => x.staffName).ToList().First(); string disbursementDate = disbursement.disburseDate.ToShortDateString(); string collectionPointID = context.Departments.Where(x => x.deptID == deptid).Select(x => x.collectionPointID).ToList().First(); string collectionPoint = context.CollectionPoints.Where(x => x.collectionPointID == collectionPointID).Select(x => x.description).ToList().First(); NotificationDAO nDAO = new NotificationDAO(); nDAO.addDeptNotification(repID, "Disbursement " + disbursement.disbursementID + " is confirmed on " + disbursementDate, DateTime.Now); Email email = new Email(); email.sendDisbursementEmailToRep(repName, disbursementDate, collectionPoint); }
protected void Btn_Reject_Click(object sender, EventArgs e) { string remark = TextBox_Remarks.Text; Requisition req = reqDAO.findRequisitionByrequisitionId(reqID); reqDAO.updateRequisition(req, remark, "Rejected"); //send feedback email and notification to employee SA45_Team09_LogicUEntities context = new SA45_Team09_LogicUEntities(); string headID = Session["loginID"].ToString(); string headName = Session["loginName"].ToString(); string staffID = req.staffID; string staffName = context.DeptStaffs.Where(x => x.staffID == staffID).Select(x => x.staffName).ToList().First(); string requisitionDate = req.requisitionDate.ToString(); NotificationDAO nDAO = new NotificationDAO(); nDAO.addDeptNotification(staffID, headName + " rejected your requisition on " + requisitionDate, DateTime.Now); Email email = new Email(); email.sendFeedBackEmailToEmployee(staffName, headName, requisitionDate, "Rejected"); Response.Redirect("./DH_ViewPendingRequisition.aspx"); }
/************************************Submit Requisition*************************************/ protected void Submit_Click(object sender, EventArgs e) { string name = Session["loginID"].ToString(); SA45_Team09_LogicUEntities m = new DBEntities().getDBInstance(); ///should use DAO string deptID = m.DeptStaffs.Where(x => x.staffID == name).Select(y => y.deptID).First().ToString();//supposed to be in DepartmentDAO List <cart> lc = new List <cart>(); lc = (List <cart>)Session["cart"]; if (lc.Count > 0) { Dictionary <string, int> dict = new Dictionary <string, int>(); int judge = 0; int num = 0; foreach (Control i in cartRepeater.Items) //get Quantity { LinkButton deletebtn = i.FindControl("cart_deleteButton") as LinkButton; //get itemID TextBox cartqty = i.FindControl("cart_qtyTextBox") as TextBox; //get quantity if (cartqty.Text.Trim() == "") { judge = 1; break; } try { lc[num].Qty = Int32.Parse(cartqty.Text.ToString()); } catch { judge = 1; break; } if ((lc[num].Qty % 1 != 0) || (lc[num].Qty <= 0)) { judge = 1; break; } dict.Add(deletebtn.CommandArgument.ToString(), Int32.Parse(cartqty.Text.ToString())); num++; } if (judge == 0) { RequisitionDAO rdao = new RequisitionDAO(); rdao.addRequisition(name, deptID, dict); lc = new List <cart>();//clear the cart session Session["cart"] = lc; //send email and notification to head string headID = m.Departments.Where(x => x.deptID == deptID).Select(x => x.headStaffID).ToList().First(); string headName = m.DeptStaffs.Where(x => x.staffID == headID).Select(x => x.staffName).ToList().First(); string staffName = Session["loginName"].ToString(); string staffID = Session["loginID"].ToString(); NotificationDAO nDAO = new NotificationDAO(); nDAO.addDeptNotification(headID, staffName + " send a new requisition!", DateTime.Now); Email email = new Email(); email.sendNewReqEmailToHead(staffName, headName); HttpContext.Current.Response.Redirect("Emp_MyRequisition.aspx"); } else { ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Input must be integer!');</script>"); } } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage2", "alert('Nothing in cart')", true); return; } }