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;
            }
        }
Ejemplo n.º 2
0
        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;
                }
            }
        }
Ejemplo n.º 4
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);
                }
            }
        }
Ejemplo n.º 5
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;
        }
        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;

            }
        }
        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 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;
                    }
                }
            }
        }
        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;
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // 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 TagPage()
        {
            hdfCompanyId.Value = Session["companyID"].ToString();
            hdfServiceId.Value = Request.QueryString["service_id"];
            hdfActiveTab.Value = Request.QueryString["active_tab"].ToString();

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

            ServiceInformationBasicInformationGateway serviceInformationBasicInformationGatewayForId = new ServiceInformationBasicInformationGateway();
            serviceInformationBasicInformationGatewayForId.LoadByServiceId(serviceId, companyId);
            int? unitId = serviceInformationBasicInformationGatewayForId.GetUnitID(serviceId);

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

            int companyLevel = Int32.Parse(hdfCompanyLevel.Value);
            CompanyLevelGateway companyLevelGateway = new CompanyLevelGateway();
            companyLevelGateway.LoadByCompanyLevelId(companyLevel, companyId);
            hdfMileageUnitOfMeasurement.Value = companyLevelGateway.GetUnitsUnitOfMeasurement(companyLevel);
            lblPnlStartWorkStartMileageUnitOfMeasurement.Text = hdfMileageUnitOfMeasurement.Value;
            lblPnlCompleteWorkCompleteMileageUnitOfMeasurement.Text = hdfMileageUnitOfMeasurement.Value;
        }
        private void UpdateDatabase()
        {
            // Get ids
            int serviceId = Int32.Parse(hdfServiceId.Value);
            string serviceType = hdfFmType.Value;
            int companyId = Int32.Parse(hdfCompanyId.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);

            // Delete
            DB.Open();
            DB.BeginTransaction();
            try
            {
                ServiceInformationBasicInformation serviceInformationBasicInformation = new ServiceInformationBasicInformation(serviceInformationTDS);
                serviceInformationBasicInformation.DeleteDirect(serviceId, unitType, (int)unitId, companyId);

                DB.CommitTransaction();
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }
        protected void btnEdit_Click(object sender, EventArgs e)
        {
            int companyId = Int32.Parse(hdfCompanyId.Value.Trim());

            PostPageChanges();

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

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

                // Redirect
                string url = "./units_edit.aspx?source_page=units_navigator2.aspx&unit_id=" + unitId + "&unit_type=" + unitType + "&unit_state=" + unitState + "&active_tab=0" + GetNavigatorState();
                Response.Redirect(url);
            }
            else
            {
                RestoreNavigatorState();
                cvSelection.IsValid = false;
            }
        }
Ejemplo 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();");
        }
        // ////////////////////////////////////////////////////////////////////////
        // 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;
        }
Ejemplo n.º 16
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 Page_PreRender(object sender, EventArgs e)
        {
            // Set active toolbar
            mForm6 master = (mForm6)this.Master;
            master.ActiveToolbar = "FleetManagement";

            // 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;
                lblCompleteWorkDataCompleteMileage.Visible = false;
                tbxCompleteWorkDataCompleteMileage.Visible = false;
                lblCompleteWorkDataMileageUnitOfMeasurement.Visible = false;
            }
            else
            {
                lblGeneralMileage.Visible = true;
                tbxGeneralMileage.Visible = true;
                lblStartWorkDataStartMileage.Visible = true;
                tbxStartWorkDataStartMileage.Visible = true;
                lblCompleteWorkDataCompleteMileage.Visible = true;
                tbxCompleteWorkDataCompleteMileage.Visible = true;
                lblGeneralMileageUnitOfMeasurement.Visible = true;
                lblStartWorkDataMileageUnitOfMeasurement.Visible = true;
                lblCompleteWorkDataMileageUnitOfMeasurement.Visible = true;
            }

            // ... Validate Assignation result
            hdfServiceState.Value = serviceInformationBasicInformationGatewayForId.GetServiceState(serviceId);
            string state = hdfServiceState.Value;

            if ((state == "Accepted") || (state == "In Progress") || (state == "Completed"))
            {
                pnlAssignmentAccept.Visible = true;
                pnlAssignmentReject.Visible = false;
            }
            else
            {
                if (state == "Rejected")
                {
                    pnlAssignmentAccept.Visible = false;
                    pnlAssignmentReject.Visible = true;
                }
                else
                {
                    pnlAssignmentAccept.Visible = false;
                    pnlAssignmentReject.Visible = false;
                }
            }

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

            // Validations for Top Menu
            // ... Get user and service data
            // ... ... Get logged employeeId
            int loginId = Int32.Parse(hdfLoginId.Value);
            bool serviceAdmin = Convert.ToBoolean(Session["sgLFS_FLEETMANAGEMENT_SERVICES_ADMIN"]);
            EmployeeGateway employeeGateway = new EmployeeGateway(new DataSet());
            int employeeId = employeeGateway.GetEmployeIdByLoginId(loginId);

            // ... ... Get ownerId,  assignTeamMemberId
            int ownerId = serviceInformationBasicInformationGatewayForId.GetOwnerID(serviceId);
            int? assignTeamMemberId = null; if (serviceInformationBasicInformationGatewayForId.GetAssignTeamMemberId(serviceId).HasValue) assignTeamMemberId = (int)serviceInformationBasicInformationGatewayForId.GetAssignTeamMemberId(serviceId);

            // ... Delete option
            if (((employeeId == ownerId) || (serviceAdmin)) && (IsDeletedSR(serviceId)))
            {
                tkrmTop.Items[1].Visible = true;
            }
            else
            {
                tkrmTop.Items[1].Visible = false;
            }

            // ... Assign option
            if ((serviceAdmin) && ((state == "Unassigned") || (state == "Rejected")))
            {
                tkrmTop.Items[2].Visible = true;
            }
            else
            {
                tkrmTop.Items[2].Visible = false;
            }

            // ... User options
            tkrmTop.Items[3].Visible = false; // Accept
            tkrmTop.Items[4].Visible = false; // Reject
            tkrmTop.Items[5].Visible = false; // Start Work
            tkrmTop.Items[6].Visible = false; // Complete Work

            // ... Accept/Reject options
            if (((employeeId == assignTeamMemberId)|| (serviceAdmin)) && (state == "Assigned"))
            {
                tkrmTop.Items[3].Visible = true;
                tkrmTop.Items[4].Visible = true;
                tkrmTop.Items[5].Visible = false;
                tkrmTop.Items[6].Visible = false;
            }

            // ... Start work option
            if (((employeeId == assignTeamMemberId)|| (serviceAdmin)) && (state == "Accepted"))
            {
                tkrmTop.Items[3].Visible = false;
                tkrmTop.Items[4].Visible = false;
                tkrmTop.Items[5].Visible = true;
                tkrmTop.Items[6].Visible = false;
            }

            // ... Start work option
            if (((employeeId == assignTeamMemberId) || (serviceAdmin)) && (state == "In Progress"))
            {
                tkrmTop.Items[3].Visible = false;
                tkrmTop.Items[4].Visible = false;
                tkrmTop.Items[5].Visible = false;
                tkrmTop.Items[6].Visible = true;
            }

            // ... Last Search or Dashboard
            tkrmTopNavigation.Items[2].Visible = true; // Last search
            tkrmTopNavigation.Items[3].Visible = false; // Dashboard

            if (hdfDashboard.Value == "True")
            {
                tkrmTopNavigation.Items[2].Visible = false; // Last search
                tkrmTopNavigation.Items[3].Visible = true; // Dashboard
            }
        }