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>
        /// Delete permanently a department.
        /// </summary>
        /// <param name="departmentId">Id of the department that you want to delete.</param>
        public void DeleteDepartment(Guid departmentId)
        {
            try
            {
                if (GetNumberOfEmployees(departmentId, false) == 0)
                {
                    EmployeeBusiness EB = new EmployeeBusiness();
                    List<Employee> listEmployee = EB.GetEmployees(departmentId, true);
                    if (listEmployee.Count > 0)
                    {
                        foreach (Employee item in listEmployee)
                        {
                            EB.DeleteEmployee(item.Employee_Id);
                        }
                    }

                    Department department = DD.GetDepartment(departmentId);
                    int result = DD.DeleteDepartment(department);
                    if (result == -1)
                    {
                        throw new Exception("An error occurred while executing this operation.");
                    }
                }
                else
                {
                    throw new Exception(String.Format("Remaining {0} employees in this department. You could not delete it.", GetNumberOfEmployees(departmentId,false)));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// Delete permanently a department.
        /// </summary>
        /// <param name="departmentId">Id of the department that you want to delete.</param>
        public void DeleteDepartment(Guid departmentId)
        {
            try
            {
                if (GetNumberOfEmployees(departmentId, false) == 0)
                {
                    EmployeeBusiness EB           = new EmployeeBusiness();
                    List <Employee>  listEmployee = EB.GetEmployees(departmentId, true);
                    if (listEmployee.Count > 0)
                    {
                        foreach (Employee item in listEmployee)
                        {
                            EB.DeleteEmployee(item.Employee_Id);
                        }
                    }

                    Department department = DD.GetDepartment(departmentId);
                    int        result     = DD.DeleteDepartment(department);
                    if (result == -1)
                    {
                        throw new Exception("An error occurred while executing this operation.");
                    }
                }
                else
                {
                    throw new Exception(String.Format("Remaining {0} employees in this department. You could not delete it.", GetNumberOfEmployees(departmentId, false)));
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// Get number of employees in department.
        /// </summary>
        /// <param name="departmentId">Id of the department.</param>
        /// <param name="isDelete">True if list of employee is deleted, false otherwise.</param>
        /// <returns>Number of employees.</returns>
        public int GetNumberOfEmployees(Guid departmentId, bool isDelete)
        {
            EmployeeBusiness EB           = new EmployeeBusiness();
            List <Employee>  listEmployee = EB.GetEmployees(departmentId, isDelete);

            return(listEmployee.Count);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        OB = new OrderBusiness();
        EB = new EmployeeBusiness();
        CB = new CompanyBLL();

        loadData();
        String script = WebHelper.Instance.GetJqueryScript("App_Themes/js/jquery/custom_jquery.js");
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "MessageWarning", script, true);
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            try
            {
                EmployeeBusiness EB = new EmployeeBusiness();

                if (EB.IsExist(txtEmail.Text.Trim()))
                {
                    pnlRed.Visible = true;
                    lblError.Text = "This email have already used.";
                    hplnkRed.Text = "Please try again.";
                    hplnkRed.NavigateUrl = "";
                    return;
                }

                String filePath = "";
                System.Drawing.Image image;
                if (fuAvatar.HasFile)
                {
                    image = System.Drawing.Image.FromStream(fuAvatar.PostedFile.InputStream);
                }
                else
                {
                    if (radListGender.Text.Equals("Male"))
                        filePath = WebHelper.Instance.GetWebsitePath() + "App_Themes/images/other/male.png";
                    else if (radListGender.Text.Equals("Female"))
                        filePath = WebHelper.Instance.GetWebsitePath() + "App_Themes/images/other/female.png";

                    image = System.Drawing.Image.FromFile(filePath);
                }

                String data = WebHelper.Instance.ImageToBase64(image, System.Drawing.Imaging.ImageFormat.Png);
                EB.CreateEmployee(Guid.NewGuid(), new Guid(ddlDepartment.SelectedValue), txtFirstName.Text.Trim(), txtLastName.Text.Trim(), radListGender.Text, txtDOB.Text.Trim(), txtAddress.Text.Trim(), txtPhoneNumber.Text.Trim(), txtEmail.Text.Trim(), data);

                pnlGreen.Visible = true;
                lblSuccess.Text = "Create new an employee successfully.";
                hplnkGreen.Text = "Go to Manage panel.";
                hplnkGreen.NavigateUrl = WebHelper.Instance.GetURL() + "ManageSystem/Employee/Manage";
                Reset();
            }
            catch (Exception ex)
            {
                pnlRed.Visible = true;
                lblError.Text = ex.Message;
                hplnkRed.Text = "Please try again.";
                hplnkRed.NavigateUrl = "";
            }

        }
    }
    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);
        }
    }
 /// <summary>
 /// Get number of employees in department.
 /// </summary>
 /// <param name="departmentId">Id of the department.</param>
 /// <param name="isDelete">True if list of employee is deleted, false otherwise.</param>
 /// <returns>Number of employees.</returns>
 public int GetNumberOfEmployees(Guid departmentId, bool isDelete)
 {
     EmployeeBusiness EB = new EmployeeBusiness();
     List<Employee> listEmployee = EB.GetEmployees(departmentId, isDelete);
     return listEmployee.Count;
 }
    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");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        pnlRed.Visible = false;
        pnlGreen.Visible = false;
        pnlYellow.Visible = false;
        pnlBlue.Visible = false;
        CompareValidator1.ValueToCompare = DateTime.Now.Date.ToShortDateString();
        EB = new EmployeeBusiness();
        DB = new DepartmentBusiness();

        if (!IsPostBack)
        {
            loadData();
        }
        String script = WebHelper.Instance.GetJqueryScript("App_Themes/js/jquery/custom_jquery.js");
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "MessageWarning", script, true);
    }
    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);
        }
    }