/// <summary> /// Populate Static Controls /// </summary> private void PopulateStaticControls() { chkPCVStatus.DataSource = Utilities.UnCamelCase(Enum.GetNames(typeof(ePCVStatus))); chkPCVStatus.DataBind(); foreach (ListItem item in chkPCVStatus.Items) { if (item.Text == Utilities.UnCamelCase(ePCVStatus.Outstanding.ToString())) { item.Selected = true; } } Facade.PCV facPCV = new Facade.PCV(); chkPCVRedemptionStatus.DataSource = facPCV.GetAllPCVRedemptionStatuses(false); chkPCVRedemptionStatus.DataBind(); foreach (ListItem item in chkPCVRedemptionStatus.Items) { if (item.Value == ((int)ePCVRedemptionStatus.ToBeRedeemed).ToString()) { item.Selected = true; } } }
private void LoadJob() { Facade.IJob facJob = new Facade.Job(); m_job = facJob.GetJob(m_jobId); if (m_job != null) { if (m_job.JobState == eJobState.Cancelled) { Response.Redirect("../../Job/job.aspx?wiz=true&jobId=" + m_job.JobId.ToString() + "&csid=" + this.CookieSessionID); } Facade.IPCV facPCV = new Facade.PCV(); m_job.PCVs = facPCV.GetForJobId(m_jobId); if (m_job.JobState == eJobState.Booked) { Response.Redirect("../jobManagement.aspx?jobId=" + m_jobId + "&csid=" + this.CookieSessionID); } // Load the various parts of the job. Facade.IInstruction facInstruction = new Facade.Instruction(); m_job.Instructions = facInstruction.GetForJobId(m_jobId); PopulateJobInformation(); } ViewState[C_JOB_VS] = m_job; }
void btnAdd_Click(object sender, System.EventArgs e) { if (Page.IsValid) { Button currentButton = sender as Button; Facade.IPCV facPCV = new Facade.PCV(); Facade.ITrafficArea facTrafficArea = new Facade.Traffic(); Entities.PCV newPCV = LoadPCV(); int pcvID = facPCV.Create(newPCV, ((Entities.CustomPrincipal)Page.User).UserName); //Do reset if specified switch (currentButton.CommandArgument.ToLower()) { case "add_reset": ConfigureDisplay(); break; } //Popup PCV Details if (pcvID > 0) { ShowConfirmationWindow(newPCV.ScannedFormId, pcvID); } LoadPCVList(); } }
private void dgRequiringScan_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e) { Facade.IPCV facPCV = new Facade.PCV(); DataSet dsRequiringScan = facPCV.GetRequiringScan(); //' Retrieve the data source from session state. DataTable dt = dsRequiringScan.Tables[0]; //' Create a DataView from the DataTable. DataView dv = new DataView(dt); //' The DataView provides an easy way to sort. Simply set the //' Sort property with the name of the field to sort by. if (this.SortCriteria == e.SortExpression) { if (this.SortDir == "desc") { this.SortDir = "asc"; } else { this.SortDir = "desc"; } } this.SortCriteria = e.SortExpression; dv.Sort = e.SortExpression + ' ' + this.SortDir; //' Re-bind the data source and specify that it should be sorted //' by the field specified in the SortExpression property. dgRequiringScan.DataSource = dv; dgRequiringScan.DataBind(); }
protected void Page_Load(object sender, System.EventArgs e) { // Retrieve the job we're working on try { if (Request.QueryString["pointID"] != null) { int.TryParse(Request.QueryString["pointID"], out m_PointId); } m_jobId = Convert.ToInt32(ViewState[C_JOB_ID_VS]); m_deliveryPointId = Convert.ToInt32(ViewState[C_DELIVERY_POINT_ID_VS]); Facade.IJob facJob = new Facade.Job(); m_job = facJob.GetJob(m_jobId); Facade.IPCV facPCV = new Facade.PCV(); m_job.PCVs = facPCV.GetForJobId(m_jobId, m_deliveryPointId); } catch {} if (!IsPostBack) { PopulateStaticControls(); LoadJobs(); } }
private void PopulateRequiringScan() { Facade.IPCV facPCV = new Facade.PCV(); DataSet dsRequiringScan = facPCV.GetRequiringScan(); dgRequiringScan.DataSource = dsRequiringScan; dgRequiringScan.DataBind(); }
/// <summary> /// Retrieved the pcvs that apply to this point and populates the pcvs datagrid. /// </summary> private void BindPCVs() { using (Facade.IPCV facPCV = new Facade.PCV()) { DataSet dsPCVs = facPCV.GetForJobIdAndDeliveryPointId(m_jobId, m_pointId); dgPCVs.DataSource = dsPCVs; dgPCVs.DataBind(); } }
private void ConfigureDisplay() { if (!string.IsNullOrEmpty(Request.QueryString["JobID"])) { int.TryParse(Request.QueryString["JobID"], out l_jobID); } Facade.PCV facPCV = new Facade.PCV(); this.lvPCVs.DataSource = facPCV.GetForJobIdDataSet(l_jobID); this.lvPCVs.DataBind(); }
/// <summary> /// Update PCV /// </summary> private bool UpdatePCV() { Facade.IPCV facPCV = new Facade.PCV(); bool retVal = false; string userName = ((Entities.CustomPrincipal)Page.User).UserName; dgDeliveryPoint.Enabled = true; retVal = facPCV.Update(pcv, userName); dgDeliveryPoint.Enabled = false; return(retVal); }
private void PopulatePCVS() { Facade.IPCV facPCV = new Facade.PCV(); DataSet ds = facPCV.GetForJobIdDataSet(m_jobId); dgPCVs.DataSource = ds; dgPCVs.DataBind(); if (ds.Tables[0].Rows.Count > 0) { pnlPCVs.Visible = true; } }
private void LoadPCVs(int jobId) { Facade.IPCV facPCV = new Facade.PCV(); DataSet ds = facPCV.GetPCVsThatCanBeTaken(jobId); DataView dv = new DataView(ds.Tables[0]); string sortExpression = PCVSortCriteria + " " + PCVSortDirection; dv.Sort = sortExpression.Trim(); dv.RowFilter = "PointId = " + m_deliveryPointId.ToString(); m_palletCount = 0; dgPCVs.DataSource = dv; dgPCVs.DataBind(); lblPalletCount.Text = m_palletCount.ToString(); dgPCVs.Visible = dv.Table.Rows.Count > 0; btnTakeOnJob.Enabled = dv.Table.Rows.Count > 0; btnGenerateRedemptionForm.Enabled = dv.Table.Rows.Count > 0; }
private void dgJobs_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName) { case "AttachPCVs": m_jobId = Convert.ToInt32(e.Item.Cells[0].Text); m_deliveryPointId = Convert.ToInt32(e.Item.Cells[5].Text); ViewState[C_JOB_ID_VS] = m_jobId; ViewState[C_DELIVERY_POINT_ID_VS] = m_deliveryPointId; Facade.IJob facJob = new Facade.Job(); m_job = facJob.GetJob(m_jobId); Facade.IPCV facPCV = new Facade.PCV(); m_job.PCVs = facPCV.GetForJobId(m_jobId, m_deliveryPointId); LoadJobs(); LoadPCVs(m_jobId); break; } }
private void LoadReport(int jobId) { Facade.IPCV facPCV = new Facade.PCV(); DataSet dsPoints = facPCV.GetPointsWithPCVsForJobId(jobId); NameValueCollection reportParams = new NameValueCollection(); reportParams.Add("JobId", jobId.ToString()); //------------------------------------------------------------------------------------- // Load Report Section //------------------------------------------------------------------------------------- Session[Globals.Constants.ReportTypeSessionVariable] = eReportType.PCVRedemptionForm; Session[Globals.Constants.ReportDataSessionTableVariable] = dsPoints; Session[Globals.Constants.ReportDataSessionSortVariable] = String.Empty; Session[Globals.Constants.ReportDataMemberSessionVariable] = "Table"; Session[Globals.Constants.ReportParamsSessionVariable] = reportParams; // Show the user control reportViewer.Visible = true; }
/// <summary> /// Add PCV /// </summary> private bool AddPCV() { int PCVId = 0; Facade.IPCV facPCV = new Facade.PCV(); bool retVal = false; string userName = ((Entities.CustomPrincipal)Page.User).UserName; int deliveryPointId = FindSelectedPoint(); if (deliveryPointId == 0) { lblConfirmation.Text = "Please select a Delivery Point and then try again, please."; lblConfirmation.Visible = true; lblConfirmation.ForeColor = Color.Red; return(retVal); } else { pcv.DeliverPointId = deliveryPointId; PCVId = facPCV.Create(pcv, m_jobId, userName); } if (PCVId == 0) { lblConfirmation.Text = "There was an error adding the PCV, please try again."; lblConfirmation.Visible = true; lblConfirmation.ForeColor = Color.Red; retVal = false; } else { lblJobPCV.Text = "PCV Id"; } txtJobPCVId.Text = PCVId.ToString(); btnAdd.Text = "Update PCV"; retVal = true; return(retVal); }
private Entities.Job GetJobEntityFromCache() { Entities.Job job = (Entities.Job)Cache.Get("JobEntityForJobId" + m_jobID); if (job == null) { Facade.IJob facJob = new Facade.Job(); Facade.IPCV facPCV = new Facade.PCV(); Facade.IJobSubContractor facJobSubContractor = new Facade.Job(); job = facJob.GetJob(m_jobID, true, true); job.Charge = ((Facade.IJobCharge)facJob).GetForJobId(m_jobID); job.Extras = facJob.GetExtras(m_jobID, true); job.PCVs = facPCV.GetForJobId(m_jobID); job.References = ((Facade.IJobReference)facJob).GetJobReferences(m_jobID); job.SubContractors = facJobSubContractor.GetSubContractorForJobId(m_jobID); AddJobEntityToCache(job); } return(job); }
private void GetData() { Facade.IPCV facPCV = new Facade.PCV(); int pCVId = m_pcvId; bool noCriteria = false; if ((txtVoucherNo.Text == "") && (m_jobId == 0) && (txtJobId.Text == "") && (pCVId == 0) && (cboClient.SelectedValue.ToString() == "") && (cboClientsCustomer.SelectedValue.ToString() == "") && (!dteStartDate.SelectedDate.HasValue || dteStartDate.SelectedDate.Value == DateTime.MinValue) && (!dteEndDate.SelectedDate.HasValue || dteEndDate.SelectedDate.Value == DateTime.MinValue)) { noCriteria = true; } // CHECK TO SEE IF ANY OF THE CHECK BOX LISTS ARE CHECKED foreach (ListItem item in chkPCVStatus.Items) { if (item.Selected) { noCriteria = false; } } foreach (ListItem item in chkPCVRedemptionStatus.Items) { if (item.Selected) { noCriteria = false; } } if (noCriteria) { // Get all PCVs dsPCV = facPCV.GetAll(); } else { // Params int jobId = 0; try { jobId = Convert.ToInt32(txtJobId.Text); } catch { } string voucherNo = txtVoucherNo.Text; int clientId = cboClient.SelectedValue != "" ? Convert.ToInt32(cboClient.SelectedValue) : 0; int clientsCustomerId = cboClientsCustomer.SelectedValue != "" ? Convert.ToInt32(cboClientsCustomer.SelectedValue) : 0; string pCVStatusIdCSV = String.Empty; foreach (ListItem item in chkPCVStatus.Items) { if (item.Selected) { if (pCVStatusIdCSV != String.Empty) { pCVStatusIdCSV += ","; } pCVStatusIdCSV += (int)Enum.Parse(typeof(ePCVStatus), item.Text.Replace(" ", "")); //Convert.ToInt32(item.Value); } } string pCVRedemptionStatusIdCSV = String.Empty; foreach (ListItem item in chkPCVRedemptionStatus.Items) { if (item.Selected) { if (pCVRedemptionStatusIdCSV != String.Empty) { pCVRedemptionStatusIdCSV += ","; } pCVRedemptionStatusIdCSV += item.Value; //(int)Enum.Parse(typeof(ePCVRedemptionStatus), item.Text.Replace(" ", "")); //Convert.ToInt32(item); } } int hasBeenSent = cboView.Visible ? Convert.ToInt32(cboView.SelectedValue) : 0; DateTime startDate = dteStartDate.SelectedDate.HasValue ? dteStartDate.SelectedDate.Value : DateTime.MinValue; DateTime endDate = dteEndDate.SelectedDate.HasValue ? dteEndDate.SelectedDate.Value : DateTime.MinValue; if (startDate == DateTime.MinValue || endDate == DateTime.MinValue) { dsPCV = facPCV.GetwithParams(jobId, clientId, clientsCustomerId, pCVId, pCVStatusIdCSV, pCVRedemptionStatusIdCSV, hasBeenSent, voucherNo); } else { endDate = endDate.Add(new TimeSpan(23, 59, 00)); dsPCV = facPCV.GetwithParamsAndDate(jobId, clientId, clientsCustomerId, pCVId, pCVStatusIdCSV, pCVRedemptionStatusIdCSV, hasBeenSent, voucherNo, startDate, endDate); } } }
private void btnTakeOnJob_Click(object sender, EventArgs e) { reportViewer.Visible = false; Facade.IPCV facPCV = new Facade.PCV(); Entities.PCVCollection pcvs = new Entities.PCVCollection(); List <int> updatePCVIDs = new List <int>(); int pcvId; DateTime AgreedDateTime; string ClientContact = string.Empty; m_palletCount = 0; foreach (DataGridItem item in dgPCVs.Items) { CheckBox takePCV = (CheckBox)item.FindControl("chkTakePCV"); CheckBox updatePCV = item.FindControl("chkUpdatePCV") as CheckBox; if (takePCV.Checked) { pcvId = Convert.ToInt32(item.Cells[0].Text); m_palletCount += Convert.ToInt32(item.Cells[4].Text); Entities.PCV pcv = facPCV.GetForPCVId(pcvId); pcvs.Add(pcv); } if (updatePCV.Checked) { updatePCVIDs.Add(int.Parse(item.Cells[0].Text)); } } lblPalletCount.Text = m_palletCount.ToString(); if (rdiSlotDate.SelectedDate.HasValue && rdiSlotTime.SelectedDate.HasValue) { AgreedDateTime = new DateTime(rdiSlotDate.SelectedDate.Value.Year, rdiSlotDate.SelectedDate.Value.Month, rdiSlotDate.SelectedDate.Value.Day, rdiSlotTime.SelectedDate.Value.Hour, rdiSlotTime.SelectedDate.Value.Minute, 0); } else { AgreedDateTime = DateTime.Today; } // If the client contact is empty, the agreed redemption details will not be added. ClientContact = txtClientContact.Text; Facade.IJob facJob = new Facade.Job(); bool success = facJob.TakePCVs(m_jobId, m_deliveryPointId, pcvs, updatePCVIDs, AgreedDateTime, ClientContact, ((Entities.CustomPrincipal)Page.User).Name); if (success) { LoadPCVAgreements(m_jobId); m_job.PCVs = facPCV.GetForJobId(m_jobId, m_deliveryPointId); LoadPCVs(m_jobId); if (m_job.PCVs.Count > 0) { LoadReport(m_jobId); } else { reportViewer.Visible = false; } } else { lblConfirmation.Visible = true; lblConfirmation.Text = "The specified PCVs will not be taken on the specified job as an error occurred, please try again."; } }
private void LoadPCVAgreements(int jobID) { Facade.IPCV facPCV = new Facade.PCV(); lvPCVRedemptionAgreed.DataSource = facPCV.GetPCVAgreementsForJobID(jobID); lvPCVRedemptionAgreed.DataBind(); }
/// <summary> /// Load PCV /// </summary> private void LoadPCV() { // May be required to be shown if PCV's are allowed to be deleted once created //chkDelete.Visible = true; //pnlPCVDeleted.Visible = true; if (ViewState["pcv"] == null) { Facade.IPCV facPCV = new Facade.PCV(); pcv = facPCV.GetForPCVId(m_PCVId); ViewState["pcv"] = pcv; } else { pcv = (Entities.PCV)ViewState["pcv"]; } if (m_isUpdate) { txtJobPCVId.Text = pcv.PCVId.ToString(); } else { txtJobPCVId.Text = m_jobId.ToString(); } txtVoucherNo.Text = pcv.VoucherNo.ToString(); txtNoOfPallets.Text = pcv.NoOfPalletsReceived.ToString(); dteDateOfIssue.SelectedDate = pcv.DateOfIssue; txtDepotId.Text = pcv.DepotId.ToString(); cboPCVStatus.Items.FindByValue(pcv.PCVStatusId.ToString()).Selected = true; cboPCVRedemptionStatus.Items.FindByValue(pcv.PCVRedemptionStatusId.ToString()).Selected = true; // Load dgDeliveryPoints with the relevant fields and markers int deliveryPointId = pcv.DeliverPointId; // Get point and mark it checked in the grid Facade.IPoint facPoint = new Facade.Point(); DataSet ds = facPoint.GetPointForPointId(deliveryPointId, "DataSet"); dgDeliveryPoint.DataSource = ds; dgDeliveryPoint.DataBind(); foreach (DataGridItem dgItem in dgDeliveryPoint.Items) { // Get RdoBtnGrouper object RdoBtnGrouper selectRadioButton = dgItem.FindControl("selectRadioButton") as RdoBtnGrouper; // Make the row highlight the radiobutton selectRadioButton.Checked = true; } txtSignings.Text = pcv.NoOfSignings.ToString(); //if (pcv.PCVStatus == ePCVStatus.NotApplicable) // chkDelete.Checked = true; Header1.Title = "Update PCV"; Header1.subTitle = "Please make any changes neccessary."; btnAdd.Text = "Update"; }
private void LoadPCVList() { Facade.IPCV facPCV = new Facade.PCV(); lvLastPCVs.DataSource = facPCV.GetLast10UnattachedCreated(); lvLastPCVs.DataBind(); }
private void LoadReport() { NameValueCollection reportParams = new NameValueCollection(); string redemptionStatusCSV = null; switch (m_reportType) { case "beingRedeemed": reportParams.Add("ReportType", "beingRedeemed"); redemptionStatusCSV = Convert.ToString((int)ePCVRedemptionStatus.ToBeRedeemed); break; case "outstanding": reportParams.Add("ReportType", "Awaiting Redemption"); redemptionStatusCSV = Convert.ToString((int)ePCVRedemptionStatus.ToBeRedeemed) + "," + Convert.ToString((int)ePCVRedemptionStatus.RequiresDeHire); break; } int clientId = cboClient.SelectedValue == "" ? 0 : int.Parse(cboClient.SelectedValue); if (clientId > 0) { reportParams.Add("Client", cboClient.Text); } DateTime dateFrom; DateTime dateTo; // Check the user hasn't cleared the WebDateTimeEdit fields. If so, // use defaults. if (dteDateFrom.SelectedDate.Value == DateTime.MinValue) { dateFrom = DateTime.Today - new TimeSpan(1, 0, 0, 0); } else { dateFrom = dteDateFrom.SelectedDate.Value; } if (dteDateTo.SelectedDate.Value == DateTime.MinValue) { dateTo = DateTime.Today; } else { dateTo = dteDateTo.SelectedDate.Value; } Facade.IPCV facPCV = new Facade.PCV(); DataSet dsPCVs = facPCV.GetWithJobByRedemptionStatus(clientId, dateFrom, dateTo, redemptionStatusCSV); if (dsPCVs.Tables[0].Rows.Count == 0) { lblError.Text = "No PCVs found for period " + dteDateFrom.SelectedDate.Value.ToString("dd/MM/yy") + " " + " to " + dteDateTo.SelectedDate.Value.ToString("dd/MM/yy"); lblError.Visible = true; } else { //------------------------------------------------------------------------------------- // Load Report Section //------------------------------------------------------------------------------------- Session[Orchestrator.Globals.Constants.ReportTypeSessionVariable] = eReportType.PCV; Session[Orchestrator.Globals.Constants.ReportParamsSessionVariable] = reportParams; reportParams.Add("DateFrom", dteDateFrom.SelectedDate.Value.ToString("dd/MM/yy")); reportParams.Add("DateTo", dteDateTo.SelectedDate.Value.ToString("dd/MM/yy")); if (clientId > 0) { reportParams.Add("ClientId", cboClient.SelectedValue); } if (Request.QueryString["sort"] != null) { reportParams.Add("sort", "true"); reportParams.Add("sortDirection", Convert.ToString(Request.QueryString["sortDirection"])); DataView dvPCVs = new DataView(dsPCVs.Tables[0]); string sortBy = Convert.ToString(Request.QueryString["sortBy"]); string sortDirection = Convert.ToString(Request.QueryString["sortDirection"]); // Check query string has not been altered by user. If it has, set to a // default value if (sortBy != "PCVId" && sortBy != "RedemptionStatus") { sortBy = "PCVId"; } if (sortDirection != "ASC" && sortDirection != "DESC") { sortDirection = "ASC"; } if (sortBy == "PCVId") { sortBy = "VoucherNo"; } Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable] = dsPCVs; Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable] = sortBy + " " + sortDirection; // Since a DataView, no DataMember as underlying DataTable object does not change and // setting it to "Table" would not reflect the sort being applied. Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = ""; } else { reportParams.Add("sort", "false"); Session[Orchestrator.Globals.Constants.ReportDataSessionTableVariable] = dsPCVs; Session[Orchestrator.Globals.Constants.ReportDataSessionSortVariable] = String.Empty; Session[Orchestrator.Globals.Constants.ReportDataMemberSessionVariable] = "Table"; } if (cboClient.SelectedValue != "") { reportViewer.IdentityId = int.Parse(cboClient.SelectedValue); } reportViewer.Visible = true; } }