protected void btnExcel_Click(object sender, EventArgs e) { byte ajancyType = Public.ToByte(this.drpAjancyType.SelectedValue); db = new Ajancy.Kimia_Ajancy(Public.ConnectionString); var drivers = (from p in db.Persons join u in db.Users on p.PersonID equals u.PersonID join dc in db.DriverCertifications on p.PersonID equals dc.PersonID join dcc in db.DriverCertificationCars on dc.DriverCertificationID equals dcc.DriverCertificationID join jd in db.AjancyDrivers on dcc.DriverCertificationCarID equals jd.DriverCertificationCarID join cpn in db.CarPlateNumbers on dcc.CarPlateNumberID equals cpn.CarPlateNumberID from pln in db.PlateNumbers.Where(number => number.PlateNumberID == cpn.PlateNumberID).DefaultIfEmpty() from zpn in db.ZonePlateNumbers.Where(number => number.ZonePlateNumberID == cpn.ZonePlateNumberID).DefaultIfEmpty() join c in db.Cars on cpn.CarID equals c.CarID join crt in db.CarTypes on c.CarTypeID equals crt.CarTypeID join fc in db.FuelCards on c.CarID equals fc.CarID join j in db.Ajancies on jd.AjancyID equals j.AjancyID join ct in db.Cities on j.CityID equals ct.CityID join pv in db.Provinces on ct.ProvinceID equals pv.ProvinceID join owp in db.Persons on cpn.OwnerPersonID equals owp.PersonID where j.AjancyType == ajancyType && !(from fcs in db.FuelCardSubstitutions join fc2 in db.FuelCards on fcs.AjancyTypeFuelCardID equals fc2.FuelCardID join c2 in db.Cars on fc2.CarID equals c2.CarID join cpn2 in db.CarPlateNumbers on c2.CarID equals cpn2.CarID join dcc2 in db.DriverCertificationCars on cpn2.CarPlateNumberID equals dcc2.CarPlateNumberID join dc2 in db.DriverCertifications on dcc2.DriverCertificationID equals dc2.DriverCertificationID join jd2 in db.AjancyDrivers on dcc2.DriverCertificationCarID equals jd2.DriverCertificationCarID join j2 in db.Ajancies on jd2.AjancyID equals j2.AjancyID where fcs.PersonalTypeFuelCardID != null && j2.AjancyType == ajancyType && (c2.ChassisNo == null && c2.EngineNo == null) && fcs.SubmitDate < new DateTime(2013, 9, 21) && ((fc2.DiscardDate == null && dcc2.LockOutDate == null && jd2.LockOutDate == null)) select dc2.PersonID).Contains(p.PersonID) select new { OWNationalCode = owp.NationalCode, OWFirstName = owp.FirstName, OWLastName = owp.LastName, p.PersonID, p.FirstName, p.LastName, p.Father, p.NationalCode, p.BirthCertificateNo, p.BirthCertificatePlace, p.BirthDate, p.Marriage, p.BirthPlace, p.Mobile, p.Phone, p.PostalCode, p.Address, p.Gender, p.SubmitDate, j.AjancyID, j.AjancyName, u.CityID, u.ProvinceID, Province = pv.Name, City = ct.Name, dc.DriverCertificationNo, c.CarTypeID, c.FuelType, c.Model, c.EngineNo, c.ChassisNo, crt.TypeName, c.VIN, ZCityID = (short?)zpn.CityID, ZNumber = zpn.Number, pln.TwoDigits, pln.ThreeDigits, pln.Alphabet, pln.RegionIdentifier, fc.CardType, fc.PAN }).Distinct(); if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex == 0) // Just province { byte provinceId = Public.ToByte(this.drpProvince.SelectedValue); drivers = from q in drivers where q.ProvinceID == provinceId select q; } if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex > 0) // province and city { short cityId = Public.ToShort(this.drpCity.SelectedValue); drivers = from q in drivers where q.CityID == cityId select q; } if (this.drpAjancies.SelectedIndex > 0) { int ajancyId = Public.ToInt(this.drpAjancies.SelectedValue); drivers = from q in drivers where q.AjancyID == ajancyId select q; } if (this.drpDriverCertification.SelectedIndex == 1) { drivers = from q in drivers where q.DriverCertificationNo != null select q; } else if (this.drpDriverCertification.SelectedIndex == 2) { drivers = from q in drivers where q.DriverCertificationNo == null select q; } if (this.drpCarType.SelectedIndex > 0) { short carTypeId = Public.ToShort(this.drpCarType.SelectedValue); drivers = from q in drivers join ct in db.CarTypes on q.CarTypeID equals ct.CarTypeID where q.CarTypeID == carTypeId select q; } if (this.drpFuelType.SelectedIndex > 0) { byte fuelType = Public.ToByte(this.drpFuelType.SelectedValue); drivers = from q in drivers where q.FuelType == fuelType select q; } if (this.drpFuelCardType.SelectedIndex > 0) { byte fuelCardType = Public.ToByte(this.drpFuelCardType.SelectedValue); drivers = from q in drivers where q.CardType == fuelCardType select q; } if (!string.IsNullOrEmpty(this.txtFuelCardPAN.Text)) { drivers = from q in drivers where q.PAN.Equals(this.txtFuelCardPAN.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtCarVIN.Text)) { drivers = from q in drivers where q.VIN.Equals(this.txtCarVIN.Text.Trim()) select q; } if (this.drpGender.SelectedIndex > 0) { byte gender = Public.ToByte(this.drpGender.SelectedValue); drivers = from q in drivers where q.Gender == gender select q; } if (!string.IsNullOrEmpty(this.txtFirstName.Text)) { drivers = from q in drivers where q.FirstName.Contains(this.txtFirstName.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtLastName.Text)) { drivers = from q in drivers where q.LastName.Contains(this.txtLastName.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtNationalCode.Text)) { drivers = from q in drivers where q.NationalCode == this.txtNationalCode.Text.Trim() select q; } if (!string.IsNullOrEmpty(this.txtBirthCertificateNo.Text)) { drivers = from q in drivers where q.BirthCertificateNo == this.txtBirthCertificateNo.Text.Trim() select q; } if (!string.IsNullOrEmpty(this.txtCarPlateNumber_1.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_2.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_3.Text)) { drivers = from q in drivers where q.TwoDigits == this.txtCarPlateNumber_1.Text.Trim() && q.ThreeDigits == this.txtCarPlateNumber_2.Text.Trim() && q.RegionIdentifier == this.txtCarPlateNumber_3.Text.Trim() && q.Alphabet == this.drpCarPlateNumber.SelectedValue select q; } if (this.txtDateFrom.HasDate && !this.txtDateTo.HasDate) { drivers = from q in drivers where q.SubmitDate == this.txtDateFrom.GeorgianDate.Value select q; } else if (this.txtDateFrom.HasDate && this.txtDateTo.HasDate) { drivers = from q in drivers where q.SubmitDate >= this.txtDateFrom.GeorgianDate.Value && q.SubmitDate <= this.txtDateTo.GeorgianDate.Value select q; } DataTable dtObj = new DataTable(); db.Connection.Open(); dtObj.Load(db.GetCommand(drivers).ExecuteReader()); DisposeContext(); dtObj.TableName = "dt"; Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport(); report.Load(HttpContext.Current.Server.MapPath("~/App_Data/Report/mrt/drivers.mrt")); report.RegData(dtObj); report.Render(); Public.ExportInfo(3, report); report.Dispose(); }
protected void btnExcel_Click(object sender, EventArgs e) { DataTable dtObj = new DataTable(); db = new Ajancy.Kimia_Ajancy(Public.ConnectionString); switch (this.drpStatus.SelectedIndex) { case 0: // All var query = (from p in db.Persons join dc in db.DriverCertifications on p.PersonID equals dc.PersonID join dcc in db.DriverCertificationCars on dc.DriverCertificationID equals dcc.DriverCertificationID join jd in db.AjancyDrivers on dcc.DriverCertificationCarID equals jd.DriverCertificationCarID join cpn in db.CarPlateNumbers on dcc.CarPlateNumberID equals cpn.CarPlateNumberID from pln in db.PlateNumbers.Where(number => number.PlateNumberID == cpn.PlateNumberID).DefaultIfEmpty() from zpn in db.ZonePlateNumbers.Where(number => number.ZonePlateNumberID == cpn.ZonePlateNumberID).DefaultIfEmpty() join c in db.Cars on cpn.CarID equals c.CarID join crt in db.CarTypes on c.CarTypeID equals crt.CarTypeID join fc in db.FuelCards on c.CarID equals fc.CarID join j in db.Ajancies on jd.AjancyID equals j.AjancyID join jp in db.AjancyPartners on j.AjancyID equals jp.AjancyID join ct in db.Cities on j.CityID equals ct.CityID join pv in db.Provinces on ct.ProvinceID equals pv.ProvinceID join owp in db.Persons on cpn.OwnerPersonID equals owp.PersonID where j.AjancyType == Public.ToByte(this.drpAjancyType.SelectedValue) orderby pv.Name, ct.Name select new { OWNationalCode = owp.NationalCode, OWFirstName = owp.FirstName, OWLastName = owp.LastName, p.PersonID, p.FirstName, p.LastName, p.Father, p.NationalCode, p.BirthCertificateNo, p.BirthCertificatePlace, p.BirthDate, p.Marriage, p.BirthPlace, p.Mobile, p.Phone, p.PostalCode, p.Address, p.Gender, p.SubmitDate, j.AjancyID, j.AjancyName, ct.CityID, ct.ProvinceID, Province = pv.Name, City = ct.Name, dc.DriverCertificationNo, c.CarTypeID, c.FuelType, c.Model, c.EngineNo, c.ChassisNo, crt.TypeName, c.VIN, ZCityID = (short?)zpn.CityID, ZNumber = zpn.Number, pln.TwoDigits, pln.ThreeDigits, pln.Alphabet, pln.RegionIdentifier, fc.CardType, fc.PAN }).Distinct(); if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex == 0) // Just province { byte provinceId = Public.ToByte(this.drpProvince.SelectedValue); query = from q in query where q.ProvinceID == provinceId select q; } if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex > 0) // province and city { short cityId = Public.ToShort(this.drpCity.SelectedValue); query = from q in query where q.CityID == cityId select q; } if (this.drpAjancies.SelectedIndex > 0) { int ajancyId = Public.ToInt(this.drpAjancies.SelectedValue); query = from q in query where q.AjancyID == ajancyId select q; } if (this.drpDriverCertification.SelectedIndex == 1) { query = from q in query where q.DriverCertificationNo != null select q; } else if (this.drpDriverCertification.SelectedIndex == 2) { query = from q in query where q.DriverCertificationNo == null select q; } if (this.drpDrivingLicenseType.SelectedIndex > 0) { byte drivingLicense = Public.ToByte(this.drpDrivingLicenseType.SelectedValue); query = from q in query join dl in db.DrivingLicenses on q.PersonID equals dl.PersonID where dl.Type == drivingLicense select q; } if (this.drpMarriage.SelectedIndex > 0) { byte marriage = Public.ToByte(this.drpMarriage.SelectedValue); query = from q in query where q.Marriage == marriage select q; } if (this.drpCarType.SelectedIndex > 0) { short carTypeId = Public.ToShort(this.drpCarType.SelectedValue); query = from q in query join ct in db.CarTypes on q.CarTypeID equals ct.CarTypeID where q.CarTypeID == carTypeId select q; } if (this.drpFuelType.SelectedIndex > 0) { byte fuelType = Public.ToByte(this.drpFuelType.SelectedValue); query = from q in query where q.FuelType == fuelType select q; } if (this.drpFuelCardType.SelectedIndex > 0) { byte fuelCardType = Public.ToByte(this.drpFuelCardType.SelectedValue); query = from q in query where q.CardType == fuelCardType select q; } if (!string.IsNullOrEmpty(this.txtFuelCardPAN.Text)) { query = from q in query where q.PAN.Equals(this.txtFuelCardPAN.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtCarVIN.Text)) { query = from q in query where q.VIN.Equals(this.txtCarVIN.Text.Trim()) select q; } if (this.drpGender.SelectedIndex > 0) { byte gender = Public.ToByte(this.drpGender.SelectedValue); query = from q in query where q.Gender == gender select q; } if (!string.IsNullOrEmpty(this.txtFirstName.Text)) { query = from q in query where q.FirstName.Contains(this.txtFirstName.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtLastName.Text)) { query = from q in query where q.LastName.Contains(this.txtLastName.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtNationalCode.Text)) { query = from q in query where q.NationalCode == this.txtNationalCode.Text.Trim() select q; } if (!string.IsNullOrEmpty(this.txtBirthCertificateNo.Text)) { query = from q in query where q.BirthCertificateNo == this.txtBirthCertificateNo.Text.Trim() select q; } if (!string.IsNullOrEmpty(this.txtCarPlateNumber_1.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_2.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_3.Text)) { query = from q in query where q.TwoDigits == this.txtCarPlateNumber_1.Text.Trim() && q.ThreeDigits == this.txtCarPlateNumber_2.Text.Trim() && q.RegionIdentifier == this.txtCarPlateNumber_3.Text.Trim() && q.Alphabet == this.drpCarPlateNumber.SelectedValue select q; } if (this.txtDateFrom.HasDate && !this.txtDateTo.HasDate) { query = from q in query where q.SubmitDate == this.txtDateFrom.GeorgianDate.Value select q; } else if (this.txtDateFrom.HasDate && this.txtDateTo.HasDate) { query = from q in query where q.SubmitDate >= this.txtDateFrom.GeorgianDate.Value && q.SubmitDate <= this.txtDateTo.GeorgianDate.Value select q; } db.Connection.Open(); dtObj.Load(db.GetCommand(query).ExecuteReader()); db.Connection.Close(); db.Dispose(); break; case 1: // Actives var query1 = (from p in db.Persons join dc in db.DriverCertifications on p.PersonID equals dc.PersonID join dcc in db.DriverCertificationCars on dc.DriverCertificationID equals dcc.DriverCertificationID join jd in db.AjancyDrivers on dcc.DriverCertificationCarID equals jd.DriverCertificationCarID join cpn in db.CarPlateNumbers on dcc.CarPlateNumberID equals cpn.CarPlateNumberID from pln in db.PlateNumbers.Where(number => number.PlateNumberID == cpn.PlateNumberID).DefaultIfEmpty() from zpn in db.ZonePlateNumbers.Where(number => number.ZonePlateNumberID == cpn.ZonePlateNumberID).DefaultIfEmpty() join c in db.Cars on cpn.CarID equals c.CarID join crt in db.CarTypes on c.CarTypeID equals crt.CarTypeID join fc in db.FuelCards on c.CarID equals fc.CarID join j in db.Ajancies on jd.AjancyID equals j.AjancyID join jp in db.AjancyPartners on j.AjancyID equals jp.AjancyID join ct in db.Cities on j.CityID equals ct.CityID join pv in db.Provinces on ct.ProvinceID equals pv.ProvinceID join owp in db.Persons on cpn.OwnerPersonID equals owp.PersonID where j.AjancyType == Public.ToByte(this.drpAjancyType.SelectedValue) && jd.LockOutDate == null && dcc.LockOutDate == null orderby pv.Name, ct.Name select new { OWNationalCode = owp.NationalCode, OWFirstName = owp.FirstName, OWLastName = owp.LastName, p.PersonID, p.FirstName, p.LastName, p.Father, p.NationalCode, p.BirthCertificateNo, p.BirthCertificatePlace, p.BirthDate, p.Marriage, p.BirthPlace, p.Mobile, p.Phone, p.PostalCode, p.Address, p.Gender, p.SubmitDate, j.AjancyID, j.AjancyName, ct.CityID, ct.ProvinceID, Province = pv.Name, City = ct.Name, dc.DriverCertificationNo, c.CarTypeID, c.FuelType, c.Model, c.EngineNo, c.ChassisNo, crt.TypeName, c.VIN, ZCityID = (short?)zpn.CityID, ZNumber = zpn.Number, pln.TwoDigits, pln.ThreeDigits, pln.Alphabet, pln.RegionIdentifier, fc.CardType, fc.PAN }).Distinct(); if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex == 0) // Just province { byte provinceId = Public.ToByte(this.drpProvince.SelectedValue); query1 = from q in query1 where q.ProvinceID == provinceId select q; } if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex > 0) // province and city { short cityId = Public.ToShort(this.drpCity.SelectedValue); query1 = from q in query1 where q.CityID == cityId select q; } if (this.drpAjancies.SelectedIndex > 0) { int ajancyId = Public.ToInt(this.drpAjancies.SelectedValue); query1 = from q in query1 where q.AjancyID == ajancyId select q; } if (this.drpDriverCertification.SelectedIndex == 1) { query1 = from q in query1 where q.DriverCertificationNo != null select q; } else if (this.drpDriverCertification.SelectedIndex == 2) { query1 = from q in query1 where q.DriverCertificationNo == null select q; } if (this.drpDrivingLicenseType.SelectedIndex > 0) { byte drivingLicense = Public.ToByte(this.drpDrivingLicenseType.SelectedValue); query1 = from q in query1 join dl in db.DrivingLicenses on q.PersonID equals dl.PersonID where dl.Type == drivingLicense select q; } if (this.drpMarriage.SelectedIndex > 0) { byte marriage = Public.ToByte(this.drpMarriage.SelectedValue); query1 = from q in query1 where q.Marriage == marriage select q; } if (this.drpCarType.SelectedIndex > 0) { short carTypeId = Public.ToShort(this.drpCarType.SelectedValue); query1 = from q in query1 join ct in db.CarTypes on q.CarTypeID equals ct.CarTypeID where q.CarTypeID == carTypeId select q; } if (this.drpFuelType.SelectedIndex > 0) { byte fuelType = Public.ToByte(this.drpFuelType.SelectedValue); query1 = from q in query1 where q.FuelType == fuelType select q; } if (this.drpFuelCardType.SelectedIndex > 0) { byte fuelCardType = Public.ToByte(this.drpFuelCardType.SelectedValue); query1 = from q in query1 where q.CardType == fuelCardType select q; } if (!string.IsNullOrEmpty(this.txtFuelCardPAN.Text)) { query1 = from q in query1 where q.PAN.Equals(this.txtFuelCardPAN.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtCarVIN.Text)) { query1 = from q in query1 where q.VIN.Equals(this.txtCarVIN.Text.Trim()) select q; } if (this.drpGender.SelectedIndex > 0) { byte gender = Public.ToByte(this.drpGender.SelectedValue); query1 = from q in query1 where q.Gender == gender select q; } if (!string.IsNullOrEmpty(this.txtFirstName.Text)) { query1 = from q in query1 where q.FirstName.Contains(this.txtFirstName.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtLastName.Text)) { query1 = from q in query1 where q.LastName.Contains(this.txtLastName.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtNationalCode.Text)) { query1 = from q in query1 where q.NationalCode == this.txtNationalCode.Text.Trim() select q; } if (!string.IsNullOrEmpty(this.txtBirthCertificateNo.Text)) { query1 = from q in query1 where q.BirthCertificateNo == this.txtBirthCertificateNo.Text.Trim() select q; } if (!string.IsNullOrEmpty(this.txtCarPlateNumber_1.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_2.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_3.Text)) { query1 = from q in query1 where q.TwoDigits == this.txtCarPlateNumber_1.Text.Trim() && q.ThreeDigits == this.txtCarPlateNumber_2.Text.Trim() && q.RegionIdentifier == this.txtCarPlateNumber_3.Text.Trim() && q.Alphabet == this.drpCarPlateNumber.SelectedValue select q; } if (this.txtDateFrom.HasDate && !this.txtDateTo.HasDate) { query1 = from q in query1 where q.SubmitDate == this.txtDateFrom.GeorgianDate.Value select q; } else if (this.txtDateFrom.HasDate && this.txtDateTo.HasDate) { query1 = from q in query1 where q.SubmitDate >= this.txtDateFrom.GeorgianDate.Value && q.SubmitDate <= this.txtDateTo.GeorgianDate.Value select q; } db.Connection.Open(); dtObj.Load(db.GetCommand(query1).ExecuteReader()); db.Connection.Close(); db.Dispose(); break; case 2: // Inactives var query2 = (from p in db.Persons join dc in db.DriverCertifications on p.PersonID equals dc.PersonID join dcc in db.DriverCertificationCars on dc.DriverCertificationID equals dcc.DriverCertificationID join jd in db.AjancyDrivers on dcc.DriverCertificationCarID equals jd.DriverCertificationCarID join cpn in db.CarPlateNumbers on dcc.CarPlateNumberID equals cpn.CarPlateNumberID from pln in db.PlateNumbers.Where(number => number.PlateNumberID == cpn.PlateNumberID).DefaultIfEmpty() from zpn in db.ZonePlateNumbers.Where(number => number.ZonePlateNumberID == cpn.ZonePlateNumberID).DefaultIfEmpty() join c in db.Cars on cpn.CarID equals c.CarID join crt in db.CarTypes on c.CarTypeID equals crt.CarTypeID join fc in db.FuelCards on c.CarID equals fc.CarID join j in db.Ajancies on jd.AjancyID equals j.AjancyID join jp in db.AjancyPartners on j.AjancyID equals jp.AjancyID join ct in db.Cities on j.CityID equals ct.CityID join pv in db.Provinces on ct.ProvinceID equals pv.ProvinceID join owp in db.Persons on cpn.OwnerPersonID equals owp.PersonID where j.AjancyType == Public.ToByte(this.drpAjancyType.SelectedValue) && jd.LockOutDate != null && dcc.LockOutDate != null orderby pv.Name, ct.Name select new { OWNationalCode = owp.NationalCode, OWFirstName = owp.FirstName, OWLastName = owp.LastName, p.PersonID, p.FirstName, p.LastName, p.Father, p.NationalCode, p.BirthCertificateNo, p.BirthCertificatePlace, p.BirthDate, p.Marriage, p.BirthPlace, p.Mobile, p.Phone, p.PostalCode, p.Address, p.Gender, p.SubmitDate, j.AjancyID, j.AjancyName, ct.CityID, ct.ProvinceID, Province = pv.Name, City = ct.Name, dc.DriverCertificationNo, c.CarTypeID, c.FuelType, c.Model, c.EngineNo, c.ChassisNo, crt.TypeName, c.VIN, ZCityID = (short?)zpn.CityID, ZNumber = zpn.Number, pln.TwoDigits, pln.ThreeDigits, pln.Alphabet, pln.RegionIdentifier, fc.CardType, fc.PAN }).Distinct(); if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex == 0) // Just province { byte provinceId = Public.ToByte(this.drpProvince.SelectedValue); query2 = from q in query2 where q.ProvinceID == provinceId select q; } if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex > 0) // province and city { short cityId = Public.ToShort(this.drpCity.SelectedValue); query2 = from q in query2 where q.CityID == cityId select q; } if (this.drpAjancies.SelectedIndex > 0) { int ajancyId = Public.ToInt(this.drpAjancies.SelectedValue); query2 = from q in query2 where q.AjancyID == ajancyId select q; } if (this.drpDriverCertification.SelectedIndex == 1) { query2 = from q in query2 where q.DriverCertificationNo != null select q; } else if (this.drpDriverCertification.SelectedIndex == 2) { query2 = from q in query2 where q.DriverCertificationNo == null select q; } if (this.drpDrivingLicenseType.SelectedIndex > 0) { byte drivingLicense = Public.ToByte(this.drpDrivingLicenseType.SelectedValue); query2 = from q in query2 join dl in db.DrivingLicenses on q.PersonID equals dl.PersonID where dl.Type == drivingLicense select q; } if (this.drpMarriage.SelectedIndex > 0) { byte marriage = Public.ToByte(this.drpMarriage.SelectedValue); query2 = from q in query2 where q.Marriage == marriage select q; } if (this.drpCarType.SelectedIndex > 0) { short carTypeId = Public.ToShort(this.drpCarType.SelectedValue); query2 = from q in query2 join ct in db.CarTypes on q.CarTypeID equals ct.CarTypeID where q.CarTypeID == carTypeId select q; } if (this.drpFuelType.SelectedIndex > 0) { byte fuelType = Public.ToByte(this.drpFuelType.SelectedValue); query2 = from q in query2 where q.FuelType == fuelType select q; } if (this.drpFuelCardType.SelectedIndex > 0) { byte fuelCardType = Public.ToByte(this.drpFuelCardType.SelectedValue); query2 = from q in query2 where q.CardType == fuelCardType select q; } if (!string.IsNullOrEmpty(this.txtFuelCardPAN.Text)) { query2 = from q in query2 where q.PAN.Equals(this.txtFuelCardPAN.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtCarVIN.Text)) { query2 = from q in query2 where q.VIN.Equals(this.txtCarVIN.Text.Trim()) select q; } if (this.drpGender.SelectedIndex > 0) { byte gender = Public.ToByte(this.drpGender.SelectedValue); query2 = from q in query2 where q.Gender == gender select q; } if (!string.IsNullOrEmpty(this.txtFirstName.Text)) { query2 = from q in query2 where q.FirstName.Contains(this.txtFirstName.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtLastName.Text)) { query2 = from q in query2 where q.LastName.Contains(this.txtLastName.Text.Trim()) select q; } if (!string.IsNullOrEmpty(this.txtNationalCode.Text)) { query2 = from q in query2 where q.NationalCode == this.txtNationalCode.Text.Trim() select q; } if (!string.IsNullOrEmpty(this.txtBirthCertificateNo.Text)) { query2 = from q in query2 where q.BirthCertificateNo == this.txtBirthCertificateNo.Text.Trim() select q; } if (!string.IsNullOrEmpty(this.txtCarPlateNumber_1.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_2.Text) && !string.IsNullOrEmpty(this.txtCarPlateNumber_3.Text)) { query2 = from q in query2 where q.TwoDigits == this.txtCarPlateNumber_1.Text.Trim() && q.ThreeDigits == this.txtCarPlateNumber_2.Text.Trim() && q.RegionIdentifier == this.txtCarPlateNumber_3.Text.Trim() && q.Alphabet == this.drpCarPlateNumber.SelectedValue select q; } if (this.txtDateFrom.HasDate && !this.txtDateTo.HasDate) { query2 = from q in query2 where q.SubmitDate == this.txtDateFrom.GeorgianDate.Value select q; } else if (this.txtDateFrom.HasDate && this.txtDateTo.HasDate) { query2 = from q in query2 where q.SubmitDate >= this.txtDateFrom.GeorgianDate.Value && q.SubmitDate <= this.txtDateTo.GeorgianDate.Value select q; } db.Connection.Open(); dtObj.Load(db.GetCommand(query2).ExecuteReader()); db.Connection.Close(); db.Dispose(); break; } dtObj.TableName = "dt"; Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport(); report.Load(HttpContext.Current.Server.MapPath("~/App_Data/Report/mrt/drivers.mrt")); report.RegData(dtObj); report.Render(); Public.ExportInfo(3, report); report.Dispose(); }