// int beforeid; protected void Page_Load(object sender, EventArgs e) { Session["changedName"] = dr_NewRep.SelectedValue; if (Session["sign"].ToString() == "") { Response.Redirect("~/LoginNew.aspx"); } Model1 ctx = new Model1(); Boolean results = empauthentication.HeadandrepAuthentication(Session["sign"].ToString()); if (results == false) { Response.Redirect("~/LoginNew.aspx"); } int ucount = ctx.Users.Count(); int count = ctx.Departments.Count(); User[] users = new User[ucount]; User u = ctx.Users.Where(x => x.Role == "DeptRepre").First(); emN.Text = u.UserName; Session["beforeid"] = u.UserID; Session["username"] = emN.Text.ToString(); Session["userid"] = u.UserID; btn_Send.Enabled = false; username = Session["username"].ToString(); User user = ctx.Users.Where(x => x.UserName == username).First(); deptcode = user.DeptCode; dr_NewRep.DataSource = DepartmentBusinessLogic.Listrepresentative(deptcode); dr_NewRep.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { try { string description = DropDownList2.SelectedValue; Stock s = ctx.Stocks.Where(x => x.Description == description).First(); int ReID = Int32.Parse(Label2.Text); string ItemCode = s.ItemCode; string desp = DropDownList2.SelectedValue.ToString(); int qty = Int32.Parse(Textbox2.Text); //int qty = -1; if (qty <= 0) { Label1.Text = "Please input Valid number"; } else { DepartmentBusinessLogic.AddReDetails(ReID, ItemCode, desp, qty, 0, 0); BindGrid(ReID); Button2.Enabled = true; Label1.Text = "Add Suceessful"; } } catch (Exception ex) { Label1.Text = "Please input Valid number"; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["sign"].ToString() == "") { Response.Redirect("~/LoginNew.aspx"); } Boolean results = empauthentication.HeadandrepAuthentication(Session["sign"].ToString()); if (results == false) { Response.Redirect("~/LoginNew.aspx"); } if (!IsPostBack) { List <Request> list = new List <Request>(); list = DepartmentBusinessLogic.GetRequestByPending(); if (list.Count() == 0) { Lab_successful.Text = "No Request now"; } else { GridView1.DataSource = list; GridView1.DataBind(); } } }
protected void Button2_Click(object sender, EventArgs e) { date = DateTime.Now; username = Session["sign"].ToString(); User u = ctx.Users.Where(x => x.UserName == username).First(); userID = u.UserID; DeptCode = u.DeptCode; DeptName = u.DeptName; UserName = u.UserName; approvalStatus = "Pending"; collectionStatus = "Uncollected"; Department d = ctx.Departments.Where(x => x.DeptCode == DeptCode).First(); ABName = d.ContactName; collectionpoint = d.CollectionPoint; User u2 = ctx.Users.Where(x => x.UserName == ABName).First(); approveby = u2.UserID; ReID = Convert.ToInt32(Label2.Text); DepartmentBusinessLogic.AddRequest(ReID, DeptCode, DeptName, userID, UserName, date, approvalStatus, approveby, ABName, null, collectionStatus, collectionpoint); string a = Session["sign"].ToString(); User c = ctx.Users.Where(x => x.UserName == a).First(); string Sender = c.Email; User departhead = ctx.Users.Where(x => x.DeptName == u.DeptName && x.Role == "DeptHead").First(); string[] receive = new string[] { departhead.Email.ToString() }; string Password = "******"; Session["Title"] = "New Request coming"; Session["content"] = Session["sign"].ToString() + " has submit request,please process as soon as possible"; Label1.Text = SendEmail.sendEmail(Sender, Password, Session["Title"].ToString(), Session["content"].ToString(), receive); Session["Title"] = ""; Session["content"] = ""; }
protected void rej_Click(object sender, EventArgs e) { Request r = ctx.Requests.Where(x => x.RequestID == requestid).First(); int requestID = r.RequestID; string status = "reject"; string comments = txb_comments.Text; DepartmentBusinessLogic.ChangeRequestAsReject(requestID, status, comments); Lab_reject.Text = "successful"; Session["Title"] = "Request reject Notification"; if (txb_comments.Text.ToString() == "" || txb_comments.Text.ToString() == null) { Session["content"] = Session["sign"].ToString() + " has reject your request which ID is" + requestid.ToString(); } else { Session["content"] = Session["sign"].ToString() + " has reject your request which ID is" + requestid.ToString() + ",comment is" + txb_comments.Text.ToString(); } string a = Session["sign"].ToString(); User c = ctx.Users.Where(x => x.UserName == a).First(); string Sender = c.Email; User d = ctx.Users.Where(x => x.UserName == r.UserName).First(); string[] receive = new string[] { d.Email.ToString() }; string Password = "******"; Label1.Text = SendEmail.sendEmail(Sender, Password, Session["Title"].ToString(), Session["content"].ToString(), receive); Session["Title"] = ""; Session["content"] = ""; }
protected void Page_Load(object sender, EventArgs e) { if (Session["sign"].ToString() == "") { Response.Redirect("~/LoginNew.aspx"); } lab_session.Text = Session["sign"].ToString(); Boolean results = empauthentication.EmpAuthentication(Session["sign"].ToString()); if (results == false) { Response.Redirect("~/LoginNew.aspx"); } List <User> users = DepartmentBusinessLogic.ListUserByName(lab_session.Text); Model1 ctx = new Model1(); int count = ctx.Users.Count(); User[] user = new User[count]; user = ctx.Users.ToArray(); // Label1.Text =; User u = ctx.Users.Where(x => x.UserName == lab_session.Text).First(); lab_user.Text = lab_session.Text.ToString(); lab_employeeID.Text = u.UserID.ToString(); lab_employeeName.Text = u.UserName.ToString(); lab_department.Text = u.DeptName.ToString(); lab_userRole.Text = u.Role.ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["sign"].ToString() == "") { Response.Redirect("~/LoginNew.aspx"); } Send.Enabled = true; Model1 ctx = new Model1(); string a = Session["sign"].ToString(); List <User> users = DepartmentBusinessLogic.ListUserByName(a); int count = ctx.Users.Count(); User[] user = new User[count]; user = ctx.Users.ToArray(); User u = ctx.Users.Where(x => x.UserName == a).First(); to.Text = u.Email; subject.Text = (string)Session["Title"]; body.Text = (string)Session["content"]; Session["Count"] = 0; System.DateTime currentTime = new System.DateTime(); currentTime = System.DateTime.Now; int year = currentTime.Year; int month = currentTime.Month; int day = currentTime.Day; int hour = currentTime.Hour; int minute = currentTime.Minute; if (year == 2018 && month == 7 && day == 19 && hour == 23 && minute == 51) { autoEmailInfo(); } }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { Button2.Enabled = true; ReID = Convert.ToInt32(Label2.Text); DepartmentBusinessLogic.DeleteItem(ReID, itemcode); BindGrid(ReID); Model1 ctx = new Model1(); List <RequestDetail> list = new List <RequestDetail>(); list = ctx.RequestDetails.Where(x => x.RequestID == ReID).ToList(); if (list.Count() == 0) { Button2.Enabled = false; } }
protected void delegate_Click(object sender, EventArgs e) { Model1 ctx = new Model1(); DateTime startDate = Calendar2.SelectedDate; DateTime endDate = Calendar3.SelectedDate; string employeename = DropDownList1.SelectedValue; User d = ctx.Users.Where(x => x.UserName == employeename).First();; id = d.UserID; string deptcode = d.DeptCode; if (deptcode == "ENGL") { deleid = 1; } else if (deptcode == "CPSC") { deleid = 2; } else if (deptcode == "COMM") { deleid = 3; } else if (deptcode == "REGR") { deleid = 4; } else if (deptcode == "ZOOL") { deleid = 5; } revoke.Enabled = true; DepartmentBusinessLogic.ChangeDelegate(id, employeename, "DeptDelegate"); DepartmentBusinessLogic.changeDelegatefromdelegate(deleid, id, employeename, startDate, endDate); Lab_successful.Text = "successful"; Session["Title"] = " DelegateAuthority Notification"; Session["content"] = Session["sign"].ToString() + " has gaved you DelegateAuthority"; string a = Session["sign"].ToString(); User c = ctx.Users.Where(x => x.UserName == a).First(); string Sender = c.Email; string[] receive = new string[] { d.Email.ToString() }; string Password = "******"; Label1.Text = SendEmail.sendEmail(Sender, Password, Session["Title"].ToString(), Session["content"].ToString(), receive); Session["Title"] = ""; Session["content"] = ""; }
protected void Button1_Click1(object sender, EventArgs e) { Model1 ctx = new Model1(); string a = Session["sign"].ToString(); List <User> users = DepartmentBusinessLogic.ListUserByName(a); int count = ctx.Users.Count(); User[] user = new User[count]; user = ctx.Users.ToArray(); User u = ctx.Users.Where(x => x.UserName == a).First(); int num = (int)u.EmailNum; Label2.Text = num.ToString(); u.EmailNum = 0; ctx.SaveChanges(); }
protected void app_Click(object sender, EventArgs e) { Request r = ctx.Requests.Where(x => x.RequestID == requestid).First(); int requestID = r.RequestID; string status = "approve"; string comments = txb_comments.Text; DepartmentBusinessLogic.ChangeRequestAsReject(requestID, status, comments); Lab_approve.Text = "successful"; Session["Title"] = "Request application Notification"; Session["content"] = "Requester's Department:" + r.DeptName.ToString() + "\n"; Session["content"] = Session["content"].ToString() + "ItemCode" + "\t" + "Description" + "\t" + "RequestQty" + "\n"; List <RequestDetail> list = new List <RequestDetail>(); list = DepartmentBusinessLogic.GetRequestDetailsByID(Convert.ToInt32(id)); foreach (RequestDetail red in list) { Session["content"] = Session["content"].ToString() + red.ItemCode.ToString() + "\t\t" + red.Description.ToString() + "\t" + red.RequestQty.ToString() + "\n"; } string a = Session["sign"].ToString(); User c = ctx.Users.Where(x => x.UserName == a).First(); string Sender = c.Email; User d = ctx.Users.Where(x => x.UserName == r.UserName).First(); string[] receive = new string[] { "*****@*****.**" }; string Password = "******"; Label1.Text = SendEmail.sendEmail(Sender, Password, Session["Title"].ToString(), Session["content"].ToString(), receive); Session["Title"] = ""; Session["content"] = ""; Session["Title"] = "Request approve Notification"; if (txb_comments.Text.ToString() == "" || txb_comments.Text.ToString() == null) { Session["content"] = Session["sign"].ToString() + " has reject your request which ID is" + requestid.ToString(); } else { Session["content"] = Session["sign"].ToString() + " has reject your request which ID is" + requestid.ToString() + ",comment is" + txb_comments.Text.ToString(); } User g = ctx.Users.Where(x => x.UserName == r.UserName).First(); string[] receive1 = new string[] { g.Email.ToString() }; Label1.Text = SendEmail.sendEmail(Sender, Password, Session["Title"].ToString(), Session["content"].ToString(), receive1); Session["Title"] = ""; Session["content"] = ""; }
protected void Page_Load(object sender, EventArgs e) { if (Session["sign"].ToString() == "") { Response.Redirect("~/LoginNew.aspx"); } Boolean results = empauthentication.HeadandrepAuthentication(Session["sign"].ToString()); if (results == false) { Response.Redirect("~/LoginNew.aspx"); } id = Session["requestid"].ToString(); requestid = Convert.ToInt32(id); RequestDetail rd = ctx.RequestDetails.Where(x => x.RequestID == requestid).First(); Request r = ctx.Requests.Where(x => x.RequestID == requestid).First(); lab_reqID.Text = rd.RequestID.ToString(); lab_empName.Text = r.UserName; GridView1.DataSource = DepartmentBusinessLogic.GetRequestDetailsByID(requestid); GridView1.DataBind(); }
protected void changecc_Click(object sender, EventArgs e) { Model1 ctx = new Model1(); Department d = ctx.Departments.Where(x => x.DeptName == lab_dept.Text).First(); string deptCode = d.DeptCode; if (radio1.Checked == true) { DepartmentBusinessLogic.ChangeCollectionPoint(deptCode, lab_dept.Text, radio1.Text); Lab_successful.Text = "successful"; } else if (radio2.Checked == true) { DepartmentBusinessLogic.ChangeCollectionPoint(deptCode, lab_dept.Text, radio2.Text); Lab_successful.Text = "successful"; } else if (radio3.Checked == true) { DepartmentBusinessLogic.ChangeCollectionPoint(deptCode, lab_dept.Text, radio3.Text); Lab_successful.Text = "successful"; } else if (radio4.Checked == true) { DepartmentBusinessLogic.ChangeCollectionPoint(deptCode, lab_dept.Text, radio4.Text); Lab_successful.Text = "successful"; } else if (radio5.Checked == true) { DepartmentBusinessLogic.ChangeCollectionPoint(deptCode, lab_dept.Text, radio5.Text); Lab_successful.Text = "successful"; } else if (radio6.Checked == true) { DepartmentBusinessLogic.ChangeCollectionPoint(deptCode, lab_dept.Text, radio6.Text); Lab_successful.Text = "successful"; } btn_Send.Enabled = true; }
protected void revoke_Click(object sender, EventArgs e) { try { int id = (int)Session["id"]; DepartmentBusinessLogic.ChangeDelegate(id, delegatename, "DeptEmp"); string a = Session["sign"].ToString(); Session["Title"] = "Revoke Delegate Notification"; Session["content"] = Session["sign"].ToString() + " has revoked your DelegateAuthority"; User c = ctx.Users.Where(x => x.UserName == a).First(); string Sender = c.Email; User d = ctx.Users.Where(x => x.UserName == delegatename).First(); string[] receive = new string[] { d.Email }; string Password = "******"; Label1.Text = SendEmail.sendEmail(Sender, Password, Session["Title"].ToString(), Session["content"].ToString(), receive); Session["Title"] = ""; Session["content"] = ""; } catch (Exception ex) { Lab_successful.Text = "This department doesn't have Delegate now"; } }
protected void change_Click(object sender, EventArgs e) { Model1 ctx = new Model1(); //string changednamed = "Tien Lor"; string changednamed = Session["changedName"].ToString(); //Session["changedName"] = changednamed; // lab_record.Text = dr_NewRep.SelectedValue; User d = ctx.Users.Where(x => x.UserName == changednamed).First(); changeid = d.UserID; int beforeid = (int)Session["beforeid"]; string beforename = Session["username"].ToString(); DepartmentBusinessLogic.ChangeRepresentative(beforeid, beforename, "DeptEmp"); DepartmentBusinessLogic.ChangeRepresentative(changeid, changednamed, "DeptRepre"); Lab_successful.Text = "successful"; btn_Send.Enabled = true; }
private void BindGrid(int ReID) { GridView1.DataSource = DepartmentBusinessLogic.ListREBy(ReID); GridView1.DataBind(); }
protected void Button2_Click(object sender, EventArgs e) { DropDownList1.DataSource = DepartmentBusinessLogic.ListUserByDeptName(dept); DropDownList1.DataBind(); }