Esempio n. 1
0
        public String[] GetManufacturerList(string prefixText, int count, string contextKey)
        {
            int companyId = int.Parse(contextKey);//

            // load Manufacturer's
            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.LoadSimilarTop12(prefixText, companyId);

            // process list and return
            if (unitsGateway.Table.Rows.Count == 0)
            {
                return new string[0];
            }
            else
            {
                List<string> items = new List<string>(count);
                for (int i = 0; (i < count) & (i < unitsGateway.Table.Rows.Count); i++)
                {
                    if (!items.Contains(unitsGateway.Table.Rows[i]["Manufacturer"].ToString()))
                    {
                        items.Add(unitsGateway.Table.Rows[i]["Manufacturer"].ToString());
                    }
                }

                return items.ToArray();
            }
        }
        /// <summary>
        /// CompanyLevelIsUsed
        /// </summary>
        /// <param name="companyLevelId">companyLevelId</param>
        /// <param name="companyId">companyId</param>
        /// <returns>True or False</returns>
        public bool CompanyLevelIsUsed(int companyLevelId, int companyId)
        {
            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.Load(companyId);

            LiquiForce.LFSLive.DA.FleetManagement.ChecklistRules.RuleGateway ruleGateway = new RuleGateway();
            ruleGateway.Load(companyId);

            bool inUse = false;

            foreach (UnitsTDS.LFS_FM_UNITRow row in (UnitsTDS.LFS_FM_UNITDataTable)unitsGateway.Table)
            {
                int unitId = row.UnitID;

                if (companyLevelId == row.CompanyLevelID)
                {
                    inUse = true;
                }
            }

            foreach (RuleTDS.LFS_FM_RULERow row in (RuleTDS.LFS_FM_RULEDataTable)ruleGateway.Table)
            {
                int ruleId = row.RuleID;

                RuleCompanyLevelGateway ruleCompanyLevelGateway = new RuleCompanyLevelGateway(null);
                if (ruleCompanyLevelGateway.IsUsedInRuleCompanyLevel(ruleId, companyLevelId))
                {
                    inUse = true;
                }
            }

            return inUse;
        }
        /// <summary>
        /// CategoryIsUsed
        /// </summary>
        /// <param name="categoryId">categoryId</param>
        /// <param name="companyId">companyId</param>
        /// <returns>True or False</returns>
        public bool CategoryIsUsed(int categoryId, int companyId)
        {
            bool inUse = false;
            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.Load(companyId);

            foreach (UnitsTDS.LFS_FM_UNITRow row in (UnitsTDS.LFS_FM_UNITDataTable)unitsGateway.Table)
            {
                int unitId = row.UnitID;

                UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway(null);
                if (unitsCategoryGateway.IsUsedInUnitCategory(unitId, categoryId))
                {
                    inUse = true;
                }
            }

            LiquiForce.LFSLive.DA.FleetManagement.ChecklistRules.RuleGateway ruleGateway = new RuleGateway();
            ruleGateway.Load(companyId);

            foreach (RuleTDS.LFS_FM_RULERow row in (RuleTDS.LFS_FM_RULEDataTable)ruleGateway.Table)
            {
                int ruleId = row.RuleID;

                RuleCategoryGateway ruleCategoryGateway = new RuleCategoryGateway(null);
                if (ruleCategoryGateway.IsUsedInRuleCategory(ruleId, categoryId))
                {
                    inUse = true;
                }
            }

            return inUse;
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            PostPageChanges();

            int unitId = GetUnitId();
            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.LoadByUnitId(unitId, companyId);
            string unitType = unitsGateway.GetType(unitId);
            string unitState = unitsGateway.GetState(unitId);

            if (unitId > 0)
            {
                switch (Delete(unitId, companyId))
                {
                    case 0:
                        // Store active tab for postback
                        Session["activeTabUnits"] = "0";
                        Session["dialogOpenedUnits"] = "0";

                        // Redirect
                        string url = "./units_delete.aspx?source_page=units_navigator2.aspx&unit_id=" + unitId + "&unit_type=" + unitType + "&unit_state=" + unitState + GetNavigatorState() + "&update=yes&active_tab=0";
                        Response.Redirect(url);
                        break;

                    case 1:
                        cvSelection.ErrorMessage = "The unit has been registered in a Timesheet, you cannot delete it.";
                        cvSelection.IsValid = false;
                        break;

                    case 2:
                        cvSelection.ErrorMessage = "The unit has been registered in the Add Team Project Time wizard, you cannot delete him.";
                        cvSelection.IsValid = false;
                        break;

                    case 3:
                        cvSelection.ErrorMessage = "The unit has been registered in the Add Team Project Time wizard, you cannot delete him.";
                        cvSelection.IsValid = false;
                        break;

                    case 4:
                        cvSelection.ErrorMessage = "The unit has services active, you cannot delete him.";
                        cvSelection.IsValid = false;
                        break;
                }
            }
            else
            {
                RestoreNavigatorState();
                cvSelection.IsValid = false;
            }
        }
        public string GetUrl(object str)
        {
            int unitId = Int32.Parse(str.ToString());
            int companyId = Int32.Parse(hdfCompanyId.Value);
            string url = "";

            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.LoadByUnitId(unitId, companyId);
            if (unitsGateway.Table.Rows.Count > 0)
            {
                string unitType = unitsGateway.GetType(unitId);
                string unitState = unitsGateway.GetState(unitId);

                url = "./../../Units/units_summary.aspx?source_page=wucAlarms.ascx&dashboard=True&dashboard=True&unit_id=" + unitId + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=0" + GetNavigatorState();
            }
            return url;
        }
        protected void cvCompleteMileage_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int serviceId = Int32.Parse(hdfServiceId.Value);

            ServiceInformationBasicInformationGateway serviceInformationBasicInformationGatewayForId = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
            int? unitId = serviceInformationBasicInformationGatewayForId.GetUnitID(serviceId);

            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.LoadByUnitId((int)unitId, companyId);
            string unitType = unitsGateway.GetType((int)unitId);

            if (unitType == "Vehicle")
            {
                if (tbxPnlCompleteWorkCompleteMileage.Text == "")
                {
                    args.IsValid = false;
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// DeleteDirect
        /// </summary>
        /// <param name="unitId">unitId</param>
        /// <param name="unitType">unitType</param>
        /// <param name="companyId">companyId</param>
        public void DeleteDirect(int unitId, string unitType, int companyId)
        {
            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.LoadByUnitId(unitId,  companyId);

            if (unitsGateway.Table.Rows.Count > 0)
            {
                // ... Delete unit categories
                UnitsCategory unitsCategory = new UnitsCategory(null);
                UnitsCategoryGateway unitsCategoryGateway = new UnitsCategoryGateway();
                unitsCategoryGateway.LoadByUnitId(unitId, companyId);

                foreach (UnitsTDS.LFS_FM_UNIT_CATEGORYRow rowCategories in (UnitsTDS.LFS_FM_UNIT_CATEGORYDataTable)unitsCategoryGateway.Table)
                {
                    unitsCategory.DeleteDirect(unitId, rowCategories.CategoryID, companyId);
                }

                // ... if vehicle type then delete unit
                if (unitType == "Vehicle")
                {
                    UnitsVehicle unitsVehicle = new UnitsVehicle(null);
                    unitsVehicle.DeleteDirect(unitId, companyId);
                }

                // ... Delete inspections
                UnitsInspection unitsInspection = new UnitsInspection(null);
                UnitsInspectionGateway unitsInspectionGateway = new UnitsInspectionGateway();
                unitsInspectionGateway.LoadByUnitId(unitId, companyId);

                foreach (UnitsTDS.LFS_FM_UNIT_INSPECTIONRow rowInspections in (UnitsTDS.LFS_FM_UNIT_INSPECTIONDataTable)unitsInspectionGateway.Table)
                {
                    unitsInspection.DeletedDirect(unitId, rowInspections.InspectionID, companyId);
                }

                // ... Delete unit
                unitsGateway.Delete(unitId, companyId);
            }
        }
Esempio n. 8
0
 /// <summary>
 /// UpdateStateDirect
 /// </summary>
 /// <param name="originalUnitId">originalUnitId</param>
 /// <param name="originalCompanyId">originalCompanyId</param>
 /// <param name="newState">newState</param>
 public void UpdateStateDirect(int originalUnitId, int originalCompanyId, string newState)
 {
     UnitsGateway unitsGateway = new UnitsGateway(null);
     unitsGateway.UpdateState(originalUnitId, originalCompanyId, newState);
 }
Esempio n. 9
0
 /// <summary>
 /// Update a unit (direct to DB)
 /// </summary>
 /// <param name="originalUnitId">originalUnitId</param>
 /// <param name="originalCode">originalCode</param>
 /// <param name="originalDescription">originalDescription</param>
 /// <param name="originalVin">originalVin</param>
 /// <param name="originalManufacturer">originalManufacturer</param>
 /// <param name="originalModel">originalModel</param>
 /// <param name="originalYear_">originalYear_</param>
 /// <param name="originalIsTowable">originalIsTowable</param>
 /// <param name="originalCompanyLevelId">originalCompanyLevelId</param>
 /// <param name="originalAcquisitionDate">originalAcquisitionDate</param>
 /// <param name="originalDispositionDate">originalDispositionDate</param>
 /// <param name="originalDispositionReason">originalDispositionReason</param>        
 /// <param name="originalOwnerType">originalOwnerType</param>
 /// <param name="originalOwnerCountry">originalOwnerCountry</param>
 /// <param name="originalOwnerState">originalOwnerState</param>
 /// <param name="originalOwnerName">originalOwnerName</param>
 /// <param name="originalOwnerContact">originalOwnerContact</param>
 /// <param name="originalQualifiedDate">originalQualifiedDate</param>
 /// <param name="originalNotQualifiedDate">originalNotQualifiedDate</param>
 /// <param name="originalNotQualifiedExplain">originalNotQualifiedExplain</param>
 /// <param name="originalState">originalState</param>
 /// <param name="originalType">originalType</param>
 /// <param name="originalDeleted">originalDeleted</param>
 /// <param name="originalCompanyId">originalCompanyId</param>
 /// <param name="originalNotes">originalNotes</param>
 /// <param name="originalCategories">originalCategories</param>
 /// <param name="originalInsuranceClass">originalInsuranceClass</param>
 /// <param name="originalInsuranceClassRyderSpecified">originalInsuranceClassRyderSpecified</param>
 /// <param name="originalPurchasePrice">originalPurchasePrice</param>
 /// <param name="originalSaleProceeds">originalSaleProceeds</param>
 /// <param name="originalScrapDate">originalScrapDate</param>
 /// <param name="originalLibraryCategoriesId">originalLibraryCategoriesId</param>
 /// 
 /// <param name="newUnitId">newUnitId</param>
 /// <param name="newCode">newCode</param>
 /// <param name="newDescription">newDescription</param>
 /// <param name="newVin">newVin</param>
 /// <param name="newManufacturer">newManufacturer</param>
 /// <param name="newModel">newModel</param>
 /// <param name="newYear_">newYear_</param>
 /// <param name="newIsTowable">newIsTowable</param>
 /// <param name="newCompanyLevelId">newCompanyLevelId</param>
 /// <param name="newAcquisitionDate">newAcquisitionDate</param>
 /// <param name="newDispositionDate"newDispositionDate></param>
 /// <param name="newDispositionReason">newDispositionReason</param>        
 /// <param name="newOwnerType">newOwnerType</param>
 /// <param name="newOwnerCountry">newOwnerCountry</param>
 /// <param name="newOwnerState">newOwnerState</param>
 /// <param name="newOwnerName">newOwnerName</param>
 /// <param name="newOwnerContact">newOwnerContact</param>
 /// <param name="newQualifiedDate">newQualifiedDate</param>
 /// <param name="newNotQualifiedDate">newNotQualifiedDate</param>
 /// <param name="newNotQualifiedExplain">newNotQualifiedExplain</param>
 /// <param name="newState">newState</param>
 /// <param name="newType">newType</param>
 /// <param name="newDeleted">newDeleted</param>
 /// <param name="newCompanyId">newCompanyId</param>
 /// <param name="newNotes">newNotes</param>
 /// <param name="newCategories">newCategories</param>
 /// <param name="newInsuranceClass">newInsuranceClass</param>
 /// <param name="newInsuranceClassRyderSpecified">newInsuranceClassRyderSpecified</param>
 /// <param name="newPurchasePrice">newPurchasePrice</param>
 /// <param name="newSaleProceeds">newSaleProceeds</param>
 /// <param name="newScrapDate">newScrapDate</param>
 /// <param name="newLibraryCategoriesId">newLibraryCategoriesId</param>
 public void UpdateDirect(int originalUnitId, string originalUnitCode, string originalDescription, string originalVin, string originalManufacturer, string originalModel, string originalYear_, bool originalIsTowable, int originalCompanyLevelId, DateTime? originalAcquisitionDate, DateTime? originalDispositionDate, string originalDispositionReason, string originalOwnerType, Int64? originalOwnerCountry, Int64? originalOwnerState, string originalOwnerName, string originalOwnerContact, DateTime? originalQualifiedDate, DateTime? originalNotQualifiedDate, string originalNotQualifiedExplain, string originalState, string originalType, bool originalDeleted, int originalCompanyId, string originalNotes, string originalCategories, string originalInsuranceClass, string originalInsuranceClassRyderSpecified, decimal? originalPurchasePrice, DateTime? originalScrapDate, decimal? originalSaleProceeds, int? originalLibraryCategoriesId, int newUnitId, string newUnitCode, string newDescription, string newVin, string newManufacturer, string newModel, string newYear_, bool newIsTowable, int newCompanyLevelId, DateTime? newAcquisitionDate, DateTime? newDispositionDate, string newDispositionReason, string newOwnerType, Int64? newOwnerCountry, Int64? newOwnerState, string newOwnerName, string newOwnerContact, DateTime? newQualifiedDate, DateTime? newNotQualifiedDate, string newNotQualifiedExplain, string newState, string newType, bool newDeleted, int newCompanyId, string newNotes, string newCategories, string newInsuranceClass, string newInsuranceClassRyderSpecified, decimal? newPurchasePrice, DateTime? newScrapDate, decimal? newSaleProceeds, int? newLibraryCategoriesId)
 {
     UnitsGateway unitsGateway = new UnitsGateway(null);
     unitsGateway.Update(originalUnitId, originalUnitCode, originalDescription, originalVin, originalManufacturer, originalModel, originalYear_, originalIsTowable, originalCompanyLevelId, originalAcquisitionDate, originalDispositionDate, originalDispositionReason,  originalOwnerType, originalOwnerCountry, originalOwnerState, originalOwnerName, originalOwnerContact, originalQualifiedDate, originalNotQualifiedDate, originalNotQualifiedExplain, originalState, originalType, originalDeleted, originalCompanyId, originalNotes, originalCategories, originalInsuranceClass, originalInsuranceClassRyderSpecified, originalPurchasePrice, originalScrapDate, originalSaleProceeds, originalLibraryCategoriesId, newUnitId, newUnitCode, newDescription, newVin, newManufacturer, newModel, newYear_, newIsTowable, newCompanyLevelId, newAcquisitionDate, newDispositionDate, newDispositionReason,  newOwnerType, newOwnerCountry, newOwnerState, newOwnerName, newOwnerContact, newQualifiedDate, newNotQualifiedDate, newNotQualifiedExplain, newState, newType, newDeleted, newCompanyId, newNotes, newCategories, newInsuranceClass, newInsuranceClassRyderSpecified, newPurchasePrice, newScrapDate, newSaleProceeds, newLibraryCategoriesId);
 }
Esempio n. 10
0
        /// <summary>
        /// IsInUse
        /// </summary>
        /// <param name="unitId">unitId</param>
        /// <param name="companyId">companyId</param>
        /// <returns>int</returns>
        public int IsInUse(int unitId, int companyId)
        {
            UnitsGateway unitsGateway = new UnitsGateway(new DataSet());

            if (unitsGateway.IsUsedInProjectTime(unitId))
            {
                return 1;
            }

            if (unitsGateway.IsUsedInTeamProjectTime(unitId))
            {
                return 2;
            }

            if (unitsGateway.IsUsedInTeamProjectTimeDetail(unitId))
            {
                return 3;
            }

            if (unitsGateway.IsUnitWithServicesActives(unitId, companyId))
            {
                return 4;
            }

            return 0;
        }
Esempio n. 11
0
        // ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// Insert direct to DB
        /// </summary>
        /// <param name="code">code</param>
        /// <param name="description">description</param>
        /// <param name="vin">vin</param>
        /// <param name="manufacturer">manufacturer</param>
        /// <param name="model">model</param>
        /// <param name="year_">year_</param>
        /// <param name="isTowable">isTowable</param>
        /// <param name="companyLevelId">companyLevelId</param>
        /// <param name="acquisitionDate">acquisitionDate</param>
        /// <param name="dispositionDate">dispositionDate</param>
        /// <param name="dispositionReason">dispositionReason</param>        
        /// <param name="ownerType">ownerType</param>
        /// <param name="ownerCountry">ownerCountry</param>
        /// <param name="ownerState">ownerState</param>
        /// <param name="ownerName">ownerName</param>
        /// <param name="ownerContact">ownerContact</param>
        /// <param name="qualifiedDate">qualifiedDate</param>
        /// <param name="notQualifiedDate">notQualifiedDate</param>
        /// <param name="notQualifiedExplain">notQualifiedExplain</param>
        /// <param name="state">state</param>
        /// <param name="type">type</param>
        /// <param name="deleted">deleted</param>
        /// <param name="companyId">companyId</param>
        /// <param name="notes">notes</param>
        /// <param name="categories">categories</param>
        /// <param name="insuranceClass">insuranceClass</param>
        /// <param name="insuranceClassRyderSpecified">insuranceClassRyderSpecified</param>
        /// <param name="purchasePrice">purchasePrice</param>
        /// <param name="scrapDate">scrapDate</param>
        /// <param name="saleProceeds">saleProceeds</param>
        /// <param name="libraryCategoriesId">libraryCategoriesId</param>
        /// <returns>unitId</returns>
        public int InsertDirect(string code, string description, string vin, string manufacturer, string model, string year_, bool isTowable, int companyLevelId, DateTime? acquisitionDate, DateTime? dispositionDate, string dispositionReason, string ownerType, Int64? ownerCountry, Int64? ownerState, string ownerName, string ownerContact, DateTime? qualifiedDate, DateTime? notQualifiedDate, string notQualifiedExplain, string state, string type, bool deleted, int companyId, string notes, string categories, string insuranceClass, string insuranceClassRyderSpecified, decimal? purchasePrice, DateTime? scrapDate, decimal? saleProceeds, int? libraryCategoriesId)
        {
            // Get unitId and insert unit
            UnitsGateway unitsGateway = new UnitsGateway(null);
            int unitId = unitsGateway.Insert(code, description, vin, manufacturer, model, year_, isTowable, companyLevelId, acquisitionDate, dispositionDate, dispositionReason, ownerType, ownerCountry, ownerState, ownerName, ownerContact, qualifiedDate, notQualifiedDate, notQualifiedExplain, state, type, deleted, companyId, notes, categories, insuranceClass, insuranceClassRyderSpecified, purchasePrice, scrapDate, saleProceeds, libraryCategoriesId);

            return unitId;
        }
Esempio n. 12
0
        protected void cvCode_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;

            UnitsGateway unitsGateway = new UnitsGateway(null);
            int unitId = int.Parse(hdfUnitId.Value);

            if (unitsGateway.IsUnitCodeInUse(args.Value.Trim(), unitId))
            {
                args.IsValid = false;
            }
        }
        protected void cvMileage_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;

            if (ckbxMtoDto.Checked)
            {
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int unitId = Int32.Parse(hdfUnitId.Value);

                UnitsGateway unitsGateway = new UnitsGateway();
                unitsGateway.LoadByUnitId(unitId, companyId);

                string unitType = unitsGateway.GetType(unitId);
                int companyLevel = unitsGateway.GetCompanyLevelId(unitId);

                if (unitType == "Vehicle")
                {
                    if (tbxMileage.Text == "")
                    {
                        args.IsValid = false;
                    }
                }
            }
        }
Esempio n. 14
0
        // /////////////////////////////////////////////////////////////////////////////////////////////////////
        // STEP6 - FINISH OPTIONS
        //
        // ////////////////////////////////////////////////////////////////////////
        // STEP6 - FINISH OPTIONS - METHODS
        //
        private void StepFinalStepIn()
        {
            // Set instruction
            mWizard2 master2 = (mWizard2)this.Master;
            master2.WizardInstruction = "What would you like to do?";

            string url = "";

            UnitsGateway unitsGateway = new UnitsGateway(null);
            int unitId = unitsGateway.GetLastUnitId();

            UnitsGateway unitsGatewayForLoad = new UnitsGateway();
            unitsGatewayForLoad.LoadByUnitId(unitId, int.Parse(hdfCompanyId.Value));
            string unitType = unitsGatewayForLoad.GetType(unitId);
            string unitState = unitsGatewayForLoad.GetState(unitId);

            hdfUpdate.Value = "yes";

            // Store active tab for postback
            Session["activeTabUnits"] = "0";
            Session["dialogOpenedUnits"] = "0";

            url = "./units_summary.aspx?source_page=units_add.aspx&unit_id=" + unitId.ToString() + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=0" + GetNavigatorState();
            lkbtnOpenUnit.Attributes.Add("onclick", string.Format("return lkbtnOpenServiceClick('{0}');", url));

            url = "./units_edit.aspx?source_page=units_add.aspx&unit_id=" + unitId.ToString() + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=0" + GetNavigatorState();
            lkbtnEditUnit.Attributes.Add("onclick", string.Format("return lkbtnEditServiceClick('{0}');", url));

            lkbtnClose.Attributes.Add("onclick", "return lkbtnCloseClick();");
        }
Esempio n. 15
0
        /// <summary>
        /// Update direct (direct a service to DB)
        /// </summary>
        /// <param name="serviceId">serviceId</param>
        /// <param name="originalNumber">originalNumber</param>
        /// <param name="originalDateTime">originalDateTime</param>
        /// <param name="originalMtoDto">originalMtoDto</param>
        /// <param name="originalDescription">originalDescription</param>
        /// <param name="originalUnitId">originalUnitId</param>
        /// <param name="originalType">originalType</param>
        /// <param name="originalState">originalState</param>
        /// <param name="originalOwnerId">originalOwnerId</param>
        /// <param name="originalAssignDateTime">originalAssignDateTime</param>
        /// <param name="originalAssignDeadlineDate">originalAssignDeadlineDate</param>
        /// <param name="originalAssignTeamMember">originalAssignTeamMember</param>
        /// <param name="originalAssignTeamMemberID">originalAssignTeamMemberID</param>
        /// <param name="originalAssignThirdPartyVendor">originalAssignThirdPartyVendor</param>
        /// <param name="originalAcceptDateTime">originalAcceptDateTime</param>
        /// <param name="originalRejectDateTime">originalRejectDateTime</param>
        /// <param name="originalRejectReason">originalRejectReason</param>
        /// <param name="originalStartWorkDateTime">originalStartWorkDateTime</param>
        /// <param name="originalStartWorkOutOfServiceDate">originalStartWorkOutOfServiceDate</param>
        /// <param name="originalStartWorkOutOfServiceTime">originalStartWorkOutOfServiceTime</param>
        /// <param name="originalCompleteWorkDateTime">originalCompleteWorkDateTime</param>
        /// <param name="originalCompleteWorkBackToServiceDate">originalCompleteWorkBackToServiceDate</param>
        /// <param name="originalCompleteWorkBackToServiceTime">originalCompleteWorkBackToServiceTime</param>
        /// <param name="originalCompleteWorkDetailDescription">originalCompleteWorkDetailDescription</param>
        /// <param name="originalCompleteWorkDetailPreventable">originalCompleteWorkDetailPreventable</param>
        /// <param name="originalCompleteWorkDetailTMLabourHours">originalCompleteWorkDetailTMLabourHours</param>
        /// <param name="originalCompleteWorkDetailTMCost">originalCompleteWorkDetailTMCost</param>
        /// <param name="originalCompleteWorkDetailTPVInvoiceNumber">originalCompleteWorkDetailTPVInvoiceNumber</param>
        /// <param name="originalCompleteWorkDetailTPVInvoiceAmout">originalCompleteWorkDetailTPVInvoiceAmout</param>
        /// <param name="originalDeleted">originalDeleted</param>
        /// <param name="originalCompanyId">originalCompanyId</param>
        /// <param name="originalNotes">originalNotes</param>
        /// <param name="originalRuleID">originalRuleID</param>
        /// <param name="originalMileage">originalMileage</param>
        /// <param name="originalStartWorkMileage">originalStartWorkMileage</param>
        /// <param name="originalCompleteWorkMileage">originalCompleteWorkMileage</param>
        /// <param name="originalLibraryCategoriesId">originalLibraryCategoriesId</param>
        /// 
        /// <param name="newNumber">newNumber</param>
        /// <param name="newDateTime">newDateTime</param>
        /// <param name="newMtoDto">newMtoDto</param>
        /// <param name="newDescription">newDescription</param>
        /// <param name="newUnitId">newUnitId</param>
        /// <param name="newType">newType</param>
        /// <param name="newState">newState</param>
        /// <param name="newOwnerId">newOwnerId</param>
        /// <param name="newAssignDateTime">newAssignDateTime</param>
        /// <param name="newAssignDeadlineDate">newAssignDeadlineDate</param>
        /// <param name="newAssignTeamMember">newAssignTeamMember</param>
        /// <param name="newAssignTeamMemberID">newAssignTeamMemberID</param>
        /// <param name="newAssignThirdPartyVendor">newAssignThirdPartyVendor</param>
        /// <param name="newAcceptDateTime">newAcceptDateTime</param>
        /// <param name="newRejectDateTime">newRejectDateTime</param>
        /// <param name="newRejectReason">newRejectReason</param>
        /// <param name="newStartWorkDateTime">newStartWorkDateTime</param>
        /// <param name="newStartWorkOutOfServiceDate">newStartWorkOutOfServiceDate</param>
        /// <param name="newStartWorkOutOfServiceTime">newStartWorkOutOfServiceTime</param>
        /// <param name="newCompleteWorkDateTime">newCompleteWorkDateTime</param>
        /// <param name="newCompleteWorkBackToServiceDate">newCompleteWorkBackToServiceDate</param>
        /// <param name="newCompleteWorkBackToServiceTime">newCompleteWorkBackToServiceTime</param>
        /// <param name="newCompleteWorkDetailDescription">newCompleteWorkDetailDescription</param>
        /// <param name="newCompleteWorkDetailPreventable">newCompleteWorkDetailPreventable</param>
        /// <param name="newCompleteWorkDetailTMLabourHours">newCompleteWorkDetailTMLabourHours</param>
        /// <param name="newCompleteWorkDetailTMCost">newCompleteWorkDetailTMCost</param>
        /// <param name="newCompleteWorkDetailTPVInvoiceNumber">newCompleteWorkDetailTPVInvoiceNumber</param>
        /// <param name="newCompleteWorkDetailTPVInvoiceAmout">newCompleteWorkDetailTPVInvoiceAmout</param>
        /// <param name="newDeleted">newDeleted</param>
        /// <param name="newCompanyId">newCompanyId</param>
        /// <param name="newNotes">newNotes</param>
        /// <param name="newRuleID">newRuleID</param>
        /// <param name="newMileage">newMileage</param> 
        /// <param name="newStartWorkMileage">newStartWorkMileage</param>
        /// <param name="newCompleteWorkMileage">newCompleteWorkMileage</param>
        /// <param name="newLibraryCategoriesId">newLibraryCategoriesId</param>
        public void UpdateDirect(int serviceId, string originalNumber, DateTime originalDateTime, bool originalMtoDto, string originalDescription, int? originalUnitId, string originalType, string originalState, int originalOwnerId, DateTime? originalAssignDateTime, DateTime? originalAssignDeadlineDate, bool originalAssignTeamMember, int? originalAssignTeamMemberID, string originalAssignThirdPartyVendor, DateTime? originalAcceptDateTime, DateTime? originalRejectDateTime, string originalRejectReason, DateTime? originalStartWorkDateTime, DateTime? originalStartWorkOutOfServiceDate, string originalStartWorkOutOfServiceTime, DateTime? originalCompleteWorkDateTime, DateTime? originalCompleteWorkBackToServiceDate, string originalCompleteWorkBackToServiceTime, string originalCompleteWorkDetailDescription, bool originalCompleteWorkDetailPreventable, decimal? originalCompleteWorkDetailTMLabourHours, decimal? originalCompleteWorkDetailTMCost, string originalCompleteWorkDetailTPVInvoiceNumber, decimal? originalCompleteWorkDetailTPVInvoiceAmout, bool originalDeleted, int originalCompanyId, string originalNotes, int? originalRuleID, string originalMileage, string originalStartWorkMileage, string originalCompleteWorkMileage, int? originalLibraryCategoriesId, string newNumber, DateTime? newDateTime, bool newMtoDto, string newDescription, int? newUnitId, string newType, string newState, int newOwnerId, DateTime? newAssignDateTime, DateTime? newAssignDeadlineDate, bool newAssignTeamMember, int? newAssignTeamMemberID, string newAssignThirdPartyVendor, DateTime? newAcceptDateTime, DateTime? newRejectDateTime, string newRejectReason, DateTime? newStartWorkDateTime, DateTime? newStartWorkOutOfServiceDate, string newStartWorkOutOfServiceTime, DateTime? newCompleteWorkDateTime, DateTime? newCompleteWorkBackToServiceDate, string newCompleteWorkBackToServiceTime, string newCompleteWorkDetailDescription, bool newCompleteWorkDetailPreventable, decimal? newCompleteWorkDetailTMLabourHours, decimal? newCompleteWorkDetailTMCost, string newCompleteWorkDetailTPVInvoiceNumber, decimal? newCompleteWorkDetailTPVInvoiceAmout, bool newDeleted, int newCompanyId, string newNotes, int? newRuleID, string newMileage, string newStartWorkMileage, string newCompleteWorkMileage, int? newLibraryCategoriesId)
        {
            ServicesGateway servicesGateway = new ServicesGateway(null);
            servicesGateway.Update(serviceId, originalNumber, originalDateTime, originalMtoDto, originalDescription, originalUnitId, originalType, originalState, originalOwnerId, originalAssignDateTime,  originalAssignDeadlineDate, originalAssignTeamMember, originalAssignTeamMemberID, originalAssignThirdPartyVendor, originalAcceptDateTime, originalRejectDateTime, originalRejectReason, originalStartWorkDateTime, originalStartWorkOutOfServiceDate, originalStartWorkOutOfServiceTime, originalCompleteWorkDateTime, originalCompleteWorkBackToServiceDate, originalCompleteWorkBackToServiceTime, originalCompleteWorkDetailDescription, originalCompleteWorkDetailPreventable, originalCompleteWorkDetailTMLabourHours, originalCompleteWorkDetailTMCost, originalCompleteWorkDetailTPVInvoiceNumber, originalCompleteWorkDetailTPVInvoiceAmout, originalDeleted, originalCompanyId, originalNotes, originalRuleID, originalLibraryCategoriesId, newNumber, newDateTime, newMtoDto,  newDescription, newUnitId, newType, newState, newOwnerId, newAssignDateTime, newAssignDeadlineDate,  newAssignTeamMember, newAssignTeamMemberID, newAssignThirdPartyVendor, newAcceptDateTime, newRejectDateTime, newRejectReason, newStartWorkDateTime, newStartWorkOutOfServiceDate, newStartWorkOutOfServiceTime, newCompleteWorkDateTime, newCompleteWorkBackToServiceDate, newCompleteWorkBackToServiceTime, newCompleteWorkDetailDescription, newCompleteWorkDetailPreventable, newCompleteWorkDetailTMLabourHours, newCompleteWorkDetailTMCost, newCompleteWorkDetailTPVInvoiceNumber, newCompleteWorkDetailTPVInvoiceAmout, newDeleted, newCompanyId, newNotes, newRuleID, newLibraryCategoriesId);

            // Validate unit type
            if (originalUnitId.HasValue)
            {
                UnitsGateway unitsGateway = new UnitsGateway();
                unitsGateway.LoadByUnitId((int)originalUnitId, originalCompanyId);
                string unitType = unitsGateway.GetType((int)originalUnitId);

                // ... Insert vehicle info
                if (unitType == "Vehicle")
                {
                    ServicesVehicle servicesVehicle = new ServicesVehicle(null);
                    servicesVehicle.UpdateDirect(serviceId, originalMileage, originalStartWorkMileage, originalCompleteWorkMileage, originalDeleted, originalCompanyId, newMileage, newStartWorkMileage, newCompleteWorkMileage, newDeleted, newCompanyId);
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // STEP2 - GENERAL INFORMATION - METHODS
        //
        private void StepGeneralInformationIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "";

            // Validate user - admin
            if (Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADMIN"]))
            {
                rbtnAssignToTeamMember.Visible = true;
                ddlAssignToTeamMember.Visible = true;
            }
            else
            {
                rbtnAssignToTeamMember.Visible = false;
                ddlAssignToTeamMember.Visible = false;
            }

            // Validate vehicle info
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int unitId = Int32.Parse(hdfUnitId.Value);

            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.LoadByUnitId(unitId, companyId);
            string unitType = unitsGateway.GetType(unitId);
            hdfUnitType.Value = unitType;
            int companyLevel = unitsGateway.GetCompanyLevelId(unitId);
            hdfCompanyLevel.Value = unitsGateway.GetCompanyLevelId(unitId).ToString();

            CompanyLevelGateway companyLevelGateway = new CompanyLevelGateway();
            companyLevelGateway.LoadByCompanyLevelId(companyLevel, companyId);
            lblMileageUnitOfMeasurement.Text = companyLevelGateway.GetUnitsUnitOfMeasurement(companyLevel);
            hdfMileageUnitOfMeasurement.Value = lblMileageUnitOfMeasurement.Text;
            lblStartWorkStartMileageUnitOfMeasurement.Text = hdfMileageUnitOfMeasurement.Value;
            lblCompleteWorkCompleteMileageUnitOfMeasurement.Text = hdfMileageUnitOfMeasurement.Value;

            if (unitType == "Vehicle")
            {
                lblMileage.Visible = true;
                tbxMileage.Visible = true;
                lblStartWorkStartMileage.Visible = true;
                tbxStartWorkStartMileage.Visible = true;
                lblCompleteWorkCompleteMileage.Visible = true;
                tbxCompleteWorkCompleteMileage.Visible = true;
                lblMileageUnitOfMeasurement.Visible = true;
                lblStartWorkStartMileageUnitOfMeasurement.Visible = true;
                lblCompleteWorkCompleteMileageUnitOfMeasurement.Visible = true;
            }
            else
            {
                lblMileage.Visible = false;
                tbxMileage.Visible = false;
                lblMileageUnitOfMeasurement.Visible = false;
                lblStartWorkStartMileage.Visible = false;
                tbxStartWorkStartMileage.Visible = false;
                lblStartWorkStartMileageUnitOfMeasurement.Visible = false;
                lblCompleteWorkCompleteMileage.Visible = false;
                tbxCompleteWorkCompleteMileage.Visible = false;
                lblCompleteWorkCompleteMileageUnitOfMeasurement.Visible = false;
            }

            // Validate panels
            if (rbtnUnassigned.Checked)
            {
                pnlAcceptInformation.Visible = false;
                pnlStartWorkInformation.Visible = false;
                pnlCompleteWorkInformation.Visible = false;
                pnlAssignThirdPartyVendor.Visible = false;
                pnlAssignTeamMember.Visible = false;
                acceptInformationSeparator.Visible = false;
                startWorkSeparator.Visible = false;
                completeWorkSeparator.Visible = false;
            }
            else
            {
                if ((rbtnAssignToMyself.Checked) || (rbtnAssignToTeamMember.Checked))
                {
                    pnlAssignThirdPartyVendor.Visible = false;
                    pnlAssignTeamMember.Visible = true;
                }
                if (rbtnAssignToThirdPartyVendor.Checked)
                {
                    pnlAssignThirdPartyVendor.Visible = true;
                    pnlAssignTeamMember.Visible = false;
                }
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;
            int companyId = Convert.ToInt32(Session["companyID"]);

            // Get Data
            LiquiForce.LFSLive.BL.FleetManagement.Units.UnitInformationReport unitInformationReport = new LiquiForce.LFSLive.BL.FleetManagement.Units.UnitInformationReport();

            if (rbtnByUnit.Checked)
            {
                if (ddlUnits.SelectedValue == "-1")
                {
                    unitInformationReport.Load(companyId);
                }
                else
                {
                    int unitId = Int32.Parse(ddlUnits.SelectedValue);
                    unitInformationReport.LoadByUnitId(unitId, companyId);
                }
            }

            if (rbtnByUnitType.Checked)
            {
                unitInformationReport.LoadByUnitType(ddlUnitType.SelectedValue, companyId);
            }

            // ... set properties to master page
            master.Data = unitInformationReport.Data;
            master.Table = unitInformationReport.TableName;

            // Get report
            if (unitInformationReport.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new UnitsInformationReport();
                    int loginId = Convert.ToInt32(Session["loginID"]);

                    LoginGateway loginGateway = new LoginGateway();
                    loginGateway.LoadByLoginId(loginId, companyId);
                    string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId);
                    master.SetParameter("User", user.Trim());

                    if (rbtnByUnit.Checked)
                    {
                        if (ddlUnits.SelectedValue != "-1")
                        {
                            // For unit code
                            int unitId = Int32.Parse(ddlUnits.SelectedValue);
                            UnitsGateway unitsGateway = new UnitsGateway();
                            unitsGateway.LoadByUnitId(unitId, companyId);
                            string unitCode = unitsGateway.GetUnitCode(unitId);
                            master.SetParameter("Unit", unitCode);
                        }
                        else
                        {
                            master.SetParameter("Unit", "All");
                        }
                    }
                    else
                    {
                        master.SetParameter("Unit", "All");
                    }
                }
                else
                {
                    master.Report = new UnitsInformationReportExport();
                }
            }
        }
        protected void cvStartMileage_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;
            CustomValidator cvConditions = (CustomValidator)source;

            int companyId = Int32.Parse(hdfCompanyId.Value);
            int unitId = Int32.Parse(hdfUnitId.Value);

            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.LoadByUnitId((int)unitId, companyId);
            string unitType = unitsGateway.GetType((int)unitId);

            if (unitType == "Vehicle")
            {
                if (ckbxStartSR.Checked)
                {
                    if (tbxStartWorkStartMileage.Text == "")
                    {
                        cvConditions.ErrorMessage = "Please provide a mileage.";
                        args.IsValid = false;
                    }
                }
                else
                {
                    if (tbxStartWorkStartMileage.Text != "")
                    {
                        cvConditions.ErrorMessage = "Please delete the mileage.";
                        args.IsValid = false;
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // STEP2 - STEPS INFORMATION - METHODS
        //
        private void StepStepsInformationIn()
        {
            // Set instruction
            Label instruction = (Label)this.Master.FindControl("lblInstruction");
            instruction.Text = "";

            // Load data for selected service request
            int serviceId = Int32.Parse(hdfSelectedSRId.Value);
            int companyId = Int32.Parse(hdfCompanyId.Value);

            ServiceRequestsManagerToolBasicInformation serviceRequestsManagerToolBasicInformation = new ServiceRequestsManagerToolBasicInformation(serviceRequestsManagerToolTDS);
            ServiceRequestsManagerToolCostInformation serviceRequestsManagerToolCostInformation = new ServiceRequestsManagerToolCostInformation(serviceRequestsManagerToolTDS);
            ServiceInformationServiceNote serviceInformationServiceNoteForEdit = new ServiceInformationServiceNote(serviceInformationTDS);

            if (Session["dialogOpenedServicesManagerTool"] == null)
            {
                // ... Load basic data
                serviceRequestsManagerToolBasicInformation.LoadByServiceId(serviceId, companyId);

                // ... Load costs
                serviceRequestsManagerToolCostInformation.LoadByServiceId(serviceId, companyId);

                //... Load notes
                serviceInformationServiceNoteForEdit.LoadByServiceId(serviceId, companyId);
            }
            else
            {
                ServiceRequestsManagerToolBasicInformationGateway serviceRequestsManagerToolBasicInformationGateway2 = new ServiceRequestsManagerToolBasicInformationGateway(serviceRequestsManagerToolBasicInformation.Data);

                Session.Remove("dialogOpenedServicesManagerTool");

                if (serviceRequestsManagerToolBasicInformationGateway2.GetAcceptedDateTime(serviceId).HasValue) ckbxAcceptSR.Checked = true;
                if (serviceRequestsManagerToolBasicInformationGateway2.GetStartWorkDateTime(serviceId).HasValue) ckbxStartSR.Checked = true;
                if (serviceRequestsManagerToolBasicInformationGateway2.GetUnitOutOfServiceDate(serviceId).HasValue) tkrdpStartWorkUnitOutOfServiceDate.SelectedDate = serviceRequestsManagerToolBasicInformationGateway2.GetUnitOutOfServiceDate(serviceId);
                tbxStartWorkStartMileage.Text = serviceRequestsManagerToolBasicInformationGateway2.GetStartWorkMileage(serviceId);
                if (serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkDateTime(serviceId).HasValue) ckbxCompleteSR.Checked = true;
                if (serviceRequestsManagerToolBasicInformationGateway2.GetUnitBackInServiceDate(serviceId).HasValue) tkrdpCompleteWorkUnitBackInServiceDate.SelectedDate = serviceRequestsManagerToolBasicInformationGateway2.GetUnitBackInServiceDate(serviceId);
                tbxCompleteWorkCompleteMileage.Text = serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkMileage(serviceId);
                tbxCompleteWorkDataDescription.Text = serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkDetailDescription(serviceId);
                ckbxPreventableTPV.Checked = serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkDetailPreventable(serviceId);
                tbxCompleteWorkDataLabourHours.Text = serviceRequestsManagerToolBasicInformationGateway2.GetCompleteWorkDetailTMLabourHours(serviceId).ToString();
            }

            ServiceRequestsManagerToolBasicInformationGateway serviceRequestsManagerToolBasicInformationGateway = new ServiceRequestsManagerToolBasicInformationGateway(serviceRequestsManagerToolBasicInformation.Data);

            // Validate panels and information
            string state = serviceRequestsManagerToolBasicInformationGateway.GetServiceStateOriginal(serviceId);
            hdfState.Value = state;
            hdfServiceNumber.Value = serviceRequestsManagerToolBasicInformationGateway.GetServiceNumberOriginal(serviceId);
            hdfServiceDescription.Value = serviceRequestsManagerToolBasicInformationGateway.GetServiceDescriptionOriginal(serviceId);

            string originalThirdsPartyVendor = serviceRequestsManagerToolBasicInformationGateway.GetAssignedThirdPartyVendor(serviceId);
            int? unitId = null;
            if (serviceRequestsManagerToolBasicInformationGateway.GetUnitId(serviceId).HasValue)
            {
                unitId = (int)serviceRequestsManagerToolBasicInformationGateway.GetUnitId(serviceId);
                hdfUnitId.Value = unitId.ToString();
            }

            // ... Validate vehicle information
            if (unitId.HasValue)
            {
                UnitsGateway unitsGateway = new UnitsGateway();
                unitsGateway.LoadByUnitId((int)unitId, companyId);
                string unitType = unitsGateway.GetType((int)unitId);
                hdfUnitType.Value = unitType;
                int companyLevel = unitsGateway.GetCompanyLevelId((int)unitId);
                hdfCompanyLevel.Value = unitsGateway.GetCompanyLevelId((int)unitId).ToString();

                CompanyLevelGateway companyLevelGateway = new CompanyLevelGateway();
                companyLevelGateway.LoadByCompanyLevelId(companyLevel, companyId);
                hdfMileageUnitOfMeasurement.Value = companyLevelGateway.GetUnitsUnitOfMeasurement(companyLevel);
                lblStartWorkStartMileageUnitOfMeasurement.Text = hdfMileageUnitOfMeasurement.Value;
                lblCompleteWorkCompleteMileageUnitOfMeasurement.Text = hdfMileageUnitOfMeasurement.Value;

                if (unitType == "Vehicle")
                {
                    lblStartWorkStartMileage.Visible = true;
                    tbxStartWorkStartMileage.Visible = true;
                    lblCompleteWorkCompleteMileage.Visible = true;
                    tbxCompleteWorkCompleteMileage.Visible = true;
                    lblStartWorkStartMileageUnitOfMeasurement.Visible = true;
                    lblCompleteWorkCompleteMileageUnitOfMeasurement.Visible = true;
                }
                else
                {
                    lblStartWorkStartMileage.Visible = false;
                    tbxStartWorkStartMileage.Visible = false;
                    lblStartWorkStartMileageUnitOfMeasurement.Visible = false;
                    lblCompleteWorkCompleteMileage.Visible = false;
                    tbxCompleteWorkCompleteMileage.Visible = false;
                    lblCompleteWorkCompleteMileageUnitOfMeasurement.Visible = false;
                }
            }

            // ... Validate visible internal panels (complete work info)
            if (state == "Unassigned")
            {
                if (!rbtnAssignToThirdPartyVendor.Checked)
                {
                    pnlAssignTeamMember.Visible = true;
                    pnlAssignThirdPartyVendor.Visible = false;
                }
                else
                {
                    pnlAssignThirdPartyVendor.Visible = true;
                    pnlAssignTeamMember.Visible = false;
                }
            }
            else
            {
                bool teamMemberAssigned = serviceRequestsManagerToolBasicInformationGateway.GetAssignTeamMember(serviceId);
                if (teamMemberAssigned)
                {
                    pnlAssignTeamMember.Visible = true;
                    pnlAssignThirdPartyVendor.Visible = false;
                }
                else
                {
                    pnlAssignThirdPartyVendor.Visible = true;
                    pnlAssignTeamMember.Visible = false;
                }
            }

            // ... Validate panels
            switch (state)
            {
                case "Unassigned":
                    pnlAssignmentInformation.Visible = true;
                    acceptInformationSeparator.Visible = true;
                    pnlAcceptInformation.Visible = true;
                    startWorkSeparator.Visible = true;
                    pnlStartWorkInformation.Visible = true;
                    completeWorkSeparator.Visible = true;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                case "Assigned":
                    pnlAssignmentInformation.Visible = false;
                    acceptInformationSeparator.Visible = false;
                    pnlAcceptInformation.Visible = true;
                    startWorkSeparator.Visible = true;
                    pnlStartWorkInformation.Visible = true;
                    completeWorkSeparator.Visible = true;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                case "Rejected":
                    pnlAssignmentInformation.Visible = true;
                    acceptInformationSeparator.Visible = true;
                    pnlAcceptInformation.Visible = true;
                    startWorkSeparator.Visible = true;
                    pnlStartWorkInformation.Visible = true;
                    completeWorkSeparator.Visible = true;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                case "Accepted":
                    pnlAssignmentInformation.Visible = false;
                    acceptInformationSeparator.Visible = false;
                    pnlAcceptInformation.Visible = false;
                    startWorkSeparator.Visible = false;
                    pnlStartWorkInformation.Visible = true;
                    completeWorkSeparator.Visible = true;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                case "In Progress":
                    pnlAssignmentInformation.Visible = false;
                    acceptInformationSeparator.Visible = false;
                    pnlAcceptInformation.Visible = false;
                    startWorkSeparator.Visible = false;
                    pnlStartWorkInformation.Visible = false;
                    completeWorkSeparator.Visible = false;
                    pnlCompleteWorkInformation.Visible = true;
                    break;

                default:
                    throw new Exception("The option for " + wzServices.ActiveStep.Name + " step in services_manager_tool.Wizard_ActiveStepChanged function does not exist");
            }

            hdfPnlAcceptInformation.Value = pnlAcceptInformation.Visible.ToString();
            hdfPnlAssignmentInformation.Value = pnlAssignmentInformation.Visible.ToString();
            hdfPnlStartWorkInformation.Value = pnlStartWorkInformation.Visible.ToString();
            hdfPnlCompleteWorkInformation.Value = pnlCompleteWorkInformation.Visible.ToString();

            // ... Load resource library
            int? libraryCategoriesId = null; if (serviceRequestsManagerToolBasicInformationGateway.GetLibraryCategoriesId(serviceId).HasValue) libraryCategoriesId = (int)serviceRequestsManagerToolBasicInformationGateway.GetLibraryCategoriesId(serviceId);

            if (libraryCategoriesId.HasValue)
            {
                ViewState["libraryCategoriesId"] = (int)libraryCategoriesId;
                tbxCategoryAssocited.Text = GetFullCategoryName((int)libraryCategoriesId, companyId);
                btnAssociate.Visible = false;
                btnUnassociate.Visible = true;
            }
            else
            {
                tbxCategoryAssocited.Text = "";
                btnAssociate.Visible = true;
                btnUnassociate.Visible = false;
            }

            // Store session
            Session["serviceRequestsManagerToolTDS"] = serviceRequestsManagerToolTDS;
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) && ((string)Request.QueryString["others"] == null) && ((string)Request.QueryString["employee_id"] == null) && ((string)Request.QueryString["period_id"] == null) && ((string)Request.QueryString["projecttime_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in timesheet_summary.aspx");
                }

                // Security check
                if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_FULL_EDITING"]))
                {
                    if (Request.QueryString["others"] == "no")
                    {
                        if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"]))
                        {
                            if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"]))
                            {
                                if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"]))
                                {
                                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_VIEW"]))
                        {
                            if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT"]))
                            {
                                if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_MY_TIMESHEETS_MANAGEMENT_WED"]))
                                {
                                    if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_VIEW"]))
                                    {
                                        if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT"]))
                                        {
                                            if (!Convert.ToBoolean(Session["sgLFS_LABOUR_HOURS_OTHERS_TIMESHEETS_MANAGEMENT_WED"]))
                                            {
                                                Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // Initialize viewstate's variables
                ViewState["others"] = Request.QueryString["others"];
                ViewState["employee_id"] = int.Parse(Request.QueryString["employee_id"]);
                ViewState["period_id"] = int.Parse(Request.QueryString["period_id"]);
                ViewState["projecttime_id"] = int.Parse(Request.QueryString["projecttime_id"]);
                System.Configuration.AppSettingsReader appSettingReader = new System.Configuration.AppSettingsReader();
                ViewState["LHMode"] = appSettingReader.GetValue("LABOUR_HOURS_OPERATION_MODE", typeof(System.String)).ToString();

                // Get ProjectTime record
                projectTimeTDS =  new ProjectTimeTDS();

                ProjectTimeGateway projectTimeGateway = new ProjectTimeGateway(projectTimeTDS);
                projectTimeGateway.LoadByProjectTimeId((int)ViewState["projecttime_id"]);

                // Store datasets
                Session["projectTimeTDS"] = projectTimeTDS;

                // Databind
                tbxDate.DataBind();
                tbxWorkingDetails.DataBind();
                tbxStartTime.DataBind();
                tbxEndTime.DataBind();
                tbxLunch.DataBind();
                tbxComments.DataBind();
                tbxState.DataBind();

                // Prepare initial data for client
                StoreNavigatorState();

                EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());
                employeeGateway.LoadByEmployeeId((int)ViewState["employee_id"]);
                tbxEmployee.Text = employeeGateway.GetFullName((int)ViewState["employee_id"]);

                int companyId = Int32.Parse(Session["companyID"].ToString());

                CompaniesGateway companiesGateway = new CompaniesGateway(new DataSet());
                companiesGateway.LoadAllByCompaniesId(projectTimeGateway.GetCompaniesId((int)ViewState["projecttime_id"]), companyId);
                tbxClient.Text = companiesGateway.GetName(projectTimeGateway.GetCompaniesId((int)ViewState["projecttime_id"]));

                ProjectGateway projectGateway = new ProjectGateway(new DataSet());
                projectGateway.LoadByProjectId(projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"]));
                tbxProject.Text = projectGateway.GetName(projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])) + "(" + projectGateway.GetProjectNumber(projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])) + ")";

                if (projectGateway.GetFairWageApplies(projectTimeGateway.GetProjectId((int)ViewState["projecttime_id"])))
                {
                    tbxJobClassType.Visible = true;
                    lblJobClassType.Visible = true;
                    tbxJobClassType.Text = projectTimeGateway.GetJobClassType((int)ViewState["projecttime_id"]);
                }
                else
                {
                    tbxJobClassType.Visible = false;
                    lblJobClassType.Visible = false;
                }

                if (projectTimeGateway.GetMealsCountry((int)ViewState["projecttime_id"]).HasValue)
                {
                    CountryGateway countryGateway = new CountryGateway(new DataSet());
                    countryGateway.LoadByCountryId((Int64)projectTimeGateway.GetMealsCountry((int)ViewState["projecttime_id"]));
                    tbxMealsCountry.Text = countryGateway.GetName((Int64)projectTimeGateway.GetMealsCountry((int)ViewState["projecttime_id"]));
                }

                //if (projectTimeGateway.GetMealsAllowance((int)ViewState["projecttime_id"]) > 0)
                //{
                //    cbxMealsAllowance.Checked = true;
                //}

                //if (projectTimeGateway.GetFairWage((int)ViewState["projecttime_id"]))
                //{
                //    cbxFairWage.Checked = true;
                //}

                if (projectTimeGateway.GetUnitId((int)ViewState["projecttime_id"]).HasValue)
                {
                    UnitsGateway unitGateway = new UnitsGateway(new DataSet());
                    unitGateway.LoadByUnitId((int)projectTimeGateway.GetUnitId((int)ViewState["projecttime_id"]), Convert.ToInt32(Session["companyID"]));
                    tbxUnit.Text = unitGateway.GetUnitCode((int)projectTimeGateway.GetUnitId((int)ViewState["projecttime_id"]));
                }

                if (projectTimeGateway.GetTowedUnitId((int)ViewState["projecttime_id"]).HasValue)
                {
                    UnitsGateway unitGateway = new UnitsGateway(new DataSet());
                    unitGateway.LoadByUnitId((int)projectTimeGateway.GetTowedUnitId((int)ViewState["projecttime_id"]), Convert.ToInt32(Session["companyID"]));
                    tbxTowed.Text = unitGateway.GetUnitCode((int)projectTimeGateway.GetTowedUnitId((int)ViewState["projecttime_id"]));
                }

                tbxTypeOfWork.Text = "";
                if (projectTimeGateway.GetWork((int)ViewState["projecttime_id"]) != "")
                {
                    tbxTypeOfWork.Text = projectTimeGateway.GetWork((int)ViewState["projecttime_id"]);
                }

                tbxFunction.Text = "";
                if (projectTimeGateway.GetFunction((int)ViewState["projecttime_id"]) != "")
                {
                    tbxFunction.Text = projectTimeGateway.GetFunction((int)ViewState["projecttime_id"]);
                }
            }
            else
            {
                // Restore datasets
                projectTimeTDS = (ProjectTimeTDS)Session["projectTimeTDS"];
            }
        }
Esempio n. 21
0
        // ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// Insert a new service (direct to DB)
        /// </summary>
        /// <param name="dateTime_">dateTime_</param>
        /// <param name="mto">mto</param>
        /// <param name="description">description</param>
        /// <param name="unitId">unitId</param>
        /// <param name="type">type</param>
        /// <param name="state">state</param>
        /// <param name="ownerId">ownerId</param>
        /// <param name="assignDateTime">assignDateTime</param>
        /// <param name="assignDeadlineDate">assignDeadlineDate</param>
        /// <param name="assignTeamMember">assignTeamMember</param>
        /// <param name="assignTeamMemberID">assignTeamMemberID</param>
        /// <param name="assignThirdPartyVendor">assignThirdPartyVendor</param>
        /// <param name="acceptDateTime">acceptDateTime</param>
        /// <param name="rejectDateTime">rejectDateTime</param>
        /// <param name="rejectReason">rejectReason</param>
        /// <param name="startWorkDateTime">startWorkDateTime</param>
        /// <param name="startWorkOutOfServiceDate">startWorkOutOfServiceDate</param>
        /// <param name="startWorkOutOfServiceTime">startWorkOutOfServiceTime</param>
        /// <param name="completeWorkDateTime">completeWorkDateTime</param>
        /// <param name="completeWorkBackToServiceDate">completeWorkBackToServiceDate</param>
        /// <param name="completeWorkBackToServiceTime">completeWorkBackToServiceTime</param>
        /// <param name="completeWorkDetailDescription">completeWorkDetailDescription</param>
        /// <param name="completeWorkDetailPreventable">completeWorkDetailPreventable</param>
        /// <param name="completeWorkDetailTMLabourHours">completeWorkDetailTMLabourHours</param>
        /// <param name="completeWorkDetailTMCost">completeWorkDetailTMCost</param>
        /// <param name="completeWorkDetailTPVInvoiceNumber">completeWorkDetailTPVInvoiceNumber</param>
        /// <param name="completeWorkDetailTPVInvoiceAmout">completeWorkDetailTPVInvoiceAmout</param>
        /// <param name="notes">notes</param>
        /// <param name="ruleId">ruleId</param>
        /// <param name="mileage">mileage</param>
        /// <param name="startWorkMileage">startWorkMileage</param>
        /// <param name="completeWorkMileage">completeWorkMileage</param>
        /// <param name="deleted">deleted</param>
        /// <param name="companyId">companyId</param>
        /// <param name="libraryCategoriesId">libraryCategoriesId</param>
        /// <returns>int</returns>
        public int InsertDirect(DateTime? dateTime_, bool mto, string description, int? unitId, string type, string state, int ownerId, DateTime? assignDateTime, DateTime? assignDeadlineDate, bool assignTeamMember, int? assignTeamMemberID, string assignThirdPartyVendor, DateTime? acceptDateTime, DateTime? rejectDateTime, string rejectReason, DateTime? startWorkDateTime, DateTime? startWorkOutOfServiceDate, string startWorkOutOfServiceTime, DateTime? completeWorkDateTime, DateTime? completeWorkBackToServiceDate, string completeWorkBackToServiceTime, string completeWorkDetailDescription, bool completeWorkDetailPreventable, decimal? completeWorkDetailTMLabourHours, decimal? completeWorkDetailTMCost, string completeWorkDetailTPVInvoiceNumber, decimal? completeWorkDetailTPVInvoiceAmout, string notes, int? ruleId, string mileage, string startWorkMileage, string completeWorkMileage, bool deleted, int companyId, int? libraryCategoriesId)
        {
            // Get new service number by commpany
            string number = GetServiceNumber(companyId);

            // Get serviceId and insert request
            ServicesGateway servicesGateway = new ServicesGateway(null);
            int serviceId = servicesGateway.Insert(number, dateTime_, mto, description, unitId, type, state, ownerId, assignDateTime, assignDeadlineDate, assignTeamMember, assignTeamMemberID, assignThirdPartyVendor, acceptDateTime, rejectDateTime, rejectReason, startWorkDateTime, startWorkOutOfServiceDate, startWorkOutOfServiceTime, completeWorkDateTime, completeWorkBackToServiceDate, completeWorkBackToServiceTime, completeWorkDetailDescription, completeWorkDetailPreventable, completeWorkDetailTMLabourHours, completeWorkDetailTMCost, completeWorkDetailTPVInvoiceNumber, completeWorkDetailTPVInvoiceAmout, notes, ruleId, deleted, companyId, libraryCategoriesId);

            // Validate unit type
            if (unitId.HasValue)
            {
                UnitsGateway unitsGateway = new UnitsGateway();
                unitsGateway.LoadByUnitId((int)unitId, companyId);
                string unitType = unitsGateway.GetType((int)unitId);

                // ... Insert vehicle info
                if (unitType == "Vehicle")
                {
                    ServicesVehicle servicesVehicle = new ServicesVehicle(null);
                    servicesVehicle.InsertDirect(serviceId, mileage, startWorkMileage, completeWorkMileage, deleted, companyId);
                }
            }

            return serviceId;
        }
        /// <summary>
        /// UpdateUnitsAndRulesCompanyLevels
        /// </summary>
        /// <param name="originalCompanyLevelId">originalCompanyLevelId</param>
        /// <param name="newCompanyLevelId">newCompanyLevelId</param>
        /// <param name="companyId">companyId</param>
        private void UpdateUnitsAndRulesCompanyLevels(int originalCompanyLevelId, int? newCompanyLevelId, int companyId)
        {
            // Update units
            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.Load(companyId);

            if (unitsGateway.Table.Rows.Count > 0)
            {
                foreach (UnitsTDS.LFS_FM_UNITRow row in (UnitsTDS.LFS_FM_UNITDataTable)unitsGateway.Table)
                {
                    int unitId = row.UnitID;

                    if (originalCompanyLevelId == row.CompanyLevelID)
                    {
                        if (newCompanyLevelId.HasValue)
                        {
                            UnitsGateway unitsGatewayToUpdate = new UnitsGateway(null);
                            unitsGatewayToUpdate.UpdateCompanyLevel(row.UnitID, row.Deleted, row.COMPANY_ID, (int)newCompanyLevelId);
                        }
                    }
                }
            }

            // Update rules company levels
            LiquiForce.LFSLive.DA.FleetManagement.ChecklistRules.RuleGateway ruleGateway = new RuleGateway();
            ruleGateway.Load(companyId);

            if (ruleGateway.Table.Rows.Count > 0)
            {
                foreach (RuleTDS.LFS_FM_RULERow row in (RuleTDS.LFS_FM_RULEDataTable)ruleGateway.Table)
                {
                    int ruleId = row.RuleID;

                    RuleCompanyLevelGateway ruleCompanyLevelGateway = new RuleCompanyLevelGateway(null);
                    if ((ruleCompanyLevelGateway.IsUsedInRuleCompanyLevel(ruleId, originalCompanyLevelId)) && (newCompanyLevelId.HasValue))
                    {
                        if (!ruleCompanyLevelGateway.IsUsedInRuleCompanyLevel(ruleId, (int)newCompanyLevelId))
                        {
                            RuleCompanyLevel ruleCompanyLevel = new RuleCompanyLevel(null);
                            ruleCompanyLevel.InsertDirect(ruleId, (int)newCompanyLevelId, false, companyId);
                            ruleCompanyLevel.DeleteDirect(ruleId, originalCompanyLevelId, companyId);
                        }
                        else
                        {
                            RuleCompanyLevel ruleCompanyLevel = new RuleCompanyLevel(null);
                            ruleCompanyLevel.DeleteDirect(ruleId, originalCompanyLevelId, companyId);
                        }
                    }
                }
            }
        }
Esempio n. 23
0
        protected void cvCode_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;

            UnitsGateway unitsGateway = new UnitsGateway(null);

            if (unitsGateway.IsUnitCodeInUse(tbxCode.Text))
            {
                args.IsValid = false;
            }
        }
        private void Generate()
        {
            mReport1 master = (mReport1)this.Master;

            // Get Data
            string projectTimeState = (ddlProjectTimeState.SelectedValue == "(All)") ? "%" : ddlProjectTimeState.SelectedValue;

            PrintVehicleLocationGateway printVehicleLocationGateway = new PrintVehicleLocationGateway();

            if (ddlCountry.SelectedValue == "(All)")
            {
                if (ddlUnit.SelectedValue == "-1")
                {
                    printVehicleLocationGateway.LoadByStartDateEndDateProjectTimeState(DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString()), DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString()), projectTimeState);
                }
                else
                {
                    printVehicleLocationGateway.LoadByStartDateEndDateUnitIdProjectTimeState(DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString()), DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString()), int.Parse(ddlUnit.SelectedValue), projectTimeState);
                }
            }
            else
            {
                if (ddlUnit.SelectedValue == "-1")
                {
                    printVehicleLocationGateway.LoadByStartDateEndDateProjectTimeStateCountryId(DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString()), DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString()), projectTimeState, int.Parse(ddlCountry.SelectedValue));
                }
                else
                {
                    printVehicleLocationGateway.LoadByStartDateEndDateUnitIdProjectTimeStateCountryId(DateTime.Parse(tkrdpStartDate.SelectedDate.Value.ToShortDateString()), DateTime.Parse(tkrdpEndDate.SelectedDate.Value.ToShortDateString()), int.Parse(ddlUnit.SelectedValue), projectTimeState, int.Parse(ddlCountry.SelectedValue));
                }
            }

            // ... set properties to master page
            master.Data = printVehicleLocationGateway.Data;
            master.Table = printVehicleLocationGateway.TableName;

            // Get report
            int companyId = Convert.ToInt32(Session["companyID"]);

            if (printVehicleLocationGateway.Table.Rows.Count > 0)
            {
                if (master.Format == "pdf")
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintVehicleLocationReport();
                }
                else
                {
                    master.Report = new LiquiForce.LFSLive.WebUI.LabourHours.ProjectTime.PrintVehicleLocationReportExport();
                }

                // ... set parameters to report
                if (master.Format == "pdf")
                {
                    // ... For report
                    // ... ... project time state
                    if (ddlProjectTimeState.SelectedValue == "(All)")
                    {
                        master.SetParameter("projectTimeState", "All");
                    }
                    else
                    {
                        master.SetParameter("projectTimeState", ddlProjectTimeState.SelectedItem.Text);
                    }

                    // ... ... unit
                    if (ddlUnit.SelectedValue == "-1")
                    {
                        master.SetParameter("unitName", "All");
                    }
                    else
                    {
                        int unitId = Int32.Parse(ddlUnit.SelectedValue);
                        UnitsGateway unitsGateway = new UnitsGateway();
                        unitsGateway.LoadByUnitId(unitId, companyId);
                        string unitName = "(" + unitsGateway.GetUnitCode(unitId) + ") " + unitsGateway.GetDescription(unitId);

                        master.SetParameter("unitName", unitName);
                    }

                    // ... ...  user
                    int loginId = Convert.ToInt32(Session["loginID"]);

                    LoginGateway loginGateway = new LoginGateway();
                    loginGateway.LoadByLoginId(loginId, companyId);
                    string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId);
                    master.SetParameter("User", user.Trim());

                    // ... ...  dates
                    master.SetParameter("dateFrom", tkrdpStartDate.SelectedDate.Value.ToShortDateString());
                    master.SetParameter("dateTo", tkrdpEndDate.SelectedDate.Value.ToShortDateString());

                    // ... ... country
                    if (ddlCountry.SelectedValue == "2")
                    {
                        master.SetParameter("Country", "USA");
                    }
                    else
                    {
                        if (ddlCountry.SelectedValue == "1")
                        {
                            master.SetParameter("Country", "Canada");
                        }
                        else
                        {
                            master.SetParameter("Country", "All");
                        }
                    }
                }
            }
        }
        private void LoadData(int toDoId)
        {
            ToDoListInformationBasicInformationGateway toDoListInformationBasicInformationGateway = new ToDoListInformationBasicInformationGateway(toDoListInformationTDS);
            if (toDoListInformationBasicInformationGateway.Table.Rows.Count > 0)
            {
                // Load to do Details
                int companyId = Int32.Parse(hdfCompanyId.Value);

                int createdById = toDoListInformationBasicInformationGateway.GetCreatedByID(toDoId);
                hdfCreatedById.Value = createdById.ToString();
                EmployeeGateway employeeGateway = new EmployeeGateway();
                employeeGateway.LoadByEmployeeId(createdById);
                tbxCreatedBy.Text = employeeGateway.GetFullName(createdById);

                tbxCreationDate.Text = toDoListInformationBasicInformationGateway.GetCreationDate(toDoId).ToString();
                tbxState.Text = toDoListInformationBasicInformationGateway.GetState(toDoId);

                if (toDoListInformationBasicInformationGateway.GetDueDate(toDoId).HasValue)
                {
                    DateTime dueDateValue = (DateTime)toDoListInformationBasicInformationGateway.GetDueDate(toDoId);
                    tbxDueDate.Text = dueDateValue.Month.ToString() + "/" + dueDateValue.Day.ToString() + "/" + dueDateValue.Year.ToString();
                }

                int? unitId = toDoListInformationBasicInformationGateway.GetUnitID(toDoId);
                tbxUnit.Text = "";
                if (unitId.HasValue)
                {
                    UnitsGateway unitsGateway = new UnitsGateway();
                    unitsGateway.LoadByUnitId((int)unitId, companyId);
                    tbxUnit.Text = unitsGateway.GetUnitCode((int)unitId) + " " + unitsGateway.GetDescription((int)unitId);
                }
            }
        }
        protected string GetUnitCode(object unitId)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value);
            if (unitId != DBNull.Value)
            {
                UnitsGateway unitsGateway = new UnitsGateway();
                unitsGateway.LoadByUnitId((int)unitId, companyId);

                if (unitsGateway.Table.Rows.Count > 0)
                {
                    return unitsGateway.GetUnitCode((int)unitId);
                }
                else
                {
                    return "";
                }
            }
            else
            {
                return "";
            }
        }
Esempio n. 27
0
        // ////////////////////////////////////////////////////////////////////////
        // NAVIGATION EVENTS
        //
        protected void tkrmTop_ItemClick(object sender, RadMenuEventArgs e)
        {
            // Store active tab for postback
            Session["activeTabUnits"] = "0";
            Session["dialogOpenedUnits"] = "0";

            string activeTab = hdfActiveTab.Value;
            string url = "";

            switch (e.Item.Value)
            {
                case "mSave":
                    this.Save();
                    break;

                case "mApply":
                    this.Apply();
                    break;

                case "mCancel":
                    Session.Remove("libraryTDSForUnits");

                    if (Request.QueryString["source_page"] == "units_navigator2.aspx" || Request.QueryString["source_page"] == "units_add.aspx")
                    {
                        url = "./units_navigator2.aspx?source_page=units_edit.aspx" + GetNavigatorState() + "&update=" + (string)ViewState["update"];
                    }

                    if (Request.QueryString["source_page"] == "units_summary.aspx")
                    {
                        url = "./units_summary.aspx?source_page=units_edit.aspx&unit_id=" + hdfUnitId.Value + "&unit_type=" + hdfUnitType.Value + "&unit_state=" + hdfUnitState.Value + "&active_tab=" + hdfActiveTab.Value + GetNavigatorState() + "&update=" + (string)ViewState["update"];
                    }
                    break;

                case "mPrevious":
                    Session.Remove("libraryTDSForUnits");

                    // Get previous record
                    int previousId = UnitsNavigator.GetPreviousId((UnitsNavigatorTDS)Session["unitsNavigatorTDS"], Int32.Parse(hdfUnitId.Value));

                    if (previousId != Int32.Parse(hdfUnitId.Value))
                    {
                        this.Apply();

                        // ... Redirect
                        int companyId = Int32.Parse(hdfCompanyId.Value);
                        int unitId = Int32.Parse(hdfUnitId.Value);
                        UnitsGateway unitsGateway = new UnitsGateway();
                        unitsGateway.LoadByUnitId(unitId, companyId);
                        string unitType = unitsGateway.GetType(unitId);
                        string unitState = unitsGateway.GetState(unitId);

                        url = "./units_edit.aspx?source_page=" + Request.QueryString["source_page"] + "&unit_id=" + previousId + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=" + activeTab + GetNavigatorState() + "&update=yes";
                    }
                    break;

                case "mNext":
                    Session.Remove("libraryTDSForUnits");

                    // Get next record
                    int nextId = UnitsNavigator.GetNextId((UnitsNavigatorTDS)Session["unitsNavigatorTDS"], Int32.Parse(hdfUnitId.Value));

                    if (nextId != Int32.Parse(hdfUnitId.Value))
                    {
                        this.Apply();

                        // ... Redirect
                        int companyId = Int32.Parse(hdfCompanyId.Value);
                        int unitId = Int32.Parse(hdfUnitId.Value);
                        UnitsGateway unitsGateway = new UnitsGateway();
                        unitsGateway.LoadByUnitId(unitId, companyId);
                        string unitType = unitsGateway.GetType(unitId);
                        string unitState = unitsGateway.GetState(unitId);

                        url = "./units_edit.aspx?source_page=" + Request.QueryString["source_page"] + "&unit_id=" + nextId + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=" + activeTab + GetNavigatorState() + "&update=yes";
                    }
                    break;
            }

            if (url != "") Response.Redirect(url);
        }
        protected void cvStartWorkDataMileage_ServerValidate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int serviceId = Int32.Parse(hdfServiceId.Value);

            ServiceInformationBasicInformationGateway serviceInformationBasicInformationGatewayForId = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
            int? unitId = serviceInformationBasicInformationGatewayForId.GetUnitID(serviceId);

            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.LoadByUnitId((int)unitId, companyId);
            string unitType = unitsGateway.GetType((int)unitId);

            if (unitType == "Vehicle")
            {
                if (tbxStartWorkDataWorkStartDateTime.Text != "")
                {
                    if (tbxStartWorkDataStartMileage.Text == "")
                    {
                        args.IsValid = false;
                        hdfErrorFieldList.Value = hdfErrorFieldList.Value + ", Mileage (Start Work)";
                    }
                }
            }
        }
        protected bool IsUnitWithServicesActives(int unitId, int companyId)
        {
            UnitsGateway unitsGateway = new UnitsGateway(null);

            if (unitsGateway.IsUnitWithServicesActives(unitId, companyId))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            // Set active toolbar
            mForm6 master = (mForm6)this.Master;
            master.ActiveToolbar = "FleetManagement";

            // For error message
            hdfErrorFieldList.Value = "";

            // Validate left menu if the user has admin permission
            if (Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADMIN"]))
            {
                tkrpbLeftMenuAllServiceRequests.Visible = true;
                tkrpbLeftMenuMyServiceRequests.Visible = false;
                tkrpbLeftMenuTools.Visible = true;
            }
            else
            {
                tkrpbLeftMenuAllServiceRequests.Visible = false;
                tkrpbLeftMenuMyServiceRequests.Visible = true;
                tkrpbLeftMenuTools.Visible = false;
            }

            // Tabs validation
            // ... Validate vehicle info
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int serviceId = Int32.Parse(hdfServiceId.Value);

            ServiceInformationBasicInformationGateway serviceInformationBasicInformationGatewayForId = new ServiceInformationBasicInformationGateway(serviceInformationTDS);
            int? unitId = serviceInformationBasicInformationGatewayForId.GetUnitID(serviceId);

            UnitsGateway unitsGateway = new UnitsGateway();
            unitsGateway.LoadByUnitId((int)unitId, companyId);
            string unitType = unitsGateway.GetType((int)unitId);
            int companyLevel = unitsGateway.GetCompanyLevelId((int)unitId);

            if (unitType != "Vehicle")
            {
                lblGeneralMileage.Visible = false;
                tbxGeneralMileage.Visible = false;
                lblGeneralMileageUnitOfMeasurement.Visible = false;
                lblStartWorkDataStartMileage.Visible = false;
                tbxStartWorkDataStartMileage.Visible = false;
                lblStartWorkDataMileageUnitOfMeasurement.Visible = false;
                lblStartWorkDataMileageUnitOfMeasurementReadOnly.Visible = false;
                lblCompleteWorkDataCompleteMileage.Visible = false;
                tbxCompleteWorkDataCompleteMileage.Visible = false;
                lblCompleteWorkDataMileageUnitOfMeasurement.Visible = false;
                lblCompleteWorkDataMileageUnitOfMeasurementReadOnly.Visible = false;
            }
            else
            {
                // .. For Vehicles
                lblGeneralMileage.Visible = true;
                tbxGeneralMileage.Visible = true;
                lblStartWorkDataStartMileage.Visible = true;
                tbxStartWorkDataStartMileage.Visible = true;
                lblCompleteWorkDataCompleteMileage.Visible = true;
                tbxCompleteWorkDataCompleteMileage.Visible = true;
                lblGeneralMileageUnitOfMeasurement.Visible = true;
                lblStartWorkDataMileageUnitOfMeasurement.Visible = true;
                lblStartWorkDataMileageUnitOfMeasurementReadOnly.Visible = true;
                lblCompleteWorkDataMileageUnitOfMeasurementReadOnly.Visible = true;
            }

            // Assign Tab
            // ... Assigned To
            hdfServiceState.Value = serviceInformationBasicInformationGatewayForId.GetServiceState(serviceId);
            string state = hdfServiceState.Value;

            if (state == "Unassigned")
            {
                // ... Princial Panels
                pnlAssignmentData.Visible = false;
                pnlAssignmentDataReadOnly.Visible = true;

                // ... ...Subpanels
                pnlAssignedTo.Visible = false;
                pnlAssignedToReadOnly.Visible = false;
                pnlAssignmentAccept.Visible = false;
                pnlAssignmentReject.Visible = false;

                pnlAssignmentAcceptReadOnly.Visible = true;
                pnlAssignmentRejectReadOnly.Visible = true;
            }

            if ((state == "Assigned") || (state == "Rejected"))
            {
                // ... ... Principal Panels
                pnlAssignmentData.Visible = true;
                pnlAssignmentDataReadOnly.Visible = false;

                // ... ...Subpanels
                pnlAssignedTo.Visible = true;
                pnlAssignedToReadOnly.Visible = false;
                pnlAssignmentAccept.Visible = false;
                pnlAssignmentReject.Visible = false;

                pnlAssignmentAcceptReadOnly.Visible = false;
                pnlAssignmentRejectReadOnly.Visible = false;
            }
            else
            {
                if ((state == "Accepted") || (state == "In Progress") || (state == "Completed"))
                {
                    // ... ... Principal Panels
                    pnlAssignmentData.Visible = true;
                    pnlAssignmentDataReadOnly.Visible = false;

                    // ... ...Subpanels
                    pnlAssignedTo.Visible = false;
                    pnlAssignedToReadOnly.Visible = true;
                    pnlAssignmentAccept.Visible = false;
                    pnlAssignmentReject.Visible = false;
                    pnlAssignmentAcceptReadOnly.Visible = false;
                    pnlAssignmentRejectReadOnly.Visible = false;
                }
            }

            // ... Assignation result
            if ((state == "Accepted") || (state == "In Progress") || (state == "Completed"))
            {
                // ... ... Principal Panels
                pnlAssignmentData.Visible = true;
                pnlAssignmentDataReadOnly.Visible = false;

                // ... ...Subpanels
                pnlAssignedTo.Visible = false;
                pnlAssignedToReadOnly.Visible = true;
                pnlAssignmentAccept.Visible = true;
                pnlAssignmentReject.Visible = false;
                pnlAssignmentAcceptReadOnly.Visible = false;
                pnlAssignmentRejectReadOnly.Visible = false;
            }

            // StartWork tab
            if ((state == "Unassigned") || (state == "Assigned") || (state == "Rejected") || (state == "Accepted"))
            {
                pnlStartWorkDataReadOnly.Visible = true;
                pnlStartWorkData.Visible = false;
            }
            else
            {
                pnlStartWorkDataReadOnly.Visible = false;
                pnlStartWorkData.Visible = true;
            }

            // Complete Work tab
            if ((state == "Unassigned") || (state == "Assigned") || (state == "Rejected") || (state == "Accepted") || (state == "In Progress"))
            {
                pnlCompleteWorkDataReadOnly.Visible = true;
                pnlCompleteWorkData.Visible = false;
            }
            else
            {
                pnlCompleteWorkDataReadOnly.Visible = false;
                pnlCompleteWorkData.Visible = true;
            }

            // ... Validate for assignated person
            if (serviceInformationBasicInformationGatewayForId.GetToTeamMember(serviceId))
            {
                pnlTeamMemberAssigned.Visible = true;
                pnlThirdPartyVendorAssigned.Visible = false;
                pnlTeamMemberAssignedReadOnly.Visible = true;
                pnlThirdPartyVendorAssignedReadOnly.Visible = false;
            }
            else
            {
                pnlTeamMemberAssigned.Visible = false;
                pnlThirdPartyVendorAssigned.Visible = true;
                pnlTeamMemberAssignedReadOnly.Visible = false;
                pnlThirdPartyVendorAssignedReadOnly.Visible = true;

            }
        }