/// <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);
            }
        }
        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);
     }
 }
        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);
        }