private void btnViewWeeklyJobs_Click(object sender, EventArgs e) { try { int DriverId = 0; DateTime?loginDateTime = null; DateTime dtFrom = DateTime.Now.AddDays(-7).ToDate(); DateTime dtToday = DateTime.Now.ToDate(); TimeSpan tillTime = TimeSpan.Zero; TimeSpan.TryParse("23:59:59", out tillTime); string DriverNo = string.Empty; DriverId = ddlDriver.SelectedValue.ToInt(); if (DriverId == 0) { ENUtils.ShowMessage("Required : Driver"); return; } obj = General.GetObject <Fleet_DriverQueueList>(c => c.DriverId == DriverId); if (obj != null) { loginDateTime = obj.LoginDateTime; int driverType = obj.Fleet_Driver.DefaultIfEmpty().DriverTypeId.ToInt(); int?driverId = obj.DriverId.ToIntorNull(); DriverNo = obj.Fleet_Driver.DriverNo; var list = General.GetQueryable <Booking>(c => c.PickupDateTime >= dtFrom && c.PickupDateTime <= dtToday.ToDate() + tillTime && (c.DriverId == driverId || c.ReturnDriverId == driverId) && c.BookingStatusId == Enums.BOOKINGSTATUS.DISPATCHED).ToList(); if (list.Count > 0) { frmDriverJobs frmDrvJobs = new frmDriverJobs(list, DriverNo); frmDrvJobs.StartPosition = FormStartPosition.CenterScreen; frmDrvJobs.ShowDialog(); frmDrvJobs.Dispose(); } } } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }
void menu_showJobs_Click(object sender, EventArgs e) { try { RadMenuItem item = (RadMenuItem)sender; GridViewRowInfo row = grdLister.CurrentRow; using (TaxiDataContext db = new TaxiDataContext()) { db.DeferredLoadingEnabled = false; if (row != null && row is GridViewDataRowInfo) { string mobileNo = row.Cells["MobileNo"].Value.ToString(); string name = row.Cells["Name"].Value.ToString(); DateTime?fromDate = DateTime.Now.ToDate(); DateTime?tillDate = DateTime.Now.ToDate(); List <Booking> list = null; if (rdAll.ToggleState == ToggleState.On) { fromDate = null; tillDate = null; // list = db.stp_AppUsers(fromDate, tillDate, 1).ToList(); // .Where(c => (c.CustomerMobileNo == mobileNo || c.CustomerPhoneNo == mobileNo) && c.CustomerName == name).ToList(); list = db.Bookings.Where(c => (c.CustomerMobileNo == mobileNo) && (c.CustomerName == name)).ToList(); } else if (rdRegular.ToggleState == ToggleState.On) { fromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month - 1, DateTime.Now.Day); tillDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); list = db.Bookings.Where(c => (c.CustomerMobileNo == mobileNo) && (c.CustomerName == name) && (c.BookingDate.Value >= fromDate && c.BookingDate.Value <= tillDate) ).ToList(); } else if (rdDateTime.ToggleState == ToggleState.On) { fromDate = dtpFromDate.Value.ToDateTimeorNull(); tillDate = dtpToDate.Value.ToDateTimeorNull(); if (fromDate != null && dtpFromTime.Value != null && dtpFromTime.Value.Value != null) { fromDate = (fromDate.Value.ToDate() + dtpFromTime.Value.Value.TimeOfDay).ToDateTime(); } if (tillDate != null && dtptilltime.Value != null && dtptilltime.Value.Value != null) { tillDate = (tillDate.Value.ToDate() + dtptilltime.Value.Value.TimeOfDay).ToDateTime(); } //list = General.GetQueryable<Booking>(c => (c.BookingDate.Value >= fromDate && c.BookingDate.Value <= tillDate) // && (c.CustomerMobileNo == mobileNo)).ToList(); // list = db.Bookings.Where(c => c.CustomerMobileNo == mobileNo || c.CustomerPhoneNo == mobileNo).ToList(); list = db.Bookings.Where(c => (c.CustomerMobileNo == mobileNo) && (c.CustomerName == name)).ToList(); } if (list.Count > 0) { frmDriverJobs frmDrvJobs = new frmDriverJobs(list, row.Cells["Name"].Value.ToStr(), "Customer"); frmDrvJobs.StartPosition = FormStartPosition.CenterScreen; frmDrvJobs.ShowDialog(); frmDrvJobs.Dispose(); } else { MessageBox.Show("No Booking(s) Found"); } } } } catch { } }