private void UpdateDriverCommission() { try { if (CommissionId == 0) { ENUtils.ShowMessage("Driver Commission is not Generated"); return; } if (chkOther.Checked) { ddlCommissionPayReason.SelectedValue = null; } decimal CommissionDue = lblCommissionDue.Text.ToDecimal(); decimal CommissionPay = spnCommissionPay.Value.ToDecimal(); decimal CommissionPaid = (CommissionPay + CommissionDue); decimal CurrentBalance = numCurrBalance.Value.ToDecimal(); int? CommissionPayReasonId = ddlCommissionPayReason.SelectedValue.ToIntorNull(); string CommissionPayReasonText = txtReason.Text.Trim(); bool IsNewReason = false; using (TaxiDataContext db = new TaxiDataContext()) { if (CommissionPayReasonId == null && !string.IsNullOrEmpty(CommissionPayReasonText)) { 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(); DriverCommissionPayReason objCommissionPayReason = new DriverCommissionPayReason(); CommissionPayReasonId = db.DriverCommissionPayReasons.OrderByDescending(c => c.Id).FirstOrDefault().Id + 1; objCommissionPayReason.Id = CommissionPayReasonId.ToInt(); objCommissionPayReason.CommissionReason = CommissionPayReasonText; db.DriverCommissionPayReasons.InsertOnSubmit(objCommissionPayReason); db.SubmitChanges(); IsNewReason = true; } catch { } } db.stp_UpdateDriverCommissionWithReason(CommissionId, CurrentBalance, CommissionPay, CommissionPayReasonId); } if (IsNewReason) { ComboFunctions.FillCommissionReasonCombo(ddlCommissionPayReason); } spnCommissionPay.Value = 0.00m; DisplayRecord(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
private void FillCombo() { ComboFunctions.FillDriverNoCombo(ddlDrivers, c => c.DriverTypeId == 2); ComboFunctions.FillCommissionReasonCombo(ddlCommissionPayReason); }