public void SendMailTeamMember()
        {
            // Get mail information
            string mailTo = "";
            string nameTo = "";
            string subject = "This proposal is promoted to project.";
            string body = "";

            foreach (ListItem lst in cbxlEmployee.Items)
            {
                int employeeId = int.Parse(lst.Value);

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

            // Mails body
            body = body + "\nHi " + nameTo + ",\n\nThe following project was promoted to active state. \n";

            // ... for client and project
            body = body + "\n " + lblTitleClientName.Text;
            body = body + "\n Project: " + lblTitleProjectName.Text;

            //Send Mail
            SendMail(mailTo, subject, body);
        }
예제 #2
0
        private void LoadWorkData(int workId, int assetId)
        {
            FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway(fullLengthLiningTDS);

            if (fullLengthLiningWorkDetailsGateway.Table.Rows.Count > 0)
            {
                // For Header
                tbxVideoLength.Text = fullLengthLiningWorkDetailsGateway.GetVideoLength(workId);

                // Load full length lining general data
                tbxGeneralClientId.Text = fullLengthLiningWorkDetailsGateway.GetClientId(workId);
                ckbxGeneralIssueIdentified.Checked = fullLengthLiningWorkDetailsGateway.GetIssueIdentified(workId);
                ckbxGeneralLfsIssue.Checked = fullLengthLiningWorkDetailsGateway.GetIssueLFS(workId);
                ckbxGeneralClientIssue.Checked = fullLengthLiningWorkDetailsGateway.GetIssueClient(workId);
                ckbxGeneralSalesIssue.Checked = fullLengthLiningWorkDetailsGateway.GetIssueSales(workId);
                ckbxGeneralIssueGivenToClient.Checked = fullLengthLiningWorkDetailsGateway.GetIssueGivenToClient(workId);
                ckbxGeneralIssueResolved.Checked = fullLengthLiningWorkDetailsGateway.GetIssueResolved(workId);
                ckbxGeneralIssueInvestigation.Checked = fullLengthLiningWorkDetailsGateway.GetIssueInvestigation(workId);

                // ... Load Dates
                if (fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workId).HasValue)
                {
                    tkrdpGeneralProposedLiningDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetProposedLiningDate(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDate(workId).HasValue)
                {
                    tkrdpGeneralDeadlineLiningDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetDeadlineLiningDate(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetP1Date(workId).HasValue)
                {
                    tkrdpPrepDataP1Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetP1Date(workId);
                    tkrdpGeneralP1Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetP1Date(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetM1Date(workId).HasValue)
                {
                    tkrdpM1DataM1Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetM1Date(workId);
                    tkrdpGeneralM1Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetM1Date(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetM2Date(workId).HasValue)
                {
                    tkrdpGeneralM2Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetM2Date(workId);
                    tkrdpM2DataM2Date.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetM2Date(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetInstallDate(workId).HasValue)
                {
                    tkrdpGeneralInstallDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetInstallDate(workId);
                    tkrdpInstallDataInstallDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetInstallDate(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId).HasValue)
                {
                    tkrdpGeneralFinalVideo.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId);
                    tkrdpInstallDataFinalVideoDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId);
                }

                // ... for RA data
                if (fullLengthLiningWorkDetailsGateway.GetPreFlushDate(workId).HasValue)
                {
                    tkrdpGeneralPreFlushDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreFlushDate(workId);
                    tkrdpGeneralPreFlushDateReadOnly.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreFlushDate(workId);
                }

                if (fullLengthLiningWorkDetailsGateway.GetPreVideoDate(workId).HasValue)
                {
                    tkrdpGeneralPreVideoDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreVideoDate(workId);
                    tkrdpGeneralPreVideoDateReadOnly.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetPreVideoDate(workId);
                }

                // For FullLengthLiningP1 data
                tbxPrepDataCXIsRemoved.Text = ""; if (fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId).HasValue) tbxPrepDataCXIsRemoved.Text = fullLengthLiningWorkDetailsGateway.GetCxisRemoved(workId).ToString();
                ckbxPrepDataRoboticPrepCompleted.Checked = fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompleted(workId);
                if (fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId).HasValue)
                {
                    tkrdpPrepDataRoboticPrepCompletedDate.SelectedDate = (DateTime)fullLengthLiningWorkDetailsGateway.GetRoboticPrepCompletedDate(workId);
                }
                ckbxPrepDataP1Completed.Checked = fullLengthLiningWorkDetailsGateway.GetP1Completed(workId);

                // For FullLengthLiningM1 data
                // ... for material
                ddlM1DataMaterial.SelectedValue = fullLengthLiningWorkDetailsGateway.GetMaterial(workId);

                // ... form m1 data
                tbxM1DataMeasurementsTakenBy.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenBy(workId);
                ddlM1DataTrafficControl.SelectedValue = fullLengthLiningWorkDetailsGateway.GetTrafficControl(workId);
                if(fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId) == "") ddlM1DataSiteDetails.SelectedIndex = 0; else ddlM1DataSiteDetails.SelectedValue = fullLengthLiningWorkDetailsGateway.GetSiteDetails(workId);
                if (fullLengthLiningWorkDetailsGateway.GetAccessType(workId) == "") ddlM1DataAccessType.SelectedIndex = 0; else ddlM1DataAccessType.SelectedValue = fullLengthLiningWorkDetailsGateway.GetAccessType(workId);
                ckbxM1DataPipeSizeChange.Checked = fullLengthLiningWorkDetailsGateway.GetPipeSizeChange(workId);
                ckbxM1DataStandardBypass.Checked = fullLengthLiningWorkDetailsGateway.GetStandardBypass(workId);
                tbxM1DataStandardBypassComments.Text = fullLengthLiningWorkDetailsGateway.GetStandardBypassComments(workId);
                tbxM1DataTrafficControlDetails.Text = fullLengthLiningWorkDetailsGateway.GetTrafficControlDetails(workId);
                ddlM1DataMeasurementType.SelectedValue = fullLengthLiningWorkDetailsGateway.GetMeasurementType(workId);
                ddlM1DataMeasuredFromMh.SelectedValue = fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
                tbxM1DataMeasuredFromMh.Text = ""; fullLengthLiningWorkDetailsGateway.GetMeasurementFromMh(workId);
                ddlM1DataVideoDoneFromMh.SelectedValue = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId);
                tbxM1DataVideoDoneFromMh.Text = fullLengthLiningWorkDetailsGateway.GetVideoDoneFromMh(workId);
                ddlM1DataVideoDoneToMh.SelectedValue = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId);
                tbxM1DataVideoDoneToMh.Text = fullLengthLiningWorkDetailsGateway.GetVideoDoneToMh(workId);

                // For FullLengthLiningM2 data
                tbxM2DataMeasurementsTakenBy.Text = fullLengthLiningWorkDetailsGateway.GetMeasurementTakenByM2(workId);
                ckbxM2DataDropPipe.Checked = fullLengthLiningWorkDetailsGateway.GetDropPipe(workId);
                tbxM2DataDropPipeInvertdepth.Text = fullLengthLiningWorkDetailsGateway.GetDropPipeInvertDepth(workId);
                tbxM2DataCappedLaterals.Text = ""; if (fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workId).HasValue) tbxM2DataCappedLaterals.Text = fullLengthLiningWorkDetailsGateway.GetCappedLaterals(workId).ToString();
                tbxM2DataLineWidthId.Text = fullLengthLiningWorkDetailsGateway.GetLineWithId(workId);
                tbxM2DataHydrantAddress.Text = fullLengthLiningWorkDetailsGateway.GetHydrantAddress(workId);
                ddlM2DataHydroWireWithin10FtOfInversionMh.SelectedValue = fullLengthLiningWorkDetailsGateway.GetHydroWiredWithin10FtOfInversionMH(workId);
                tbxM2DataDistanceToInversionMH.Text = fullLengthLiningWorkDetailsGateway.GetDistanceToInversionMh(workId);
                if (fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workId) == "") ddlM2DataSurfaceGrade.SelectedIndex = 0; else ddlM2DataSurfaceGrade.SelectedValue = fullLengthLiningWorkDetailsGateway.GetSurfaceGrade(workId);
                cbxM2DataHydroPulley.Checked = fullLengthLiningWorkDetailsGateway.GetHydroPulley(workId);
                cbxM2DataFridgeCart.Checked = fullLengthLiningWorkDetailsGateway.GetFridgeCart(workId);
                cbxM2DataTwoPump.Checked = fullLengthLiningWorkDetailsGateway.GetTwoPump(workId);
                cbxM2DataSixBypass.Checked = fullLengthLiningWorkDetailsGateway.GetSixBypass(workId);
                cbxM2DataScaffolding.Checked = fullLengthLiningWorkDetailsGateway.GetScaffolding(workId);
                cbxM2DataWinchExtension.Checked = fullLengthLiningWorkDetailsGateway.GetWinchExtension(workId);
                cbxM2DataExtraGenerator.Checked = fullLengthLiningWorkDetailsGateway.GetExtraGenerator(workId);
                cbxM2DataGreyCableExtension.Checked = fullLengthLiningWorkDetailsGateway.GetGreyCableExtension(workId);
                cbxM2DataEasementMats.Checked = fullLengthLiningWorkDetailsGateway.GetEasementMats(workId);
                cbxM2DataRampsRequired.Checked = fullLengthLiningWorkDetailsGateway.GetRampRequired(workId);
                cbxM2DataCameraSkid.Checked = fullLengthLiningWorkDetailsGateway.GetCameraSkid(workId);

                // For FullLengthLiningWetOut data
                int companyId = Int32.Parse(hdfCompanyId.Value);

                // ... ... tube size = confirmed Size
                Distance confirmedSizeDistance = new Distance(tbxConfirmedSize.Text);
                double confirmedSize = 0;
                string[] confirmedSizeString = confirmedSizeDistance.ToStringInEng1().Split('\"');

                if (!confirmedSizeDistance.ToStringInEng1().Contains("'"))
                {
                    if (Validator.IsValidDouble(tbxConfirmedSize.Text))
                    {
                        confirmedSize = double.Parse(tbxConfirmedSize.Text);
                    }
                    else
                    {
                        confirmedSize = double.Parse(confirmedSizeString[0]);
                    }
                }
                else
                {
                    confirmedSize = Math.Ceiling(confirmedSizeDistance.ToDoubleInEng3()*12);
                    tbxConfirmedSize.Text = confirmedSize.ToString();
                }

                // ... Verify if work has wet out information
                WorkFullLengthLiningWetOutGateway workFullLengthLiningWetOutGateway = new WorkFullLengthLiningWetOutGateway();
                workFullLengthLiningWetOutGateway.LoadByWorkId(workId, companyId);

                if (workFullLengthLiningWetOutGateway.Table.Rows.Count > 0)
                {
                    // ... setup data
                    ddlWetOutDataLinerTube.SelectedValue = fullLengthLiningWorkDetailsGateway.GetLinerTube(workId);
                    if (ddlWetOutDataLinerTube.SelectedValue != "(Select)")
                    {
                        ckbxWetOutDataIncludeWetOutInformation.Checked = true;
                    }
                    else
                    {
                        ckbxWetOutDataIncludeWetOutInformation.Checked = false;
                    }

                    ddlWetOutDataResins.SelectedValue = fullLengthLiningWorkDetailsGateway.GetResinId(workId).ToString();
                    tbxWetOutDataExcessResin.Text = fullLengthLiningWorkDetailsGateway.GetExcessResin(workId).ToString();
                    ddlWetOutDataPoundsDrums.SelectedValue = fullLengthLiningWorkDetailsGateway.GetPoundsDrums(workId);
                    tbxWetOutDataDrumDiameter.Text = fullLengthLiningWorkDetailsGateway.GetDrumDiameter(workId).ToString();
                    tbxWetOutDataHoistMaximumHeight.Text = fullLengthLiningWorkDetailsGateway.GetHoistMaximumHeight(workId).ToString();
                    tbxWetOutDataHoistMinimumHeight.Text = fullLengthLiningWorkDetailsGateway.GetHoistMinimumHeight(workId).ToString();
                    tbxWetOutDataDownDropTubeLength.Text = fullLengthLiningWorkDetailsGateway.GetDownDropTubeLenght(workId).ToString();
                    tbxWetOutDataPumpHeightAboveGround.Text = fullLengthLiningWorkDetailsGateway.GetPumpHeightAboveGround(workId).ToString();
                    tbxWetOutDataTubeResinToFeltFactor.Text = fullLengthLiningWorkDetailsGateway.GetTubeResinToFeltFactor(workId).ToString();

                    // ... wet out sheet
                    DateTime wetOutDataDateOfSheet = fullLengthLiningWorkDetailsGateway.GetDateOfSheet(workId);
                    tbxWetOutDataDateOfSheet.Text = wetOutDataDateOfSheet.Month.ToString() + "/" + wetOutDataDateOfSheet.Day.ToString() + "/" + wetOutDataDateOfSheet.Year.ToString();
                    ddlWetOutDataMadeBy.SelectedValue = fullLengthLiningWorkDetailsGateway.GetEmployeeId(workId).ToString();
                    hdfRunDetails.Value = fullLengthLiningWorkDetailsGateway.GetRunDetails(workId);
                    ddlWetOutDataRunDetails2.SelectedValue = fullLengthLiningWorkDetailsGateway.GetRunDetails2(workId);
                    tkrdpWetOutDataWetOutDate.SelectedDate = fullLengthLiningWorkDetailsGateway.GetWetOutDate(workId);

                    tbxWetOutDataInstallDate.Text = "";
                    if (fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId).HasValue)
                    {
                        DateTime? wetOutDataInstallDate = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId);
                        DateTime wetOutDataInstallDateDateTime = (DateTime)wetOutDataInstallDate;
                        tbxWetOutDataInstallDate.Text = wetOutDataInstallDateDateTime.Month.ToString() + "/" + wetOutDataInstallDateDateTime.Day.ToString() + "/" + wetOutDataInstallDateDateTime.Year.ToString();
                    }

                    tbxWetOutDataTubeThickness.Text = fullLengthLiningWorkDetailsGateway.GetInversionThickness(workId);
                    tbxWetOutDataLengthToLine.Text = decimal.Round(decimal.Parse(fullLengthLiningWorkDetailsGateway.GetLengthToLine(workId).ToString()), 1).ToString();
                    tbxWetOutDataPlusExtra.Text = fullLengthLiningWorkDetailsGateway.GetPlusExtra(workId).ToString();
                    tbxWetOutDataForTurnOffset.Text = fullLengthLiningWorkDetailsGateway.GetForTurnOffset(workId).ToString();
                    tbxWetOutDataLengthtToWetOut.Text = fullLengthLiningWorkDetailsGateway.GetLengthToWetOut(workId).ToString();

                    tbxWetOutDataTubeMaxColdHead.Text = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHead(workId).ToString();
                    tbxWetOutDataTubeMaxColdHeadPSI.Text = fullLengthLiningWorkDetailsGateway.GetTubeMaxColdHeadPsi(workId).ToString();
                    tbxWetOutDataTubeMaxHotHead.Text = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHead(workId).ToString();
                    tbxWetOutDataTubeMaxHotHeadPSI.Text = fullLengthLiningWorkDetailsGateway.GetTubeMaxHotHeadPsi(workId).ToString();
                    tbxWetOutDataTubeIdealHead.Text = fullLengthLiningWorkDetailsGateway.GetTubeIdealHead(workId).ToString();
                    tbxWetOutDataTubeIdealHeadPSI.Text = fullLengthLiningWorkDetailsGateway.GetTubeIdealHeadPsi(workId).ToString();

                    tbxWetOutDataNetResinForTube.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTube(workId).ToString();
                    tbxWetOutDataNetResinForTubeUsgals.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgals(workId).ToString();
                    tbxWetOutDataNetResinForTubeDrumsIns.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeDrumsIns(workId);
                    tbxWetOutDataNetResinForTubeLbsFt.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeLbsFt(workId).ToString();
                    tbxWetOutDataNetResinForTubeUsgFt.Text = fullLengthLiningWorkDetailsGateway.GetNetResinForTubeUsgFt(workId).ToString();

                    tbxWetOutDataExtraResinForMix.Text = fullLengthLiningWorkDetailsGateway.GetExtraResinForMix(workId).ToString();
                    tbxWetOutDataExtraLbsForMix.Text = fullLengthLiningWorkDetailsGateway.GetExtraLbsForMix(workId).ToString();
                    tbxWetOutDataTotalMixQuantity.Text = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantity(workId).ToString();
                    tbxWetOutDataTotalMixQuantityUsgals.Text = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityUsgals(workId).ToString();
                    tbxWetOutDataTotalMixQuantityDrumsIns.Text = fullLengthLiningWorkDetailsGateway.GetTotalMixQuantityDrumsIns(workId);

                    ddlWetOutDataInversionType.SelectedValue = fullLengthLiningWorkDetailsGateway.GetInversionType(workId);
                    tbxWetOutDataDepthOfInversionMH.Text = fullLengthLiningWorkDetailsGateway.GetDepthOfInversionMH(workId).ToString();
                    tbxWetOutDataTubeForColumn.Text = fullLengthLiningWorkDetailsGateway.GetTubeForColumn(workId).ToString();
                    tbxWetOutDataTubeForStartDry.Text = fullLengthLiningWorkDetailsGateway.GetTubeForStartDry(workId).ToString();
                    tbxWetOutDataTotalTube.Text = fullLengthLiningWorkDetailsGateway.GetTotalTube(workId).ToString();
                    tbxWetOutDataDropTubeConnects.Text = fullLengthLiningWorkDetailsGateway.GetDropTubeConnects(workId);
                    tbxWetOutDataAllowsHeadTo.Text = fullLengthLiningWorkDetailsGateway.GetAllowsHeadTo(workId).ToString();
                    tbxWetOutDataRollerGap.Text = fullLengthLiningWorkDetailsGateway.GetRollerGap(workId).ToString();

                    tbxWetOutDataHeightNeeded.Text = fullLengthLiningWorkDetailsGateway.GetHeightNeeded(workId).ToString();
                    tbxWetOutDataAvailable.Text = fullLengthLiningWorkDetailsGateway.GetAvailable(workId);
                    tbxWetOutDataHoistHeight.Text = fullLengthLiningWorkDetailsGateway.GetHoistHeight(workId);
                    hdfResinId.Value = fullLengthLiningWorkDetailsGateway.GetResinId(workId).ToString();
                    hdfMadeBy.Value = fullLengthLiningWorkDetailsGateway.GetEmployeeId(workId).ToString();
                    tbxWetOutDataNotes.Text = fullLengthLiningWorkDetailsGateway.GetCommentsCipp(workId);

                    lblWetOutDataResinGray.Text = fullLengthLiningWorkDetailsGateway.GetResinsLabel(workId);
                    lblWetOutDataDrumContainsGray.Text = fullLengthLiningWorkDetailsGateway.GetDrumContainsLabel(workId);
                    lblWetOutDataLinerTubeGray.Text = fullLengthLiningWorkDetailsGateway.GetLinerTubeLabel(workId);
                    lblWetOutDataLbDrumsGrey.Text = fullLengthLiningWorkDetailsGateway.GetForLbDrumsLabel(workId);
                    lblWetOutDataNetResinGrey.Text = fullLengthLiningWorkDetailsGateway.GetNetResinLabel(workId);
                    lblWetOutDataCatalystGrey.Text = fullLengthLiningWorkDetailsGateway.GetCatalystLabel(workId);

                    // ... ... graphic labels
                    lblWetOutDataDimensionLabel.Text = confirmedSize + " ins x " + ddlThickness.SelectedValue + " mm Tube";
                    lblWetOutDataTotalTubeLengthlabel.Text = "Total Tube Length " + tbxWetOutDataTotalTube.Text + " ft";
                    lblWetOutDataForColumnLabel.Text = tbxWetOutDataTubeForColumn.Text + " ft  for Column";
                    lblWetOutDataDryFtLabel.Text = "Dry " + tbxWetOutDataTubeForStartDry.Text + " ft";
                    lblWetOutDataWetOutLengthlabel.Text = "Wet-Out Length " + tbxWetOutDataLengthtToWetOut.Text + " ft";
                    lblWetOutDataDryFtEndLabel.Text = "Dry " + tbxWetOutDataTubeForColumn.Text + " ft";
                    lblWetOutDataTailEndlabel.Text = "Tail End";
                    lblWetOutDataColumnEndlabel.Text = "Column End";
                    lblWetOutDataRollerGapLabel.Text = "Roller Gap " + tbxWetOutDataRollerGap.Text + " mm";
                }
                else
                {
                    //  Wet Out Data
                    // ... Show current day for new sheets
                    DateTime sheetDate = DateTime.Now;
                    tbxWetOutDataDateOfSheet.Text = sheetDate.Month.ToString() + "/" + sheetDate.Day.ToString() + "/" + sheetDate.Year.ToString();

                    // Set default values.
                    tbxWetOutDataExcessResin.Text = "0.0";
                    ddlWetOutDataPoundsDrums.SelectedIndex = 1;
                    tbxWetOutDataDrumDiameter.Text = "22.5";
                    tbxWetOutDataHoistMaximumHeight.Text = "24";
                    tbxWetOutDataHoistMinimumHeight.Text = "5";
                    tbxWetOutDataDownDropTubeLength.Text = "19";
                    tbxWetOutDataPumpHeightAboveGround.Text = "6";
                    tbxWetOutDataTubeResinToFeltFactor.Text = "87";

                    tbxWetOutDataPlusExtra.Text = "3";
                    tbxWetOutDataForTurnOffset.Text = "0";

                    tbxWetOutDataExtraResinForMix.Text = "0";
                    tbxWetOutDataTubeForColumn.Text = "16";
                    tbxWetOutDataTubeForStartDry.Text = "3";
                    if (ddlWetOutDataInversionType.SelectedValue == "Top")
                    {
                        Distance usmhDepthDistance = new Distance(tbxM1DataUsmhDepth.Text);
                        tbxWetOutDataDepthOfInversionMH.Text = decimal.Round(decimal.Parse(usmhDepthDistance.ToStringInEng3()), 1).ToString();
                    }
                    else
                    {
                        if (ddlWetOutDataInversionType.SelectedValue == "Bottom")
                        {
                            Distance dsmhDepthDistance = new Distance(tbxM1DataDsmhDepth.Text);
                            tbxWetOutDataDepthOfInversionMH.Text = decimal.Round(decimal.Parse(dsmhDepthDistance.ToStringInEng3()), 1).ToString();
                        }
                        else
                        {
                            tbxWetOutDataDepthOfInversionMH.Text = "0";
                        }
                    }

                    tbxWetOutDataRollerGap.Text = "13";
                    tbxWetOutDataNotes.Text = fullLengthLiningWorkDetailsGateway.GetCommentsCipp(workId);

                    // ...Section values
                    // ... ... Length To Line = Steel Tape Length, the first section to consider is the work one in Xft Yin
                    Distance steelTapeLength = new Distance(tbxSteelTapeLength.Text);
                    tbxWetOutDataLengthToLine.Text = decimal.Round(decimal.Parse(steelTapeLength.ToStringInEng3()), 1).ToString();
                    tbxInversionDataRunLength.Text = decimal.Round(decimal.Parse(steelTapeLength.ToStringInEng3()),1).ToString();
                    double lengthToLine = double.Parse(steelTapeLength.ToStringInEng3());

                    // ... Run details
                    if (cbxlSectionId.Items.Count > 1)
                    {
                        hdfRunDetails.Value = hdfSectionId.Value;
                    }

                    // .... Install Date
                    tbxWetOutDataInstallDate.Text = "";
                    if (tkrdpInstallDataInstallDate.SelectedDate.ToString() != "")
                    {
                        DateTime? inversionDataInstalledOn = tkrdpInstallDataInstallDate.SelectedDate;
                        DateTime installedOnDateTime = (DateTime)inversionDataInstalledOn;

                        tbxWetOutDataInstallDate.Text = installedOnDateTime.Month.ToString() + "/" + installedOnDateTime.Day.ToString() + "/" + installedOnDateTime.Year.ToString();
                    }
                }

                // ... Verify if work has inversion information
                WorkFullLengthLiningInversionGateway workFullLengthLiningInversionGateway = new WorkFullLengthLiningInversionGateway();
                workFullLengthLiningInversionGateway.LoadByWorkId(workId, companyId);

                // ... Verify if work has inversion information
                if (workFullLengthLiningInversionGateway.Table.Rows.Count > 0)
                {
                    // ... Inversion data
                    lblInversionDataSubtitle.Text = fullLengthLiningWorkDetailsGateway.GetLinerTube(workId);

                    DateTime inversionDataDateOfSheet = fullLengthLiningWorkDetailsGateway.GetDateOfSheet(workId);
                    tbxInversionDataDateOfSheet.Text = inversionDataDateOfSheet.Month.ToString() + "/" + inversionDataDateOfSheet.Day.ToString() + "/" + inversionDataDateOfSheet.Year.ToString();

                    int employeeId = fullLengthLiningWorkDetailsGateway.GetEmployeeId(workId);
                    EmployeeGateway employeeGateway = new EmployeeGateway();
                    employeeGateway.LoadByEmployeeId(employeeId);
                    tbxInversionDataMadeBy.Text = employeeGateway.GetLastName(employeeId) + " " + employeeGateway.GetFirstName(employeeId);

                    tbxInversionDataInstalledOn.Text = "";
                    if (fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId).HasValue)
                    {
                        DateTime? inversionDataInstalledOn = fullLengthLiningWorkDetailsGateway.GetWetOutInstallDate(workId);
                        DateTime inversionDataInstalledOnDateTime = (DateTime)inversionDataInstalledOn;
                        tbxInversionDataInstalledOn.Text = inversionDataInstalledOnDateTime.Month.ToString() + "/" + inversionDataInstalledOnDateTime.Day.ToString() + "/" + inversionDataInstalledOnDateTime.Year.ToString();
                    }

                    tbxInversionDataRunDetails2.Text = fullLengthLiningWorkDetailsGateway.GetRunDetails2(workId);
                    tbxInversionDataCommentsEdit.Text = fullLengthLiningWorkDetailsGateway.GetInversionComment(workId);
                    tbxInversionDataLinerSize.Text = confirmedSizeString + " ins x" + fullLengthLiningWorkDetailsGateway.GetInversionThickness(workId);
                    tbxInversionDataRunLength.Text = decimal.Round(decimal.Parse(fullLengthLiningWorkDetailsGateway.GetLengthToLine(workId).ToString()), 1).ToString();
                    tbxInversionDataWetOutLenght.Text = fullLengthLiningWorkDetailsGateway.GetLengthToWetOut(workId).ToString();

                    ddlInversionDataInversionPipeType.SelectedValue = fullLengthLiningWorkDetailsGateway.GetPipeType(workId);
                    if (ddlInversionDataInversionPipeType.SelectedValue != "(Select)")
                    {
                        ckbxInversionDataIncludeInversionInformation.Checked = true;
                    }
                    else
                    {
                        ckbxInversionDataIncludeInversionInformation.Checked = false;
                    }

                    ddlInversionDataPipeCondition.SelectedValue = fullLengthLiningWorkDetailsGateway.GetPipeCondition(workId);
                    ddlInversionDataGroundMoisture.SelectedValue = fullLengthLiningWorkDetailsGateway.GetGroundMoisture(workId);
                    tbxInversionDataBoilerSize.Text = fullLengthLiningWorkDetailsGateway.GetBoilerSize(workId).ToString();
                    tbxInversionDataPumpsTotalCapacity.Text = fullLengthLiningWorkDetailsGateway.GetPumpTotalCapacity(workId).ToString();
                    tbxInversionDataLayflatSize.Text = fullLengthLiningWorkDetailsGateway.GetLayFlatSize(workId).ToString();
                    tbxInversionDataLayflatQuantityTotal.Text = fullLengthLiningWorkDetailsGateway.GetLayFlatQuantityTotal(workId).ToString();

                    tbxInversionDataWaterStartTempTs.Text = fullLengthLiningWorkDetailsGateway.GetWaterStartTemp(workId).ToString();
                    tbxInversionDataTempT1.Text = fullLengthLiningWorkDetailsGateway.GetTemp1(workId).ToString();
                    tbxInversionDataHoldAtT1For.Text = fullLengthLiningWorkDetailsGateway.GetHoldAtT1(workId).ToString();
                    tbxInversionDataTempT2.Text = fullLengthLiningWorkDetailsGateway.GetTempT2(workId).ToString();
                    tbxInversionDataCookAtT2For.Text = fullLengthLiningWorkDetailsGateway.GetCookAtT2(workId).ToString();
                    tbxInversionDataCoolDownFor.Text = fullLengthLiningWorkDetailsGateway.GetCoolDownFor(workId).ToString();

                    tbxInversionDataCoolToTemp.Text = fullLengthLiningWorkDetailsGateway.GetCoolToTemp(workId).ToString();
                    tbxInversionDataDropInPipeRun.Text = fullLengthLiningWorkDetailsGateway.GetDropInPipeRun(workId).ToString();
                    tbxInversionDataPipeSlopeOf.Text = fullLengthLiningWorkDetailsGateway.GetPipeSlopOf(workId).ToString();

                    lblInversionData45F120F.Text = tbxInversionDataWaterStartTempTs.Text + "°F-" + tbxInversionDataTempT1.Text + "°F (hr)";
                    tbxInversionData45F120F.Text = fullLengthLiningWorkDetailsGateway.GetF45F120(workId).ToString();
                    tbxInversionDataHold.Text = fullLengthLiningWorkDetailsGateway.GetHold(workId).ToString();
                    lblInversionData120F185F.Text = tbxInversionDataTempT1.Text + "°F-" + tbxInversionDataTempT2.Text + "°F (hr)";
                    tbxInversionData120F185F.Text = fullLengthLiningWorkDetailsGateway.GetF120F185(workId).ToString();
                    tbxInversionDataCookTime.Text = fullLengthLiningWorkDetailsGateway.GetCookTime(workId).ToString();
                    tbxInversionDataCoolTime.Text = fullLengthLiningWorkDetailsGateway.GetCoolTime(workId).ToString();
                    tbxInversionDataAproxTotal.Text = fullLengthLiningWorkDetailsGateway.GetAproxTotal(workId).ToString();

                    tbxInversionDataWaterChangesPerHour.Text = fullLengthLiningWorkDetailsGateway.GetWaterChangesPerHour(workId).ToString();
                    tbxInversionDataReturnWaterVelocity.Text = fullLengthLiningWorkDetailsGateway.GetReturnWaterVelocity(workId).ToString();
                    tbxInversionDataLayflatBackPressure.Text = fullLengthLiningWorkDetailsGateway.GetLayflatBackPressure(workId).ToString();
                    tbxInversionDataPumpLiftAtIdealHead.Text = fullLengthLiningWorkDetailsGateway.GetPumpLiftAtIdealHead(workId).ToString();
                    tbxInversionDataWaterToFillLinerColumn.Text = fullLengthLiningWorkDetailsGateway.GetWaterToFillLinerColumn(workId).ToString();
                    tbxInversionDataWaterPerFit.Text = fullLengthLiningWorkDetailsGateway.GetWaterPerFit(workId).ToString();

                    tbxInversionDataNotesAndInstallationResults.Text = fullLengthLiningWorkDetailsGateway.GetInstallationResults(workId);

                    lblInversionDataLinerInfoGrey.Text = fullLengthLiningWorkDetailsGateway.GetInversionLinerTubeLabel(workId);
                    lblInversionDataHeadsGrey.Text = fullLengthLiningWorkDetailsGateway.GetHeadsIdealLabel(workId);
                    lblInversionDataPumpingCirculationSubtitle.Text = fullLengthLiningWorkDetailsGateway.GetPumpingAndCirculationLabel(workId);

                    // ... ... graphic labels
                    lblInversionDataMaxColdForTubeLabel.Text = tbxWetOutDataTubeMaxColdHead.Text + " ft = Max Cold for tube";
                    lblInversionDataMaxHotForTubeLabel.Text = tbxWetOutDataTubeMaxHotHead.Text + " ft = Max Hot for tube";
                    lblInversionDataIdelForTubeLabel.Text = tbxWetOutDataTubeIdealHead.Text + " ft = Ideal for tube";

                    double maxColdForTubeEnd = double.Parse(tbxWetOutDataTubeMaxColdHead.Text) + double.Parse(tbxInversionDataDropInPipeRun.Text);
                    lblInversionDataMaxColdForTubeEndLabel.Text = decimal.Round(decimal.Parse(maxColdForTubeEnd.ToString()), 1).ToString() + " ft";

                    double maxHotForTubeEnd = double.Parse(tbxWetOutDataTubeMaxHotHead.Text) + double.Parse(tbxInversionDataDropInPipeRun.Text);
                    lblInversionDataMaxHotForTubeEndLabel.Text = decimal.Round(decimal.Parse(maxHotForTubeEnd.ToString()), 1).ToString() + " ft";

                    double idealForTubeEnd = double.Parse(tbxWetOutDataTubeIdealHead.Text) + double.Parse(tbxInversionDataDropInPipeRun.Text);
                    lblInversionDataIdelForTubeEndLabel.Text = decimal.Round(decimal.Parse(idealForTubeEnd.ToString()), 1).ToString() + " ft";

                    lblInversionDataPumpHeightLabel.Text = "   " + tbxWetOutDataPumpHeightAboveGround.Text + " ft";
                    lblInversionDataLinerSizeLabel.Text = confirmedSize.ToString() + " ins x" + fullLengthLiningWorkDetailsGateway.GetInversionThickness(workId) + " Liner";

                    lblInversionDataRunLengthLabel.Text = "Run Length: " + tbxInversionDataRunLength.Text + " ft; Fall: " + tbxInversionDataDropInPipeRun.Text + " ft";
                    lblInversionDataDepthOfInversionMHLabel.Text = "   " + tbxWetOutDataDepthOfInversionMH.Text + " ft";
                    lblInversionDataEndLabel.Text = "End";
                }
                else
                {
                    //  Wet Out Data
                    // ... Show current day for new sheets
                    DateTime sheetDate = DateTime.Now;
                    tbxInversionDataDateOfSheet.Text = sheetDate.Month.ToString() + "/" + sheetDate.Day.ToString() + "/" + sheetDate.Year.ToString();

                    // Set default values.
                    lblInversionData45F120F.Text = "";
                    lblInversionData120F185F.Text = "";
                    tbxInversionDataBoilerSize.Text = "7000000";
                    tbxInversionDataPumpsTotalCapacity.Text = "300";
                    tbxInversionDataLayflatSize.Text = "4";
                    tbxInversionDataLayflatQuantityTotal.Text = "1";

                    tbxInversionDataWaterStartTempTs.Text = "45";
                    tbxInversionDataTempT1.Text = "120";
                    tbxInversionDataHoldAtT1For.Text = "0.5";
                    tbxInversionDataTempT2.Text = "185";
                    tbxInversionDataCookAtT2For.Text = "2";
                    tbxInversionDataCoolDownFor.Text = "1";
                    tbxInversionDataCoolToTemp.Text = "85";

                    // ...Section values
                    // ... ... Length To Line = Steel Tape Length, the first section to consider is the work one in Xft Yin
                    Distance steelTapeLength = new Distance(tbxSteelTapeLength.Text);
                    tbxInversionDataRunLength.Text = decimal.Round(decimal.Parse(steelTapeLength.ToStringInEng3()), 1).ToString();
                    double lengthToLine = double.Parse(steelTapeLength.ToStringInEng3());

                    // ... Run details
                    if (cbxlSectionId.Items.Count > 1)
                    {
                        hdfRunDetails.Value = hdfSectionId.Value;
                    }

                    // .... Install Date
                    tbxInversionDataInstalledOn.Text = "";
                    if (tkrdpInstallDataInstallDate.SelectedDate.ToString() != "")
                    {
                        DateTime? inversionDataInstalledOn = tkrdpInstallDataInstallDate.SelectedDate;
                        DateTime installedOnDateTime = (DateTime)inversionDataInstalledOn;

                        tbxInversionDataInstalledOn.Text = installedOnDateTime.Month.ToString() + "/" + installedOnDateTime.Day.ToString() + "/" + installedOnDateTime.Year.ToString();
                    }
                 }

                // ... Show FLL Comments + RA Comments
                int flWorkId = workId;

                // ... ... Get raWorkId
                int raWorkId = 0;
                int projectId = Int32.Parse(hdfCurrentProjectId.Value);
                WorkGateway workGateway = new WorkGateway();
                workGateway.LoadByProjectIdAssetIdWorkType(projectId, assetId, "Rehab Assessment", companyId);
                if (workGateway.Table.Rows.Count > 0)
                {
                    raWorkId = workGateway.GetWorkId(assetId, "Rehab Assessment", projectId);
                }

                // ... ... Get comments
                FullLengthLiningAllComments fullLengthLiningAllComments = new FullLengthLiningAllComments(fullLengthLiningTDS);
                fullLengthLiningAllComments.LoadAllByFlWorkIdRaWorkId(flWorkId, raWorkId, companyId);

                // ... ... Store datasets
                Session["fullLengthLiningTDS"] = fullLengthLiningTDS;

                // ... ... Show comments
                tbxCommentsDataComments.Text = fullLengthLiningAllComments.GetFLOrRAComments(companyId, fullLengthLiningAllComments.Table.Rows.Count, "\n");
            }
        }
예제 #3
0
 protected void ddlWetOutDataMadeBy_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (ddlWetOutDataMadeBy.SelectedValue != "(Select)")
     {
         int employeeId = Int32.Parse(ddlWetOutDataMadeBy.SelectedValue);
         EmployeeGateway employeeGateway = new EmployeeGateway();
         employeeGateway.LoadByEmployeeId(employeeId);
         tbxInversionDataMadeBy.Text = employeeGateway.GetLastName(employeeId) + " " + employeeGateway.GetFirstName(employeeId);
     }
 }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_VIEW"]) && Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_EDIT"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["service_id"] == null) || ((string)Request.QueryString["active_tab"] == null) || ((string)Request.QueryString["dashboard"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in services_edit.aspx");
                }

                // Tag Page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfFmType.Value = "Services";
                hdfServiceId.Value = Request.QueryString["service_id"].ToString();
                hdfActiveTab.Value = Request.QueryString["active_tab"].ToString();
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();
                hdfDashboard.Value = Request.QueryString["dashboard"].ToString();

                // Prepare initial data
                Session.Remove("serviceCostsDummy");
                Session.Remove("serviceNotesDummy");

                // If coming from
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int serviceId = Int32.Parse(hdfServiceId.Value.Trim());
                string fmType = hdfFmType.Value;

                // ... services_navigator2.aspx, services_add_request.aspx, services_manager_tool.aspx
                if ((Request.QueryString["source_page"] == "services_navigator2.aspx") || (Request.QueryString["source_page"] == "services_add_request.aspx") || (Request.QueryString["source_page"] == "services_manager_tool.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedServices"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];

                        serviceInformationTDS = new ServiceInformationTDS();

                        ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS);
                        serviceInformationBasicInformation.LoadByServiceId(serviceId, companyId);

                        ServiceInformationServiceCost serviceInformationServiceCostForEdit = new ServiceInformationServiceCost(serviceInformationTDS);
                        serviceInformationServiceCostForEdit.LoadByServiceId(serviceId, companyId);

                        ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS);
                        serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId);
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabServices"];

                        // Restore datasets
                        serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"];
                    }

                    // ... Store dataset
                    Session["serviceInformationTDS"] = serviceInformationTDS;
                }

                // ... services_summary.aspx or services_edit
                if ((Request.QueryString["source_page"] == "services_summary.aspx") || (Request.QueryString["source_page"] == "services_edit.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // ... Restore dataset
                    serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"];

                    // ... Set initial tab
                    if ((string)Session["dialogOpenedServices"] != "1")
                    {
                        hdfActiveTab.Value = Request.QueryString["active_tab"];

                        if (ViewState["update"].ToString().Trim() == "yes")
                        {
                            ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS);
                            serviceInformationBasicInformation.LoadByServiceId(serviceId, companyId);

                            ServiceInformationServiceCost serviceInformationServiceCostForEdit = new ServiceInformationServiceCost(serviceInformationTDS);
                            serviceInformationServiceCostForEdit.LoadByServiceId(serviceId, companyId);

                            ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS);
                            serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId);

                            // ... Store dataset
                            Session["serviceInformationTDS"] = serviceInformationTDS;
                        }
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabServices"];
                    }
                }

                // Prepare initial data
                lblMissingData.Visible = false;

                // ... Set initial tab
                int activeTab = Int32.Parse(hdfActiveTab.Value);
                tcDetailedInformation.ActiveTabIndex = activeTab;

                // ... For total cost
                ServiceInformationServiceCost serviceInformationServiceCostForTotalCost = new ServiceInformationServiceCost(serviceInformationTDS);
                tbxTotalCost.Text = Decimal.Round(serviceInformationServiceCostForTotalCost.GetTotalCost(serviceId, companyId), 2).ToString();

                // ... Data for current servicew
                LoadServiceData(companyId);

                // Databind
                Page.DataBind();

                ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
                if (serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId).HasValue)
                {
                    try
                    {
                        ddlAssignmentDataAssignToTeamMember.SelectedValue = ((int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId)).ToString();
                    }
                    catch
                    {
                        ddlAssignmentDataAssignToTeamMember.SelectedIndex = 0;
                    }

                    int teamMemberId = (int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId);
                    EmployeeGateway employeeGateway = new EmployeeGateway();
                    employeeGateway.LoadByEmployeeId(teamMemberId);
                    tbxAssignmentDataAssignToTeamMemberReadOnly.Text = employeeGateway.GetLastName(teamMemberId) + " " + employeeGateway.GetFirstName(teamMemberId);
                }

                // For thirds party vendor autocomplete
                aceThirdPartyVendor.ContextKey = serviceId.ToString() + "," + hdfCompanyId.Value;

                // ... For Library
                if (Session["libraryTDSForServices"] != null)
                {
                    libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"];
                }
                else
                {
                    libraryTDSForServices = new LibraryTDS();
                }
            }
            else
            {
                // Restore datasets
                serviceInformationTDS = (ServiceInformationTDS)Session["serviceInformationTDS"];

                // Set initial tab
                int activeTab = Int32.Parse(hdfActiveTab.Value);
                tcDetailedInformation.ActiveTabIndex = activeTab;

                if (Session["libraryTDSForServices"] != null)
                {
                    libraryTDSForServices = (LibraryTDS)Session["libraryTDSForServices"];
                }
                else
                {
                    libraryTDSForServices = new LibraryTDS();
                }

                LoadNotes();
            }
        }
        private void LoadDetailaDataAssignmentData(int serviceId, ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway)
        {
            // Load for Assignment Tab
            // ... pnlAssignmentData
            tbxAssignmentDataAssignmentDateTime.Text = serviceInformationBasicInformationGateway.GetAssignmentDateTime(serviceId).ToString();

            if (serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId).HasValue)
            {
                DateTime deadlineDate = (DateTime)serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId);
                tkrdpAssignmentDataAssignedDeadlineDate.SelectedDate = DateTime.Parse(deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString());
            }

            if ((serviceInformationBasicInformationGateway.GetToTeamMember(serviceId)) && (serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId)) == "")
            {
                // ... For team member
                rbtnAssignmentDataToTeamMember.Checked = true;
                rbtnAssignmentDataToTeamMemberReadOnly.Checked = true;

                // ... For third party vendor
                rbtnAssignmentDataToThirdPartyVendor.Checked = false;
                rbtnAssignmentDataToThirdPartyVendorReadOnly.Checked = false;
            }
            else
            {
                if ((!serviceInformationBasicInformationGateway.GetToTeamMember(serviceId)) && (serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId)) != "")
                {
                    // ... For team member
                    rbtnAssignmentDataToTeamMember.Checked = false;
                    rbtnAssignmentDataToTeamMemberReadOnly.Checked = false;

                    // ... For third party vendor
                    rbtnAssignmentDataToThirdPartyVendor.Checked = true;
                    rbtnAssignmentDataToThirdPartyVendorReadOnly.Checked = true;

                    tbxAssignmentDataAssignToThirdPartyVendor.Text = serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId);
                    tbxAssignmentDataAssignToThirdPartyVendorReadOnly.Text = serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId);
                }
                else
                {
                    rbtnAssignmentDataToTeamMember.Checked = false;
                    rbtnAssignmentDataToTeamMemberReadOnly.Checked = false;
                    rbtnAssignmentDataToThirdPartyVendor.Checked = false;
                    rbtnAssignmentDataToThirdPartyVendorReadOnly.Checked = false;
                }
            }

            tbxAssignmentDataAcceptedDateTime.Text = serviceInformationBasicInformationGateway.GetAcceptedDateTime(serviceId).ToString();

            DateTime? acceptedDateTime = serviceInformationBasicInformationGateway.GetAcceptedDateTime(serviceId);
            if (acceptedDateTime.HasValue) tbxAssignmentDataAcceptedDateTime.Text = acceptedDateTime.ToString();

            DateTime? rejectedDateTime = serviceInformationBasicInformationGateway.GetRejectedDateTime(serviceId);
            if (rejectedDateTime.HasValue) tbxAssignmentDataRejectedDateTime.Text = rejectedDateTime.ToString();
            tbxAssignmentDataRejectedReason.Text = serviceInformationBasicInformationGateway.GetRejectedReason(serviceId);

            // ... pnlAssignmentDataReadOnly
            tbxAssignmentDataAssignmentDateTimeReadOnly.Text = serviceInformationBasicInformationGateway.GetAssignmentDateTime(serviceId).ToString();

            tbxAssignmentDataAssignedDeadlineDateReadOnly.Text = "";
            if (serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId).HasValue)
            {
                DateTime deadlineDate = (DateTime)serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId);
                tbxAssignmentDataAssignedDeadlineDateReadOnly.Text = deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString();
            }

            if ((serviceInformationBasicInformationGateway.GetToTeamMember(serviceId)) && (serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId)) == "")
            {
                // ... For team member
                rbtnAssignmentDataReadOnlyToTeamMemberReadOnly.Checked = true;

                if (serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId).HasValue)
                {
                    int teamMemberId = (int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId);
                    EmployeeGateway employeeGateway = new EmployeeGateway();
                    employeeGateway.LoadByEmployeeId(teamMemberId);
                    tbxAssignmentDataReadOnlyAssignToTeamMemberReadOnly.Text = employeeGateway.GetLastName(teamMemberId) + " " + employeeGateway.GetFirstName(teamMemberId);
                }

                // ... For third party vendor
                rbtnAssignmentDataReadOnlyToThirdPartyVendorReadOnly.Checked = false;
            }
            else
            {
                if ((!serviceInformationBasicInformationGateway.GetToTeamMember(serviceId)) && (serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId)) != "")
                {
                    // ... For team member
                    rbtnAssignmentDataReadOnlyToTeamMemberReadOnly.Checked = false;

                    // ... For third party vendor
                    rbtnAssignmentDataReadOnlyToThirdPartyVendorReadOnly.Checked = true;

                    tbxAssignmentDataReadOnlyAssignToThirdPartyVendorReadOnly.Text = serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId);
                }
                else
                {
                    rbtnAssignmentDataReadOnlyToTeamMemberReadOnly.Checked = false;
                    rbtnAssignmentDataReadOnlyToThirdPartyVendorReadOnly.Checked = false;
                }
            }

            tbxAssignmentDataAcceptedDateTimeReadOnly.Text = serviceInformationBasicInformationGateway.GetAcceptedDateTime(serviceId).ToString();

            DateTime? acceptedDateTimeReadOnly = serviceInformationBasicInformationGateway.GetAcceptedDateTime(serviceId);
            if (acceptedDateTimeReadOnly.HasValue) tbxAssignmentDataAcceptedDateTimeReadOnly.Text = acceptedDateTimeReadOnly.ToString();

            DateTime? rejectedDateTimeReadOnly = serviceInformationBasicInformationGateway.GetRejectedDateTime(serviceId);
            if (rejectedDateTimeReadOnly.HasValue) tbxAssignmentDataRejectedDateTimeReadOnly.Text = rejectedDateTimeReadOnly.ToString();
            tbxAssignmentDataRejectedReasonReadOnly.Text = serviceInformationBasicInformationGateway.GetRejectedReason(serviceId);
        }
        public void SendMailFleetManager()
        {
            // Get mail information
            string mailTo = "";
            string nameTo = "";
            string subject = "Service request has been modified.";
            string body = "";

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

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

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

            // Mails body
            body = body + "\nHi " + nameTo + ",\n\nThe following service request has been modified. \n";

            body = body + "\n Service Number: " + hdfServiceNumber.Value;
            body = body + "\n Service Description: " + hdfServiceDescription.Value;

            // ... Assignation of work
            // ... ... Deadline date
            if (hdfDeadlineDate.Value != "")
            {
                DateTime deadlineDate = DateTime.Parse(hdfDeadlineDate.Value);
                string deadlineDateText = deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString();
                body = body + "\n Deadline date: " + deadlineDateText;
            }
            else
            {
                body = body + "\n Deadline date: ";
            }

            // ... ... Assigned Personal
            if (hdfAssignToTeamMember.Value == "True")
            {
                int employeeId = Int32.Parse(hdfTeamMemberId.Value);
                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;
            }

            // ... ... Assigned third party vendor
            if (hdfAssignToThirdPartyVendor.Value == "True")
            {
                body = body + "\n Assigned Third Party Vendor: " + hdfThirdPartyVendor.Value;
            }

            int registeredByLoginId = Convert.ToInt32(Session["loginID"]);
            EmployeeGateway employeeGateway = new EmployeeGateway();
            employeeGateway.LoadByLoginId(registeredByLoginId);
            int registeredByEmployeeId = employeeGateway.GetEmployeIdByLoginId(registeredByLoginId);

            // ... ... Assigned myself
            if (hdfAssignToMyself.Value == "True")
            {
                if (employeeGateway.Table.Rows.Count > 0)
                {
                    body = body + "\n Assigned to myself: " + employeeGateway.GetFirstName(registeredByEmployeeId) + " " + employeeGateway.GetLastName(registeredByEmployeeId);
                }
            }

            // Registered by
            if (employeeGateway.Table.Rows.Count > 0)
            {
                body = body + "\n Registered By: " + employeeGateway.GetFirstName(registeredByEmployeeId) + " " + employeeGateway.GetLastName(registeredByEmployeeId);
            }

            // Service State
            body = body + "\n\n Service State: " + hdfServiceState.Value;

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

            if (hdfAssignToTeamMember.Value == "True")
            {
                int employeeId = Int32.Parse(hdfTeamMemberId.Value);

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

                // Mails body
                body = body + "\nHi " + nameTo + ",\n\nThe following service request has been assigned to you. \n";

                body = body + "\n Service Number: " + hdfServiceNumber.Value;
                body = body + "\n Service Description: " + hdfServiceDescription.Value;

                if (hdfDeadlineDate.Value != "")
                {
                    DateTime deadlineDate = DateTime.Parse(hdfDeadlineDate.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 SendMailEmployee(string newState)
        {
            if (newState == "Rejected")
            {
                // Update grid rows
                foreach (GridViewRow row in grdVacations.Rows)
                {
                    int requestId = Int32.Parse(grdVacations.DataKeys[row.RowIndex].Values["RequestID"].ToString());
                    if (((CheckBox)row.FindControl("cbxSelected")).Checked)
                    {
                        string rejectReason = ((TextBox)row.FindControl("tbxRejectReason")).Text;

                        // Get mail information
                        string mailTo = "";
                        string nameTo = "";
                        string body = "";
                        string subject = "";

                        VacationsInformationRequestsInformationGateway vacationsInformationRequestsInformationGateway = new VacationsInformationRequestsInformationGateway(vacationsInformationTDS);

                        int employeeId = vacationsInformationRequestsInformationGateway.GetEmployeeID(requestId);
                        int rejectedById = (int)ViewState["rejected_by_id"];

                        EmployeeGateway employeesGateway = new EmployeeGateway();
                        employeesGateway.LoadByEmployeeId(employeeId);

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

                        subject = "Vacation request from " + vacationsInformationRequestsInformationGateway.GetStartDate(requestId).ToShortDateString() + " to " + vacationsInformationRequestsInformationGateway.GetEndDate(requestId).ToShortDateString();

                        // Mails body
                        body = body + "\nHi " + nameTo + ",\n\nThe following vacation request has been rejected: \n\n";
                        body = body + "\t - Vacation request from " + vacationsInformationRequestsInformationGateway.GetStartDate(requestId).ToShortDateString() + " to " + vacationsInformationRequestsInformationGateway.GetEndDate(requestId).ToShortDateString() + "\n";
                        body = body + "\t - Detail: " + vacationsInformationRequestsInformationGateway.GetDetails(requestId) + "\n";
                        body = body + "\t - Comment: " + rejectReason;

                        EmployeeGateway employeeRejected = new EmployeeGateway();
                        employeeRejected.LoadByEmployeeId(rejectedById);

                        if (employeeRejected.Table.Rows.Count > 0)
                        {
                            body = body + "\n" + "\t - Rejected by: " + employeeRejected.GetFirstName(rejectedById) + " " + employeeRejected.GetLastName(rejectedById);
                        }

                        //Send Mail
                        SendMail(mailTo, subject, body);
                    }
                }
            }
        }
        /// <summary>
        /// UpdateForProcess
        /// </summary>
        /// <param name="projectId">projectId</param>
        /// <param name="companiesId">companiesId</param>
        /// <param name="salesmanId">salesmanId</param>
        /// <param name="projectLeadId">projectLeadId</param>
        /// <param name="companyId">companyId</param>
        public void UpdateForReport(int projectId, int companiesId, int salesmanId, int projectLeadId, int companyId)
        {
            CompaniesGateway companiesGateway = new CompaniesGateway();
            AddressGateway addressGateway = new AddressGateway();
            ContactsGateway contactsGateway = new ContactsGateway();
            PhoneGateway phoneGateway = new PhoneGateway();
            EmployeeGateway employeeGateway = new EmployeeGateway();

            ProjectSynopsisReportTDS.LFS_PROJECTRow projectRow = GetProjectRow(projectId);

            // Companies Name
            companiesGateway.LoadAllByCompaniesId(companiesId, companyId);
            projectRow.ClientName = companiesGateway.GetName(companiesId);

            // Companies Address
            addressGateway.LoadByCompaniesId(companiesId, companyId);
            projectRow.ClientAddress = addressGateway.GetAddressByCompaniesId(companiesId);

            // Submitted By
            // ...If the project has a record at history
            employeeGateway.LoadByEmployeeId(salesmanId);
            projectRow.SubmittedBy = employeeGateway.GetLastName(salesmanId) + " " + employeeGateway.GetFirstName(salesmanId);

            // ... Leaded By
            if (projectLeadId > 0)
            {
                employeeGateway.LoadByEmployeeId(projectLeadId);
                projectRow.LeadedBy = employeeGateway.GetLastName(projectLeadId) + " " + employeeGateway.GetFirstName(projectLeadId);
            }
            else
            {
                projectRow.LeadedBy = "";
            }

            // ... Primary contact
            if (!projectRow.IsClientPrimaryContactIDNull())
            {
                // ... ... Primary contact name
                contactsGateway.LoadAllByContactId(projectRow.ClientPrimaryContactID, companyId);
                projectRow.ClientPrimaryContactName = contactsGateway.GetCompleteName(projectRow.ClientPrimaryContactID);

                // ... ... Primary contact position
                projectRow.ClientPrimaryContactPosition = contactsGateway.GetCompaniesPosition(projectRow.ClientPrimaryContactID);

                // ... ... Phone
                phoneGateway.LoadByContactId(projectRow.ClientPrimaryContactID, companyId);
                projectRow.ClientPrimaryContactPhones = phoneGateway.GetPhones(projectRow.ClientPrimaryContactID);
            }

            // ... Secondary contact
            if (!projectRow.IsClientSecondaryContactIDNull())
            {
                // ... ... Primary contact name
                contactsGateway.LoadAllByContactId(projectRow.ClientSecondaryContactID, companyId);
                projectRow.ClientSecondaryContactName = contactsGateway.GetCompleteName(projectRow.ClientSecondaryContactID);

                // ... ... Primary contact position
                projectRow.ClientSecondaryContactPosition = contactsGateway.GetCompaniesPosition(projectRow.ClientSecondaryContactID);

                // ... ... Phone
                phoneGateway.LoadByContactId(projectRow.ClientSecondaryContactID, companyId);
                projectRow.ClientSecondaryContactPhones = phoneGateway.GetPhones(projectRow.ClientSecondaryContactID);
            }
        }
        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 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 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);
        }
        private void SendMailEmployees(DataRow[] drEmployees)
        {
            // Get mail information
            string mailTo = "";
            string nameTo = "";
            string body = "";
            string subject = "";

            List<int> employeeIds = new List<int>();
            int lastEmployeeId = 0;
            int lastApprovedById = 0;

            foreach (DataRow row in drEmployees)
            {
                lastEmployeeId = ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).EmployeeID;
                lastApprovedById = ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).ApprovedByID;

                if (!employeeIds.Contains(lastEmployeeId))
                {
                    employeeIds.Add(lastEmployeeId);

                    if (body.Length > 0)
                    {
                        EmployeeGateway employeeApproved = new EmployeeGateway();
                        employeeApproved.LoadByEmployeeId(lastApprovedById);

                        if (employeeApproved.Table.Rows.Count > 0)
                        {
                            body = body + "\n\nApproved by " + employeeApproved.GetFirstName(lastApprovedById) + " " + employeeApproved.GetLastName(lastApprovedById);
                        }

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

                        mailTo = "";
                        nameTo = "";
                        subject = "";
                        body = "";
                    }

                    EmployeeGateway employeesGateway = new EmployeeGateway();
                    employeesGateway.LoadByEmployeeId(lastEmployeeId);

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

                        subject = "Project Times Approved";

                        // Mails body
                        body = body + "\nHi " + nameTo + ",\n\nThe followings project time has been approved: \n\n";
                        if (!((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).IsStartTimeNull() && !((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).IsEndTimeNull())
                        {
                            body = body + "\t - Project Time for " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).Date_.ToShortDateString() + ", Start Time: " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).StartTime.ToShortTimeString() + ", End Time: " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).EndTime.ToShortTimeString() + "\n";
                        }
                        else
                        {
                            body = body + "\t - Project Time for " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).Date_.ToShortDateString() + ", " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).WorkingDetails;
                        }
                    }
                }
                else
                {
                    if (!((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).IsStartTimeNull() && !((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).IsEndTimeNull())
                    {
                        body = body + "\t - Project Time for " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).Date_.ToShortDateString() + ", Start Time: " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).StartTime.ToShortTimeString() + ", End Time: " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).EndTime.ToShortTimeString() + "\n";
                    }
                    else
                    {
                        body = body + "\t - Project Time for " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).Date_.ToShortDateString() + ", " + ((ProjectTimeTDS.LFS_PROJECT_TIMERow)row).WorkingDetails;
                    }
                }
            }

            if (body.Length > 0)
            {
                EmployeeGateway employeeApproved = new EmployeeGateway();
                employeeApproved.LoadByEmployeeId(lastApprovedById);

                if (employeeApproved.Table.Rows.Count > 0)
                {
                    body = body + "\n\nApproved by " + employeeApproved.GetFirstName(lastApprovedById) + " " + employeeApproved.GetLastName(lastApprovedById);
                }

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

                mailTo = "";
                nameTo = "";
                subject = "";
                body = "";
            }
        }
        private void LoadDetailedData(int serviceId)
        {
            ServiceInformationBasicInformationGateway serviceInformationBasicInformationGateway = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
            if (serviceInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load for General Tab
                tbxGeneralCreatedBy.Text = serviceInformationBasicInformationGateway.GetCreatedBy(serviceId);
                tbxGeneralMileage.Text = serviceInformationBasicInformationGateway.GetMileage(serviceId);
                lblGeneralMileageUnitOfMeasurement.Text = serviceInformationBasicInformationGateway.GetMileageUnitOfMeasurement(serviceId);

                // Load for Assginment Tab
                tbxAssignmentDataAssignmentDateTime.Text = serviceInformationBasicInformationGateway.GetAssignmentDateTime(serviceId).ToString();

                tbxAssignmentDataAssignedDeadlineDate.Text = "";
                if (serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId).HasValue)
                {
                    DateTime deadlineDate = (DateTime)serviceInformationBasicInformationGateway.GetAssignedDeadlineDate(serviceId);
                    tbxAssignmentDataAssignedDeadlineDate.Text = deadlineDate.Month.ToString() + "/" + deadlineDate.Day.ToString() + "/" + deadlineDate.Year.ToString();
                }

                if ((serviceInformationBasicInformationGateway.GetToTeamMember(serviceId)) && (serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId)) == "")
                {
                    // ... For team member
                    rbtnAssignmentDataToTeamMember.Checked = true;
                    if (serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId).HasValue)
                    {
                        int teamMemberId = (int)serviceInformationBasicInformationGateway.GetAssignTeamMemberId(serviceId);
                        EmployeeGateway employeeGateway = new EmployeeGateway();
                        employeeGateway.LoadByEmployeeId(teamMemberId);

                        tbxAssigmentDataToTeamMemberName.Text = employeeGateway.GetLastName(teamMemberId) + " " + employeeGateway.GetFirstName(teamMemberId);
                    }

                    // ... For third party vendor
                    rbtnAssignmentDataToThirdPartyVendor.Checked = false;
                }
                else
                {
                    if ((!serviceInformationBasicInformationGateway.GetToTeamMember(serviceId)) && (serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId)) != "")
                    {
                        // ... For team member
                        rbtnAssignmentDataToTeamMember.Checked = false;

                        // ... For third party vendor
                        rbtnAssignmentDataToThirdPartyVendor.Checked = true;
                        tbxAssignmentDataAssignToThirdPartyVendor.Text = serviceInformationBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId);
                    }
                    else
                    {
                        rbtnAssignmentDataToTeamMember.Checked = false;
                        rbtnAssignmentDataToThirdPartyVendor.Checked = false;
                    }
                }

                tbxAssignmentDataAcceptedDateTime.Text = serviceInformationBasicInformationGateway.GetAcceptedDateTime(serviceId).ToString();

                DateTime? acceptedDateTime = serviceInformationBasicInformationGateway.GetAcceptedDateTime(serviceId);
                if (acceptedDateTime.HasValue) tbxAssignmentDataAcceptedDateTime.Text = acceptedDateTime.ToString();

                DateTime? rejectedDateTime = serviceInformationBasicInformationGateway.GetRejectedDateTime(serviceId);
                if (rejectedDateTime.HasValue) tbxAssignmentDataRejectedDateTime.Text = rejectedDateTime.ToString();
                tbxAssignmentDataRejectedReason.Text = serviceInformationBasicInformationGateway.GetRejectedReason(serviceId);

                // Load for StartWork Tab
                tbxStartWorkDataWorkStartDateTime.Text = serviceInformationBasicInformationGateway.GetStartWorkDateTime(serviceId).ToString();

                tbxStartWorkDataUnitOutOfServiceDate.Text = "";
                if (serviceInformationBasicInformationGateway.GetUnitOutOfServiceDate(serviceId).HasValue)
                {
                    DateTime outOfServiceDate = (DateTime)serviceInformationBasicInformationGateway.GetUnitOutOfServiceDate(serviceId);
                    tbxStartWorkDataUnitOutOfServiceDate.Text = outOfServiceDate.Month.ToString() + "/" + outOfServiceDate.Day.ToString() + "/" + outOfServiceDate.Year.ToString();
                }

                tbxStartWorkDataStartMileage.Text = serviceInformationBasicInformationGateway.GetStartWorkMileage(serviceId);
                lblStartWorkDataMileageUnitOfMeasurement.Text = serviceInformationBasicInformationGateway.GetMileageUnitOfMeasurement(serviceId);

                // Load for Complete Work Tab
                tbxCompleteWorkDataCompleteWorkDateTime.Text = serviceInformationBasicInformationGateway.GetCompleteWorkDateTime(serviceId).ToString();

                tbxCompleteWorkDataUnitBackInServiceDate.Text = "";
                if (serviceInformationBasicInformationGateway.GetUnitBackInServiceDate(serviceId).HasValue)
                {
                    DateTime backInServiceDate = (DateTime)serviceInformationBasicInformationGateway.GetUnitBackInServiceDate(serviceId);
                    tbxCompleteWorkDataUnitBackInServiceDate.Text = backInServiceDate.Month.ToString() + "/" + backInServiceDate.Day.ToString() + "/" + backInServiceDate.Year.ToString();
                }

                tbxCompleteWorkDataCompleteMileage.Text = serviceInformationBasicInformationGateway.GetCompleteWorkMileage(serviceId);
                lblCompleteWorkDataMileageUnitOfMeasurement.Text = serviceInformationBasicInformationGateway.GetMileageUnitOfMeasurement(serviceId);

                // ... For team member
                tbxCompleteWorkDataDescription.Text = serviceInformationBasicInformationGateway.GetCompleteWorkDetailDescription(serviceId);
                ckbxCompleteWorkDataPreventable.Checked = serviceInformationBasicInformationGateway.GetCompleteWorkDetailPreventable(serviceId);
                tbxCompleteWorkDataLabourHours.Text = serviceInformationBasicInformationGateway.GetCompleteWorkDetailTMLabourHours(serviceId).ToString();

                // ... For third party vendor
                tbxCompleteWorkDataDescriptionThirdPartyVendor.Text = serviceInformationBasicInformationGateway.GetCompleteWorkDetailDescription(serviceId);
                ckbxCompleteWorkDataPreventableThirdPartyVendor.Checked = serviceInformationBasicInformationGateway.GetCompleteWorkDetailPreventable(serviceId);
                tbxCompleteWorkDataInvoiceNumberThirdPartyVendor.Text = serviceInformationBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceNumber(serviceId);
                tbxCompleteWorkDataInvoiceAmountThirdPartyVendor.Text = serviceInformationBasicInformationGateway.GetCompleteWorkDetailTPVInvoiceAmout(serviceId).ToString();
            }
        }
        protected string GetEmployeeName(object employeeId)
        {
            if (employeeId != DBNull.Value)
            {
                EmployeeGateway employeeGateway = new EmployeeGateway();
                employeeGateway.LoadByEmployeeId((int)employeeId);

                if (employeeGateway.Table.Rows.Count > 0)
                {
                    return employeeGateway.GetLastName((int)employeeId) + " " + employeeGateway.GetFirstName((int)employeeId);
                }

                return "";
            }

            return "";
        }