private void UpdateExtras(ComponentArt.Web.UI.GridItem item, string command) { switch (command) { case "UPDATE": int extraId = Convert.ToInt32(item["ExtraId"].ToString()); Facade.IJobExtra facJobExtra = new Facade.Job(); Entities.Extra updatingExtra = facJobExtra.GetExtraForExtraId(extraId); updatingExtra.ExtraState = (eExtraState)Enum.Parse(typeof(eExtraState), item["ExtraState"].ToString()); Facade.IExchangeRates facER = new Facade.ExchangeRates(); if (updatingExtra.ExchangeRateID != null) { updatingExtra.ExtraAmount = facER.GetConvertedRate((int)updatingExtra.ExchangeRateID, Decimal.Parse(item["ForeignAmount"].ToString(), NumberStyles.Currency)); } else { updatingExtra.ExtraAmount = Decimal.Parse(item["ForeignAmount"].ToString(), NumberStyles.Currency); } updatingExtra.ForeignAmount = Decimal.Parse(item["ForeignAmount"].ToString(), NumberStyles.Currency); updatingExtra.ClientContact = item["ClientContact"].ToString(); facJobExtra.UpdateExtra(updatingExtra, ((Entities.CustomPrincipal)Page.User).UserName); break; } }
private void LoadExtra() { Facade.IJobExtra facExtra = new Facade.Job(); Entities.Extra extra = facExtra.GetExtraForExtraId(m_extraId); string isBeingInvoiced = facExtra.IsExtraBeingInvoiced(m_extraId); cboExtraState.ClearSelection(); cboExtraState.Items.FindByValue(Utilities.UnCamelCase(extra.ExtraState.ToString())).Selected = true; txtClientContact.Text = extra.ClientContact; rntAmount.Text = extra.ForeignAmount.ToString(); m_exchangeRateID = extra.ExchangeRateID; txtComment.Text = extra.CustomDescription; cboExtraType.ClearSelection(); cboExtraType.Items.FindByValue(((int)extra.ExtraType).ToString()).Selected = true; cboExtraType.Enabled = extra.ExtraState != eExtraState.Invoiced && String.IsNullOrEmpty(isBeingInvoiced); cboExtraState.Enabled = String.IsNullOrEmpty(isBeingInvoiced); rntAmount.Enabled = extra.ExtraState != eExtraState.Invoiced && String.IsNullOrEmpty(isBeingInvoiced); btnAddExtra.Visible = String.IsNullOrEmpty(isBeingInvoiced); btnDeleteExtra.Visible = extra.ExtraState != eExtraState.Invoiced && String.IsNullOrEmpty(isBeingInvoiced); divInvoicedMessage.Visible = !String.IsNullOrEmpty(isBeingInvoiced); lblInvoiceReason.Text = "This Extra cannot be altered as it is currently on " + isBeingInvoiced; Session["_extra"] = extra; }
private void UpdateExtra() { Entities.Extra extra = (Entities.Extra)Session["_extra"]; extra.ExtraType = (eExtraType)Enum.Parse(typeof(eExtraType), cboExtraType.SelectedValue.Replace(" ", "")); extra.ExtraState = (eExtraState)Enum.Parse(typeof(eExtraState), cboExtraState.SelectedValue.Replace(" ", "")); extra.ClientContact = txtClientContact.Text; extra.ExtraAmount = decimal.Parse(txtAmount.Text, System.Globalization.NumberStyles.Currency); //This page is only ever used for adding Job based extras which are //NOT multi-currency. So set ForeignAmount to the UK Amount //(Its not necessary to do this for the create because the BL does //it for us - but it has to be done for the Update as the logic is also //used by the Extras Invoice.). extra.ForeignAmount = extra.ExtraAmount; //if (extra.ExtraType == eExtraType.Demurrage) // extra.DemurrageComments = txtDemurrageComments.Text; //if (extra.ExtraType == eExtraType.Custom) extra.CustomDescription = txtCustomDescription.Text; bool success = false; if (extra.OrderID > 0) { Facade.IOrderExtra facExtra = new Facade.Order(); success = facExtra.Update(extra, ((Entities.CustomPrincipal)Page.User).UserName); } else { Facade.IJobExtra facExtra = new Facade.Job(); success = facExtra.UpdateExtra(extra, ((Entities.CustomPrincipal)Page.User).UserName); } if (success) { this.ReturnValue = bool.TrueString; this.Close("AddExtra"); } else { lblError.Text = "There was a problem trying to update this extra."; pnlError.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { int jobId = Convert.ToInt32(Request.QueryString["jobId"]); string retVal = string.Empty; if (jobId > 0) { Entities.Extra extra = null; string cacheName = "_jobExtras_" + jobId.ToString(); System.Text.StringBuilder sbOuput = new System.Text.StringBuilder(); if (Cache[cacheName] == null) { DataAccess.IJobExtra dacExtra = new DataAccess.Job(); System.Data.SqlClient.SqlDataReader reader = dacExtra.GetExtrasForJobId(jobId); //build up the return string information sbOuput.Append("<table cellpadding=\"3\" class=\"DataGridStyle\" "); sbOuput.Append("<tr style=\"background-image: url('../images/header_rowBg.gif');background-repeat: repeat-x;height:24px;\"><td>Type</td><td>Amount</td><td>Accepted By</td></tr>"); while (reader.Read()) { sbOuput.Append("<tr><td>" + reader["ExtraType"].ToString() + "</td>"); sbOuput.Append("<td>" + ((decimal)reader["ExtraAmount"]).ToString("C") + "</td>"); sbOuput.Append("<td>" + reader["ClientContact"].ToString() + "</td>"); } sbOuput.Append("</tr></table>"); reader.Close(); Cache.Add(cacheName, sbOuput.ToString(), null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), System.Web.Caching.CacheItemPriority.Normal, null); retVal = sbOuput.ToString(); } else { retVal = Cache[cacheName].ToString(); } if (retVal != null) { litExtraPopup.Text = string.Empty; litExtraPopup.Text = retVal.ToString(); return; } } }
private void UpdateExtra() { Entities.Extra extra = (Entities.Extra)Session["_extra"]; extra = PopulateExtra(extra); //if (extra.ExtraType == eExtraType.Demurrage) // extra.DemurrageComments = txtDemurrageComments.Text; Facade.IOrderExtra facExtra = new Facade.Order(); if (facExtra.Update(extra, ((Entities.CustomPrincipal)Page.User).UserName)) { // lblInjectScript.Text = "<script>window.close()</script>"; } else { lblError.Text = "There was a problem trying to update this extra."; pnlError.Visible = true; } }
private Entities.Extra PopulateExtra(Entities.Extra extra) { decimal rate = 0m; decimal fuelSurchargeRate = 0m; extra.ExtraType = (eExtraType)Enum.Parse(typeof(eExtraType), cboExtraType.SelectedValue.Replace(" ", "")); extra.ExtraState = (eExtraState)Enum.Parse(typeof(eExtraState), cboExtraState.SelectedValue.Replace(" ", "")); extra.ClientContact = txtClientContact.Text; if (rntAmount.Value.HasValue) { rate = (decimal)rntAmount.Value.Value; if (ApplyFuelSurcharge()) { fuelSurchargeRate = Math.Round(rate * (m_fuelSurchargePercentage / 100.0m), 4, MidpointRounding.AwayFromZero); } } extra.ForeignAmount = rate; extra.FuelSurchargeForeignAmount = fuelSurchargeRate; if (m_exchangeRateID != null && extra.ForeignAmount > 0) { Facade.IExchangeRates facER = new Facade.ExchangeRates(); extra.ExtraAmount = facER.GetConvertedRate((int)m_exchangeRateID, extra.ForeignAmount); extra.FuelSurchargeAmount = facER.GetConvertedRate((int)m_exchangeRateID, extra.FuelSurchargeForeignAmount); extra.ExchangeRateID = m_exchangeRateID; } else { extra.ExtraAmount = extra.ForeignAmount; extra.FuelSurchargeAmount = extra.FuelSurchargeForeignAmount; } extra.CustomDescription = txtComment.Text; return(extra); }
private void LoadExtra() { Facade.IJobExtra facExtra = new Facade.Job(); Entities.Extra extra = facExtra.GetExtraForExtraId(m_extraId); cboExtraState.ClearSelection(); cboExtraState.Items.FindByValue(Utilities.UnCamelCase(extra.ExtraState.ToString())).Selected = true; txtClientContact.Text = extra.ClientContact; txtAmount.Text = extra.ExtraAmount.ToString("C"); //if (extra.ExtraType == eExtraType.Demurrage) //{ // pnlDemurrageComments.Visible = true; // txtDemurrageComments.Text = extra.DemurrageComments; // if (cboExtraState.Items.FindByValue(eExtraType.Demurrage.ToString()) == null) // { // cboExtraType.Items.Insert(0, new ListItem(eExtraType.Demurrage.ToString())); // cboExtraType.Enabled = false; // pnlDemurrageComments.Visible = true; // } //} //if (extra.ExtraType == eExtraType.Custom) //{ pnlCustomExtra.Visible = true; txtCustomDescription.Text = extra.CustomDescription; //} cboExtraType.ClearSelection(); cboExtraType.Items.FindByValue(((int)extra.ExtraType).ToString()).Selected = true; btnAddExtra.Enabled = extra.ExtraState != eExtraState.Invoiced; btnDeleteExtra.Enabled = extra.ExtraState != eExtraState.Invoiced; Session["_extra"] = extra; btnDeleteExtra.Enabled = true; }
void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { Entities.FacadeResult success = new Orchestrator.Entities.FacadeResult(false); if (rdOrderAction_NotCollected.Checked) { #region Get Page details int rReasonId = 0; int.TryParse(cboRedeliveryReason.SelectedValue, out rReasonId); int nCPointId = 0, nDPointId = 0, dayDifference = 0; bool nCIsAnytime = false, nDIsAnyTime = false; DateTime nCDateTime = new DateTime(), nCByDateTime = new DateTime(), nDDateTime = new DateTime(), nDFromDateTime = new DateTime(), dateDiff = new DateTime(); nCDateTime = dteCollectionFromDate.SelectedDate.Value; nCDateTime = nCDateTime.Add(new TimeSpan(dteCollectionFromTime.SelectedDate.Value.Hour, dteCollectionFromTime.SelectedDate.Value.Minute, 0)); nCByDateTime = nCDateTime; if (rdCollectionBookingWindow.Checked) { nCByDateTime = dteCollectionByDate.SelectedDate.Value; nCByDateTime = nCByDateTime.Add(new TimeSpan(dteCollectionByTime.SelectedDate.Value.Hour, dteCollectionByTime.SelectedDate.Value.Minute, 0)); } nCIsAnytime = rdCollectionIsAnytime.Checked; if (chkChangeDeliveryDate.Checked) { nDFromDateTime = dteDeliveryFromDate.SelectedDate.Value; nDFromDateTime = nDFromDateTime.Add(new TimeSpan(dteDeliveryFromTime.SelectedDate.Value.Hour, dteDeliveryFromTime.SelectedDate.Value.Minute, 0)); nDDateTime = nDFromDateTime; if (rdDeliveryBookingWindow.Checked) { nDDateTime = dteDeliveryByDate.SelectedDate.Value; nDDateTime = nDDateTime.Add(new TimeSpan(dteDeliveryByTime.SelectedDate.Value.Hour, dteDeliveryByTime.SelectedDate.Value.Minute, 0)); } nDIsAnyTime = rdDeliveryIsAnytime.Checked; } if (chkCollectGoodsElsewhere.Checked && ucNewCollectionPoint.SelectedPoint != null) { nCPointId = ucNewCollectionPoint.SelectedPoint.PointId; } if (chkDeliverGoodsElsewhere.Checked && ucNewDeliveryPoint.SelectedPoint != null) { nDPointId = ucNewDeliveryPoint.SelectedPoint.PointId; } Entities.Extra extra = null; // If Updates processed sucessfully, log the extra against the highest value order. if (chkCharging.Checked) { // Build an extra to cover the redelivery. extra = new Entities.Extra(); extra.ExtraType = (eExtraType)int.Parse(cboExtraType.SelectedValue); extra.ForeignAmount = (decimal)txtExtraAmount.Value; extra.ExtraState = Utilities.SelectedEnumValue <eExtraState>(cboExtraState.SelectedValue);; extra.CustomDescription = txtExtraCustomReason.Text; if (!string.IsNullOrEmpty(txtClientContact.Text)) { extra.ClientContact = txtClientContact.Text; } } #endregion Facade.IAttemptedCollection facAC = new Facade.AttemptedCollection(); success = facAC.Create(JobId, InstructionId, rdResolutionMethod_AttemptLater.Checked, rReasonId, txtAttemptedCollectionReference.Text, txtAttemptedClientContact.Text, nCDateTime, nCByDateTime, nCIsAnytime, nCPointId, chkChangeDeliveryDate.Checked, nDFromDateTime, nDDateTime, nDIsAnyTime, nDPointId, chkCreateOnwardRun.Checked, extra, Page.User.Identity.Name); } #region Display Results if (success != null && success.Success) { if (success.ObjectId > 0) { Facade.IJob facJob = new Facade.Job(); Entities.Job eJob = facJob.GetJob(JobId); // If the existing run has been cancelled, then re-direct to the new run. if (eJob == null) { JobId = success.ObjectId; InstructionId = -1; } else { dlgOrder.Open(string.Format("jobId={0}", success.ObjectId)); } } btnCancel_Click(null, null); } else { if (success != null) { idErrors.Infringements = success.Infringements; } idErrors.DisplayInfringments(); idErrors.Visible = true; } #endregion } }