示例#1
0
 public selectlabel_test()
 {
     InitializeComponent();
     dcore = new DataCoreLibrary();
     DataControls.LoadComboBoxData(cmbunit, DataDefinition.GetUnitTab(), "UNITNAME", "REFNUM");
     cmbunit.SelectedValue = 0;
 }
示例#2
0
        public navy_search(string id13, string name, string sname, string status, string mode)
        {
            dcore = new DataCoreLibrary();
            InitializeComponent();
            DataControls.LoadComboBoxData(cmbselectaddress, DataDefinition.GetUnitTab(), "unitname", "REFNUM");
            if (!string.IsNullOrEmpty(txtid13.Text.Trim()))
            {
                id13 = txtid13.Text.Trim();
            }
            else if (!string.IsNullOrEmpty(id13))
            {
                txtid13.Text = id13;
            }

            if (!string.IsNullOrEmpty(txtname.Text.Trim()))
            {
                name = txtname.Text.Trim();
            }
            else if (!string.IsNullOrEmpty(name))
            {
                txtname.Text = name;
            }
            if (!string.IsNullOrEmpty(txtlname.Text.Trim()))
            {
                sname = txtlname.Text.Trim();
            }
            else if (!string.IsNullOrEmpty(sname))
            {
                txtlname.Text = sname;
            }
            mode_search = mode;

            GetData(id13, name, sname, status);
        }
示例#3
0
        public ReportAddressMore()
        {
            InitializeComponent();
            dcore = new DataCoreLibrary();


            DataControls.LoadComboBoxData(cmbselectaddress, DataDefinition.GetUnitTab(), "UNITNAME", "REFNUM");
        }
示例#4
0
        private void InitialControls()
        {
            //hide some value for lite mode
            if (!Constants.fullMode)
            {
                label5.Visible    = false;
                tbRemark2.Visible = false;

                ////////////
                label3.Visible = false;
                cbbNUM.Visible = false;
                ////////////

                tabControl1.Controls.Remove(tabPage2);
                personShortDetailView1.HideDataForLiteMode();
            }

            //Load person detail
            personShortDetailView1.InitialValue(personShortDetailData);
            personShortDetailView1.Dock = DockStyle.Fill;

            //Load data into ComboBox
            if (cbbUnit.DataSource == null)
            {
                DataControls.LoadComboBoxData(cbbUnit, DataDefinition.GetUnitTab(), "UNITNAME", "REFNUM", personShortDetailData.request.unit);
            }

            if (cbbRequester1.DataSource == null)
            {
                DataControls.LoadComboBoxData(cbbRequester1, DataDefinition.GetAskByTab(), "ask", "ask", String.IsNullOrWhiteSpace(personShortDetailData.request.askby) ? "" : personShortDetailData.request.askby.Substring(0, 2));
            }

            //Load new copy data into ComboBox
            if (cbbUnit2.DataSource == null)
            {
                DataControls.LoadComboBoxData(cbbUnit2, DataDefinition.GetUnitTab().Copy(), "UNITNAME", "REFNUM", personShortDetailData.person.unit3);
            }

            DataControls.LoadComboBoxData(cbbNUM, DataDefinition.GetAskByNUMTab(DataControls.GetSelectedValueComboBoxToString(cbbRequester1), personShortDetailData.person.yearin), "NUM", "NUM");
        }
示例#5
0
        //======================= ออกรายงานทั้งหมด (ทุกหน่วย, ทุกรูป, ทุก Excel)
        private void button1_Click(object sender, EventArgs e)
        {
            progressBar1.Visible = true;
            progressBar1.Maximum = 22;
            progressBar1.Step    = 1;
            progressBar1.Value   = 0;

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

            if (!Directory.Exists(FilePathDesktopForOutputData))
            {
                Directory.CreateDirectory(FilePathDesktopForOutputData);
            }
            try
            {
                for (int i = 0; i < 35; i++)
                {
                    int                    recodeperpage = 20;
                    Warning[]              warnings;
                    string[]               streamids;
                    string                 mimeType;
                    string                 encoding;
                    string                 filenameExtension;
                    Reports.ReportDisplay  f           = new Reports.ReportDisplay();
                    DataTable              dataSource  = dcore.GetReportListAddressmore(mtxtYearin.Text.Trim(), i.ToString());
                    List <ReportParameter> reportParam = new List <ReportParameter>();

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

                    if (dataSource.Rows.Count > 0)
                    {
                        DataControls.LoadComboBoxData(cmbselectaddress, DataDefinition.GetUnitTab(), "UNITNAME", "REFNUM", i.ToString());
                        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);
                        }
                        if (checkBox1.Checked)
                        {
                            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
                            {
                                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) + "//" + 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("มีนาคม","มี.ค.");
                            // ----------------- ลายเซ็น Check ---------------
                            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();
                        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());
                            }
                        }
                    }
                    progressBar1.PerformStep();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            MessageBox.Show("ออกรายงานสำเร็จ");
        }