Exemplo n.º 1
0
        public void ShowReportRequestPerson(ParamSearchPerson param, QueryString.Search.RequestPersonFilter reportType)
        {
            try
            {
                var dataSource          = dcore.GetSearchRequest(param, reportType);
                Reports.ReportDisplay f = new Reports.ReportDisplay();

                if (!Constants.fullMode)
                {
                    //f.ReportViewer.ShowExportButton = false;
                }

                string headerText = "";
                if (reportType == QueryString.Search.RequestPersonFilter.RTC)
                {
                    headerText = "รายชื่อเสนอความต้องการทหารกองประจำการลงสังกัด ศฝท.";
                }
                else
                {
                    headerText = "รายชื่อเสนอความต้องการทหารกองประจำการไปสังกัดหน่วยต่างๆ";
                }

                List <ReportParameter> reportParam = new List <ReportParameter>();
                reportParam.Add(new ReportParameter("reportHeaderText", headerText));
                reportParam.Add(new ReportParameter("yearin", param.yearin));

                f.ReportViewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
                f.DisplayReport(dataSource, "Navy.Reports.ReportRequestPerson.rdlc", reportParam);
                f.Show();
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 2
0
        public void ShowReportViewProfile(string navyid)
        {
            try
            {
                Reports.ReportDisplay f = new Reports.ReportDisplay();
                rtcDetails = Function.GetRTCRespository().GetSelectedDetail(navyid);
                DataTable dataSource = dcore.GetViewdata(navyid);
                //  List<ReportParameter> reportParam = new List<ReportParameter>();
                //  reportParam.Add(new ReportParameter("pathimg", ConfigurationManager.AppSettings["PhotoPath"].ToString() + "/" + rtcDetails.yearin + "/" + rtcDetails.navyid + ".jpg"));
                dataSource.Rows[0]["address"] = rtcDetails.address_all;


                dataSource.Rows[0]["birthdate"]  = rtcDetails.birthdate;
                dataSource.Rows[0]["regdate"]    = rtcDetails.regdate;
                dataSource.Rows[0]["repdate"]    = rtcDetails.repdate;
                dataSource.Rows[0]["MOVEDATE"]   = rtcDetails.MOVEDATE;
                dataSource.Rows[0]["IS_REQUEST"] = rtcDetails.IS_REQUEST;

                f.DisplayReport(dataSource, "Navy.Reports.ReportViewProfile.rdlc");
                f.Show();
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public void ShowReportPrintHistoryBook(System.Data.DataTable dataSource, string yearin)
        {
            try
            {
                Reports.ReportDisplay f = new Reports.ReportDisplay();

                if (dataSource.Rows.Count > 0)
                {
                    System.Data.DataColumn dc = new System.Data.DataColumn("imagepath", typeof(string));
                    dataSource.Columns.Add(dc);

                    string imageserver = dcore.getConnection().DataSource;
                    yearin = yearin.Replace("/", ".");

                    foreach (System.Data.DataRow dr in dataSource.Rows)
                    {
                        string imagepath = @"\\" + imageserver + @"\navyimages\" + yearin + @"\" + dr["NAVYID"].ToString() + @".jpg";
                        dr["imagepath"] = imagepath;
                    }

                    f.ReportViewer.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
                    f.DisplayReport(dataSource, "Navy.Reports.ReportHistoryBook.rdlc");
                    f.ReportViewer.LocalReport.EnableExternalImages = true;
                    Refresh(f.ReportViewer);
                    f.Show();
                }
                else
                {
                }
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 4
0
        private void btnprint_Click(object sender, EventArgs e)
        {
            Reports.ReportDisplay  f           = new Reports.ReportDisplay();
            DataTable              dataSource  = dcore.GetReportListPeople(txtreport_number2.Text.Trim());
            List <ReportParameter> reportParam = new List <ReportParameter>();

            //  reportParam.Add(new ReportParameter("yearin", dcore.GetMaxYearin()));
            reportViewer1.Reset();

            //Setup Report Value
            reportViewer1.LocalReport.ReportEmbeddedResource = "Navy.Reports.ReportPropleList.rdlc";
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", dataSource));
            reportViewer1.LocalReport.Refresh();
            reportViewer1.RefreshReport();
        }
Exemplo n.º 5
0
        public void ShowReportDevideUnitPersonList(string yearin)
        {
            try
            {
                Reports.ReportDisplay f            = new Reports.ReportDisplay();
                var dataSource                     = dcore.ReportLabelUnitListPerson(yearin);
                List <ReportParameter> reportParam = new List <ReportParameter>();
                reportParam.Add(new ReportParameter("yearin", dcore.GetMaxYearin()));

                f.DisplayReport(dataSource, "Navy.Reports.ReportDevideUnit.rdlc");
                f.Show();
            }
            catch
            {
                throw;
            }
        }
Exemplo n.º 6
0
        protected void Getreport()
        {
            Reports.ReportDisplay  f           = new Reports.ReportDisplay();
            DataTable              dataSource  = dcore.GetReportSumpeople();
            List <ReportParameter> reportParam = new List <ReportParameter>();

            //reportParam.Add(new ReportParameter("unit_name", "test"));
            reportViewer1.Reset();


            //Setup Report Value
            reportViewer1.LocalReport.ReportEmbeddedResource = "Navy.Reports.ReportSumpeople.rdlc";
            //reportParam.Add(new ReportParameter("Title", string.Format("{0} {1}", "รายชื่อทหารกองประจำการ ย้ายทะเบียนบ้าน สังกัด ", DataControls.GetSelectedTextComboBoxToString(cmbselectaddress))));
            //this.reportViewer1.LocalReport.SetParameters(reportParam);
            //ReportParameter[] parameters = new ReportParameter[1];
            //   parameters[0] = new ReportParameter("Title", "test");
            reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dataSource));
            reportViewer1.LocalReport.Refresh();
            reportViewer1.RefreshReport();
        }
Exemplo n.º 7
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            int recodeperpage = 20;

            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    filenameExtension;

            //ถ้าไม่มี Folder ไว้เก็บข้อมูลที่ desktop จะสร้าง Folder นั้นขึ้นมาก่อน
            string FilePathDesktopForOutputData = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "//" + mtxtYearin.Text.Trim().Replace('/', '.');

            if (!Directory.Exists(FilePathDesktopForOutputData))
            {
                Directory.CreateDirectory(FilePathDesktopForOutputData);
            }

            try
            {
                Reports.ReportDisplay  f           = new Reports.ReportDisplay();
                DataTable              dataSource  = dcore.GetReportListAddressmore(mtxtYearin.Text.Trim(), DataControls.GetSelectedValueComboBoxToString(cmbselectaddress));
                List <ReportParameter> reportParam = new List <ReportParameter>();

                //reportParam.Add(new ReportParameter("unit_name", "test"));
                reportViewer1.Reset();

                if (dataSource.Rows.Count > 0)
                {
                    while ((dataSource.Rows.Count % recodeperpage) > 20 || (dataSource.Rows.Count % recodeperpage) == 0)
                    {
                        recodeperpage--;
                    }
                    string str = string.Empty;
                    //Setup Report Value
                    string[] str1 = dpdateR.Text.Split(' ');

                    // ============== Export Image Checked =============
                    if (chkimage.Checked)
                    {
                        try
                        {
                            //Create Folder for image output
                            string FilePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "//" + mtxtYearin.Text.Trim().Replace('/', '.') + "//" + DataControls.GetSelectedTextComboBoxToString(cmbselectaddress);
                            if (!Directory.Exists(FilePath))
                            {
                                Directory.CreateDirectory(FilePath);
                            }
                            else
                            {
                                System.IO.Directory.Delete(FilePath, true);
                                System.IO.Directory.CreateDirectory(FilePath);
                            }

                            //Copy Image file in to folder
                            foreach (DataRow dr in dataSource.Rows)
                            {
                                //string path = @"\\192.168.0.1\NavyImages\" + dr["YEARIN"].ToString().Replace('/', '.') + @"\" + dr["NAVYID"].ToString() + ".jpg";
                                //if (File.Exists(path))
                                //{
                                //
                                //    System.IO.File.Copy(@"\\192.168.0.1\NavyImages\" + dr["YEARIN"].ToString().Replace('/', '.') + @"\" + dr["NAVYID"].ToString() + ".jpg"
                                //       , Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"//" + dr["unitname"].ToString() + @"//" + dr["NAME"].ToString() + "  " + dr["SNAME"].ToString() + "  " + dr["NAVYID"].ToString() + ".jpg", true);
                                // }
                                string path = @"\\192.168.0.1\NavyImages\" + dr["YEARIN"].ToString().Replace('/', '.') + @"\" + dr["NAVYID"].ToString() + ".jpg";
                                if (File.Exists(path))
                                {
                                    {
                                        System.IO.File.Copy(@"\\192.168.0.1\NavyImages\" + dr["YEARIN"].ToString().Replace('/', '.') + @"\" + dr["NAVYID"].ToString() + ".jpg"
                                                            , Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "//" + mtxtYearin.Text.Trim().Replace('/', '.') + "//" + dr["unitname"].ToString() + @"//" + dr["NAME"].ToString() + "  " + dr["SNAME"].ToString() + "  " + dr["NAVYID"].ToString() + ".jpg", true);
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }

                    // ============== Export Report PDF Checked =============
                    if (chk.Checked)
                    {
                        // string  str11 =  dpdateR.Text.Replace("มีนาคม","มี.ค.");
                        if (checkBox1.Checked)
                        {
                            reportViewer1.LocalReport.ReportEmbeddedResource = "Navy.Reports.Report2.rdlc";
                            reportParam.Add(new ReportParameter("Title", string.Format("บัญชีรายชื่อทหารกองประจำการจัดแบ่งให้หน่วย  {0}", DataControls.GetSelectedTextComboBoxToString(cmbselectaddress))));
                            reportParam.Add(new ReportParameter("date", string.Format("วันที่ส่งมอบ  {0} {1} {2}", str1[0], ConvertM(str1[1]), (Convert.ToInt32(str1[2])) - 2500).ToString()));
                            reportParam.Add(new ReportParameter("TitleNotation", "หมายเหตุ"));
                            reportParam.Add(new ReportParameter("notationaddict", "ผลการคัดกรองสารเสพติด " +
                                                                "กลุ่ม 1 = ผู้ไม่เคยใช้สารเสพติด " +
                                                                "กลุ่ม 2 = กลุ่มเสี่ยง(เคยทดลอง) " +
                                                                "กลุ่ม 3 = กลุ่มผู้เสพ " +
                                                                "กลุ่ม 4 = กลุ่มผู้ติด"));
                            reportParam.Add(new ReportParameter("text", txttext.Text.Trim()));
                            reportParam.Add(new ReportParameter("rank", txtrank.Text.Trim()));
                            reportParam.Add(new ReportParameter("name", txtname.Text.Trim()));
                            reportParam.Add(new ReportParameter("position", txtposition.Text.Trim()));
                            reportParam.Add(new ReportParameter("day", dpday.Text.Trim()));
                            reportParam.Add(new ReportParameter("recodeperpage", recodeperpage.ToString()));
                            this.reportViewer1.LocalReport.SetParameters(reportParam);
                        }
                        else
                        {
                            reportViewer1.LocalReport.ReportEmbeddedResource = "Navy.Reports.Report2None.rdlc";
                            reportParam.Add(new ReportParameter("Title", string.Format("บัญชีรายชื่อทหารกองประจำการจัดแบ่งให้หน่วย  {0}", DataControls.GetSelectedTextComboBoxToString(cmbselectaddress))));
                            reportParam.Add(new ReportParameter("date", string.Format("วันที่ส่งมอบ  {0} {1} {2}", str1[0], ConvertM(str1[1]), (Convert.ToInt32(str1[2])) - 2500).ToString()));
                            reportParam.Add(new ReportParameter("TitleNotation", "หมายเหตุ"));
                            reportParam.Add(new ReportParameter("notationaddict", "ผลการคัดกรองสารเสพติด " +
                                                                "กลุ่ม 1 = ผู้ไม่เคยใช้สารเสพติด " +
                                                                "กลุ่ม 2 = กลุ่มเสี่ยง(เคยทดลอง) " +
                                                                "กลุ่ม 3 = กลุ่มผู้เสพ " +
                                                                "กลุ่ม 4 = กลุ่มผู้ติด"));
                            reportParam.Add(new ReportParameter("recodeperpage", recodeperpage.ToString()));
                            this.reportViewer1.LocalReport.SetParameters(reportParam);
                        }


                        reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dataSource));


                        byte[] bytes = reportViewer1.LocalReport.Render(
                            "PDF", null, out mimeType, out encoding, out filenameExtension,
                            out streamids, out warnings);

                        try
                        {
                            using (FileStream fs = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "//" + mtxtYearin.Text.Trim().Replace('/', '.') + "//" + DataControls.GetSelectedTextComboBoxToString(cmbselectaddress) + ".pdf", FileMode.Create))
                            {
                                fs.Write(bytes, 0, bytes.Length);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                    }


                    // reportViewer1.LocalReport.Refresh();
                    // reportViewer1.RefreshReport();
                    // ============== Export Excel Checked =============
                    if (chkexport.Checked)
                    {
                        Reports.ReportDisplay  f1           = new Reports.ReportDisplay();
                        DataTable              dataSource1  = dcore.GetReportExportToExcel(mtxtYearin.Text.Trim(), DataControls.GetSelectedValueComboBoxToString(cmbselectaddress));
                        List <ReportParameter> reportParam1 = new List <ReportParameter>();

                        //reportParam.Add(new ReportParameter("unit_name", "test"));
                        reportViewer1.Reset();
                        reportViewer1.LocalReport.ReportEmbeddedResource = "Navy.Reports.ExportToExcel.rdlc";
                        reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dataSource1));


                        Warning[] warningsE;
                        string[]  streamidsE;
                        string    mimeTypeE;
                        string    encodingE;
                        string    extensionE;


                        byte[] bytesE = reportViewer1.LocalReport.Render(
                            "Excel", null, out mimeTypeE, out encodingE,
                            out extensionE,
                            out streamidsE, out warningsE);



                        try
                        {
                            using (FileStream fs = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "//" + mtxtYearin.Text.Trim().Replace('/', '.') + "//" + DataControls.GetSelectedTextComboBoxToString(cmbselectaddress) + ".xls", FileMode.Create))
                            {
                                fs.Write(bytesE, 0, bytesE.Length);
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message.ToString());
                        }
                        //Reports.ReportDisplay f1 = new Reports.ReportDisplay();
                        //DataTable dataSource1 = dcore.GetReportExportToExcel(mtxtYearin.Text.Trim(), DataControls.GetSelectedValueComboBoxToString(cmbselectaddress));
                        //List<ReportParameter> reportParam1 = new List<ReportParameter>();

                        ////reportParam.Add(new ReportParameter("unit_name", "test"));
                        //reportViewer1.Reset();
                        //reportViewer1.LocalReport.ReportEmbeddedResource = "Navy.Reports.ExportToExcel.rdlc";
                        //reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dataSource1));


                        //Warning[] warningsE;
                        //string[] streamidsE;
                        //string mimeTypeE;
                        //string encodingE;
                        //string extensionE;


                        //byte[] bytesE = reportViewer1.LocalReport.Render(
                        //   "Excel", null, out mimeTypeE, out encodingE,
                        //    out extensionE,
                        //   out streamidsE, out warningsE);



                        //try
                        //{
                        //    using (FileStream fs = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "//" + DataControls.GetSelectedTextComboBoxToString(cmbselectaddress) + ".xls", FileMode.Create))
                        //    {
                        //        fs.Write(bytesE, 0, bytesE.Length);
                        //    }
                        //     MessageBox.Show("สร้าง Excel สำเร็จ");
                        // }
                        //catch (Exception ex)
                        //{
                        //    MessageBox.Show(ex.Message.ToString());
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            MessageBox.Show("ออกรายงานสำเร็จ");
        }