private void CalculateServicesAndCharges(Order order, bool isDelete)
        {
            List <OrderOfServiceDetail> listOrderDetail = OD.GetOrderDetails(String.Format("OrderOfService_Id = '{0}' AND ", order.OrderOfService_Id.ToString()), isDelete);

            if (listOrderDetail.Count == 1)
            {
                order.Total_Service = "1 service";
            }
            else if (listOrderDetail.Count > 1)
            {
                order.Total_Service = listOrderDetail.Count.ToString() + " services";
            }

            double          totalPrice = 0;
            ServiceBusiness SB         = new ServiceBusiness();

            foreach (OrderOfServiceDetail item in listOrderDetail)
            {
                Service service  = SB.GetService(item.Service_Id);
                double  days     = (item.OrderOfServiceDetail_ToDate - item.OrderOfServiceDetail_FromDate).TotalDays;
                double  charge   = Double.Parse(SecurityHelper.Instance.DecryptCryptography(service.Service_Charge, true));
                int     employee = item.OrderOfServiceDetail_NumberOfEmployee;
                double  price    = days * charge * employee;

                totalPrice += price;
            }
            order.Total_Charge = totalPrice.ToString();
        }
        /// <summary>
        /// Get all details of 1 order by order's id.
        /// </summary>
        /// <param name="orderID">Id of the order.</param>
        /// <param name="isDelete">True if these details of oder is deleted, false otherwise.</param>
        /// <returns>A list object of order's detail type.</returns>
        public List <OrderDetail> GetOrderDetailsByOrderId(Guid orderID, bool isDelete)
        {
            try
            {
                String where = "OrderOfService_Id = '{0}' AND ";
                if (orderID != null)
                {
                    where = String.Format(where, orderID.ToString());
                }
                else
                {
                    where = "";
                }

                List <OrderOfServiceDetail> listDetail = OD.GetOrderDetails(where, isDelete);

                List <OrderDetail> list = new List <OrderDetail>();
                foreach (OrderOfServiceDetail item in listDetail)
                {
                    OrderDetail orderDetail = new OrderDetail();
                    orderDetail.OrderOfService_Id                     = item.OrderOfService_Id;
                    orderDetail.OrderOfServiceDetail_FromDate         = item.OrderOfServiceDetail_FromDate.ToShortDateString();
                    orderDetail.OrderOfServiceDetail_IsDelete         = item.OrderOfServiceDetail_IsDelete;
                    orderDetail.OrderOfServiceDetail_NumberOfEmployee = item.OrderOfServiceDetail_NumberOfEmployee;
                    orderDetail.OrderOfServiceDetail_ToDate           = item.OrderOfServiceDetail_ToDate.ToShortDateString();

                    ServiceBusiness SB      = new ServiceBusiness();
                    Service         service = SB.GetService(item.Service_Id);
                    orderDetail.Service_Charge      = service.Service_Charge;
                    orderDetail.Service_Description = service.Service_Description;
                    orderDetail.Service_Id          = service.Service_Id;
                    orderDetail.Service_Image       = service.Service_Image;
                    orderDetail.Service_IsDelete    = service.Service_IsDelete;
                    orderDetail.Service_Name        = service.Service_Name;

                    DateTime toDate   = DateTime.Parse(orderDetail.OrderOfServiceDetail_ToDate);
                    DateTime fromDate = DateTime.Parse(orderDetail.OrderOfServiceDetail_FromDate);
                    double   days     = (toDate - fromDate).TotalDays;
                    double   charge   = Double.Parse(SecurityHelper.Instance.DecryptCryptography(service.Service_Charge, true));
                    int      employee = orderDetail.OrderOfServiceDetail_NumberOfEmployee;
                    double   price    = days * charge * employee;

                    orderDetail.OrderOfServiceDetail_Price = price.ToString();

                    list.Add(orderDetail);
                }
                return(list);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private void CalculateServicesAndCharges(Order order, bool isDelete)
        {
            List<OrderOfServiceDetail> listOrderDetail = OD.GetOrderDetails(String.Format("OrderOfService_Id = '{0}' AND ", order.OrderOfService_Id.ToString()), isDelete);

            if (listOrderDetail.Count == 1)
                order.Total_Service = "1 service";
            else if (listOrderDetail.Count > 1)
                order.Total_Service = listOrderDetail.Count.ToString() + " services";

            double totalPrice = 0;
            ServiceBusiness SB = new ServiceBusiness();
            foreach (OrderOfServiceDetail item in listOrderDetail)
            {
                Service service = SB.GetService(item.Service_Id);
                double days = (item.OrderOfServiceDetail_ToDate - item.OrderOfServiceDetail_FromDate).TotalDays;
                double charge = Double.Parse(SecurityHelper.Instance.DecryptCryptography(service.Service_Charge, true));
                int employee = item.OrderOfServiceDetail_NumberOfEmployee;
                double price = days * charge * employee;

                totalPrice += price;
            }
            order.Total_Charge = totalPrice.ToString();
        }
        /// <summary>
        /// Get all details of 1 order by order's id.
        /// </summary>
        /// <param name="orderID">Id of the order.</param>
        /// <param name="isDelete">True if these details of oder is deleted, false otherwise.</param>
        /// <returns>A list object of order's detail type.</returns>
        public List<OrderDetail> GetOrderDetailsByOrderId(Guid orderID, bool isDelete)
        {
            try
            {
                String where = "OrderOfService_Id = '{0}' AND ";
                if (orderID != null)
                    where = String.Format(where, orderID.ToString());
                else
                    where = "";

                List<OrderOfServiceDetail> listDetail = OD.GetOrderDetails(where, isDelete);

                List<OrderDetail> list = new List<OrderDetail>();
                foreach (OrderOfServiceDetail item in listDetail)
                {
                    OrderDetail orderDetail = new OrderDetail();
                    orderDetail.OrderOfService_Id = item.OrderOfService_Id;
                    orderDetail.OrderOfServiceDetail_FromDate = item.OrderOfServiceDetail_FromDate.ToShortDateString();
                    orderDetail.OrderOfServiceDetail_IsDelete = item.OrderOfServiceDetail_IsDelete;
                    orderDetail.OrderOfServiceDetail_NumberOfEmployee = item.OrderOfServiceDetail_NumberOfEmployee;
                    orderDetail.OrderOfServiceDetail_ToDate = item.OrderOfServiceDetail_ToDate.ToShortDateString();

                    ServiceBusiness SB = new ServiceBusiness();
                    Service service = SB.GetService(item.Service_Id);
                    orderDetail.Service_Charge = service.Service_Charge;
                    orderDetail.Service_Description = service.Service_Description;
                    orderDetail.Service_Id = service.Service_Id;
                    orderDetail.Service_Image = service.Service_Image;
                    orderDetail.Service_IsDelete = service.Service_IsDelete;
                    orderDetail.Service_Name = service.Service_Name;

                    DateTime toDate = DateTime.Parse(orderDetail.OrderOfServiceDetail_ToDate);
                    DateTime fromDate = DateTime.Parse(orderDetail.OrderOfServiceDetail_FromDate);
                    double days = (toDate - fromDate).TotalDays;
                    double charge = Double.Parse(SecurityHelper.Instance.DecryptCryptography(service.Service_Charge, true));
                    int employee = orderDetail.OrderOfServiceDetail_NumberOfEmployee;
                    double price = days * charge * employee;

                    orderDetail.OrderOfServiceDetail_Price = price.ToString();

                    list.Add(orderDetail);
                }
                return list;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }