public List<UtilityModel<uint>> GetDrivers() { using (var db = DB.GetContext()) { DriverFilterModel filter = new DriverFilterModel(); filter.IncludeDisabled = true; return DriverRepository.FindDrivers(db, filter) .Select(d => new UtilityModel<uint>(d.DriverID, d.FullName)) .ToList(); } }
public void Clear() { var fil = new DriverFilterModel(); this.DriverCode = fil.DriverCode; this.FirstName = fil.FirstName; this.SecondName = fil.SecondName; this.LastName = fil.LastName; this.CellPhone = fil.CellPhone; this.Email = fil.Email; this.LicenseID = fil.LicenseID; this.PermitID = fil.PermitID; this.IncludeDisabled = fil.IncludeDisabled; }
private void LoadDefaults() { DriverFilterModel filter = new DriverFilterModel(); filter.IncludeDisabled = false; var drivers = DriverRepository.FindDrivers(this.DbContext, filter); DriverID.Properties.DataSource = drivers; DriverID.Properties.DropDownRows = drivers.Count + 1; var companies = CompanyRepository.FindCompanies(this.DbContext); CompanyID.Properties.DataSource = companies; CompanyID.Properties.DropDownRows = companies.Count + 1; var reports = ReportRepository.GetReports(this.DbContext); ReportID.Properties.DataSource = reports; ReportID.Properties.DropDownRows = reports.Count + 1; }
public static List<DriverModel> FindDrivers(DSModel db, DriverFilterModel filter) { if (db == null) throw new ArgumentNullException("db"); if (filter == null) throw new ArgumentNullException("filter"); List<MySqlParameter> parameters = new List<MySqlParameter>(); string sql = SqlCache.Get(db, "drivers catalog load"); if (!string.IsNullOrWhiteSpace(filter.DriverCode)) { sql = sql.Replace("#DriverCode", string.Empty); parameters.Add(new MySqlParameter("DriverCode", filter.DriverCode + "%")); } if (!string.IsNullOrWhiteSpace(filter.FirstName)) { sql = sql.Replace("#FirstName", string.Empty); parameters.Add(new MySqlParameter("FirstName", filter.FirstName + "%")); } if (!string.IsNullOrWhiteSpace(filter.SecondName)) { sql = sql.Replace("#SecondName", string.Empty); parameters.Add(new MySqlParameter("SecondName", filter.SecondName + "%")); } if (!string.IsNullOrWhiteSpace(filter.LastName)) { sql = sql.Replace("#LastName", string.Empty); parameters.Add(new MySqlParameter("LastName", filter.LastName + "%")); } if (!string.IsNullOrWhiteSpace(filter.CellPhone)) { sql = sql.Replace("#CellPhone", string.Empty); parameters.Add(new MySqlParameter("CellPhone", filter.CellPhone + "%")); } if (!string.IsNullOrWhiteSpace(filter.Email)) { sql = sql.Replace("#Email", string.Empty); parameters.Add(new MySqlParameter("Email", filter.Email + "%")); } if (!string.IsNullOrWhiteSpace(filter.LicenseID)) { sql = sql.Replace("#LicenseID", string.Empty); sql = sql.Replace("@LicenseID", filter.LicenseID); } if (!string.IsNullOrWhiteSpace(filter.PermitID)) { sql = sql.Replace("#PermitID", string.Empty); sql = sql.Replace("@PermitID", filter.PermitID); } string isEnabled = (filter.IncludeDisabled ? "0,1" : "1"); sql = sql.Replace("@IsEnabled", isEnabled); parameters.Add(new MySqlParameter("TodayDate", DateTime.Now.Date)); return db.ExecuteQuery<DriverModel>(sql, parameters.ToArray()) .ToList(); }
public XU_Driver() { InitializeComponent(); if (this.DesignMode) return; try { DriverFilterModel filter = new DriverFilterModel(); filter.IncludeDisabled = true; btnDriver.Properties.DataSource = DriverRepository.FindDrivers(this.DbContext, filter); } catch { } btnDriver.DataBindings.Add("EditValue", this, this.GetName(p => p.DriverID), true, DataSourceUpdateMode.OnPropertyChanged); btnDriver.ButtonClick += btnDriver_ButtonClick; DriverCode.EditValueChanging += DriverCode_EditValueChanging; this.Load += XU_Driver_Load; }
public List<DriverModel> GetDrivers() { using (var db = DB.GetContext()) { DriverFilterModel filter = new DriverFilterModel(); filter.IncludeDisabled = false; return DriverRepository.FindDrivers(db, filter); } }