private void SetEntityProperties(Entities.JobRate jobRate) { jobRate.IdentityId = Convert.ToInt32(cboClient.SelectedValue); jobRate.CollectionPointId = int.Parse(cboCollectionPoint.SelectedValue); jobRate.DeliveryPointId = int.Parse(cboDeliveryPoint.SelectedValue); jobRate.FullLoadRate = Decimal.Parse(txtFullLoadRate.Text, System.Globalization.NumberStyles.Currency); jobRate.MultiDropRate = Decimal.Parse(txtMultiDropRate.Text, System.Globalization.NumberStyles.Currency); jobRate.PartLoadRate = Decimal.Parse(txtPartLoadRate.Text, System.Globalization.NumberStyles.Currency); // The start of the start date jobRate.StartDate = dteStartDate.SelectedDate.Value; jobRate.StartDate = jobRate.StartDate.Subtract(jobRate.StartDate.TimeOfDay); if (!dteEndDate.SelectedDate.HasValue) { // Insert null into EndDate in tblJobRate if date equal to // '01/01/1753', indicating rate never expires. jobRate.EndDate = (DateTime)SqlDateTime.MinValue; } else { // The end of the end date jobRate.EndDate = dteEndDate.SelectedDate.Value; jobRate.EndDate = jobRate.EndDate.Subtract(jobRate.EndDate.TimeOfDay); jobRate.EndDate = jobRate.EndDate.AddDays(1); jobRate.EndDate = jobRate.EndDate.AddMinutes(-1); } }
private void PopulateControls() { Facade.IJobRate facJobRate = new Facade.Job(); Entities.JobRate jobRate = facJobRate.GetRateForRateId(m_rateId); if (jobRate != null) { // Delivery point Facade.IPoint facPoint = new Facade.Point(); Entities.Point point = facPoint.GetPointForPointId(jobRate.DeliveryPointId); cboDeliveryPoint.Text = point.Description; cboDeliveryPoint.SelectedValue = jobRate.DeliveryPointId.ToString(); cboDelivery.Text = point.OrganisationName; cboDelivery.SelectedValue = point.IdentityId.ToString(); // Collection point point = facPoint.GetPointForPointId(jobRate.CollectionPointId); cboCollectionPoint.Text = point.Description; cboCollectionPoint.SelectedValue = jobRate.CollectionPointId.ToString(); cboCollection.Text = point.OrganisationName; cboCollection.SelectedValue = point.IdentityId.ToString(); txtFullLoadRate.Text = jobRate.FullLoadRate.ToString("C"); txtMultiDropRate.Text = jobRate.MultiDropRate.ToString("C"); dteStartDate.SelectedDate = jobRate.StartDate; dteStartDate.Text = jobRate.StartDate.ToString(); if (!(jobRate.EndDate.ToString() == "01/01/1753 00:00:00")) { dteEndDate.SelectedDate = jobRate.EndDate; dteEndDate.Text = jobRate.EndDate.ToString(); } } }
private void btnSubmit_Click(object sender, EventArgs e) { if (Page.IsValid) { Facade.IJobRate facJobRate = new Facade.Job(); Entities.JobRate jobRate = new Entities.JobRate(); SetEntityProperties(jobRate); int rateId = facJobRate.Create(jobRate, ((Entities.CustomPrincipal)Page.User).UserName); if (rateId > 0) { lblConfirmation.Text = "The rate was added successfully"; lblConfirmation.Visible = true; } } }
private void btnNext_Click(object sender, EventArgs e) { if (Page.IsValid) { m_job = (Entities.Job)Session[wizard.C_JOB]; // Populate the job rate. Entities.JobRate jobRate = new Entities.JobRate(); jobRate.IdentityId = m_job.IdentityId; jobRate.CollectionPointId = m_collectionPointId; jobRate.DeliveryPointId = m_deliveryPointId; jobRate.FullLoadRate = Decimal.Parse(txtFullLoadRate.Text); jobRate.PartLoadRate = Decimal.Parse(txtPartLoadRate.Text); jobRate.MultiDropRate = Decimal.Parse(txtMultiDropRate.Text); jobRate.StartDate = DateTime.UtcNow; if (!dteEndDate.SelectedDate.HasValue) { // Not great. jobRate.EndDate = new DateTime(1753, 1, 1, 0, 0, 0); } else { jobRate.EndDate = dteEndDate.SelectedDate.Value; } // Create the new rate. Facade.IJobRate facJobRate = new Facade.Job(); int jobRateId = facJobRate.Create(jobRate, ((Entities.CustomPrincipal)Page.User).UserName); if (jobRateId > 0) { if (m_job.JobId > 0) { GoToStep("PC"); } else { GoToStep("JD"); } } } }