private void btnAdd_Click(object sender, EventArgs e) { if (Page.IsValid) { PopulateRequest(); bool success = false; string userId = ((Entities.CustomPrincipal)Page.User).UserName; using (Facade.IPlannerRequest facPlannerRequest = new Facade.PlannerRequest()) { if (m_isUpdate) { success = facPlannerRequest.Update(m_request, userId); } else { m_request.RequestId = facPlannerRequest.Create(m_request, userId); success = m_request.RequestId > 0; } lblConfirmation.Text = "The request has " + (success ? "" : "not") + "been " + (m_isUpdate ? "updated." : "added."); lblConfirmation.Visible = true; if (success) { ViewState[C_REQUEST_VS] = m_request; btnAdd.Text = "Update Request"; } } } }
protected void Page_Load(object sender, System.EventArgs e) { Orchestrator.WebUI.Security.Authorise.EnforceAuthorisation(eSystemPortion.GeneralUsage, eSystemPortion.Plan); m_requestId = Convert.ToInt32(Request.QueryString["RequestId"]); m_sourceJobId = Convert.ToInt32(Request.QueryString["SourceJobId"]); m_targetJobId = Convert.ToInt32(Request.QueryString["TargetJobId"]); m_request = (Entities.PlannerRequest)ViewState[C_REQUEST_VS]; if (!IsPostBack) { if (m_requestId > 0) { m_isUpdate = true; using (Facade.IPlannerRequest facPlannerRequest = new Facade.PlannerRequest()) { m_request = facPlannerRequest.GetPlannerRequestForRequestId(m_requestId); ViewState[C_REQUEST_VS] = m_request; txtRequestText.Text = m_request.RequestText; txtSourceJobId.Text = m_request.SourceJobId.ToString(); txtTargetJobId.Text = m_request.TargetJobId.ToString(); chkUseDriver.Checked = m_request.UseDriver; chkUseVehicle.Checked = m_request.UseVehicle; chkUseTrailer.Checked = m_request.UseTrailer; } } else { if (m_sourceJobId > 0) { txtSourceJobId.Text = m_sourceJobId.ToString(); } if (m_targetJobId > 0) { txtTargetJobId.Text = m_targetJobId.ToString(); } } } if (m_request != null) { m_isUpdate = true; btnAdd.Text = "Update Request"; } else { btnAdd.Text = "Add Request"; } lblConfirmation.Visible = false; }
private void BindData() { if (m_jobId > 0) { Facade.IPlannerRequest facPlannerRequest = new Facade.PlannerRequest(); dgRequests.DataSource = facPlannerRequest.GetPlannerRequestsForJobId(m_jobId); dgRequests.DataBind(); lblJobId.Text = m_jobId.ToString(); } }
private void dgRequests_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToLower()) { case "delete": int requestId = Convert.ToInt32(e.Item.Cells[0].Text); Facade.IPlannerRequest facPlannerRequest = new Facade.PlannerRequest(); bool success = facPlannerRequest.Delete(requestId); if (success) { BindData(); } lblConfirmation.Text = "The planner request was " + (success ? "" : "not ") + "deleted."; lblConfirmation.Visible = true; break; } }
private void BindData() { // Get the users we're interested in StringBuilder sb = new StringBuilder(); foreach (ListItem item in chkPlanners.Items) { if (item.Selected) { if (sb.Length > 0) { sb.Append(","); } sb.Append(item.Value); } } // Get the job id int jobId = 0; try { jobId = Convert.ToInt32(txtJobId.Text); } catch {} using (Facade.IPlannerRequest facPlannerRequest = new Facade.PlannerRequest()) { dgRequests.DataSource = facPlannerRequest.GetPlannerRequests(sb.ToString(), jobId); dgRequests.DataBind(); if (((DataTable)dgRequests.DataSource).Rows.Count == 0) { dgRequests.Visible = false; } else { dgRequests.Visible = true; } } }
private void PopulatePage() { // Populate the Job fieldset. lblJobId.Text = m_jobId.ToString(); lblJobState.Text = Utilities.UnCamelCase(m_job.JobState.ToString()); lblJobType.Text = Utilities.UnCamelCase(m_job.JobType.ToString()); if (m_job.CurrentTrafficArea == null) { lblCurrentTrafficArea.Text = "Unknown"; } else { lblCurrentTrafficArea.Text = m_job.CurrentTrafficArea.TrafficAreaName; } lblStockMovement.Text = (m_job.IsStockMovement ? "Yes" : "No"); using (Facade.IPlannerRequest facPlannerRequest = new Facade.PlannerRequest()) { if ((facPlannerRequest.GetPlannerRequestsForJobId(m_job.JobId)).Tables[0].Rows.Count > 0) { imgHasRequests.Visible = true; imgHasRequests.Attributes.Add("onClick", "javascript:ShowPlannerRequests('" + m_job.JobId.ToString() + "');"); } else { imgHasRequests.Visible = false; } } // Populate the cancelation controls txtCancellationReason.Text = m_job.ForCancellationReason; if (m_job.JobState == eJobState.Cancelled || m_job.HasBeenPosted) { btnCancelJob.Enabled = false; } // No reason for cancellation is required if the job type is groupage as groupage jobs get deleted upon cancellation. cancellationTable.Visible = m_job.JobType != eJobType.Groupage; }