/// <summary> /// Fills data with rows loaded from PrintHoursForProjectsGateway /// </summary> /// <param name="companyId">companyId</param> public void FillData(int companyId) { // Fill rows from original data PrintHoursForProjectOriginalGateway originalGateway = new PrintHoursForProjectOriginalGateway(Data); foreach (PrintHoursForProjectTDS.OriginalRow originalRow in (PrintHoursForProjectTDS.OriginalDataTable)originalGateway.Table) { PrintHoursForProjectTDS.PrintHoursForProjectRow newRow = ((PrintHoursForProjectTDS.PrintHoursForProjectDataTable)Table).NewPrintHoursForProjectRow(); newRow.ClientID = originalRow.ClientID; newRow.ClientName = originalRow.ClientName; newRow.ProjectName = originalRow.ProjectName; newRow.CountryID = originalRow.CountryID; newRow.CountryName = originalRow.CountryName; newRow.EmployeeID = originalRow.EmployeeID; newRow.EmployeeName = originalRow.EmployeeName; newRow.Type = originalRow.Type; newRow.Date_ = originalRow.Date_; if (originalRow.CountryID == 1) { newRow.TimeCA = originalRow.ProjectTime; newRow.TimeUS = 0; } else { newRow.TimeCA = 0; newRow.TimeUS = originalRow.ProjectTime; } if ((originalRow.WorkingDetails == "Sick Day") || (originalRow.WorkingDetails == "Holiday") || (originalRow.WorkingDetails == "Vacation / Other")) { newRow.WorkingDetails = originalRow.WorkingDetails; } else { newRow.WorkingDetails = ""; } if (!originalRow.IsMealsCountryNull()) { if (originalRow.MealsCountry == 1) { newRow.MealsCA = true; newRow.MealsUS = false; newRow.TotalCA = originalRow.MealsAllowance; newRow.TotalUS = 0; } else { newRow.MealsCA = false; newRow.MealsUS = true; newRow.TotalCA = 0; newRow.TotalUS = originalRow.MealsAllowance; } } else { newRow.MealsCA = false; newRow.MealsUS = false; newRow.TotalCA = 0; newRow.TotalUS = 0; } if (!originalRow.IsCommentsNull()) { newRow.Comments = originalRow.Comments; } if (!originalRow.IsUnitIDNull()) { UnitInformationUnitDetailsGateway unitInformationUnitDetailsGatewayForUnit = new UnitInformationUnitDetailsGateway(); unitInformationUnitDetailsGatewayForUnit.LoadAllByUnitId(originalRow.UnitID, companyId); newRow.Unit = unitInformationUnitDetailsGatewayForUnit.GetUnitCode(originalRow.UnitID); } if (!originalRow.IsProjectTimeStateNull()) { newRow.ProjectTimeState = originalRow.ProjectTimeState; } else { newRow.ProjectTimeState = "New"; } if (!originalRow.IsTowedUnitIDNull()) { UnitInformationUnitDetailsGateway unitInformationUnitDetailsGatewayForTowedUnit = new UnitInformationUnitDetailsGateway(); unitInformationUnitDetailsGatewayForTowedUnit.LoadAllByUnitId(originalRow.TowedUnitID, companyId); newRow.Towed = unitInformationUnitDetailsGatewayForTowedUnit.GetUnitCode(originalRow.TowedUnitID); } ((PrintHoursForProjectTDS.PrintHoursForProjectDataTable)Table).AddPrintHoursForProjectRow(newRow); } }
private void LoadBasicData(int unitId) { UnitInformationUnitDetailsGateway unitInformationUnitDetailsGateway = new UnitInformationUnitDetailsGateway(unitInformationTDS); if (unitInformationUnitDetailsGateway.Table.Rows.Count > 0) { // Load unit basic data tbxUnitState.Text = unitInformationUnitDetailsGateway.GetState(unitId); tbxCode.Text = unitInformationUnitDetailsGateway.GetUnitCode(unitId); tbxDescription.Text = unitInformationUnitDetailsGateway.GetDescription(unitId); tbxVinSn.Text = unitInformationUnitDetailsGateway.GetVin(unitId); tbxManufacturer.Text = unitInformationUnitDetailsGateway.GetManufacturer(unitId); tbxModel.Text = unitInformationUnitDetailsGateway.GetModel(unitId); tbxYear.Text = unitInformationUnitDetailsGateway.GetYear_(unitId); if (unitInformationUnitDetailsGateway.GetIsTowable(unitId)) cbxIsTowable.Checked = true; else cbxIsTowable.Checked = false; if (!String.IsNullOrEmpty(unitInformationUnitDetailsGateway.GetInsuranceClass(unitId))) ddlInsuranceClass.SelectedValue = unitInformationUnitDetailsGateway.GetInsuranceClass(unitId); if (unitInformationUnitDetailsGateway.GetInsuranceClass(unitId) == "Ryder Specified") { lblRyderSpecified.Visible = true; tbxRyderSpecified.Visible = true; tbxRyderSpecified.Text = unitInformationUnitDetailsGateway.GetInsuranceClassRyderSpecified(unitId); upnlRyderSpecifiedLabel.Update(); upnlRyderSpecified.Update(); } // Load for General Tab if (upnlGeneralDataEdit.Visible) { tbxPurchasePrice.Text = ""; if (unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).HasValue) tbxPurchasePrice.Text = Math.Round(unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).Value, 2).ToString(); tkrdpScrapDate.SelectedDate = null; if (unitInformationUnitDetailsGateway.GetScrapDate(unitId).HasValue) tkrdpScrapDate.SelectedDate = (DateTime)unitInformationUnitDetailsGateway.GetScrapDate(unitId); tbxSaleProceeds.Text = ""; if (unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).HasValue) tbxSaleProceeds.Text = Math.Round(unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).Value, 2).ToString(); } else { tbxPurchasePriceSummary.Text = ""; if (unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).HasValue) tbxPurchasePriceSummary.Text = Math.Round(unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).Value, 2).ToString(); tbxScrapDateSummary.Text = ""; if (unitInformationUnitDetailsGateway.GetScrapDate(unitId).HasValue) tbxScrapDateSummary.Text = unitInformationUnitDetailsGateway.GetScrapDate(unitId).Value.ToShortDateString(); tbxSaleProceedsSummary.Text = ""; if (unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).HasValue) tbxSaleProceedsSummary.Text = Math.Round(unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).Value, 2).ToString(); } } }
private void LoadBasicData(int unitId) { UnitInformationUnitDetailsGateway unitInformationUnitDetailsGateway = new UnitInformationUnitDetailsGateway(unitInformationTDS); if (unitInformationUnitDetailsGateway.Table.Rows.Count > 0) { // Load unit basic data tbxUnitState.Text = unitInformationUnitDetailsGateway.GetState(unitId); tbxCode.Text = unitInformationUnitDetailsGateway.GetUnitCode(unitId); tbxDescription.Text = unitInformationUnitDetailsGateway.GetDescription(unitId); tbxVinSn.Text = unitInformationUnitDetailsGateway.GetVin(unitId); tbxManufacturer.Text = unitInformationUnitDetailsGateway.GetManufacturer(unitId); tbxModel.Text = unitInformationUnitDetailsGateway.GetModel(unitId); tbxYear.Text = unitInformationUnitDetailsGateway.GetYear_(unitId); if (unitInformationUnitDetailsGateway.GetIsTowable(unitId)) cbxIsTowable.Checked = true; else cbxIsTowable.Checked = false; tbxInsuranceClass.Text = unitInformationUnitDetailsGateway.GetInsuranceClass(unitId); if (unitInformationUnitDetailsGateway.GetInsuranceClass(unitId) == "Ryder Specified") { lblRyderSpecified.Visible = true; tbxRyderSpecified.Visible = true; tbxRyderSpecified.Text = unitInformationUnitDetailsGateway.GetInsuranceClassRyderSpecified(unitId); } else { lblRyderSpecified.Visible = false; tbxRyderSpecified.Visible = false; } tbxPurchasePrice.Text = ""; if (unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).HasValue) tbxPurchasePrice.Text = Math.Round(unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).Value, 2).ToString(); tbxScrapDate.Text = ""; if (unitInformationUnitDetailsGateway.GetScrapDate(unitId).HasValue) tbxScrapDate.Text = unitInformationUnitDetailsGateway.GetScrapDate(unitId).Value.ToShortDateString(); tbxSaleProceeds.Text = ""; if (unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).HasValue) tbxSaleProceeds.Text = Math.Round(unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).Value, 2).ToString(); } }
/// <summary> /// Save /// </summary> /// <param name="categoriesSelected">categoriesSelected</param> /// <param name="companyId">companyId</param> public void Save(ArrayList categoriesSelected, int companyId) { UnitInformationTDS unitsInformationChanges = (UnitInformationTDS)Data.GetChanges(); if (unitsInformationChanges.UnitDetails.Rows.Count > 0) { UnitInformationUnitDetailsGateway unitInformationUnitDetailsGateway = new UnitInformationUnitDetailsGateway(unitsInformationChanges); // Update unit foreach (UnitInformationTDS.UnitDetailsRow unitDetailsRow in (UnitInformationTDS.UnitDetailsDataTable)unitsInformationChanges.UnitDetails) { // Unchanged values int unitId = unitDetailsRow.UnitID; string state = unitInformationUnitDetailsGateway.GetState(unitId); string type = unitInformationUnitDetailsGateway.GetType(unitId); bool deleted = false; string notes = ""; if (!unitDetailsRow.IsNotesNull()) notes = unitDetailsRow.Notes; string originalCategories = ""; if (!unitDetailsRow.IsCategoriesNull()) originalCategories = unitDetailsRow.Categories; // Original Unit values string originalUnitCode = unitInformationUnitDetailsGateway.GetUnitCodeOriginal(unitId); string originalDescription = unitInformationUnitDetailsGateway.GetDescriptionOriginal(unitId); string originalVin = unitInformationUnitDetailsGateway.GetVinOriginal(unitId); string originalManufacturer = unitInformationUnitDetailsGateway.GetManufacturerOriginal(unitId); string originalModel = unitInformationUnitDetailsGateway.GetModelOriginal(unitId); string originalYear_ = unitInformationUnitDetailsGateway.GetYear_Original(unitId); bool originalIsTowable = unitInformationUnitDetailsGateway.GetIsTowableOriginal(unitId); int originalCompanyLevelId = unitInformationUnitDetailsGateway.GetCompanyLevelIdOriginal(unitId); DateTime? originalAcquisitionDate = null; if (unitInformationUnitDetailsGateway.GetAcquisitionDateOriginal(unitId).HasValue) originalAcquisitionDate = (DateTime)unitInformationUnitDetailsGateway.GetAcquisitionDateOriginal(unitId); DateTime? originalDispositionDate = null; if (unitInformationUnitDetailsGateway.GetDispositionDateOriginal(unitId).HasValue) originalDispositionDate = (DateTime)unitInformationUnitDetailsGateway.GetDispositionDateOriginal(unitId); string originalDispositionReason = unitInformationUnitDetailsGateway.GetDispositionReasonOriginal(unitId); string originalOwnerType = unitInformationUnitDetailsGateway.GetOwnerTypeOriginal(unitId); Int64? originalOwnerCountry = null; if (unitInformationUnitDetailsGateway.GetOwnerCountryOriginal(unitId).HasValue) originalOwnerCountry = (Int64)unitInformationUnitDetailsGateway.GetOwnerCountryOriginal(unitId); Int64? originalOwnerState = null; if (unitInformationUnitDetailsGateway.GetOwnerStateOriginal(unitId).HasValue) originalOwnerState = (Int64)unitInformationUnitDetailsGateway.GetOwnerStateOriginal(unitId); string originalOwnerName = unitInformationUnitDetailsGateway.GetOwnerNameOriginal(unitId); string originalOwnerContact = unitInformationUnitDetailsGateway.GetOwnerContactOriginal(unitId); DateTime? originalQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetQualifiedDateOriginal(unitId).HasValue) originalQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetQualifiedDateOriginal(unitId); DateTime? originalNotQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetNotQualifiedDateOriginal(unitId).HasValue) originalNotQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetNotQualifiedDateOriginal(unitId); string originalNotQualifiedExplain = unitInformationUnitDetailsGateway.GetNotQualifiedExplainOriginal(unitId); string originalInsuranceClass = unitInformationUnitDetailsGateway.GetInsuranceClassOriginal(unitId); string originalInsuranceClassRyderSpecified = unitInformationUnitDetailsGateway.GetInsuranceClassRyderSpecifiedOriginal(unitId); decimal? originalPurchasePrice = null; if (unitInformationUnitDetailsGateway.GetPurchasePriceOriginal(unitId).HasValue) originalPurchasePrice = unitInformationUnitDetailsGateway.GetPurchasePriceOriginal(unitId).Value; DateTime? originalScrapDate = null; if (unitInformationUnitDetailsGateway.GetScrapDateOriginal(unitId).HasValue) originalScrapDate = (DateTime)unitInformationUnitDetailsGateway.GetScrapDateOriginal(unitId); decimal? originalSaleProceeds = null; if (unitInformationUnitDetailsGateway.GetSaleProceedsOriginal(unitId).HasValue) originalSaleProceeds = unitInformationUnitDetailsGateway.GetSaleProceedsOriginal(unitId).Value; int? originalLibraryCategoriesId = null; if (unitInformationUnitDetailsGateway.GetLibraryCategoriesIdOriginal(unitId).HasValue) originalLibraryCategoriesId = unitInformationUnitDetailsGateway.GetLibraryCategoriesIdOriginal(unitId).Value; // New Unit values string newUnitCode = unitInformationUnitDetailsGateway.GetUnitCode(unitId); string newDescription = unitInformationUnitDetailsGateway.GetDescription(unitId); string newVin = unitInformationUnitDetailsGateway.GetVin(unitId); string newManufacturer = unitInformationUnitDetailsGateway.GetManufacturer(unitId); string newModel = unitInformationUnitDetailsGateway.GetModel(unitId); string newYear_ = unitInformationUnitDetailsGateway.GetYear_(unitId); bool newIsTowable = unitInformationUnitDetailsGateway.GetIsTowable(unitId); int newCompanyLevelId = unitInformationUnitDetailsGateway.GetCompanyLevelId(unitId); DateTime? newAcquisitionDate = null; if (unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId).HasValue) newAcquisitionDate = (DateTime)unitInformationUnitDetailsGateway.GetAcquisitionDate(unitId); DateTime? newDispositionDate = null; if (unitInformationUnitDetailsGateway.GetDispositionDate(unitId).HasValue) newDispositionDate = (DateTime)unitInformationUnitDetailsGateway.GetDispositionDate(unitId); string newDispositionReason = unitInformationUnitDetailsGateway.GetDispositionReason(unitId); string newOwnerType = unitInformationUnitDetailsGateway.GetOwnerType(unitId); Int64? newOwnerCountry = null; if (unitInformationUnitDetailsGateway.GetOwnerCountry(unitId).HasValue) newOwnerCountry = (Int64)unitInformationUnitDetailsGateway.GetOwnerCountry(unitId); Int64? newOwnerState = null; if (unitInformationUnitDetailsGateway.GetOwnerState(unitId).HasValue) newOwnerState = (Int64)unitInformationUnitDetailsGateway.GetOwnerState(unitId); string newOwnerName = unitInformationUnitDetailsGateway.GetOwnerName(unitId); string newOwnerContact = unitInformationUnitDetailsGateway.GetOwnerContact(unitId); DateTime? newQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetQualifiedDate(unitId).HasValue) newQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetQualifiedDate(unitId); DateTime? newNotQualifiedDate = null; if (unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId).HasValue) newNotQualifiedDate = (DateTime)unitInformationUnitDetailsGateway.GetNotQualifiedDate(unitId); string newNotQualifiedExplain = unitInformationUnitDetailsGateway.GetNotQualifiedExplain(unitId); string newCategories = ""; if (categoriesSelected.Count > 0) { foreach (int categoryId in categoriesSelected) { CategoryGateway categoryGateway = new CategoryGateway(); categoryGateway.LoadByCategoryId(categoryId, companyId); newCategories = newCategories + categoryGateway.GetName(categoryId) + ", "; } if (newCategories.Length > 2) { newCategories = newCategories.Substring(0, newCategories.Length - 2); } } string newInsuranceClass = unitInformationUnitDetailsGateway.GetInsuranceClass(unitId); string newInsuranceClassRyderSpecified = unitInformationUnitDetailsGateway.GetInsuranceClassRyderSpecified(unitId); decimal? newPurchasePrice = null; if (unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).HasValue) newPurchasePrice = unitInformationUnitDetailsGateway.GetPurchasePrice(unitId).Value; DateTime? newScrapDate = null; if (unitInformationUnitDetailsGateway.GetScrapDate(unitId).HasValue) newScrapDate = (DateTime)unitInformationUnitDetailsGateway.GetScrapDate(unitId); decimal? newSaleProceeds = null; if (unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).HasValue) newSaleProceeds = unitInformationUnitDetailsGateway.GetSaleProceeds(unitId).Value; int? newLibraryCategoriesId = null; if (unitInformationUnitDetailsGateway.GetLibraryCategoriesId(unitId).HasValue) newLibraryCategoriesId = unitInformationUnitDetailsGateway.GetLibraryCategoriesId(unitId).Value; // Update unit UpdateUnit(unitId, originalUnitCode, originalDescription, originalVin, originalManufacturer, originalModel, originalYear_, originalIsTowable, originalCompanyLevelId, originalAcquisitionDate, originalDispositionDate, originalDispositionReason, originalOwnerType, originalOwnerCountry, originalOwnerState, originalOwnerName, originalOwnerContact, originalQualifiedDate, originalNotQualifiedDate, originalNotQualifiedExplain, state, type, deleted, companyId, notes, originalCategories, originalInsuranceClass, originalInsuranceClassRyderSpecified, originalPurchasePrice, originalScrapDate, originalSaleProceeds, originalLibraryCategoriesId, unitId, newUnitCode, newDescription, newVin, newManufacturer, newModel, newYear_, newIsTowable, newCompanyLevelId, newAcquisitionDate, newDispositionDate, newDispositionReason, newOwnerType, newOwnerCountry, newOwnerState, newOwnerName, newOwnerContact, newQualifiedDate, newNotQualifiedDate, newNotQualifiedExplain, state, type, deleted, companyId, notes, newCategories, newInsuranceClass, newInsuranceClassRyderSpecified, newPurchasePrice, newScrapDate, newSaleProceeds, newLibraryCategoriesId); UpdateUnitCategory(unitId, companyId, categoriesSelected, newCompanyLevelId); if (type == "Vehicle") { // Original Unit Vehicle values Int64? originalLicenseCountry = null; if (unitInformationUnitDetailsGateway.GetLicenseCountryOriginal(unitId).HasValue) originalLicenseCountry = (Int64)unitInformationUnitDetailsGateway.GetLicenseCountryOriginal(unitId); Int64? originalLicenseState = null; if (unitInformationUnitDetailsGateway.GetLicenseStateOriginal(unitId).HasValue) originalLicenseState = (Int64)unitInformationUnitDetailsGateway.GetLicenseStateOriginal(unitId); string originalLicensePlateNumber = unitInformationUnitDetailsGateway.GetLicensePlateNumbverOriginal(unitId); string originalAportionedTagNumber = unitInformationUnitDetailsGateway.GetAportionedTagNumberOriginal(unitId); string originalActualWeight = unitInformationUnitDetailsGateway.GetActualWeightOriginal(unitId); string originalRegisteredWeight = unitInformationUnitDetailsGateway.GetRegisteredWeightOriginal(unitId); string originalTireSizeFront = unitInformationUnitDetailsGateway.GetTireSizeFrontOriginal(unitId); string originalTireSizeBack = unitInformationUnitDetailsGateway.GetTireSizeBackOriginal(unitId); string originalNumberOfAxes = unitInformationUnitDetailsGateway.GetNumberOfAxesOriginal(unitId); string originalFuelType = unitInformationUnitDetailsGateway.GetFuelTypeOriginal(unitId); string originalBeginningOdometer = unitInformationUnitDetailsGateway.GetBeginningOdometerOriginal(unitId); bool originalIsReeferEquipped = unitInformationUnitDetailsGateway.GetIsReeferEquippedOriginal(unitId); bool originalIsPtoEquipped = unitInformationUnitDetailsGateway.GetIsPTOEquippedOriginal(unitId); // New Unit Vehicle values Int64? newLicenseCountry = null; if (unitInformationUnitDetailsGateway.GetLicenseCountry(unitId).HasValue) newLicenseCountry = (Int64)unitInformationUnitDetailsGateway.GetLicenseCountry(unitId); Int64? newLicenseState = null; if (unitInformationUnitDetailsGateway.GetLicenseState(unitId).HasValue) newLicenseState = (Int64)unitInformationUnitDetailsGateway.GetLicenseState(unitId); string newLicensePlateNumber = unitInformationUnitDetailsGateway.GetLicensePlateNumbver(unitId); string newAportionedTagNumber = unitInformationUnitDetailsGateway.GetAportionedTagNumber(unitId); string newActualWeight = unitInformationUnitDetailsGateway.GetActualWeight(unitId); string newRegisteredWeight = unitInformationUnitDetailsGateway.GetRegisteredWeight(unitId); string newTireSizeFront = unitInformationUnitDetailsGateway.GetTireSizeFront(unitId); string newTireSizeBack = unitInformationUnitDetailsGateway.GetTireSizeBack(unitId); string newNumberOfAxes = unitInformationUnitDetailsGateway.GetNumberOfAxes(unitId); string newFuelType = unitInformationUnitDetailsGateway.GetFuelType(unitId); string newBeginningOdometer = unitInformationUnitDetailsGateway.GetBeginningOdometer(unitId); bool newIsReeferEquipped = unitInformationUnitDetailsGateway.GetIsReeferEquipped(unitId); bool newIsPtoEquipped = unitInformationUnitDetailsGateway.GetIsPTOEquipped(unitId); UpdateUnitVehicle(unitId, originalLicenseCountry, originalLicenseState, originalLicensePlateNumber, originalAportionedTagNumber, originalActualWeight, originalRegisteredWeight, originalTireSizeFront, originalTireSizeBack, originalNumberOfAxes, originalFuelType, originalBeginningOdometer, originalIsReeferEquipped, originalIsPtoEquipped, deleted, companyId, unitId, newLicenseCountry, newLicenseState, newLicensePlateNumber, newAportionedTagNumber, newActualWeight, newRegisteredWeight, newTireSizeFront, newTireSizeBack, newNumberOfAxes, newFuelType, newBeginningOdometer, newIsReeferEquipped, newIsPtoEquipped, deleted, companyId); } } } }