private void loadInfoPreview() { AB = new AccountBusiness(); account = AB.GetAccount(Page.User.Identity.Name); EB = new EmployeeBusiness(); employee = EB.GetEmployee(account.Employee_Id); DB = new DepartmentBusiness(); department = DB.GetDepartment(employee.Department_Id); imgAvatar.ImageUrl = WebHelper.Instance.GetImageURL(employee.Employee_Avatar, 128, 128, false); imgAvatar.PostBackUrl = WebHelper.Instance.GetURL() + "Account"; lblUserName.Text = account.Account_UserName; lblRole.Text = account.Role_Name; lblFirstName.Text = employee.Employee_FirtName; lblLastName.Text = employee.Employee_LastName; lblEmail.Text = employee.Employee_Email; lblAddress.Text = employee.Employee_Address; lblPhoneNumber.Text = employee.Employee_PhoneNumber; if (employee.Employee_DateOfBirth.ToShortDateString().Equals("1/1/1900")) lblDOB.Text = ""; else lblDOB.Text = employee.Employee_DateOfBirth.ToShortDateString(); if (employee.Employee_Gender) lblGender.Text = "Male"; else lblGender.Text = "Female"; hplnkModifyProfile.NavigateUrl = WebHelper.Instance.GetURL() + "Account"; lblDepartmentName.Text = department.Department_Name; lblDescription.Text = department.Department_Description; }
/// <summary> /// Remove an employee to trash. /// </summary> /// <param name="employeeId">Id of the employee that you want to remove.</param> public void RemoveEmployee(Guid employeeId) { try { Employee employee = GetEmployee(employeeId); //Remove account first. AccountBusiness AB = new AccountBusiness(); Account account = AB.GetAccountOfEmployee(employeeId); if (account != null) { AB.RemoveAccount(account.Account_Id); } employee.Employee_IsDelete = true; int result = ED.UpdateEmployee(employee); if (result == -1) { throw new Exception("An error occurred while executing this operation."); } } catch (NullReferenceException ex) { throw new Exception(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { String userName = this.Page.User.Identity.Name; if (userName.Equals("")) //Response.Redirect(Server.HtmlEncode(Request.PhysicalApplicationPath) + "Login"); { Response.Redirect(WebHelper.Instance.GetURL() + "Login"); } else { AccountBusiness AB = new AccountBusiness(); String role = AB.GetRole(userName); Control myUserControl = new Control(); plcMenu.Controls.Clear(); if (role != null) { if (role.Equals("Administrator")) { myUserControl = (Control)Page.LoadControl("~/Controls/AdminControl.ascx"); } else if (role.Equals("HR Manager")) { myUserControl = (Control)Page.LoadControl("~/Controls/HRManagerControl.ascx"); } else if (role.Equals("Service Manager")) { myUserControl = (Control)Page.LoadControl("~/Controls/ServiceManagerControl.ascx"); } else if (role.Equals("Service Employee")) { myUserControl = (Control)Page.LoadControl("~/Controls/ServiceEmployeeControl.ascx"); } else if (role.Equals("Employee")) { myUserControl = (Control)Page.LoadControl("~/Controls/EmployeeControl.ascx"); } else { return; } plcMenu.Controls.Add(myUserControl); } } }
protected void Page_Load(object sender, EventArgs e) { pnlRed.Visible = false; pnlGreen.Visible = false; pnlYellow.Visible = false; pnlBlue.Visible = false; EB = new EmployeeBusiness(); AB = new AccountBusiness(); GetRouteData(); if (!IsPostBack) loadData(); else { String script = WebHelper.Instance.GetJqueryScript("App_Themes/js/jquery/custom_jquery.js"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "MessageWarning", script, true); } }
private void FillDataToOrder(Order order, OrderOfService orderService) { order.OrderOfService_Id = orderService.OrderOfService_Id; order.Company_Id = orderService.Company_Id; order.Employee_Id = orderService.Employee_Id; order.OrderOfService_BillDate = orderService.OrderOfService_BillDate.ToShortDateString(); order.OrderOfService_Description = orderService.OrderOfService_Description; order.OrderOfService_IsDelete = orderService.OrderOfService_IsDelete; order.OrderOfService_PaymentDate = orderService.OrderOfService_PaymentDate.ToShortDateString(); order.OrderOfService_PaymentMethod = orderService.OrderOfService_PaymentMethod; switch (orderService.OrderOfService_Status) { case 0: order.OrderOfService_Status = "Pending"; break; case 99: order.OrderOfService_Status = "In Progress"; break; case 1: order.OrderOfService_Status = "Resolved"; break; default: break; } CompanyBLL CB = new CompanyBLL(); DataRow company = CB.Company_ShowOnewDisplay(orderService.Company_Id.ToString()); order.Company_Name = company["Company_Name"].ToString(); AccountBusiness AB = new AccountBusiness(); Account account = AB.GetAccountOfEmployee(orderService.Employee_Id); order.Account_UserName = account.Account_UserName; CalculateServicesAndCharges(order, order.OrderOfService_IsDelete); }
/// <summary> /// Delete permanently an employee. /// </summary> /// <param name="emId">Id of the employee that you want to delete.</param> public void DeleteEmployee(Guid emId) { try { Employee employee = ED.GetEmployee(emId); // Check related datas OrderBusiness OB = new OrderBusiness(); List <Order> list = OB.GetOrdersByEmployeeId(emId, false); if (list.Count == 0) { // Delete account of this employee first. AccountBusiness AB = new AccountBusiness(); Account account = AB.GetAccountOfEmployee(emId); if (account != null) { AB.DeleteAccount(account.Account_Id); } // Then delete orders of this employee foreach (Order item in list) { OB.DeleteOrder(item.OrderOfService_Id); } int result = ED.DeleteEmployee(employee); if (result == -1) { throw new Exception("An error occurred while executing this operation."); } } else { throw new Exception("This employee's data is also related to some other data. It could be not deleted."); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Delete permanently an employee. /// </summary> /// <param name="emId">Id of the employee that you want to delete.</param> public void DeleteEmployee(Guid emId) { try { Employee employee = ED.GetEmployee(emId); // Check related datas OrderBusiness OB = new OrderBusiness(); List<Order> list = OB.GetOrdersByEmployeeId(emId, false); if (list.Count == 0) { // Delete account of this employee first. AccountBusiness AB = new AccountBusiness(); Account account = AB.GetAccountOfEmployee(emId); if (account != null) AB.DeleteAccount(account.Account_Id); // Then delete orders of this employee foreach (Order item in list) { OB.DeleteOrder(item.OrderOfService_Id); } int result = ED.DeleteEmployee(employee); if (result == -1) { throw new Exception("An error occurred while executing this operation."); } } else { throw new Exception("This employee's data is also related to some other data. It could be not deleted."); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// Restore an employee from trash. /// </summary> /// <param name="employeeId">Id of the employee that you want to restore.</param> public void RestoreEmployee(Guid employeeId) { try { Employee employee = GetEmployee(employeeId); employee.Employee_IsDelete = false; int result = ED.UpdateEmployee(employee); if (result == -1) { throw new Exception("An error occurred while executing this operation."); } //Then restore account. AccountBusiness AB = new AccountBusiness(); Account account = AB.GetAccountOfEmployee(employeeId); if (account != null) AB.RestoreAccount(account.Account_Id); } catch (NullReferenceException ex) { throw new Exception(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { pnlRed.Visible = false; pnlGreen.Visible = false; pnlYellow.Visible = false; pnlBlue.Visible = false; EB = new EmployeeBusiness(); DB = new DepartmentBusiness(); AB = new AccountBusiness(); GetRouteData(); loadData(); Search(); if (IsPostBack) { String script = WebHelper.Instance.GetJqueryScript("App_Themes/js/jquery/custom_jquery.js"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "MessageWarning", script, true); } else { ddlSearchBy.Items.Clear(); ddlSearchBy.Items.Add("All"); if (IsAdmin()) ddlSearchBy.Items.Add("Account"); ddlSearchBy.Items.Add("Employee"); ddlSearchBy.Items.Add("Department"); } }
private void FillDataToOrder(Order order, OrderOfService orderService) { order.OrderOfService_Id = orderService.OrderOfService_Id; order.Company_Id = orderService.Company_Id; order.Employee_Id = orderService.Employee_Id; order.OrderOfService_BillDate = orderService.OrderOfService_BillDate.ToShortDateString(); order.OrderOfService_Description = orderService.OrderOfService_Description; order.OrderOfService_IsDelete = orderService.OrderOfService_IsDelete; order.OrderOfService_PaymentDate = orderService.OrderOfService_PaymentDate.ToShortDateString(); order.OrderOfService_PaymentMethod = orderService.OrderOfService_PaymentMethod; switch (orderService.OrderOfService_Status) { case 0: order.OrderOfService_Status = "Pending"; break; case 99: order.OrderOfService_Status = "In Progress"; break; case 1: order.OrderOfService_Status = "Resolved"; break; default: break; } CompanyBLL CB = new CompanyBLL(); DataRow company = CB.Company_ShowOnewDisplay(orderService.Company_Id.ToString()); order.Company_Name = company["Company_Name"].ToString(); AccountBusiness AB = new AccountBusiness(); Account account = AB.GetAccountOfEmployee(orderService.Employee_Id); order.Account_UserName = account.Account_UserName; CalculateServicesAndCharges(order, order.OrderOfService_IsDelete); }
protected void Page_Load(object sender, EventArgs e) { pnlRed.Visible = false; pnlGreen.Visible = false; pnlYellow.Visible = false; pnlBlue.Visible = false; SB = new ServiceBusiness(); AB = new AccountBusiness(); EB = new EmployeeBusiness(); DB = new DepartmentBusiness(); CB = new CompanyBLL(); OB = new OrderBusiness(); GetRouteData(); cvBillDate.ValueToCompare = DateTime.Now.Date.ToShortDateString(); if (!IsPostBack) loadData(); else { String script = WebHelper.Instance.GetJqueryScript("App_Themes/js/jquery/custom_jquery.js"); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "MessageWarning", script, true); } }