Пример #1
0
        ///	<summary>
        /// Button Add_Click
        ///	</summary>
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                bool retVal = false;
                lblConfirmation.Text    = "";
                lblConfirmation.Visible = true;

                populateTrailer();

                if (m_isUpdate)
                {
                    retVal = UpdateTrailer();
                }
                else
                {
                    retVal = AddTrailer();
                }

                if (retVal)
                {
                    if (m_isUpdate)
                    {
                        lblConfirmation.Text = "The trailer has been updated successfully.";
                    }
                    else
                    {
                        lblConfirmation.Text = "The trailer has been added successfully.";
                        btnAdd.Text          = "Update";
                    }

                    if (cboControlArea.SelectedValue != String.Empty && cboTrafficArea.SelectedValue != String.Empty)
                    {
                        using (Facade.IResource facResource = new Facade.Resource())
                            facResource.AssignToArea(Convert.ToInt32(cboControlArea.SelectedValue), Convert.ToInt32(cboTrafficArea.SelectedValue), trailer.ResourceId, "Trailer has been updated", ((Entities.CustomPrincipal)Page.User).UserName);
                    }

                    // refresh the page we came from if it is expecting a call back
                    this.ClientScript.RegisterStartupScript(this.GetType(), "CallBack", "__dialogCallBack(window, 'refresh');", true);

                    this.ReturnValue = lblConfirmation.Text;

                    this.Close();
                }
                else
                {
                    if (string.IsNullOrWhiteSpace(lblConfirmation.Text))
                    {
                        lblConfirmation.Text = m_isUpdate ? "The trailer has not been updated successfully." : "The trailer has not been added successfully.";
                    }

                    this.ReturnValue = lblConfirmation.Text;
                }
            }
        }
Пример #2
0
        ///	<summary>
        /// Button Add Click
        ///	</summary>
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                bool retVal = false;

                if (_driver == null)
                {
                    populateDriver();
                }

                if (_isUpdate)
                {
                    retVal = UpdateDriver();

                    if (retVal)
                    {
                        lblConfirmation.Text = "The Driver has been updated successfully";

                        if (cboControlArea.SelectedValue != String.Empty && cboTrafficArea.SelectedValue != String.Empty)
                        {
                            using (Facade.IResource facResource = new Facade.Resource())
                                facResource.AssignToArea(Convert.ToInt32(cboControlArea.SelectedValue), Convert.ToInt32(cboTrafficArea.SelectedValue), _driver.ResourceId, "Driver has been updated", ((Entities.CustomPrincipal)Page.User).UserName);
                        }

                        this.ReturnValue = lblConfirmation.Text;
                    }
                }
                else
                {
                    retVal = AddDriver();

                    if (retVal)
                    {
                        lblConfirmation.Text = "The Driver has been added successfully.";

                        if (cboControlArea.SelectedValue != String.Empty && cboTrafficArea.SelectedValue != String.Empty)
                        {
                            using (Facade.IResource facResource = new Facade.Resource())
                                facResource.AssignToArea(Convert.ToInt32(cboControlArea.SelectedValue), Convert.ToInt32(cboTrafficArea.SelectedValue), _driver.ResourceId, "Driver has been updated", ((Entities.CustomPrincipal)Page.User).UserName);
                        }

                        this.ReturnValue = lblConfirmation.Text;
                    }
                }

                lblConfirmation.Visible = true;

                if (retVal)
                {
                    this.ReturnValue = "success";
                    this.Close();
                }
            }
        }
Пример #3
0
        void btnConfirm_Click(object sender, EventArgs e)
        {
            Facade.IResource facResource = new Facade.Resource();
            int controlAreaId            = int.Parse(cboControlArea.SelectedValue);
            int trafficAreaId            = int.Parse(cboTrafficArea.SelectedValue);

            if (m_instructionId != 0)
            {
                Facade.IInstruction  facInstruction = new Facade.Instruction();
                Entities.Instruction instruction    = facInstruction.GetInstruction(m_instructionId);

                if (instruction.Driver != null)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, instruction.Driver.ResourceId, "Driver was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
                if (instruction.Vehicle != null)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, instruction.Vehicle.ResourceId, "Vehicle was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
                if (instruction.Trailer != null)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, instruction.Trailer.ResourceId, "Trailer was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
            }
            else
            {
                if (m_driverResourceId != 0)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, m_driverResourceId, "Driver was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
                if (m_vehicleResourceId != 0)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, m_vehicleResourceId, "Vehicle was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
                if (m_trailerResourceId != 0)
                {
                    facResource.AssignToArea(controlAreaId, trafficAreaId, m_trailerResourceId, "Trailer was updated via give resources", ((Entities.CustomPrincipal)Page.User).UserName);
                }
            }

            mwhelper.CausePostBack = false;
            mwhelper.CloseForm     = true;
        }
Пример #4
0
        ///	<summary>
        /// Button Add
        ///	</summary>
        private void btnAdd_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                Entities.FacadeResult retVal;

                populateVehicle();

                if (m_isUpdate)
                {
                    retVal = UpdateVehicle();
                }
                else
                {
                    retVal = AddVehicle();
                }

                if (m_isUpdate)
                {
                    if (retVal.Success)
                    {
                        infringementDisplay.Visible = false;
                        lblConfirmation.Text        = "The vehicle has been updated successfully.";
                        // refresh the page we came from if it is expecting a call back
                        this.ClientScript.RegisterStartupScript(this.GetType(), "CallBack", "window.opener.location.reload()", true);

                        if (cboControlArea.SelectedValue != String.Empty && cboTrafficArea.SelectedValue != String.Empty)
                        {
                            using (Facade.IResource facResource = new Facade.Resource())
                                facResource.AssignToArea(Convert.ToInt32(cboControlArea.SelectedValue), Convert.ToInt32(cboTrafficArea.SelectedValue), vehicle.ResourceId, "Vehicle has been updated", ((Entities.CustomPrincipal)Page.User).UserName);
                        }

                        audit.Reload();

                        mwhelper.OutputData = lblConfirmation.Text;
                        mwhelper.CloseForm  = true;
                    }
                    else
                    {
                        // Display the infringements
                        infringementDisplay.Visible       = true;
                        infringementDisplay.Infringements = retVal.Infringements;
                        infringementDisplay.DisplayInfringments();

                        lblConfirmation.Visible   = true;
                        lblConfirmation.ForeColor = Color.Red;

                        if (!string.IsNullOrEmpty(retVal.ErrorMessage))
                        {
                            lblConfirmation.Text = retVal.ErrorMessage;
                        }
                        else
                        {
                            lblConfirmation.Text = "The vehicle has not been updated successfully.";
                        }
                    }
                }
                else
                {
                    if (retVal.Success)
                    {
                        infringementDisplay.Visible = false;

                        lblConfirmation.Text = "The vehicle has been added successfully.";
                        // refresh the page we came from if it is expecting a call back
                        this.ClientScript.RegisterStartupScript(this.GetType(), "CallBack", "window.opener.location.reload();", true);

                        if (cboControlArea.SelectedValue != String.Empty && cboTrafficArea.SelectedValue != String.Empty)
                        {
                            using (Facade.IResource facResource = new Facade.Resource())
                                facResource.AssignToArea(Convert.ToInt32(cboControlArea.SelectedValue), Convert.ToInt32(cboTrafficArea.SelectedValue), vehicle.ResourceId, "Vehicle has been updated", ((Entities.CustomPrincipal)Page.User).UserName);
                        }

                        // Switch to update mode
                        ViewState[C_RESOURCE_ID] = vehicle.ResourceId;
                        m_isUpdate = true;

                        string confirmMessage = @"javascript:return(confirm('Any changes you have made will need to be saved before you continue.\nTo save your changes, click Cancel, the click the " + (m_isUpdate ? "Update" : "Add") + " button, you may then try again.'))";
                        btnAddVehicleKey.Enabled = m_isUpdate;
                        btnAddVehicleKey.Attributes.Add("onClick", confirmMessage);
                        btnAdd.Text = "Update";

                        mwhelper.OutputData = lblConfirmation.Text;
                        mwhelper.CloseForm  = true;
                    }
                    else
                    {
                        // Display the infringements
                        infringementDisplay.Visible       = true;
                        infringementDisplay.Infringements = retVal.Infringements;
                        infringementDisplay.DisplayInfringments();

                        lblConfirmation.Visible   = true;
                        lblConfirmation.ForeColor = Color.Red;

                        if (!string.IsNullOrEmpty(retVal.ErrorMessage))
                        {
                            lblConfirmation.Text = retVal.ErrorMessage;
                        }
                        else
                        {
                            lblConfirmation.Text = "The vehicle has not been updated successfully.";
                        }
                    }
                }

                lblConfirmation.Visible = true;
            }
        }