private void UpdateDriverRent() { try { if (RentId == 0) { ENUtils.ShowMessage("Driver Rent is not Generated"); return; } if (chkOther.Checked) { ddlRentPayReason.SelectedValue = null; } decimal RentDue = lblRentDue.Text.ToDecimal(); decimal RentPay = spnRentPay.Value.ToDecimal(); decimal RentPaid = (RentPay + RentDue); decimal CurrentBalance = numCurrBalance.Value.ToDecimal(); int? rentPayReasonId = ddlRentPayReason.SelectedValue.ToIntorNull(); string rentPayReasonText = txtReason.Text.Trim(); bool IsNewReason = false; using (TaxiDataContext db = new TaxiDataContext()) { if (rentPayReasonId == null && !string.IsNullOrEmpty(rentPayReasonText)) { try { DriverRentPayReason objRentPayReason = new DriverRentPayReason(); rentPayReasonId = db.DriverRentPayReasons.OrderByDescending(c => c.Id).FirstOrDefault().Id + 1; objRentPayReason.Id = rentPayReasonId.ToInt(); objRentPayReason.RentReason = rentPayReasonText; db.DriverRentPayReasons.InsertOnSubmit(objRentPayReason); db.SubmitChanges(); IsNewReason = true; } catch { } } db.stp_UpdateDriverRentWithReason(RentId, CurrentBalance, RentPay, rentPayReasonId); } if (IsNewReason) { ComboFunctions.FillRentPayReasonCombo(ddlRentPayReason); } //else //{ // DriverRentBO rentBo = new DriverRentBO(); // rentBo.GetByPrimaryKey(RentId); // if (rentBo.Current != null) // { // rentBo.Current.RentPayReasonId = ddlRentPayReason.SelectedValue.ToIntorNull(); // rentBo.Current.Balance // } //} DisplayRecord(); // this.Close(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void FillCombo() { ComboFunctions.FillDriverNoCombo(ddlDrivers, c => c.DriverTypeId == 1); ComboFunctions.FillRentPayReasonCombo(ddlRentPayReason); }