protected void ButtonRecalc_Click(object sender, EventArgs e) { RentalItemActivity ria = (DataItem as RentalItemActivity); SaveDataIntoDataItemFromControls(); ria.RecalcRentPrice(CheckBoxBasedOnOfficialRent.Checked); if (CheckBoxChangeInvoiceLine.Checked) { ria.UpdateLinkedInvoiceLine(); } ria.UpdateAdvancePaymentStatus(ControlObjectContext, CheckBoxChangeInvoiceLine.Checked, CheckBox_IsTreatedAsAdvancePayment_Checked.Checked); RebindControls(); StandardButtonSaveClickHandler(sender, e); }
public void SwapItems(ModelTMSContainer _ControlObjectContext) { // disable item LabelNewRIAId.Text = ""; Guid Temp; Guid RentalItemGuid; foreach (GridViewRow gvr in GridViewRentedOutMaterials.Rows) { // need this item be swapped? // get the combobox ComboBox cbx = (gvr.Cells[8].Controls[3] as ComboBox); if (cbx.SelectedIndex >= 1) { // get the corresponding RentalItemActivitySet Temp = new Guid((gvr.Cells[0].Controls[1] as CheckBox).ToolTip); // RentalItemActivity ria = _ControlObjectContext.RentalItemActivitySet.Where(m => m.Id == Temp).First<RentalItemActivity>(); RentalItemActivity ria = _ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemActivitySet", "Id", Temp)) as RentalItemActivity; // and swap RentalItemActivity NewRia = ria.CloneToNew(_ControlObjectContext); RentalItemGuid = new Guid(cbx.SelectedValue); // NewRia.RentalItem = _ControlObjectContext.RentalItemSet.Where(m => m.Id == RentalItemGuid).First<RentalItem>(); NewRia.RentalItem = _ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemSet", "Id", RentalItemGuid)) as RentalItem; // make sure that the new item's rent starts when the old item''s period ends NewRia.RentEndStartDateTime = ria.RentEndStartDateTime; ria.RentEndStartDateTime = Common.CurrentClientDateTime(Session); NewRia.RentStartDateTime = ria.RentEndStartDateTime; _ControlObjectContext.RentalItemActivitySet.AddObject(NewRia); // recalc rent price & update the invoice line if there is an invoiceline and the invoicestatus is still open or partially paid ria.RecalcRentPrice(true); ria.CheckInvoiceStatus(); ria.UpdateLinkedInvoiceLine(); NewRia.RecalcRentPrice(true); LabelNewRIAId.Text = NewRia.Id.ToString() + ";"; } } }
public void GrabUpdatedEndDateTimesForRIAs(ModelTMSContainer ControlObjectContext, bool RecalcIfChanged, bool RestoreWithOriginal) { Guid Temp; foreach (GridViewRow gvr in GridViewRentedOutMaterials.Rows) { Temp = new Guid((gvr.Cells[0].Controls[1] as CheckBox).ToolTip); // get the corresponding RentalItemActivitySet // RentalItemActivity ria = ControlObjectContext.RentalItemActivitySet.Where(m => m.Id == Temp).First<RentalItemActivity>(); RentalItemActivity ria = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.RentalItemActivitySet", "Id", Temp)) as RentalItemActivity; // grab the possible new enddate from the grid DateTime OldDateTime = ria.RentEndStartDateTime; try { if (RestoreWithOriginal) { ria.RentEndStartDateTime = Convert.ToDateTime((gvr.Cells[3].Controls[0] as TextBox).ToolTip); } else { ria.RentEndStartDateTime = Convert.ToDateTime((gvr.Cells[4].Controls[1] as CalendarWithTimeControl).Text); } } catch { } if (OldDateTime != ria.RentEndStartDateTime) { ria.RecalcRentPrice(true); // update the invoice line if there is an invoiceline and the invoicestatus is still open or partially paid ria.CheckInvoiceStatus(); ria.UpdateLinkedInvoiceLine(); } } }