public frmRentList() { InitializeComponent(); grdLister.CellDoubleClick += new GridViewCellEventHandler(grdLister_CellDoubleClick); grdLister.RowsChanging += new Telerik.WinControls.UI.GridViewCollectionChangingEventHandler(Grid_RowsChanging); objMaster = new DriverRentBO(); this.SetProperties((INavigation)objMaster); grdLister.ShowRowHeaderColumn = false; this.Shown += new EventHandler(frmCompanyInvoiceList_Shown); grdLister.CommandCellClick += new CommandCellClickEventHandler(grid_CommandCellClick); }
public frmDriverRentList3() { InitializeComponent(); grdLister.CellDoubleClick += new GridViewCellEventHandler(grdLister_CellDoubleClick); grdLister.RowsChanging += new Telerik.WinControls.UI.GridViewCollectionChangingEventHandler(Grid_RowsChanging); objMaster = new DriverRentBO(); this.SetProperties((INavigation)objMaster); grdLister.ShowRowHeaderColumn = false; this.Shown += new EventHandler(frmCompanyInvoiceList_Shown); grdLister.CommandCellClick += new CommandCellClickEventHandler(grid_CommandCellClick); // for menus grdLister.ContextMenuOpening += new ContextMenuOpeningEventHandler(grdLister_ContextMenuOpening); AddRentItems = new RadDropDownMenu(); AddRentItems.BackColor = Color.Orange; RadMenuItem AddRentItems1 = new RadMenuItem("Add Driver Rent"); AddRentItems1.ForeColor = Color.DarkBlue; AddRentItems1.BackColor = Color.Orange; AddRentItems1.Font = new Font("Tahoma", 10, FontStyle.Bold); AddRentItems1.Click += new EventHandler(AddRentItems1_Click); AddRentItems.Items.Add(AddRentItems1); RadMenuItem AddCommisionItems3 = new RadMenuItem("Edit Last Statement"); AddCommisionItems3.ForeColor = Color.DarkBlue; AddCommisionItems3.BackColor = Color.Orange; AddCommisionItems3.Font = new Font("Tahoma", 10, FontStyle.Bold); AddCommisionItems3.Click += new EventHandler(AddCommisionItems3_Click); AddRentItems.Items.Add(AddCommisionItems3); RadMenuItem AddRentItems2 = new RadMenuItem("Driver Rent List"); AddRentItems2.ForeColor = Color.DarkBlue; AddRentItems2.BackColor = Color.Orange; AddRentItems2.Font = new Font("Tahoma", 10, FontStyle.Bold); AddRentItems2.Click += new EventHandler(AddRentItems2_Click); AddRentItems.Items.Add(AddRentItems2); }
void Grid_RowsChanging(object sender, GridViewCollectionChangingEventArgs e) { if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove) { objMaster = new DriverRentBO(); try { objMaster.GetByPrimaryKey(grdLister.CurrentRow.Cells["Id"].Value.ToInt()); string Transaction = grdLister.CurrentRow.Cells["TransNo"].Value.ToStr(); int DriverId = grdLister.CurrentRow.Cells["DriverID"].Value.ToInt(); var query = General.GetQueryable <DriverRent>(c => c.DriverId == DriverId).OrderByDescending(c => c.Id).FirstOrDefault(); if (query != null) { string Transno = query.TransNo.ToStr(); if (Transno == Transaction) { objMaster.Delete(objMaster.Current); } else { ENUtils.ShowMessage("You Can not delete a record.."); } } } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } e.Cancel = true; } } }
private bool OnSave(int DriverId, decimal oldBalance, decimal DriverRent, decimal pdaRent, decimal InitialBalance, decimal rentPayValue, ref decimal accJobs, ref long transId, ref decimal rentDue, ref decimal currBalance) { bool IsSaved = false; try { bool RentForProcessedJobs = AppVars.objPolicyConfiguration.RentForProcessedJobs.ToBool(); //var list = (from b in list1 // join c in list2 on b.Id equals c.BookingId into table2 // from c in table2.DefaultIfEmpty() // where (c == null) // select new var rentList = General.GetGeneralList <DriverRent_Charge>(c => c.BookingId != null && c.TransId != null); Expression <Func <Booking, bool> > _exp = null; if (AppVars.objPolicyConfiguration.PickBookingOnInvoicingType.ToInt() == 2) { _exp = c => c.CompanyId != null && ((c.PaymentTypeId != Enums.PAYMENT_TYPES.CASH && c.BookingStatusId == Enums.BOOKINGSTATUS.NOPICKUP) || c.BookingStatusId == Enums.BOOKINGSTATUS.DISPATCHED) && (c.FareRate != null) && ((RentForProcessedJobs == true && (c.IsProcessed != null && c.IsProcessed == true)) || (RentForProcessedJobs == false && (c.IsProcessed == null || c.IsProcessed == false))) && (c.DriverId == DriverId) && (c.PickupDateTime.Value.Date >= dtpFromDate.Value.Value.Date && c.PickupDateTime.Value.Date <= dtpTillDate.Value.Value.Date); } else { _exp = c => c.CompanyId != null && c.BookingStatusId == Enums.BOOKINGSTATUS.DISPATCHED && (c.FareRate != null) && ((RentForProcessedJobs == true && (c.IsProcessed != null && c.IsProcessed == true)) || (RentForProcessedJobs == false && (c.IsProcessed == null || c.IsProcessed == false))) && (c.DriverId == DriverId) && (c.PickupDateTime.Value.Date >= dtpFromDate.Value.Value.Date && c.PickupDateTime.Value.Date <= dtpTillDate.Value.Value.Date); } var list2 = (from a in General.GetGeneralList <Booking>(_exp) join b in rentList on a.Id equals b.BookingId into table2 from b in table2.DefaultIfEmpty() where (b == null) select new { Id = a.Id, TotalFare = a.FareRate.ToDecimal() + a.CongtionCharges.ToDecimal() + a.MeetAndGreetCharges.ToDecimal(), // TotalCharges = a.TotalCharges, CompanyId = a.CompanyId, AccountTypeId = a.Gen_Company.AccountTypeId, DriverCommissionAmount = a.DriverCommission, DriverCommissionType = a.DriverCommissionType, IsCommissionWise = a.IsCommissionWise }).ToList(); //if (list2.Count == 0) // return false; objMaster = new DriverRentBO(); objMaster.New(); List <DriverRent_Charge> ListDetail = (from a in list2 select new DriverRent_Charge { //Id = a.Id, TransId = objMaster.Current.Id, BookingId = a.Id }).ToList(); decimal Total = list2.Sum(c => c.TotalFare).ToDecimal(); decimal ACCJobsTotal = list2.Where(c => c.CompanyId != null && c.AccountTypeId.ToInt() == Enums.ACCOUNT_TYPE.ACCOUNT) .Sum(c => c.TotalFare).ToDecimal(); decimal ACCCashJobsAmountTotal = list2.Where(c => c.CompanyId != null && c.AccountTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH && c.IsCommissionWise.ToBool() && c.DriverCommissionType.ToStr().Trim() == "Amount") .Sum(c => c.DriverCommissionAmount.ToDecimal()).ToDecimal(); decimal ACCCashJobsPercentTotal = list2.Where(c => c.CompanyId != null && c.AccountTypeId.ToInt() == Enums.ACCOUNT_TYPE.CASH && c.IsCommissionWise.ToBool() && c.DriverCommissionType.ToStr().Trim() == "Percent") .Sum(c => (c.DriverCommissionAmount.ToDecimal() * 100) / c.TotalFare).ToDecimal(); objMaster.Current.JobsTotal = ACCJobsTotal; accJobs = ACCJobsTotal; decimal owed = ACCJobsTotal - (DriverRent + pdaRent + (ACCCashJobsAmountTotal + ACCCashJobsPercentTotal)); owed = owed + oldBalance; rentDue = owed; // decimal balance = owed;// +payment; currBalance = owed + rentPayValue.ToDecimal(); objMaster.Current.RentPay = rentPayValue.ToDecimal(); objMaster.Current.Balance = currBalance;//RentPay - DriverRent; objMaster.Current.DriverRent1 = DriverRent; // add pda rent objMaster.Current.PDARent = pdaRent; objMaster.Current.AddBy = AppVars.LoginObj.LuserId.ToInt(); objMaster.Current.AddLog = AppVars.LoginObj.LoginName.ToStr(); objMaster.Current.AddOn = DateTime.Now; objMaster.Current.TransDate = DateTime.Now; //dtpTransactionDate.Value.ToDateTime(); objMaster.Current.DriverId = DriverId; //ddlDriver.SelectedValue.ToIntorNull(); objMaster.Current.OldBalance = oldBalance;// (CurrentBalance - RentPay); objMaster.Current.FromDate = dtpFromDate.Value.ToDate(); objMaster.Current.ToDate = dtpTillDate.Value.ToDate(); objMaster.Current.TransFor = "Weekly";//ddlDayWise.SelectedText.ToStr(); objMaster.Current.Fuel = 0; //Fuel.ToDecimal(); objMaster.Current.Extra = 0; // Extra.ToDecimal(); string[] skipProperties = { "DriverRent", "Booking" }; IList <DriverRent_Charge> savedList = objMaster.Current.DriverRent_Charges; var list = objMaster.Current.DriverRent_Charges.ToList(); Utils.General.SyncChildCollection(ref savedList, ref ListDetail, "Id", skipProperties); objMaster.Save(); IsSaved = true; transId = objMaster.Current.Id; } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } } return(IsSaved); }
public void GetDrivers() { try { objMaster = new DriverRentBO(); //DateTime OneMonthBefore = DateTime.Now; //OneMonthBefore = OneMonthBefore.A(-1); GridViewCheckBoxColumn col = new GridViewCheckBoxColumn(); col.Width = 40; col.AutoSizeMode = BestFitColumnMode.None; col.HeaderText = ""; col.Name = "Check"; // col.ReadOnly = true; grdDriverRent.Columns.Add(col); GridViewTextBoxColumn tbcol = new GridViewTextBoxColumn(); tbcol.Name = COLS.Id; tbcol.IsVisible = false; grdDriverRent.Columns.Add(tbcol); tbcol = new GridViewTextBoxColumn(); tbcol.Name = COLS.RentId; tbcol.IsVisible = false; grdDriverRent.Columns.Add(tbcol); tbcol = new GridViewTextBoxColumn(); tbcol.Name = COLS.DriverNo; tbcol.HeaderText = "Driver"; tbcol.Width = 160; tbcol.ReadOnly = true; grdDriverRent.Columns.Add(tbcol); //tbcol = new GridViewTextBoxColumn(); //tbcol.Name = COLS.TransNo; //tbcol.HeaderText = "Transaction No"; //tbcol.Width = 110; //tbcol.ReadOnly = true; //grdDriverRent.Columns.Add(tbcol); //tbcol = new GridViewTextBoxColumn(); GridViewDecimalColumn dcol = new GridViewDecimalColumn(); dcol.Name = COLS.DriverRent; dcol.Width = 70; dcol.ReadOnly = true; dcol.DecimalPlaces = 2; dcol.HeaderText = "Rent"; grdDriverRent.Columns.Add(dcol); dcol = new GridViewDecimalColumn(); dcol.Name = COLS.DriverPDARent; dcol.Width = 70; dcol.ReadOnly = true; dcol.DecimalPlaces = 2; dcol.HeaderText = "PDA Rent"; grdDriverRent.Columns.Add(dcol); dcol = new GridViewDecimalColumn(); dcol.Name = COLS.OldBalance; dcol.Width = 100; dcol.DecimalPlaces = 2; dcol.HeaderText = "Old Balance"; dcol.ReadOnly = true; grdDriverRent.Columns.Add(dcol); //tbcol = new GridViewTextBoxColumn(); //GridViewDecimalColumn dcol = new GridViewDecimalColumn(); dcol.Name = COLS.InitialBalance; dcol.HeaderText = "Initial Balance"; dcol.DecimalPlaces = 2; dcol.IsVisible = false; grdDriverRent.Columns.Add(dcol); dcol = new GridViewDecimalColumn(); dcol.Name = COLS.AccountsTotal; dcol.HeaderText = "Accounts Total"; dcol.Width = 110; dcol.ReadOnly = true; dcol.DecimalPlaces = 2; grdDriverRent.Columns.Add(dcol); dcol = new GridViewDecimalColumn(); dcol.Name = COLS.RentPay; dcol.HeaderText = "Rent Pay"; dcol.Width = 90; dcol.DecimalPlaces = 2; dcol.ReadOnly = false; grdDriverRent.Columns.Add(dcol); dcol = new GridViewDecimalColumn(); dcol.Name = COLS.RentDue; dcol.HeaderText = "Rent Due"; dcol.Width = 90; dcol.ReadOnly = true; dcol.DecimalPlaces = 2; grdDriverRent.Columns.Add(dcol); dcol = new GridViewDecimalColumn(); dcol.Name = COLS.CurrBalance; dcol.HeaderText = "Current Balance"; dcol.Width = 120; dcol.DecimalPlaces = 2; dcol.ReadOnly = true; grdDriverRent.Columns.Add(dcol); grdDriverRent.ShowRowHeaderColumn = false; objCondition.CellForeColor = Color.Red; objCondition.TValue1 = "x"; objCondition.ConditionType = ConditionTypes.NotEqual; grdDriverRent.Columns[COLS.CurrBalance].ConditionalFormattingObjectList.Add(objCondition); objConditionGeneratedTrans.RowBackColor = Color.LightGreen; objConditionGeneratedTrans.TValue1 = "0"; objConditionGeneratedTrans.ApplyToRow = true; objConditionGeneratedTrans.ConditionType = ConditionTypes.Greater; grdDriverRent.Columns[COLS.RentId].ConditionalFormattingObjectList.Add(objConditionGeneratedTrans); RefreshRentView(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }