Пример #1
0
    protected void SetandoRelExcel()
    {
        Stimulsoft.Report.StiReport Report = new Stimulsoft.Report.StiReport();
        DataTable dt            = new DataTable();
        string    nomeRelatorio = string.Empty;

        if (Convert.ToString(Request.QueryString["Rel"]) == "frmFechamentoRel")
        {
            FechamentoFolhaSrv fechamentoFolhaSrv = new FechamentoFolhaSrv();
            dt            = new DataTable();
            dt            = fechamentoFolhaSrv.GetDadosImprimir(Request.QueryString["Mes"].ToString());
            nomeRelatorio = "FechamentoFolha.xls";
            Report.Load(Server.MapPath(@"~/Relatorio/STF/FechamentoFolha.mrt"));
            Report.Compile();
        }

        Report.RegData("DADOS", dt);
        Report.Render();
        System.IO.MemoryStream memStream = new System.IO.MemoryStream();

        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ContentType = "application/xls";

        HttpContext.Current.Response.AddHeader(nomeRelatorio, "");
        Stimulsoft.Report.Export.StiExcelExportService ExportXSL = new Stimulsoft.Report.Export.StiExcelExportService();
        ExportXSL.ExportExcel(Report, memStream, Stimulsoft.Report.StiPagesRange.All, false, false, true, true);
        Response.ContentType = "application/xls";

        Response.AddHeader("content-disposition", "inline; filename=" + nomeRelatorio + "");
        Response.BinaryWrite(memStream.ToArray());
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MetodosPontoFrequencia.Frequencia Freq = new MetodosPontoFrequencia.Frequencia();

        MetodosPontoFrequencia.DataSetPontoFrequencia ds = new DataSetPontoFrequencia();

        MetodosPontoFrequencia.PreencheTabela pt = new MetodosPontoFrequencia.PreencheTabela();

        Freq.HorasDias(7, 688, 2014, ds, 4, 7);

        Stimulsoft.Report.StiReport Report = new Stimulsoft.Report.StiReport();

        //Stimulsoft.Report.Web.StiWebDesigner st1 = new Stimulsoft.Report.Web.StiWebDesigner();

        Report.Load(Server.MapPath(@"~/Relatorio/RPT/ReportTesteFeito.mrt"));

        Report.RegData("DatasetPontoFrequencia", ds);

        Report.Render();

        MemoryStream memStream = new MemoryStream();

        Stimulsoft.Report.Export.StiPdfExportService Export = new Stimulsoft.Report.Export.StiPdfExportService();

        Export.ExportPdf(Report, memStream, Stimulsoft.Report.StiPagesRange.All, 100, 100, false, false, true, true, "", "", Stimulsoft.Report.Export.StiUserAccessPrivileges.All, Stimulsoft.Report.Export.StiPdfEncryptionKeyLength.Bit128, false);

        //HttpContext.Current.Response.ClearContent();
        //HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ContentType = "application/pdf";
        HttpContext.Current.Response.BinaryWrite(memStream.ToArray());
        //HttpContext.Current.Response.Flush();
        //HttpContext.Current.Response.Close();
    }
Пример #3
0
 private void btRefresh_Click(object sender, System.EventArgs e)
 {
     Report.Render(false);
     PreviewControl.SaveConfig();
     PreviewControl.Refresh();
     PreviewControl.LoadConfig();
 }
Пример #4
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RenderInThread.MasterDetailSubdetail.mrt"))
            {
                report.Load(stream);
            }

            report.IsRendered = false;
            report.Compile();
            report.CompiledReport.Rendering += new EventHandler(CompiledReport_Rendering);
            report.Render(false);
        }
Пример #5
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            stiReport1.Render();
            StiComponentsCollection comps = stiReport1.RenderedPages[0].GetComponents();

            text  = comps["Text1"] as StiText;
            chart = comps["Chart1"] as StiChart;
        }
Пример #6
0
 private void Print_Click(object sender, EventArgs e)
 {
     try
     {
         Stimulsoft.Report.StiReport rpt = new Stimulsoft.Report.StiReport();
         string startupPath = System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
         rpt.Load(startupPath + "\\Reports\\GoodsReport.mrt");
         rpt.Dictionary.Variables["today"].Value = DateTodayFullChar();
         rpt.RegBusinessObject("Goods", (List <Connection.Services.GoodsService>)dataGridView1.DataSource);
         rpt.Render();
         rpt.Show();
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.ToString());
     }
 }
Пример #7
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RenderInThread.Master-Detail-Subdetail.mrt"))
            {
                report.Load(stream);
            }

            DataSet data = new DataSet();

            data.ReadXmlSchema("..\\..\\Data\\demo.xsd");
            data.ReadXml("..\\..\\Data\\demo.xml");

            report.RegData(data);
            report.IsRendered = false;
            report.Compile();
            report.CompiledReport.Rendering += new EventHandler(CompiledReport_Rendering);
            report.Render(false);
        }
Пример #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MetodosPontoFrequencia.Frequencia Freq = new MetodosPontoFrequencia.Frequencia();

        DataSetPontoFrequencia ds = new DataSetPontoFrequencia();

        MetodosPontoFrequencia.PreencheTabela pt = new MetodosPontoFrequencia.PreencheTabela();

        Freq.HorasDias(7, 688, 2014, ds, 4, 7);

        Stimulsoft.Report.StiReport Report = new Stimulsoft.Report.StiReport();

        //Stimulsoft.Report.Web.StiWebDesigner st1 = new Stimulsoft.Report.Web.StiWebDesigner();

        Report.Load(Server.MapPath(@"~/Relatorio/RPT/rptFolhaFrequencia.mrt"));

        Report.RegData("DatasetPontoFrequencia", ds);

        Report.Render();

        System.IO.MemoryStream memStream = new System.IO.MemoryStream();

        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ContentType = "application/pdf";

        HttpContext.Current.Response.AddHeader("Teste.pdf", "");

        Stimulsoft.Report.Export.StiPdfExportService Export = new Stimulsoft.Report.Export.StiPdfExportService();

        Export.ExportPdf(Report, memStream, Stimulsoft.Report.StiPagesRange.All, 100, 100, false, false, true, true, "", "", Stimulsoft.Report.Export.StiUserAccessPrivileges.All, Stimulsoft.Report.Export.StiPdfEncryptionKeyLength.Bit40, false);

        Response.ContentType = "application/pdf";

        Response.AddHeader("content-disposition", "inline; filename=Teste.pdf");


        Response.BinaryWrite(memStream.ToArray());

        //Stimulsoft.Report.Web.StiReportResponse.ResponseAs(this,

        //st1.Design(Report);
    }
Пример #9
0
        public Form1()
        {
            // How to Activate
            //Stimulsoft.Base.StiLicense.Key = "6vJhGtLLLz2GNviWmUTrhSqnO...";
            //Stimulsoft.Base.StiLicense.LoadFromFile("license.key");
            //Stimulsoft.Base.StiLicense.LoadFromStream(stream);

            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            stiPreviewControl1.PageViewMode = Stimulsoft.Report.Viewer.StiPageViewMode.Continuous;
            stiReport1.Render();
            StiComponentsCollection comps = stiReport1.RenderedPages[0].GetComponents();

            text  = comps["Text1"] as StiText;
            chart = comps["Chart1"] as StiChart;
        }
Пример #10
0
    protected void SetandoRel()
    {
        //Report da stimulsoft

        Stimulsoft.Report.StiReport Report = new Stimulsoft.Report.StiReport();

        //Stimulsoft.Report.Web.StiWebDesigner st1 = new Stimulsoft.Report.Web.StiWebDesigner();

        if (Convert.ToString(Request.QueryString["Rel"]) == "frmZuxa")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/EspelhoPonto.mrt"));
            Report.Compile();
            Report["DiasMes"]        = TotalDiasMes.ToString();
            Report["DiasCumpridos"]  = TotalDiasCumprido.ToString();
            Report["TotalHorasMes"]  = TotalHoraMes.ToString();
            Report["HorasCumpridas"] = HorasCumpridas.ToString();
        }

        Report.RegData("DatasetPontoFrequencia", ds);

        Report.Render();

        System.IO.MemoryStream memStream = new System.IO.MemoryStream();

        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ContentType = "application/pdf";

        HttpContext.Current.Response.AddHeader("Pontoweb.pdf", "");

        Stimulsoft.Report.Export.StiPdfExportService Export = new Stimulsoft.Report.Export.StiPdfExportService();

        Export.ExportPdf(Report, memStream, Stimulsoft.Report.StiPagesRange.All, 100, 100, false, false, true, true,
                         "", "", Stimulsoft.Report.Export.StiUserAccessPrivileges.All, Stimulsoft.Report.Export.StiPdfEncryptionKeyLength.Bit40, false);

        Response.ContentType = "application/pdf";

        Response.AddHeader("content-disposition", "inline; filename=Pontoweb.pdf");

        Response.BinaryWrite(memStream.ToArray());
    }
Пример #11
0
        private static byte[] GetPdfBytes(byte[] reportTemplate, List <ReportDataSource> dataSources)
        {
            using (Stimulsoft.Report.StiReport stiReport = new Stimulsoft.Report.StiReport())
            {
                foreach (var dataSource in dataSources)
                {
                    stiReport.RegBusinessObject(dataSource.DataSourceName, dataSource.DataSource);
                }

                stiReport.Load(reportTemplate);
                stiReport.Render();

                byte[] result = null;
                using (MemoryStream stream = new MemoryStream())
                {
                    StiPdfExportService pdfService = new StiPdfExportService();
                    pdfService.ExportPdf(stiReport, stream);
                    result = stream.ToArray();
                }
                return(result);
            }
        }
Пример #12
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //

            // How to Activate
            //Stimulsoft.Base.StiLicense.Key = "6vJhGtLLLz2GNviWmUTrhSqnO...";
            //Stimulsoft.Base.StiLicense.LoadFromFile("license.key");
            //Stimulsoft.Base.StiLicense.LoadFromStream(stream);

            stiReport1.Render();
            StiComponentsCollection comps = stiReport1.RenderedPages[0].GetComponents();

            text  = comps["Text1"] as StiText;
            chart = comps["Chart1"] as StiChart;
        }
Пример #13
0
    protected void btnZoneReport_Click(object sender, EventArgs e)
    {
        Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
        report.Load(HttpContext.Current.Server.MapPath(this.drpReportType.SelectedIndex == 1 ? "~/App_Data/Report/mrt/fc_zone-replace.mrt" : "~/App_Data/Report/mrt/fc_zone-dis.mrt"));
        switch (this.drpReportType.SelectedIndex)
        {
            case 0:
                report.RegData(ZoneDiscards());
                break;

            case 1:
                report.RegData(ZoneReplacement());
                break;

            case 2:
                report.RegData(ZoneDiscardeds());
                break;
        }

        report.Render();
        Public.ExportInfo(3, report);
        report.Dispose();
    }
Пример #14
0
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            var query = from s in db.Schools
                        join slv in db.SchoolLevels on s.SchoolID equals slv.SchoolID
                        join ssl in db.SchoolSubLevels on slv.SchoolLevelID equals ssl.SchoolLevelID
                        join sc in db.SchoolClothes on ssl.SchoolSubLevelID equals sc.SchoolSubLevelID
                        join st in db.StudentClothes on sc.SchoolClotheID equals st.SchoolClotheID
                        join cc in db.CycleClothes on sc.CycleClotheID equals cc.CycleClotheID
                        join stf in db.REP_Stuffs on cc.StuffID equals stf.StuffID
                        join a in db.Areas on s.AreaCode equals a.AreaCode
                        join lv in db.Levels on slv.LevelID equals lv.LevelID
                        where a.ProvinceID == 71 && cc.CycleID == Public.ToInt(this.drpCycle.SelectedValue) &&
                              slv.LockOutDate == null && cc.CycleClotheID == Public.ToInt(this.drpStuffs.SelectedValue)
                        group ssl by new { s.SchoolCode, s.SchoolName, lv.LevelName, a.AreaCode, a.AreaName, st.ClotheCount, stf.StuffName, cc.CycleClotheID } into grp
                        orderby grp.Key.SchoolCode
                        select new
                        {
                            grp.Key.SchoolCode,
                            grp.Key.SchoolName,
                            grp.Key.LevelName,
                            grp.Key.AreaCode,
                            grp.Key.AreaName,
                            grp.Key.StuffName,
                            ClotheCount = grp.Count()
                        };

            if (!string.IsNullOrEmpty(this.txtAreaCode.Text))
            {
                query = from q in query
                        where q.AreaCode == Public.ToInt(this.txtAreaCode.Text)
                        select q;
            }

            if (!string.IsNullOrEmpty(this.txtSchoolCode.Text))
            {
                query = from q in query
                        where q.SchoolCode == Public.ToInt(this.txtSchoolCode.Text)
                        select q;
            }

            var result = from q in query
                         group q by new { q.SchoolCode, q.SchoolName, q.AreaName, q.StuffName } into grp
                         select new
                         {
                             grp.Key.SchoolCode,
                             grp.Key.SchoolName,
                             grp.Key.AreaName,
                             grp.Key.StuffName,
                             ClotheCount = grp.Sum(s => s.ClotheCount)
                         };

            DataTable dtObj = new DataTable();
            dtObj.Columns.Add(new DataColumn("SchoolCode", typeof(int)));
            dtObj.Columns.Add(new DataColumn("SchoolName", typeof(string)));
            dtObj.Columns.Add(new DataColumn("AreaName", typeof(string)));
            dtObj.Columns.Add(new DataColumn("GoodName", typeof(string)));
            dtObj.Columns.Add(new DataColumn("ClotheCount", typeof(short)));
            dtObj.Columns.Add(new DataColumn("LevelName", typeof(string)));

            foreach (var item in query)
            {
                DataRow row = dtObj.NewRow();
                row[0] = item.SchoolCode;
                row[1] = item.SchoolName;
                row[2] = item.AreaName;
                row[3] = item.StuffName;
                row[4] = item.ClotheCount;
                row[5] = item.LevelName;
                dtObj.Rows.Add(row);
            }

            dtObj.TableName = "dt";
            Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
            report.RegData(dtObj);
            report.Load(HttpContext.Current.Server.MapPath("~/App_Data/Report/mrt/sch_clothe.mrt"));
            report.Render();
            Public.ExportInfo(3, report);
            report.Dispose();
        }
    }
Пример #15
0
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            int cycleFoodId = Public.ToInt(this.drpStuffs.SelectedValue);
            var query = from sf in db.SchoolFoods
                        join cl in db.Calendars on sf.CalendarID equals cl.CalendarID
                        join ssl in db.SchoolSubLevels on sf.SchoolSubLevelID equals ssl.SchoolSubLevelID
                        join slv in db.SchoolLevels on ssl.SchoolLevelID equals slv.SchoolLevelID
                        join lv in db.Levels on slv.LevelID equals lv.LevelID
                        join s in db.Schools on slv.SchoolID equals s.SchoolID
                        join sl in db.SubLevels on ssl.SubLevelID equals sl.SubLevelID
                        join cf in db.CycleFoods on sf.CycleFoodID equals cf.CycleFoodID
                        join st in db.REP_Stuffs on cf.StuffID equals st.StuffID
                        join a in db.Areas on s.AreaCode equals a.AreaCode
                        orderby a.AreaCode, s.SchoolCode, sf.CalendarID
                        where a.ProvinceID == int.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings["DefaultProvinceId"]) &&
                                 sf.CycleFoodID == Public.ToInt(this.drpStuffs.SelectedValue) && slv.LockOutDate == null
                        group ssl by new
                        {
                            s.SchoolID,
                            s.SchoolCode,
                            s.SchoolName,
                            lv.LevelName,
                            a.AreaCode,
                            a.AreaName,
                            st.StuffName,
                            cl.SolarYear,
                            cl.SolarMonth,
                            cl.SolarDay
                        } into grp
                        orderby grp.Key.SchoolCode
                        select new
                        {
                            grp.Key.SchoolCode,
                            grp.Key.SchoolName,
                            grp.Key.AreaCode,
                            grp.Key.AreaName,
                            grp.Key.LevelName,
                            grp.Key.StuffName,
                            grp.Key.SolarYear,
                            grp.Key.SolarMonth,
                            RationDate = string.Concat(grp.Key.SolarYear, "/", grp.Key.SolarMonth, "/", grp.Key.SolarDay),
                            Ration = (from sf2 in db.SchoolFoods
                                      join cl2 in db.Calendars on sf2.CalendarID equals cl2.CalendarID
                                      join ssl2 in db.SchoolSubLevels on sf2.SchoolSubLevelID equals ssl2.SchoolSubLevelID
                                      join slv2 in db.SchoolLevels on ssl2.SchoolLevelID equals slv2.SchoolLevelID
                                      where slv2.SchoolID == grp.Key.SchoolID && slv2.LockOutDate == null &&
                                               sf2.CycleFoodID == cycleFoodId && cl2.SolarYear == grp.Key.SolarYear &&
                                               cl2.SolarMonth == grp.Key.SolarMonth && cl2.SolarDay == grp.Key.SolarDay
                                      select new
                                      {
                                          sf2.FoodCount
                                      }).Sum(fc => fc.FoodCount)
                        };

            if (this.drpMonths.SelectedIndex > 0)
            {
                string[] monthVals = this.drpMonths.SelectedValue.Split('|');
                short solarYear = Public.ToShort(monthVals[0]);
                byte solarMonth = Public.ToByte(monthVals[1]);
                query = from q in query
                        where q.SolarYear == solarYear && q.SolarMonth == solarMonth
                        select q;
            }

            if (!string.IsNullOrEmpty(this.txtAreaCode.Text))
            {
                query = from q in query
                        where q.AreaCode == Public.ToInt(this.txtAreaCode.Text)
                        select q;
            }

            if (!string.IsNullOrEmpty(this.txtSchoolCode.Text))
            {
                query = from q in query
                        where q.SchoolCode == Public.ToInt(this.txtSchoolCode.Text)
                        select q;
            }

            DataTable dtObj = new DataTable();
            db.Connection.Open();
            dtObj.Load(db.GetCommand(query).ExecuteReader());
            db.Connection.Close();
            dtObj.TableName = "dt";
            Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
            report.RegData(dtObj);
            report.Load(HttpContext.Current.Server.MapPath("~/App_Data/Report/mrt/sch_ration.mrt"));
            report.Render();
            Public.ExportInfo(3, report);
            report.Dispose();
        }
    }
Пример #16
0
    protected void btnDrivers_Click(object sender, EventArgs e)
    {
        db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
        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
                     join pn in db.PlateNumbers on cpn.PlateNumberID equals pn.PlateNumberID
                     join c in db.Cars on cpn.CarID equals c.CarID
                     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 ur in db.UsersInRoles on jp.UserRoleID equals ur.UserRoleID
                     join ct in db.Cities on j.CityID equals ct.CityID
                     join owp in db.Persons on cpn.OwnerPersonID equals owp.PersonID
                     where j.AjancyType == Public.ToByte(this.drpAjancyType.SelectedValue) &&
                                ur.RoleID == (short)Public.Role.AjancyManager &&
                                jd.LockOutDate == null &&
                                dcc.LockOutDate == null &&
                                fc.DiscardDate == null
                     orderby p.LastName
                     select new
                     {
                         Driver = p,
                         Owner = new { owp.NationalCode, owp.FirstName, owp.LastName, },
                         DrivingLicense = p.DrivingLicenses.Count > 0 ? p.DrivingLicenses[0] : null,
                         j.AjancyName,
                         City = ct.Name,
                         Car = new
                         {
                             Color = c.Color,
                             Model = c.Model,
                             EngineNo = c.EngineNo,
                             ChassisNo = c.ChassisNo,
                             TypeName = c.CarType.TypeName,
                             FuelType = c.FuelType,
                             VIN = c.VIN,
                             TwoDigits = cpn.PlateNumber.TwoDigits,
                             Alphabet = cpn.PlateNumber.Alphabet,
                             ThreeDigits = cpn.PlateNumber.ThreeDigits,
                             Iran = "ایران",
                             RegionIdentifier = cpn.PlateNumber.RegionIdentifier,
                         },
                         ct.ProvinceID,
                         ct.CityID,
                         dc.DriverCertificationNo,
                         FuelCard = new { fc.CardType, fc.PAN },
                         j.AjancyID
                     });

        if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex == 0) // Just province
        {
            query = from q in query
                    where q.ProvinceID == Public.ToByte(this.drpProvince.SelectedValue)
                    select q;
        }

        if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex > 0) // province and city
        {
            query = from q in query
                    where q.CityID == Public.ToByte(this.drpCity.SelectedValue)
                    select q;
        }

        if (this.drpAjancies.SelectedIndex > 0)
        {
            query = from q in query
                    where q.AjancyID == Public.ToInt(this.drpAjancies.SelectedValue)
                    select q;
        }

        DataTable dtObj = new DataTable();
        dtObj.Columns.Add(new DataColumn("OWNationalCode", typeof(string)));
        dtObj.Columns.Add(new DataColumn("OWFirstName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("OWLastName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("NationalCode", typeof(string)));
        dtObj.Columns.Add(new DataColumn("FirstName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("LastName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Father", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BirthCertificateNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BirthCertificateAlfa", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BirthCertificateSerie", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BirthCertificateSerial", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BirthCertificatePlace", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BirthDate", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BirthPlace", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Gender", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Marriage", typeof(string)));
        dtObj.Columns.Add(new DataColumn("FamilyMembersCount", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Education", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Religion", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Subreligion", typeof(string)));
        dtObj.Columns.Add(new DataColumn("JobStatus", typeof(string)));
        dtObj.Columns.Add(new DataColumn("MilitaryService", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Mobile", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Phone", typeof(string)));
        dtObj.Columns.Add(new DataColumn("PostalCode", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Address", typeof(string)));

        dtObj.Columns.Add(new DataColumn("DrivingLicenseNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("ExportDate", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Type", typeof(string)));
        dtObj.Columns.Add(new DataColumn("ExportPlace", typeof(string)));

        dtObj.Columns.Add(new DataColumn("VIN", typeof(string)));
        dtObj.Columns.Add(new DataColumn("PAN", typeof(string)));
        dtObj.Columns.Add(new DataColumn("CardType", typeof(string)));
        dtObj.Columns.Add(new DataColumn("TypeName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Model", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Color", typeof(string)));
        dtObj.Columns.Add(new DataColumn("EngineNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("ChassisNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("FuelType", typeof(string)));
        dtObj.Columns.Add(new DataColumn("TwoDigits", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Alphabet", typeof(string)));
        dtObj.Columns.Add(new DataColumn("ThreeDigits", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Iran", typeof(string)));
        dtObj.Columns.Add(new DataColumn("RegionIdentifier", typeof(string)));

        dtObj.Columns.Add(new DataColumn("AjancyName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("City", typeof(string)));
        dtObj.Columns.Add(new DataColumn("DriverCertificationNo", typeof(string)));

        foreach (var item in query)
        {
            DataRow row = dtObj.NewRow();
            row[0] = item.Owner.NationalCode;
            row[1] = item.Owner.FirstName;
            row[2] = item.Owner.LastName;
            row[3] = item.Driver.NationalCode;
            row[4] = item.Driver.FirstName;
            row[5] = item.Driver.LastName;
            row[6] = item.Driver.Father;
            row[7] = item.Driver.BirthCertificateNo;
            row[8] = Public.GetAlphabet(item.Driver.BirthCertificateAlfa);
            row[9] = item.Driver.BirthCertificateSerie;
            row[10] = item.Driver.BirthCertificateSerial;
            row[11] = item.Driver.BirthCertificatePlace;
            row[12] = item.Driver.BirthDate;
            row[13] = item.Driver.BirthPlace;
            row[14] = item.Driver.Gender.GetValueOrDefault() == 0 ? "مرد" : "زن";
            row[15] = item.Driver.Marriage.GetValueOrDefault() == 1 ? "متاهل" : "مجرد";
            row[16] = item.Driver.FamilyMembersCount;
            row[17] = Public.GetEducation(item.Driver.Education.GetValueOrDefault());
            row[18] = Public.GetReligion(item.Driver.Religion.GetValueOrDefault());
            row[19] = item.Driver.Subreligion;
            row[20] = Public.GetJobStatus(item.Driver.JobStatus.GetValueOrDefault());
            row[21] = Public.GetMilitaryService(item.Driver.MilitaryService.GetValueOrDefault());
            row[22] = item.Driver.Mobile;
            row[23] = item.Driver.Phone;
            row[24] = item.Driver.PostalCode;
            row[25] = item.Driver.Address;

            if (item.DrivingLicense != null)
            {
                row[26] = item.DrivingLicense.DrivingLicenseNo;
                row[27] = Public.ToPersianDate(item.DrivingLicense.ExportDate);
                row[28] = Public.GetDrivingLicenseType(item.DrivingLicense.Type);
                row[29] = item.DrivingLicense.ExportPlace;
            }
            else
            {
                row[26] = string.Empty;
                row[27] = string.Empty;
                row[28] = string.Empty;
                row[29] = string.Empty;
            }

            row[30] = item.Car.VIN;
            row[31] = item.FuelCard.PAN;
            row[32] = Public.GetFuelCardTypeName((Public.FuelCardType)item.FuelCard.CardType);
            row[33] = item.Car.TypeName;
            row[34] = item.Car.Model;
            row[35] = item.Car.Color;
            row[36] = item.Car.EngineNo;
            row[37] = item.Car.ChassisNo;
            row[38] = Public.GetFuelTypeName((Public.FuelType)item.Car.FuelType);
            row[39] = item.Car.TwoDigits;
            row[40] = Public.GetAlphabet(item.Car.Alphabet);
            row[41] = item.Car.ThreeDigits;
            row[42] = "ایران";
            row[43] = item.Car.RegionIdentifier;
            row[44] = item.AjancyName;
            row[45] = item.City;
            row[46] = item.DriverCertificationNo;
            dtObj.Rows.Add(row);
        }

        dtObj.TableName = "dt";
        Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
        report.Load(HttpContext.Current.Server.MapPath("~/App_Data/Report/mrt/drivers_all.mrt"));
        report.RegData(dtObj);
        report.Render();
        Public.ExportInfo(3, report);
        report.Dispose();
    }
Пример #17
0
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        if (Page.IsValid)
        {
            var query = from s in db.Schools
                        join slv in db.SchoolLevels on s.SchoolID equals slv.SchoolID
                        join lv in db.Levels on slv.LevelID equals lv.LevelID
                        join a in db.Areas on s.AreaCode equals a.AreaCode
                        where slv.LockOutDate == null
                        orderby a.AreaCode, s.SchoolCode
                        select
                        new
                        {
                            s.SchoolID,
                            s.SchoolCode,
                            s.SchoolName,
                            s.Gender,
                            s.SchoolKindID,
                            s.EmployeesCount_Changable,
                            s.EmployeesCount_Fixed,
                            lv.LevelID,
                            lv.LevelName,
                            a.AreaName,
                            a.AreaCode,
                            GirlsCount = GetGirlsCount(s),
                            BoysCount = GetBoysCount(s)
                        };

            if (!string.IsNullOrEmpty(this.txtSchoolCode_From.Text) && string.IsNullOrEmpty(this.txtSchoolCode_To.Text))
            {
                query = from q in query
                        where q.SchoolCode == Public.ToInt(this.txtSchoolCode_From.Text)
                        select q;
            }
            else if (!string.IsNullOrEmpty(this.txtSchoolCode_From.Text) && !string.IsNullOrEmpty(this.txtSchoolCode_To.Text))
            {
                query = from q in query
                        where q.SchoolCode >= Public.ToInt(this.txtSchoolCode_From.Text) && q.SchoolCode <= Public.ToInt(this.txtSchoolCode_To.Text)
                        select q;
            }

            if (!string.IsNullOrEmpty(this.txtSchoolName.Text))
            {
                query = from q in query
                        where q.SchoolName.Contains(this.txtSchoolName.Text)
                        select q;
            }

            if (this.drpSchoolLevel.SelectedIndex > 0)
            {
                query = from q in query
                        where q.LevelID == Public.ToShort(this.drpSchoolLevel.SelectedValue)
                        select q;
            }

            if (this.drpSchoolKind.SelectedIndex > 0)
            {
                query = from q in query
                        where q.SchoolKindID == Public.ToShort(this.drpSchoolKind.SelectedValue)
                        select q;
            }

            if (this.drpGender.SelectedIndex < 3)
            {
                query = from q in query
                        where q.Gender == this.drpGender.SelectedIndex
                        select q;
            }

            if (!string.IsNullOrEmpty(this.txtAreaCode.Text))
            {
                query = from q in query
                        where q.AreaCode == Public.ToInt(this.txtAreaCode.Text)
                        select q;
            }

            DataTable dtObj = new DataTable();
            dtObj.Columns.Add(new DataColumn("SchoolCode", typeof(int)));
            dtObj.Columns.Add(new DataColumn("SchoolName", typeof(string)));
            dtObj.Columns.Add(new DataColumn("LevelName", typeof(string)));
            dtObj.Columns.Add(new DataColumn("AreaName", typeof(string)));
            dtObj.Columns.Add(new DataColumn("BoysCount", typeof(short)));
            dtObj.Columns.Add(new DataColumn("GirlsCount", typeof(short)));
            dtObj.Columns.Add(new DataColumn("StudentsCount", typeof(short)));
            dtObj.Columns.Add(new DataColumn("EmployeesCount_Fixed", typeof(byte)));
            dtObj.Columns.Add(new DataColumn("EmployeesCount_Changable", typeof(byte)));
            dtObj.Columns.Add(new DataColumn("Sum", typeof(short)));

            foreach (var item in query)
            {
                DataRow row = dtObj.NewRow();
                row[0] = item.SchoolCode;
                row[1] = item.SchoolName;
                row[2] = item.LevelName;
                row[3] = item.AreaName;
                row[4] = item.BoysCount;
                row[5] = item.GirlsCount;
                row[6] = item.BoysCount + item.GirlsCount;
                row[7] = item.EmployeesCount_Fixed;
                row[8] = item.EmployeesCount_Changable;
                row[9] = item.BoysCount + item.GirlsCount + item.EmployeesCount_Fixed + item.EmployeesCount_Changable;
                dtObj.Rows.Add(row);
            }

            dtObj.TableName = "dt";
            Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
            report.RegData(dtObj);
            report.Load(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Report/mrt/sch.mrt"));
            report.Render();
            Public.ExportInfo(3, report);
            report.Dispose();
        }
    }
Пример #18
0
    protected void btnAjancy_Click(object sender, EventArgs e)
    {
        db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
        var query = from j in db.Ajancies
                    join bl in db.BusinessLicenses on j.AjancyID equals bl.AjancyID
                    join jp in db.AjancyPartners on j.AjancyID equals jp.AjancyID
                    join ur in db.UsersInRoles on jp.UserRoleID equals ur.UserRoleID
                    join u in db.Users on ur.UserID equals u.UserID
                    join p in db.Persons on u.PersonID equals p.PersonID
                    join ct in db.Cities on j.CityID equals ct.CityID
                    where jp.LockOutDate == null &&
                               j.AjancyType == Public.ToByte(this.drpAjancyType.SelectedValue) &&
                               bl.LockOutDate == null
                    orderby j.AjancyName
                    select new
                    {
                        Ajancy = j,
                        Utility = j.AjancyUtilities.Select(ju => new { ju.Utility }),
                        BusinessLicense = j.BusinessLicenses[0],
                        ct.ProvinceID,
                        ct.CityID,
                        City = ct.Name,
                        Manager = string.Format("{0} {1}", p.FirstName, p.LastName)
                    };

        if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex == 0) // Just province
        {
            query = from q in query
                    where q.ProvinceID == Public.ToByte(this.drpProvince.SelectedValue)
                    select q;
        }

        if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex > 0) // province and city
        {
            query = from q in query
                    where q.CityID == Public.ToByte(this.drpCity.SelectedValue)
                    select q;
        }

        if (this.drpAjancies.SelectedIndex > 0)
        {
            query = from q in query
                    where q.Ajancy.AjancyID == Public.ToInt(this.drpAjancies.SelectedValue)
                    select q;
        }

        DataTable dtObj = new DataTable();
        dtObj.Columns.Add(new DataColumn("BusinessLicenseType", typeof(string)));
        dtObj.Columns.Add(new DataColumn("AjancyName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("OfficePosition", typeof(string)));
        dtObj.Columns.Add(new DataColumn("OfficeLevel", typeof(string)));
        dtObj.Columns.Add(new DataColumn("OfficeSpace", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BalconySpace", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BalconyHeight", typeof(string)));
        dtObj.Columns.Add(new DataColumn("ParkingSpace", typeof(string)));
        dtObj.Columns.Add(new DataColumn("ParkingState", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BusinessScope", typeof(string)));
        dtObj.Columns.Add(new DataColumn("PoliceStation", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Mayor", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Address", typeof(string)));
        dtObj.Columns.Add(new DataColumn("PostalCode", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Phone", typeof(string)));
        dtObj.Columns.Add(new DataColumn("RegisteredPelak", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BluePelak", typeof(string)));
        dtObj.Columns.Add(new DataColumn("EstateType", typeof(string)));
        dtObj.Columns.Add(new DataColumn("DocumentType", typeof(string)));
        dtObj.Columns.Add(new DataColumn("PlaceOwner", typeof(string)));
        dtObj.Columns.Add(new DataColumn("WaterBillSerial", typeof(string)));
        dtObj.Columns.Add(new DataColumn("ElectricityBillSerial", typeof(string)));
        dtObj.Columns.Add(new DataColumn("GasBillSerial", typeof(string)));

        dtObj.Columns.Add(new DataColumn("BusinessLicenseNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("MemberShipCode", typeof(string)));
        dtObj.Columns.Add(new DataColumn("SerialNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("ISIC", typeof(string)));
        dtObj.Columns.Add(new DataColumn("CategoryCode", typeof(string)));

        dtObj.Columns.Add(new DataColumn("Water", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Electricity", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Gas", typeof(string)));
        dtObj.Columns.Add(new DataColumn("TelePhone", typeof(string)));
        dtObj.Columns.Add(new DataColumn("WC", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Fax", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Balcon", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Manager", typeof(string)));
        dtObj.Columns.Add(new DataColumn("City", typeof(string)));

        foreach (var item in query)
        {
            DataRow row = dtObj.NewRow();
            row[0] = item.Ajancy.BusinessLicenseType == 0 ? "عادی" : "ویژه ایثارگران و جانبازان و شهدا";
            row[1] = item.Ajancy.AjancyName;
            row[2] = OfficePosition(item.Ajancy.OfficePosition.GetValueOrDefault());
            row[3] = !string.IsNullOrEmpty(item.Ajancy.OfficeLevel) ? item.Ajancy.OfficeLevel : "1";
            row[4] = item.Ajancy.OfficeSpace;
            row[5] = !string.IsNullOrEmpty(item.Ajancy.BalconySpace) ? item.Ajancy.BalconySpace : "0";
            row[6] = !string.IsNullOrEmpty(item.Ajancy.BalconyHeight) ? item.Ajancy.BalconyHeight : "0";
            row[7] = item.Ajancy.ParkingSpace;
            row[8] = item.Ajancy.ParkingState.GetValueOrDefault() ? "بلی" : "خیر";
            row[9] = !string.IsNullOrEmpty(item.Ajancy.BusinessScope) ? item.Ajancy.BusinessScope : "...";
            row[10] = !string.IsNullOrEmpty(item.Ajancy.PoliceStation) ? item.Ajancy.PoliceStation : "...";
            row[11] = Mayor(item.Ajancy.Mayor.GetValueOrDefault());
            row[12] = item.Ajancy.Address;
            row[13] = item.Ajancy.PostalCode;
            row[14] = item.Ajancy.Phone;
            row[15] = item.Ajancy.RegisteredPelak;
            row[16] = !string.IsNullOrEmpty(item.Ajancy.BluePelak) ? item.Ajancy.BluePelak : "...";
            row[17] = item.Ajancy.EstateType.GetValueOrDefault() == 0 ? "ملکی" : "استیجاری";
            row[18] = DocumentType(item.Ajancy.DocumentType.GetValueOrDefault());
            row[19] = !string.IsNullOrEmpty(item.Ajancy.PlaceOwner) ? item.Ajancy.PlaceOwner : "...";
            row[20] = item.Ajancy.WaterBillSerial;
            row[21] = item.Ajancy.ElectricityBillSerial;
            row[22] = item.Ajancy.GasBillSerial;

            row[23] = item.BusinessLicense.BusinessLicenseNo;
            row[24] = item.BusinessLicense.MemberShipCode;
            row[25] = item.BusinessLicense.SerialNo;
            row[26] = item.BusinessLicense.ISIC;
            row[27] = item.BusinessLicense.CategoryCode;

            row[28] = "ندارد";
            row[29] = "ندارد";
            row[30] = "ندارد";
            row[31] = "ندارد";
            row[32] = "ندارد";
            row[33] = "ندارد";
            foreach (var util in item.Utility)
            {
                switch (util.Utility)
                {
                    case 0:
                        row[28] = "دارد";
                        break;

                    case 1:
                        row[29] = "دارد";
                        break;

                    case 2:
                        row[30] = "دارد";
                        break;

                    case 3:
                        row[31] = "دارد";
                        break;

                    case 4:
                        row[32] = "دارد";
                        break;

                    case 5:
                        row[33] = "دارد";
                        break;
                }
            }
            if (!string.IsNullOrEmpty(item.Ajancy.BalconySpace) && item.Ajancy.BalconySpace.ToString() != "0")
            {
                row[34] = "بلی";
            }
            else
            {
                row[34] = "خیر";
            }
            row[35] = item.Manager;
            row[36] = item.City;
            dtObj.Rows.Add(row);
        }

        dtObj.TableName = "dt";
        Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
        report.Load(HttpContext.Current.Server.MapPath("~/App_Data/Report/mrt/ajancy_all.mrt"));
        report.RegData(dtObj);
        report.Render();
        Public.ExportInfo(3, report);
        report.Dispose();
    }
Пример #19
0
    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();
    }
Пример #20
0
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
        var query = from ins in db.Insurances
                    join dc in db.DriverCertifications on ins.DriverCertificationID equals dc.DriverCertificationID
                    join dcc in db.DriverCertificationCars on dc.DriverCertificationID equals dcc.DriverCertificationID
                    join cpn in db.CarPlateNumbers on dcc.CarPlateNumberID equals cpn.CarPlateNumberID
                    join pl in db.PlateNumbers on cpn.PlateNumberID equals pl.PlateNumberID
                    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 p in db.Persons on dc.PersonID equals p.PersonID
                    join u in db.Users on p.PersonID equals u.PersonID
                    join ct in db.Cities on u.CityID equals ct.CityID
                    join pv in db.Provinces on ct.ProvinceID equals pv.ProvinceID
                    where dcc.LockOutDate == null && ins.CancelInsurance == Convert.ToBoolean(this.drpCancelInsurance.SelectedIndex)
                    orderby p.LastName
                    select new
                    {
                        p.PersonID,
                        p.FirstName,
                        p.LastName,
                        p.Father,
                        p.NationalCode,
                        p.BirthCertificateNo,
                        p.BirthDate,
                        u.CityID,
                        u.ProvinceID,
                        City = ct.Name,
                        Province = pv.Name,
                        c.FuelType,
                        crt.TypeName,
                        crt.Capacity,
                        c.VIN,
                        cpn.OwnerPersonID,
                        pl.TwoDigits,
                        pl.ThreeDigits,
                        pl.Alphabet,
                        pl.RegionIdentifier,
                        fc.PAN,
                        ins.InsuranceNo,
                        ins.BranchNo,
                        ins.SubmitDate
                    };

        if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex == 0) // Just province
        {
            query = from q in query
                    where q.ProvinceID == Public.ToByte(this.drpProvince.SelectedValue)
                    select q;
        }

        if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex > 0) // province and city
        {
            query = from q in query
                    where q.CityID == Public.ToShort(this.drpCity.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;
        }

        if (!string.IsNullOrEmpty(this.txtNationalCode.Text))
        {
            query = from q in query
                    where q.NationalCode == this.txtNationalCode.Text.Trim()
                    select q;
        }

        DataTable dtObj = new DataTable();
        dtObj.Columns.Add(new DataColumn("FirstName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("LastName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Father", typeof(string)));
        dtObj.Columns.Add(new DataColumn("NationalCode", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BirthCertificateNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BirthDate", typeof(string)));
        dtObj.Columns.Add(new DataColumn("InsuranceNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BranchNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("VIN", typeof(string)));
        dtObj.Columns.Add(new DataColumn("PAN", typeof(string)));
        dtObj.Columns.Add(new DataColumn("TypeName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("FuelType", typeof(string)));
        dtObj.Columns.Add(new DataColumn("TwoDigits", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Alphabet", typeof(string)));
        dtObj.Columns.Add(new DataColumn("ThreeDigits", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Iran", typeof(string)));
        dtObj.Columns.Add(new DataColumn("RegionIdentifier", typeof(string)));
        dtObj.Columns.Add(new DataColumn("City", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Province", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Ownership", typeof(string)));
        dtObj.Columns.Add(new DataColumn("WorkType", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Scope", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Capacity", typeof(string)));

        foreach (var item in query)
        {
            DataRow row = dtObj.NewRow();
            row[0] = item.FirstName;
            row[1] = item.LastName;
            row[2] = item.Father;
            row[3] = item.NationalCode;
            row[4] = item.BirthCertificateNo;
            row[5] = Public.ToPersianDate(item.BirthDate);
            row[6] = item.InsuranceNo;
            row[7] = item.BranchNo;
            row[8] = item.VIN;
            row[9] = item.PAN;
            row[10] = item.TypeName;
            row[11] = Public.GetFuelTypeName((Public.FuelType)item.FuelType);
            row[12] = item.TwoDigits;
            row[13] = Public.GetAlphabet(item.Alphabet);
            row[14] = item.ThreeDigits;
            row[15] = "ایران";
            row[16] = item.RegionIdentifier;
            row[17] = item.City;
            row[18] = item.Province;
            row[19] = item.OwnerPersonID == item.PersonID ? "مالک" : "بهره بردار";
            row[20] = "آژانس";
            row[21] = "درون شهری";
            row[22] = item.Capacity;
            dtObj.Rows.Add(row);
        }

        dtObj.TableName = "dt";
        Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
        report.RegData(dtObj);
        report.Load(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Report/mrt/Insurance.mrt"));
        report.Render();
        Public.ExportInfo(3, report);
        report.Dispose();
    }
Пример #21
0
    protected void SetandoRel()
    {
        //Report da stimulsoft

        Stimulsoft.Report.StiReport Report = new Stimulsoft.Report.StiReport();

        //Stimulsoft.Report.Web.StiWebDesigner st1 = new Stimulsoft.Report.Web.StiWebDesigner();

        if (Convert.ToString(Request.QueryString["Rel"]) == "frmZurel")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/folhafrequencia.mrt"));
            Report.Compile();
            Report["DiasMes"]         = TotalDiasMes.ToString();
            Report["DiasCumpridos"]   = TotalDiasCumprido.ToString();
            Report["TotalHorasMes"]   = TotalHoraMes.ToString();
            Report["HorasCumpridas"]  = HorasCumpridas;
            Report["HorasRealizadas"] = HorasRealizadas;
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmZuxa")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/EspelhoPonto.mrt"));
            Report.Compile();
            Report["DiasMes"]        = TotalDiasMes.ToString();
            Report["DiasCumpridos"]  = TotalDiasCumprido.ToString();
            Report["TotalHorasMes"]  = TotalHoraMes.ToString();
            Report["HorasCumpridas"] = HorasCumpridas.ToString();
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmsitu")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/situacaousuario.mrt"));
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmbco")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/totalhorasdiarias.mrt"));
            Report.Compile();
            //Report["Teste"] = 932;
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmbcoHoraMes")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/bancoHoraMes.mrt"));
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmRelacDia")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/relacaopontoDia.mrt"));
            Report.Compile();
            Report["DTInicio"] = INICIO;
            Report["DTFim"]    = FIM;
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmLocalRegistro")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/LocalRegistro.mrt"));
            Report.Compile();
            Report["DTInicio"] = INICIO;
            Report["DTFim"]    = FIM;
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmMotivoFalta")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/RelacaoMotivoFalta.mrt"));
            Report.Compile();
            Report["DTInicio"] = INICIO;
            Report["DTFim"]    = FIM;
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmfca")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/FichaCadastral.mrt"));
            Report.Compile();
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmfi")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/FichaCadastral.mrt"));
            Report.Compile();
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmdesc")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/RelRelacaoRegistroPeriodo.mrt"));
            Report.Compile();
            Report["DTInicio"] = INICIO;
            Report["DTFim"]    = FIM;
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmfaltaInjust")
        {
            if (RelUtilizado == 0)
            {
                Report.Load(Server.MapPath(@"~/Relatorio/STF/RelDataInjustificada.mrt"));
            }
            else
            {
                Report.Load(Server.MapPath(@"~/Relatorio/STF/RelRegistroAusente.mrt"));
            }
            //o Outro Aqui
            Report.Compile();
            Report["DTInicio"] = INICIO;
            Report["DTFim"]    = FIM;
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmAuditRel")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/RelatorioAuditoriaJustificativa.mrt"));
            Report.Compile();
            Report["DTInicio"] = INICIO;
            Report["DTFim"]    = FIM;
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmLogMaqRel")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/AuditoriaGeralDasConexoes.mrt"));
            Report.Compile();
        }
        else if (Convert.ToString(Request.QueryString["Rel"]) == "frmInfoMaqRel")
        {
            Report.Load(Server.MapPath(@"~/Relatorio/STF/InformacoesMaquinasColetorLocal.mrt"));
            Report.Compile();
        }

        Report.RegData("DatasetPontoFrequencia", ds);

        Report.Render();

        System.IO.MemoryStream memStream = new System.IO.MemoryStream();

        HttpContext.Current.Response.ClearContent();
        HttpContext.Current.Response.ClearHeaders();
        HttpContext.Current.Response.ContentType = "application/pdf";

        HttpContext.Current.Response.AddHeader("Pontoweb.pdf", "");

        Stimulsoft.Report.Export.StiPdfExportService Export = new Stimulsoft.Report.Export.StiPdfExportService();

        Export.ExportPdf(Report, memStream, Stimulsoft.Report.StiPagesRange.All, 100, 100, false, false, true, true,
                         "", "", Stimulsoft.Report.Export.StiUserAccessPrivileges.All, Stimulsoft.Report.Export.StiPdfEncryptionKeyLength.Bit40, false);

        Response.ContentType = "application/pdf";

        Response.AddHeader("content-disposition", "inline; filename=Pontoweb.pdf");

        Response.BinaryWrite(memStream.ToArray());
    }
Пример #22
0
        private void StimulViewer_Load(object sender, EventArgs e)
        {
            //try
            //{
            if (_Traffic_bit == false && _Othercar_bit == false)
            {
                AcceptedTurnstiReport.Dictionary.Synchronize();
                AcceptedTurnstiReport.Dictionary.Databases.Clear();
                AcceptedTurnstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                AcceptedTurnstiReport.Compile();
                AcceptedTurnstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory   PortPlaceFactory = new HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory();
                HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillFactory      = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory();
                if (TrafficEntity.BillMessageID_int == 0 || TrafficEntity.BillMessageID_int == null)
                {
                }
                else
                {
                    string Billcondition = "[BillMessage_T].[BillMessageID_int]=" + TrafficEntity.BillMessageID_int;
                    List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> BillLst = BillFactory.GetAllByCondition(Billcondition);
                    if (BillLst != null)
                    {
                        AcceptedTurnstiReport["Messagetxt"]  = BillLst[0].Message_nvc;
                        AcceptedTurnstiReport["Message_bit"] = true;
                    }
                    else
                    {
                        AcceptedTurnstiReport["Message_bit"] = false;
                    }
                }
                NumericTextBox txt = new NumericTextBox();
                txt.DigitsInGroup = 3;
                if (TrafficEntity.Price_dec != null)
                {
                    txt.Text = TrafficEntity.Price_dec.ToString();
                    AcceptedTurnstiReport["Price_nvc"] = " مبلغ دریافت شده هنگام ورود " + txt.Text + "  ريال می باشد";
                }
                if (TrafficEntity.Price_dec != null)
                {
                    AcceptedTurnstiReport["PricewithOutTax_nvc"] = (TrafficEntity.Price_dec - TrafficEntity.PriceTax_dec).ToString();
                }

                if (!string.IsNullOrEmpty(TrafficEntity.AcceptedTurnComment_nvc))
                {
                    if (TrafficEntity.Area_bit)
                    {
                        AcceptedTurnstiReport["Comment_nvc"] = "توضيحات : " + TrafficEntity.AcceptedTurnComment_nvc;// +" حومه";
                    }
                    else
                    {
                        AcceptedTurnstiReport["Comment_nvc"] = "توضيحات : " + TrafficEntity.AcceptedTurnComment_nvc;
                    }
                }
                else
                {
                    //if (TrafficEntity.Area_bit)
                    //{
                    //    AcceptedTurnstiReport["Comment_nvc"] = "حومه";
                    //}
                }
                if (TrafficEntity.TurnPrinted_bit == true)
                {
                    AcceptedTurnstiReport["PrintedAgain_nvc"] = "المثنی";
                }
                else
                {
                    AcceptedTurnstiReport["PrintedAgain_nvc"] = "";
                }

                HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory PlatecityFactory = new HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory();
                HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys    Platecitykey     = new HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys();
                Platecitykey.PlateCityID_int = TrafficEntity.PlateCityID_int;
                HPS.BLL.PlateCityBLL.BLLPlateCity_T PlateCityEntity = new HPS.BLL.PlateCityBLL.BLLPlateCity_T();
                PlateCityEntity = PlatecityFactory.GetBy(Platecitykey);

                if (PlateCityEntity != null)
                {
                    AcceptedTurnstiReport["Number_nvc"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + PlateCityEntity.PlateCity_nvc + " " + TrafficEntity.SerialPlate_nvc;
                }
                else
                {
                    AcceptedTurnstiReport["Number_nvc"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + TrafficEntity.SerialPlate_nvc;
                }

                if (TrafficEntity.LadeReturn_bit == true)
                {
                    AcceptedTurnstiReport["TurnNumber"] = "برگشت از بار";
                }
                else
                {
                    if (TrafficEntity.AcceptedTurnNumber_bint.HasValue)
                    {
                        AcceptedTurnstiReport["TurnNumber"] = "شماره نوبت : " + TrafficEntity.AcceptedTurnNumber_bint.ToString();
                    }
                    else
                    {
                        AcceptedTurnstiReport["TurnNumber"] = "شماره نوبت رزرو : " + TrafficEntity.TurnNumber_bint.ToString();
                    }
                }

                AcceptedTurnstiReport["TrafficNumber"] = " شماره قبض پارکینگ: " + TrafficEntity.TrafficNumber_bint.ToString();


                AcceptedTurnstiReport["InDate_vc"]    = TrafficEntity.Date_nvc;
                AcceptedTurnstiReport["InTime_vc"]    = TrafficEntity.Time_nvc;
                AcceptedTurnstiReport["Time_vc"]      = PortPlaceFactory.ServerTime;
                AcceptedTurnstiReport["Date_vc"]      = PortPlaceFactory.ServerJalaliDate;
                AcceptedTurnstiReport["username_nvc"] = HPS.Common.CurrentUser.user.UserName_nvc;


                HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory laderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
                string LaderTypecondition = "[LaderType_T].[LaderTypeID_int]='" + TrafficEntity.LaderTypeID_int + "'";

                AcceptedTurnstiReport["@TrafficID_bint"] = TrafficEntity.TrafficID_bint;
                AcceptedTurnstiReport["@Condition"]      = LaderTypecondition;
                AcceptedTurnstiReport.Render();

                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    AcceptedTurnstiReport.Print(true);
                }
                else
                {
                    PrinterSetting.PrinterName = s.PrinterName;
                    AcceptedTurnstiReport.Print(false, PrinterSetting);
                }

                this.Close();
            }

            else if (_Traffic_bit == true && _Othercar_bit == false)
            {
                TrafficstiReport.Dictionary.Synchronize();
                TrafficstiReport.Dictionary.Databases.Clear();
                TrafficstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                TrafficstiReport.Compile();
                TrafficstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory   PortPlaceFactory = new HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory();
                HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillFactory      = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory();
                if (TrafficEntity.BillMessageID_int == 0 || TrafficEntity.BillMessageID_int == null)
                {
                }
                else
                {
                    string Billcondition = "[BillMessage_T].[BillMessageID_int]=" + TrafficEntity.BillMessageID_int;
                    List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> BillLst = BillFactory.GetAllByCondition(Billcondition);
                    if (BillLst != null)
                    {
                        TrafficstiReport["Messagetxt"]  = BillLst[0].Message_nvc;
                        TrafficstiReport["Message_bit"] = true;
                    }
                    else
                    {
                        TrafficstiReport["Message_bit"] = false;
                    }
                }
                NumericTextBox txt = new NumericTextBox();
                txt.DigitsInGroup = 3;
                if (TrafficEntity.Price_dec != null)
                {
                    txt.Text = TrafficEntity.Price_dec.ToString();
                    TrafficstiReport["Price_nvc"] = " مبلغ دریافت شده هنگام ورود " + txt.Text + "  ريال می باشد";
                }

                if (!string.IsNullOrEmpty(TrafficEntity.AcceptedTurnComment_nvc))
                {
                    if (TrafficEntity.Area_bit)
                    {
                        TrafficstiReport["Comment_nvc"] = "توضيحات : " + TrafficEntity.AcceptedTurnComment_nvc;// +" حومه";
                    }
                    else
                    {
                        TrafficstiReport["Comment_nvc"] = "توضيحات : " + TrafficEntity.AcceptedTurnComment_nvc;
                    }
                }
                else
                {
                    //if (TrafficEntity.Area_bit)
                    //{
                    //    TrafficstiReport["Comment_nvc"] = "حومه";
                    //}
                }
                if (TrafficEntity.TurnPrinted_bit == true)
                {
                    TrafficstiReport["PrintedAgain_nvc"] = "المثنی";
                }
                else
                {
                    TrafficstiReport["PrintedAgain_nvc"] = "";
                }

                HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory PlatecityFactory = new HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory();
                HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys    Platecitykey     = new HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys();
                Platecitykey.PlateCityID_int = TrafficEntity.PlateCityID_int;
                HPS.BLL.PlateCityBLL.BLLPlateCity_T PlateCityEntity = new HPS.BLL.PlateCityBLL.BLLPlateCity_T();
                PlateCityEntity = PlatecityFactory.GetBy(Platecitykey);

                if (PlateCityEntity != null)
                {
                    TrafficstiReport["Number_nvc"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + PlateCityEntity.PlateCity_nvc + " " + TrafficEntity.SerialPlate_nvc;
                }
                else
                {
                    TrafficstiReport["Number_nvc"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + TrafficEntity.SerialPlate_nvc;
                }


                if (TrafficEntity.ServiceID_int == 2)
                {
                    if (TrafficEntity.TurnAccepted_bit == true)
                    {
                        //نوبت تأیید شده داره
                        TrafficstiReport["TurnNumber"] = "شماره نوبت :   " + Convert.ToString(TrafficEntity.AcceptedTurnNumber_bint);
                        //AcceptedDate2TextBox.Text = TrafficEntityrpt.TurnDate_nvc;
                        //AcceptedTime2TextBox.Text = TrafficEntityrpt.TurnTime_nvc;
                        //TurnNumber2txt.Text = TrafficEntityrpt.AcceptedTurnNumber_bint.ToString();
                    }
                    else
                    {
                        //نوبت تأیید شده ندارد
                        TrafficstiReport["TurnNumber"] = "شماره نوبت رزرو :   " + Convert.ToString(TrafficEntity.TurnNumber_bint);
                    }
                }
                else
                {
                    // (عدم نمایش نوبت (مراجعه به غیر از نوبت
                    TrafficstiReport["TurnNumber"] = "";
                }

                TrafficstiReport["TrafficNumber"] = "شماره قبض پارکینگ : " + TrafficEntity.TrafficNumber_bint.ToString();

                HPS.BLL.SettingsBLL.BLLSetting_TFactory settingsFactory = new HPS.BLL.SettingsBLL.BLLSetting_TFactory();
                HPS.BLL.SettingsBLL.BLLSetting_T        SettingEntity   = new HPS.BLL.SettingsBLL.BLLSetting_T();
                HPS.BLL.SettingsBLL.BLLSetting_TKeys    SettingKey      = new HPS.BLL.SettingsBLL.BLLSetting_TKeys();
                SettingKey.SettingID_int = 1002;
                SettingEntity            = settingsFactory.GetBy(SettingKey);
                if (TrafficEntity.ServiceID_int == 2)
                {
                    TrafficstiReport["TAllowableHour"] = SettingEntity.Value_nvc; //TrafficEntityrpt.AllowableHour_int.ToString();
                }
                else
                {
                    TrafficstiReport["TAllowableHour"] = TrafficEntity.AllowableHour_int.ToString();
                }



                HPS.BLL.ServicesBLL.BLLServices_TFactory servicesFactory = new HPS.BLL.ServicesBLL.BLLServices_TFactory();
                HPS.BLL.ServicesBLL.BLLServices_TKeys    ServicesKey     = new HPS.BLL.ServicesBLL.BLLServices_TKeys();
                ServicesKey.ServicesID_int = TrafficEntity.ServiceID_int;
                HPS.BLL.ServicesBLL.BLLServices_T ServicesEntity = new HPS.BLL.ServicesBLL.BLLServices_T();
                ServicesEntity = servicesFactory.GetBy(ServicesKey);
                TrafficstiReport["system_nvc"] = " قبض مراجعه به : " + ServicesEntity.ServicesType_nvc;

                if (TrafficEntity.WithLade_bit == true)
                {
                    TrafficstiReport["WithLade_nvc"] = "وضعیت : " + "با بار" + "(" + TrafficEntity.Comment_nvc + ") ";
                }
                else
                {
                    TrafficstiReport["WithLade_nvc"] = "وضعیت : " + "بدون بار";
                }

                if (TrafficEntity.TurnHour_int != null)
                {
                    TrafficstiReport["TurnNumberAllert_nvc"] = " شماره نوبت شما رزرو می باشد لطفاً تا " + TrafficEntity.TurnHour_int.ToString() + " ساعت نسبت به تأیید آن اقدام نمایید";
                }


                TrafficstiReport["InDate_vc"]    = TrafficEntity.Date_nvc;
                TrafficstiReport["InTime_vc"]    = TrafficEntity.Time_nvc;
                TrafficstiReport["Time_vc"]      = PortPlaceFactory.ServerTime;
                TrafficstiReport["Date_vc"]      = PortPlaceFactory.ServerJalaliDate;
                TrafficstiReport["username_nvc"] = HPS.Common.CurrentUser.user.UserName_nvc;


                HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory laderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
                string LaderTypecondition = "[LaderType_T].[LaderTypeID_int]='" + TrafficEntity.LaderTypeID_int + "'";

                TrafficstiReport["@TrafficID_bint"] = TrafficEntity.TrafficID_bint;
                TrafficstiReport["@Condition"]      = LaderTypecondition;
                TrafficstiReport.Render();

                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    TrafficstiReport.Print(true);
                }
                else
                {
                    PrinterSetting.PrinterName = s.PrinterName;
                    TrafficstiReport.Print(false, PrinterSetting);
                }

                this.Close();
            }
            //سواری وغیره
            else if (_Traffic_bit == false && _Othercar_bit == true)
            {
                //HPS.BLL.TrafficBLL.BLLTraffic_T TrafficEntityrpt = new HPS.BLL.TrafficBLL.BLLTraffic_T();
                OtherCarstiReport.Dictionary.Synchronize();
                OtherCarstiReport.Dictionary.Databases.Clear();
                OtherCarstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                OtherCarstiReport.Compile();
                OtherCarstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                OtherCarstiReport["DateTextBox"]      = TrafficEntity.Date_nvc;
                OtherCarstiReport["TimeTextBox"]      = TrafficEntity.Time_nvc;
                OtherCarstiReport["TrafficNumbertxt"] = TrafficEntity.TrafficNumber_bint.ToString();
                OtherCarstiReport["Servicestxt"]      = " مراجعه به : " + TrafficEntity.Services_nvc;
                OtherCarstiReport["CarTypetxt"]       = "نوع وسیله : " + TrafficEntity.System_nvc;
                HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory PlateCityFactory = new HPS.BLL.PlateCityBLL.BLLPlateCity_TFactory();
                HPS.BLL.PlateCityBLL.BLLPlateCity_T        PlatecityEntity  = new HPS.BLL.PlateCityBLL.BLLPlateCity_T();
                HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys    PlateCityKey     = new HPS.BLL.PlateCityBLL.BLLPlateCity_TKeys();
                PlateCityKey.PlateCityID_int = TrafficEntity.PlateCityID_int;
                PlatecityEntity = PlateCityFactory.GetBy(PlateCityKey);
                OtherCarstiReport["NumberPlatetxt"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + PlatecityEntity.PlateCity_nvc + " " + TrafficEntity.SerialPlate_nvc;
                HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillFactory = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory();
                if (TrafficEntity.BillMessageID_int == 0 || TrafficEntity.BillMessageID_int == null)
                {
                    OtherCarstiReport["Messagetxt"] = "";
                }
                else
                {
                    string Billcondition = "[BillMessage_T].[BillMessageID_int]=" + TrafficEntity.BillMessageID_int;
                    List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> BillLst = BillFactory.GetAllByCondition(Billcondition);
                    if (BillLst != null)
                    {
                        OtherCarstiReport["Messagetxt"] = BillLst[0].Message_nvc;
                    }
                    else
                    {
                        OtherCarstiReport["Messagetxt"] = "";
                    }
                }

                NumericTextBox txt = new NumericTextBox();
                txt.DigitsInGroup = 3;
                if (TrafficEntity.Price_dec != null)
                {
                    txt.Text = TrafficEntity.Price_dec.ToString();
                    OtherCarstiReport["Pricetxt"] = " مبلغ دریافتی هنگام ورود " + txt.Text + "  ريال می باشد";
                }
                OtherCarstiReport["AllowableHourtxt"] = TrafficEntity.AllowableHour_int.ToString();
                OtherCarstiReport["ExtraHourtxt"]     = TrafficEntity.ExtraHour_int.ToString();
                txt.Text = TrafficEntity.Fee_dec.ToString();
                OtherCarstiReport["Feetxt"] = txt.Text;
                txt.Text = TrafficEntity.ExtraHourFee_dec.ToString();
                OtherCarstiReport["ExtraHourFeetxt"]      = txt.Text;
                OtherCarstiReport["UserNametxt"]          = TrafficEntity.UserName_nvc;
                OtherCarstiReport["TrafficNumberbarcode"] = TrafficEntity.TrafficNumber_bint.ToString();

                if (TrafficEntity.Printed_bit == true)
                {
                    OtherCarstiReport["txtPrintedAgain"] = "المثنی";
                }
                else
                {
                    OtherCarstiReport["txtPrintedAgain"] = "";
                }

                //DriverName_nvc
                OtherCarstiReport["DriverName_nvc"] = "نام راننده : " + TrafficEntity.FirstName_nvc + " " + TrafficEntity.LastName_nvc;
                OtherCarstiReport["Fee_dec"]        = TrafficEntity.Fee_dec.ToString();
                OtherCarstiReport["PriceTax_dec"]   = TrafficEntity.PriceTax_dec.ToString();
                OtherCarstiReport.Render();

                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    OtherCarstiReport.Print(true);
                }
                else
                {
                    PrinterSetting.PrinterName = s.PrinterName;
                    OtherCarstiReport.Print(false, PrinterSetting);
                }

                this.Close();
            }
            //خارجی
            else if (_Traffic_bit == true && _Othercar_bit == true)
            {
                //HPS.BLL.TrafficBLL.BLLTraffic_T TrafficEntityrpt = new HPS.BLL.TrafficBLL.BLLTraffic_T();
                ForeignCarstiReport.Dictionary.Synchronize();
                ForeignCarstiReport.Dictionary.Databases.Clear();
                ForeignCarstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                ForeignCarstiReport.Compile();
                ForeignCarstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                ForeignCarstiReport["DateTextBox"]      = TrafficEntity.Date_nvc;
                ForeignCarstiReport["TimeTextBox"]      = TrafficEntity.Time_nvc;
                ForeignCarstiReport["TrafficNumbertxt"] = TrafficEntity.TrafficNumber_bint.ToString();
                ForeignCarstiReport["DriverNametxt"]    = " نام راننده : " + TrafficEntity.FirstName_nvc + " " + TrafficEntity.LastName_nvc;
                HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory laderTypeFactory = new HPS.BLL.LaderTypeBLL.BLLLaderType_TFactory();
                string LaderTypecondition = "[LaderType_T].[LaderTypeID_int]='" + TrafficEntity.LaderTypeID_int + "'";
                List <HPS.BLL.LaderTypeBLL.BLLLaderType_T> LaderTypeLst = laderTypeFactory.GetAllByCondition(LaderTypecondition);
                if (LaderTypeLst != null)
                {
                    ForeignCarstiReport["CarTypetxt"] = "نوع وسيله : " + TrafficEntity.System_nvc + "-  " + LaderTypeLst[0].LaderType_nvc;
                }
                if (!string.IsNullOrEmpty(TrafficEntity.SerialPlate_nvc))
                {
                    ForeignCarstiReport["NumberPlatetxt"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc) + " - " + TrafficEntity.SerialPlate_nvc;
                }
                else
                {
                    ForeignCarstiReport["NumberPlatetxt"] = "شماره پلاک : " + Hepsa.Core.Common.PersentationController.CorrectNumberPlate(TrafficEntity.NumberPlate_nvc);
                }

                if (TrafficEntity.WithLade_bit == true)
                {
                    ForeignCarstiReport["WithLadetxt"] = "وضعیت : " + "با بار" + "(" + TrafficEntity.Comment_nvc + ") ";
                }
                else
                {
                    ForeignCarstiReport["WithLadetxt"] = "وضعیت : " + "بدون بار";
                }
                NumericTextBox txt = new NumericTextBox();
                txt.DigitsInGroup = 3;
                if (TrafficEntity.Price_dec != null)
                {
                    txt.Text = TrafficEntity.Price_dec.ToString();
                    ForeignCarstiReport["Pricetxt"] = " مبلغ دریافتی هنگام ورود " + txt.Text + "  ريال می باشد";
                }
                ForeignCarstiReport["AllowableHourtxt"] = TrafficEntity.AllowableHour_int.ToString();
                ForeignCarstiReport["ExtraHourtxt"]     = TrafficEntity.ExtraHour_int.ToString();
                txt.Text = TrafficEntity.Fee_dec.ToString();
                ForeignCarstiReport["Feetxt"] = txt.Text;
                txt.Text = TrafficEntity.ExtraHourFee_dec.ToString();
                ForeignCarstiReport["ExtraHourFeetxt"]      = txt.Text;
                ForeignCarstiReport["UserNametxt"]          = TrafficEntity.UserName_nvc;
                ForeignCarstiReport["TrafficNumberbarcode"] = TrafficEntity.TrafficNumber_bint.ToString();
                if (TrafficEntity.Printed_bit == true)
                {
                    ForeignCarstiReport["txtPrintedAgain"] = "المثنی";
                }
                else
                {
                    ForeignCarstiReport["txtPrintedAgain"] = "";
                }
                ForeignCarstiReport["Fee_dec"]      = TrafficEntity.Fee_dec.ToString();
                ForeignCarstiReport["PriceTax_dec"] = TrafficEntity.PriceTax_dec.ToString();
                ForeignCarstiReport.Render();

                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    ForeignCarstiReport.Print(true);
                }
                else
                {
                    PrinterSetting.PrinterName = s.PrinterName;
                    ForeignCarstiReport.Print(false, PrinterSetting);
                }

                this.Close();
            }
            else if (_type == "dublicateTurns")
            {
                BLL.TrafficBLL.BLLTraffic_TFactory trafficFactory = new HPS.BLL.TrafficBLL.BLLTraffic_TFactory();
                DataTable duplicateTurnDataTable = new DataTable();
                trafficFactory.DuplicateTurnsReport(duplicateTurnDataTable);
                stiViewerControl1.Report = _sti;


                DuplicateTurnsReport.Dictionary.Synchronize();
                DuplicateTurnsReport.Dictionary.Databases.Clear();
                DuplicateTurnsReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                DuplicateTurnsReport.Compile();
                DuplicateTurnsReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory PortPlaceFactory = new HPS.BLL.PortPlacesBLL.BLLPortPlaces_TFactory();
                DuplicateTurnsReport["date_vc"]     = PortPlaceFactory.ServerJalaliDate + "   " + PortPlaceFactory.ServerTime;;
                DuplicateTurnsReport["userName_vc"] = HPS.Common.CurrentUser.user.UserName_nvc;
                DuplicateTurnsReport.Render();
                DuplicateTurnsReport.Show();
            }
            else if (_again == 1)
            {
                HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory LadBillCreditFactory = new HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TFactory();
                HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TKeys    LadBillKey           = new HPS.BLL.LadBillCreditBLL.BLLLadBillCredit_TKeys();
                LadBillKey.LadBillCreditID_int = _LadBIillCreditID;
                DataTable LadBillLadeAssignmentDataTable = new DataTable();
                LadBillCreditFactory.GetAllLadeAssignment(LadBillKey, ref LadBillLadeAssignmentDataTable);
                Stimulsoft.Report.StiReport LadBillReportstiReport = new Stimulsoft.Report.StiReport();
                LadBillReportstiReport.Load(Application.StartupPath + "\\LadBillCredit.mrt");
                LadBillReportstiReport.Dictionary.Synchronize();
                LadBillReportstiReport.Dictionary.Databases.Clear();
                LadBillReportstiReport.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", Hepsa.Core.Common.ConnectionString.ConnectionString));
                LadBillReportstiReport.Compile();
                LadBillReportstiReport["organ"] = new HPS.BLL.SettingsBLL.BLLSetting_TFactory().GetBy(new BLL.SettingsBLL.BLLSetting_TKeys()
                {
                    SettingID_int = 1029
                }).Value_nvc.ToString();
                if (!string.IsNullOrEmpty(LadBillLadeAssignmentDataTable.Rows[0]["DriverCardNumber_nvc"].ToString()))
                {
                    LadBillReportstiReport["DriverCardNumber_vc"] = " کارت هوشمند راننده: " + LadBillLadeAssignmentDataTable.Rows[0]["DriverCardNumber_nvc"].ToString();
                }
                else
                {
                    LadBillReportstiReport["DriverCardNumber_vc"] = " کارت هوشمند راننده:فاقد كارت ";
                }
                if (!string.IsNullOrEmpty(LadBillLadeAssignmentDataTable.Rows[0]["CarCardNumber_nvc"].ToString()))
                {
                    LadBillReportstiReport["CarCardNumber_vc"] = " کارت هوشمند کامیون : " + LadBillLadeAssignmentDataTable.Rows[0]["CarCardNumber_nvc"].ToString();
                }
                else
                {
                    LadBillReportstiReport["CarCardNumber_vc"] = " کارت هوشمند کامیون :فاقد كارت ";
                }

                LadBillReportstiReport["MobileNumber_vc"]       = string.Format("موبایل راننده: {0}", LadBillLadeAssignmentDataTable.Rows[0]["DriverMobileNumber_nvc"].ToString());
                LadBillReportstiReport["Company_nvc"]           = LadBillLadeAssignmentDataTable.Rows[0]["CompanyID_intCompany_nvc"].ToString() + "(" + LadBillLadeAssignmentDataTable.Rows[0]["CompanyCode_nvc"].ToString() + ")" + "(" + LadBillLadeAssignmentDataTable.Rows[0]["Phone_nvc"].ToString() + ")";                                         //Cmp_nvc
                LadBillReportstiReport["LaderType_nvc"]         = LadBillLadeAssignmentDataTable.Rows[0]["LaderTypeID_intLaderType_nvc"].ToString();
                LadBillReportstiReport["Boxing_nvc"]            = LadBillLadeAssignmentDataTable.Rows[0]["BoxingID_intBoxingType_nvc"].ToString();                                                                                                                                                                                                       //LaderType
                LadBillReportstiReport["PlateNumber_nvc"]       = Hepsa.Core.Common.PersentationController.CorrectNumberPlate(LadBillLadeAssignmentDataTable.Rows[0]["NumberPlate_nvc"].ToString()) + " - " + LadBillLadeAssignmentDataTable.Rows[0]["PlateCity_nvc"].ToString() + LadBillLadeAssignmentDataTable.Rows[0]["SerialPlate_nvc"].ToString(); //Plaque
                LadBillReportstiReport["DriverName_nvc"]        = LadBillLadeAssignmentDataTable.Rows[0]["DriverName"].ToString();                                                                                                                                                                                                                       //Driver
                LadBillReportstiReport["LicenceNumber_bint"]    = (LadBillLadeAssignmentDataTable.Rows[0]["licenceNumber_int"] != DBNull.Value?Convert.ToInt64(LadBillLadeAssignmentDataTable.Rows[0]["licenceNumber_int"]):0);                                                                                                                          //LicenceNumber
                LadBillReportstiReport["LicenceCity_nvc"]       = LadBillLadeAssignmentDataTable.Rows[0]["LicenceCityID_intCity_nvc"].ToString();                                                                                                                                                                                                        //LicenceCity
                LadBillReportstiReport["Good_nvc"]              = LadBillLadeAssignmentDataTable.Rows[0]["GoodID_intGood_nvc"].ToString();                                                                                                                                                                                                               //Good
                LadBillReportstiReport["Date_vc"]               = LadBillLadeAssignmentDataTable.Rows[0]["LadingDate_nvc"].ToString();                                                                                                                                                                                                                   //
                LadBillReportstiReport["Destination_nvc"]       = LadBillLadeAssignmentDataTable.Rows[0]["CityID_intCity_nvc"].ToString() + "-" + LadBillLadeAssignmentDataTable.Rows[0]["Address_nvc"].ToString();
                LadBillReportstiReport["PortajeFee_dec"]        = LadBillLadeAssignmentDataTable.Rows[0]["PortageFee_dec"].ToString();
                LadBillReportstiReport["AssignmentComment_nvc"] = LadBillLadeAssignmentDataTable.Rows[0]["AssignmentComment_nvc"].ToString();
                LadBillReportstiReport["Date_vc"]               = LadBillLadeAssignmentDataTable.Rows[0]["LadBillDate"].ToString();
                LadBillReportstiReport["Time_vc"]               = LadBillLadeAssignmentDataTable.Rows[0]["LadBillTime"].ToString();
                LadBillReportstiReport["TurnNumber_bint"]       = Convert.ToInt64(LadBillLadeAssignmentDataTable.Rows[0]["AcceptedTurnNumber_bint"]);
                LadBillReportstiReport["LadBillNumber_bint"]    = Convert.ToInt64(LadBillLadeAssignmentDataTable.Rows[0]["LadBillCreditID_int"]);
                LadBillReportstiReport["UserName_nvc"]          = LadBillLadeAssignmentDataTable.Rows[0]["LadBillUser"].ToString();
                LadBillReportstiReport["PortPlace_nvc"]         = LadBillLadeAssignmentDataTable.Rows[0]["PortPlaceID_intPortPlaces_nvc"].ToString();
                LadBillReportstiReport["MinWeight_nvc"]         = "از وزن: " + LadBillLadeAssignmentDataTable.Rows[0]["MinWeight_dec"];
                LadBillReportstiReport["MaxWeight_nvc"]         = "تا وزن: " + LadBillLadeAssignmentDataTable.Rows[0]["MaxWeight_dec"];
                LadBillReportstiReport["TrafficNumber_bint"]    = Convert.ToInt64(LadBillLadeAssignmentDataTable.Rows[0]["TrafficNumber_bint"]);
                LadBillReportstiReport["System_nvc"]            = LadBillLadeAssignmentDataTable.Rows[0]["System_nvc"].ToString();
                HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory BillMessage_TFactory = new HPS.BLL.BillMessageBLL.BLLBillMessage_TFactory();
                List <HPS.BLL.BillMessageBLL.BLLBillMessage_T> BillMessage_TList    = new List <HPS.BLL.BillMessageBLL.BLLBillMessage_T>();
                string Condition = string.Format("TrafficType_T.TrafficTypeID_int=9 AND [BillMessage_T].StartDate_nvc<='{0}' AND [BillMessage_T].[EndDate_nvc]>='{0}' ", BillMessage_TFactory.ServerJalaliDate);
                BillMessage_TList = BillMessage_TFactory.GetAllByCondition(Condition);
                if (BillMessage_TList != null && BillMessage_TList.Count > 0)
                {
                    LadBillReportstiReport["BillMessage_nvc"] = BillMessage_TList[0].Message_nvc;
                }
                if (_again != 1)
                {
                    if (LadBillLadeAssignmentDataTable.Rows[0]["LadeDate"].ToString().CompareTo(LadBillCreditFactory.ServerJalaliDate) < 0)
                    {
                        LadBillReportstiReport["Remained_bit"] = true;
                    }
                    else
                    {
                        LadBillReportstiReport["Remained_bit"] = false;
                    }
                }

                if (_again == 1)
                {
                    LadBillReportstiReport["Again_bit"]          = true;
                    LadBillReportstiReport["AgainPrintDate_vc"]  = LadBillCreditFactory.ServerJalaliDate;
                    LadBillReportstiReport["AgainPrintTime_vc"]  = LadBillCreditFactory.ServerTime;
                    LadBillReportstiReport["AgainPrintUser_vnc"] = HPS.Common.CurrentUser.user.UserName_nvc;
                }
                LadBillReportstiReport.Render();
                Properties.Settings s = new HPS.Properties.Settings();
                System.Drawing.Printing.PrinterSettings PrinterSetting = new System.Drawing.Printing.PrinterSettings();
                if (string.IsNullOrEmpty(s.PrinterName))
                {
                    LadBillReportstiReport.PrinterSettings.Copies = 3;
                    LadBillReportstiReport.Print(true);
                }

                else
                {
                    LadBillReportstiReport.PrinterSettings.Copies = 3;
                    PrinterSetting.PrinterName = s.PrinterName;
                    LadBillReportstiReport.Print(false, PrinterSetting);
                }
            }
            else
            {
                stiViewerControl1.Report = _sti;
            }
            this.Close();
        }
Пример #23
0
    protected void btnExcel_Click(object sender, EventArgs e)
    {
        Ajancy.Kimia_Ajancy db = new Ajancy.Kimia_Ajancy(Public.ConnectionString);
        var query = from j in db.Ajancies
                    join bl in db.BusinessLicenses on j.AjancyID equals bl.AjancyID
                    join jp in db.AjancyPartners on j.AjancyID equals jp.AjancyID
                    join ur in db.UsersInRoles on jp.UserRoleID equals ur.UserRoleID
                    join u in db.Users on ur.UserID equals u.UserID
                    join p in db.Persons on u.PersonID equals p.PersonID
                    join ct in db.Cities on j.CityID equals ct.CityID
                    join pv in db.Provinces on ct.ProvinceID equals pv.ProvinceID
                    where jp.LockOutDate == null &&
                               j.AjancyType == Public.ToByte(this.drpAjancyType.SelectedValue) && bl.LockOutDate == null
                    orderby pv.Name, ct.Name, j.AjancyName
                    select new
                    {
                        ct.ProvinceID,
                        ct.CityID,
                        Province = pv.Name,
                        City = ct.Name,
                        j.AjancyName,
                        j.Phone,
                        j.PostalCode,
                        j.Address,
                        bl.BusinessLicenseNo,
                        j.BusinessLicenseType,
                        p.NationalCode,
                        p.FirstName,
                        p.LastName,
                        p.Mobile
                    };

        if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex == 0) // Just province
        {
            query = from q in query
                    where q.ProvinceID == Public.ToByte(this.drpProvince.SelectedValue)
                    select q;
        }

        if (this.drpProvince.SelectedIndex > 0 && this.drpCity.SelectedIndex > 0) // province and city
        {
            query = from q in query
                    where q.CityID == Public.ToShort(this.drpCity.SelectedValue)
                    select q;
        }

        if (!string.IsNullOrEmpty(this.txtAjancyName.Text))
        {
            query = from q in query
                    where q.AjancyName.Contains(this.txtAjancyName.Text.Trim())
                    select q;
        }

        DataTable dtObj = new DataTable();
        dtObj.Columns.Add(new DataColumn("FirstName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("LastName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("NationalCode", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Mobile", typeof(string)));
        dtObj.Columns.Add(new DataColumn("AjancyName", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BusinessLicenseNo", typeof(string)));
        dtObj.Columns.Add(new DataColumn("BusinessLicenseType", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Address", typeof(string)));
        dtObj.Columns.Add(new DataColumn("PostalCode", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Phone", typeof(string)));
        dtObj.Columns.Add(new DataColumn("Province", typeof(string)));
        dtObj.Columns.Add(new DataColumn("City", typeof(string)));

        foreach (var item in query)
        {
            DataRow row = dtObj.NewRow();
            row[0] = item.FirstName;
            row[1] = item.LastName;
            row[2] = item.NationalCode;
            row[3] = item.Mobile;
            row[4] = item.AjancyName;
            row[5] = item.BusinessLicenseNo;
            row[6] = item.BusinessLicenseType == 0 ? "عادی" : "ویژه ایثارگران و جانبازان و شهدا";
            row[7] = item.Address;
            row[8] = item.PostalCode;
            row[9] = item.Phone;
            row[10] = item.Province;
            row[11] = item.City;

            dtObj.Rows.Add(row);
        }

        db.Dispose();
        dtObj.TableName = "dt";
        Stimulsoft.Report.StiReport report = new Stimulsoft.Report.StiReport();
        report.RegData(dtObj);
        report.Load(HttpContext.Current.Server.MapPath("~/App_Data/Report/mrt/ajancy_list.mrt"));
        report.Render();
        Public.ExportInfo(3, report);
        report.Dispose();
    }
Пример #24
0
    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();
    }