protected void Button1_Click(object sender, EventArgs e) { //try //{ if (Page.IsValid) { int ecode; string startdate, enddate; DateTime from, to; startdate = TextBox1.Text; enddate = TextBox2.Text; from = Convert.ToDateTime(startdate); to = Convert.ToDateTime(enddate); ecode = Convert.ToInt32(DropDownList1.SelectedValue); d.delegateAuthority(headcode, ecode, from, to); if (from.CompareTo(DateTime.Now) <= 0) { d.executeDelegation(); FormsAuthentication.SignOut(); FormsAuthentication.RedirectToLoginPage(); } else { MessageBox1.Show(this.Page, "Delegation completed. This delegation will trigger on " + startdate); } } //} //catch (Exception ex) //{ // MessageBox1.Show(this.Page, "delegation failed. try again"); // System.Diagnostics.Debug.WriteLine(ex); //} }
protected void Login1_LoggedIn(object sender, EventArgs e) { AdminserviceManager am = new AdminserviceManager(); DHserviceManager dm = new DHserviceManager(); string userRole = Roles.GetRolesForUser(Login1.UserName)[0]; Department dept = am.FindEmployeebyID(Convert.ToInt32(Login1.UserName)).Department; if (dept.delegatecode.HasValue && dept.startdate.HasValue && dept.enddate.HasValue) { if (((DateTime)dept.startdate).CompareTo(DateTime.Now) <= 0) { if (((DateTime)dept.enddate).CompareTo(DateTime.Now) >= 0) { dm.executeDelegation(); } else { dm.retrieveAuthority(dept.Employees.Where(x => x.role == "departmenthead" || x.role == "delegatedhead").First().employeecode); } } } switch (userRole) { case "departmentemployee": case "departmentrepresentative": Response.Redirect("~/Department/DErequestItem.aspx"); break; case "departmenthead": case "delegatedemployee": Response.Redirect("~/Department/DHapproveReject.aspx"); break; case "delegatedhead": Response.Redirect("~/Department/DHRetriveAuthority.aspx"); break; case "storeclerk": Response.Redirect("~/Store/retrieveStockCard.aspx"); break; case "storesupervisor": case "storemanager": Response.Redirect("~/Store/SSapproveRejectOrder.aspx"); break; default: FormsAuthentication.SignOut(); FormsAuthentication.RedirectToLoginPage(); break; } }