protected void reee() { string IDstring; string baseUrl = Request.Url.AbsoluteUri; IDstring = baseUrl.Substring(baseUrl.IndexOf("?=ID")); Label2.Text = IDstring; Label3.Text = IDstring.Replace("?=ID", ""); Label1.Text = baseUrl; }
public void UnprocessInvoice() { bool Success = false; ModelTMSContainer _ControlObjectContext = new ModelTMSContainer(Session["CustomerConnectString"].ToString(), Session); // start transaction using (TransactionScope TS = new TransactionScope()) { try { // roll back order // correct invoice if there if (LabelInvoiceId.Text != "") { Invoice CorrInvoice = _ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.InvoiceSet", "Id", Guid.Parse(LabelInvoiceId.Text))) as Invoice; // unprocess CorrInvoice.UnprocessInvoice(_ControlObjectContext, CorrInvoice.GroupCode, Common.CurrentClientDateTime(Session)); } // correct rentalitemactivity status ResetRentalItemStatus(_ControlObjectContext); // remove any generated swap if (LabelNewRIAId.Text != "") { string[] IDs = LabelNewRIAId.Text.Split(';'); foreach (string IDstring in IDs) { if (IDstring.Trim() != "") { RentalItemActivity NewRia = _ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemActivitySet", "Id", Guid.Parse(IDstring))) as RentalItemActivity; if (NewRia != null) { _ControlObjectContext.RentalItemActivitySet.DeleteObject(NewRia); } } } } // enable any disabled item if (LabelDisabledItems.Text != "") { string[] IDs = LabelDisabledItems.Text.Split(';'); foreach (string IDstring in IDs) { if (IDstring.Trim() != "") { RentalItem NewRI = _ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemSet", "Id", Guid.Parse(IDstring))) as RentalItem; if (NewRI != null) { NewRI.ItemState = "Available"; } } } } // update the datetime from the original values in the grid. GrabUpdatedEndDateTimesForRIAs(_ControlObjectContext, true, true); // and save to persistent storage _ControlObjectContext.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave); // commit TS.Complete(); Success = true; } catch (Exception ex) { // rollback transaction TS.Dispose(); // inform user Common.InformUserOnTransactionFail(ex, Page); } } if (Success) { // when success revert PageNr--; ShowCorrectElements(); } }