private void LoadBasicData(int serviceId)
        {
            ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
            if (serviceInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load service basic data
                tbxServiceState.Text = serviceInformationBasicInformationGateway.GetServiceState(serviceId);
                tbxServiceNumber.Text = serviceInformationBasicInformationGateway.GetServiceNumber(serviceId);
                tbxDateTime.Text = serviceInformationBasicInformationGateway.GetDateTime_(serviceId).ToString();
                ckbxMtoDto.Checked = serviceInformationBasicInformationGateway.GetMtoDto(serviceId);
                tbxServiceDescription.Text = serviceInformationBasicInformationGateway.GetServiceDescription(serviceId);

                // Load unit basic data
                tbxUnitCode.Text = serviceInformationBasicInformationGateway.GetUnitCode(serviceId);
                tbxUnitDescription.Text = serviceInformationBasicInformationGateway.GetUnitDescription(serviceId);
                tbxVinSn.Text = serviceInformationBasicInformationGateway.GetVinSn(serviceId);
                tbxUnitState.Text = serviceInformationBasicInformationGateway.GetUnitState(serviceId);

                // Load checklist data
                tbxAssociatedChecklistRule.Text = serviceInformationBasicInformationGateway.GetAssociatedChecklistRule(serviceId);
                tbxChecklistState.Text = serviceInformationBasicInformationGateway.GetAssociatedChecklistRuleState(serviceId);

                if (serviceInformationBasicInformationGateway.GetRuleId(serviceId).HasValue)
                {
                    RuleGateway ruleGateway = new RuleGateway();
                    int? ruleId = serviceInformationBasicInformationGateway.GetRuleId(serviceId);
                    ruleGateway.LoadAllByRuleId(ruleId.Value, Int32.Parse(hdfCompanyId.Value));
                    int? serviceRequestDays = ruleGateway.GetServiceRequestDays(ruleId.Value);

                    if (ruleGateway.GetMto(ruleId.Value) && serviceInformationBasicInformationGateway.GetAssociatedChecklistLastService(serviceId).HasValue)
                    {
                        tbxChecklistNextDueDate.Text = serviceInformationBasicInformationGateway.GetAssociatedChecklistLastService(serviceId).Value.ToShortDateString();
                    }
                    else
                    {
                        if (serviceRequestDays.HasValue)
                        {
                            int negValue = -1;
                            serviceRequestDays = serviceRequestDays.Value * negValue;
                            DateTime serviceRequestCreationDate = serviceInformationBasicInformationGateway.GetDateTime_(serviceId);
                            tbxChecklistNextDueDate.Text = serviceInformationBasicInformationGateway.GetAssociatedChecklistNextDue(serviceId).Value.AddDays(Convert.ToDouble(serviceRequestDays.Value)).ToShortDateString();
                        }
                    }
                }
            }
        }
        private void SendMailFleetManagerAcceptRejectCompleted(string subject, string title)
        {
            // Get mail information
            string mailTo = "";
            string nameTo = "";
            string body = "";
            int serviceId = Int32.Parse(hdfServiceId.Value);
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int companyLevel = Int32.Parse(hdfCompanyLevel.Value);

            // MailtTo, nameTo
            int companyLevelId = Int32.Parse(hdfCompanyLevel.Value);

            Employee employees = new Employee();
            employees.LoadByFleetManager(companyLevelId);

            mailTo = employees.GetAllFleetManagersEMails();
            nameTo = employees.GetAllFleetManagersNames();

            ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
            serviceInformationBasicInformationGateway.LoadByServiceId(serviceId, companyId);

            // Mails body
            body = body + "\nHi " + nameTo + ",\n\n" + title + " \n";
            body = body + "\n Service: " + serviceInformationBasicInformationGateway.GetServiceNumber(serviceId) + " - " + serviceInformationBasicInformationGateway.GetServiceDescription(serviceId);
            body = body + "\n Unit: " + serviceInformationBasicInformationGateway.GetUnitCode(serviceId) + " - " + serviceInformationBasicInformationGateway.GetUnitDescription(serviceId);
            body = body + "\n Fixed Date: ";
            if (serviceInformationBasicInformationGateway.GetMtoDto(serviceId)) body = body + "Yes "; else body = body + "No ";

            string unitType = hdfUnitType.Value;
            if (unitType == "Vehicle")
            {
                body = body + "\n Mileage: " + serviceInformationBasicInformationGateway.GetMileage(serviceId) + " " + hdfMileageUnitOfMeasurement.Value;
            }

            body = body + "\n Problem Description: " + serviceInformationBasicInformationGateway.GetServiceDescription(serviceId);

            if (serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId).HasValue)
            {
                DateTime deadlineDate = (DateTime)serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId);
                string deadlineDateText = deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString();
                body = body + "\n Deadline Date: " + deadlineDateText;
            }

            // Asignation
            if (serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId).HasValue)
            {
                int employeeId = (int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId);
                EmployeeGateway employeesGateway = new EmployeeGateway();
                employeesGateway.LoadByEmployeeId(employeeId);

                string assignedTo = "";
                if (employeesGateway.Table.Rows.Count > 0)
                {
                    // Assigned TeamMember
                    assignedTo = employeesGateway.GetFirstName(employeeId) + " " + employeesGateway.GetLastName(employeeId);
                }

                body = body + "\n Assigned Team Member: " + assignedTo;
            }

            // ... Start work information
            if (serviceInformationBasicInformationGateway.GetStartWorkDateTime(serviceId).HasValue)
            {
                DateTime startWorkDate = (DateTime)serviceInformationBasicInformationGateway.GetStartWorkDateTime(serviceId);
                body = body + "\n Start Work Date & Time: " + startWorkDate;
            }

            // ... Complete work information
            if (serviceInformationBasicInformationGateway.GetCompleteWorkDateTime(serviceId).HasValue)
            {
                DateTime completeWorkDate = (DateTime)serviceInformationBasicInformationGateway.GetCompleteWorkDateTime(serviceId);
                body = body + "\n Complete Work Date & Time: " + completeWorkDate;
            }

            //Send Mail
            SendMail(mailTo, subject, body);
        }
        private void SendMailTeamMember()
        {
            // Get mail information
            string mailTo = "";
            string nameTo = "";
            string subject = "You have assigned service requests.";
            string body = "";

            int employeeId = Int32.Parse(ddlPnlAssignAssignToTeamMember.SelectedValue);
            EmployeeGateway employeesGateway = new EmployeeGateway();
            employeesGateway.LoadForMailsByEmployeeId(employeeId);

            if (employeesGateway.Table.Rows.Count > 0)
            {
                // Assigned TeamMember
                mailTo = employeesGateway.GetEMail(employeeId);
                nameTo = employeesGateway.GetFirstName(employeeId) + " " + employeesGateway.GetLastName(employeeId);
            }

            int serviceId = Int32.Parse(hdfServiceId.Value);
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int companyLevel = Int32.Parse(hdfCompanyLevel.Value);

            ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
            serviceInformationBasicInformationGateway.LoadByServiceId(serviceId, companyId);

            // Mails body
            body = body + "\nHi " + nameTo + ",\n\nThe following service request has been assigned to you. \n";
            body = body + "\n Unit: " + serviceInformationBasicInformationGateway.GetUnitCode(serviceId) + " - " + serviceInformationBasicInformationGateway.GetUnitDescription(serviceId) + "\n";
            body = body + "\n Fixed Date: ";
            if (serviceInformationBasicInformationGateway.GetMtoDto(serviceId)) body = body + "Yes "; else body = body + "No ";

            string unitType = hdfUnitType.Value;
            if (unitType == "Vehicle")
            {
                body = body + "\n Mileage: " + serviceInformationBasicInformationGateway.GetMileage(serviceId) + " " + hdfMileageUnitOfMeasurement.Value;
            }

            body = body + "\n Problem Description: " + serviceInformationBasicInformationGateway.GetServiceDescription(serviceId);

            if (tkrdpPnlAssignDeadlineDate.SelectedDate.HasValue)
            {
                DateTime deadlineDate = tkrdpPnlAssignDeadlineDate.SelectedDate.Value;
                string deadlineDateText = deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString();
                body = body + " \n Deadline date: " + deadlineDateText;
            }
            else
            {
                body = body + " \n Deadline date: ";
            }

            int registeredByLoginId = Convert.ToInt32(Session["loginID"]);
            employeesGateway.LoadByLoginId(registeredByLoginId);
            int registeredByEmployeeId = employeesGateway.GetEmployeIdByLoginId(registeredByLoginId);
            if (employeesGateway.Table.Rows.Count > 0)
            {
                body = body + "\n Assigned By: " + employeesGateway.GetFirstName(registeredByEmployeeId) + " " + employeesGateway.GetLastName(registeredByEmployeeId);
            }

            //Send Mail
            SendMail(mailTo, subject, body);
        }
        private void SendMailFleetManager( string subject, string title)
        {
            // Get mail information
            string mailTo = "";
            string nameTo = "";
            string body = "";
            int serviceId = Int32.Parse(hdfServiceId.Value);
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int companyLevel = Int32.Parse(hdfCompanyLevel.Value);

            // MailtTo, nameTo
            int companyLevelId = Int32.Parse(hdfCompanyLevel.Value);

            Employee employees = new Employee();
            employees.LoadByFleetManager(companyLevelId);

            mailTo = employees.GetAllFleetManagersEMails();
            nameTo = employees.GetAllFleetManagersNames();

            ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
            serviceInformationBasicInformationGateway.LoadByServiceId(serviceId, companyId);

            // Mails body
            body = body + "\nHi " + nameTo + ",\n\n"+ title + " \n";
            body = body + "\n Unit: " + serviceInformationBasicInformationGateway.GetUnitCode(serviceId) + " - " + serviceInformationBasicInformationGateway.GetUnitDescription(serviceId);
            body = body + "\n Fixed Date: ";
            if (serviceInformationBasicInformationGateway.GetMtoDto(serviceId)) body = body + "Yes "; else body = body + "No ";

            string unitType = hdfUnitType.Value;
            if (unitType == "Vehicle")
            {
                body = body + "\n Mileage: " + serviceInformationBasicInformationGateway.GetMileage(serviceId) + " " + hdfMileageUnitOfMeasurement.Value;
            }

            body = body + "\n Problem Description: " + serviceInformationBasicInformationGateway.GetServiceDescription(serviceId);

            if (tkrdpPnlAssignDeadlineDate.SelectedDate.HasValue)
            {
                DateTime deadlineDate = tkrdpPnlAssignDeadlineDate.SelectedDate.Value;
                string deadlineDateText = deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString();
                body = body + " \n Deadline date: " + deadlineDateText;
            }
            else
            {
                body = body + " \n Deadline date: ";
            }

            if(rbtnPnlAssignToTeamMember.Checked)
            {
                int employeeId = Int32.Parse(ddlPnlAssignAssignToTeamMember.SelectedValue);
                EmployeeGateway employeesGateway = new EmployeeGateway();
                employeesGateway.LoadForMailsByEmployeeId(employeeId);
                string assignedTo = "";
                if (employeesGateway.Table.Rows.Count > 0)
                {
                    // Assigned TeamMember
                    assignedTo = employeesGateway.GetFirstName(employeeId) + " " + employeesGateway.GetLastName(employeeId);
                }

                body = body + "\n Assigned Team Member: " + assignedTo;
            }

            if (rbtnPnlAssignToThirdPartyVendor.Checked)
            {
                body = body + "\n Assigned Third Party Vendor: " + tbxPnlAssignAssignToThirdPartyVendor.Text;
            }

            //Send Mail
            SendMail(mailTo, subject, body);
        }