コード例 #1
0
ファイル: rpt_NdhCtNew.cs プロジェクト: tutmvbsp/vbspinfor
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rpt_NdhCtNew rpt = new rpt_NdhCtNew();

            rpt.Site = this.Site;
            return(rpt);
        }
コード例 #2
0
ファイル: WpfNdhCt.xaml.cs プロジェクト: tutmvbsp/vbspinfor
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            #region

            try
            {
                cls.ClsConnect();
                int      thamso = 6;
                string[] bien   = new string[thamso];
                object[] giatri = new object[thamso];
                bien[0] = "@Ngay";
                if (dtpNgay.SelectedDate != null)
                {
                    giatri[0] = dtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd");
                }
                bien[5] = "@DenNgay";
                if (dtpDenNgay.SelectedDate != null)
                {
                    giatri[5] = dtpDenNgay.SelectedDate.Value.ToString("yyyy-MM-dd");
                }
                bien[1]   = "@MaPos";
                giatri[1] = str.Left(CboPos.SelectedValue.ToString().Trim(), 6);
                bien[2]   = "@MaXa";
                giatri[2] = str.Left(CboXa.SelectedValue.ToString().Trim(), 6);
                bien[3]   = "@Htvay";
                if (Ration1.IsChecked == true)
                {
                    giatri[3] = "1";
                }
                else if (Ration2.IsChecked == true)
                {
                    giatri[3] = "2";
                }
                else
                {
                    giatri[3] = "3";
                }

                bien[4] = "@Nguon";
                if (Ration4.IsChecked == true)
                {
                    giatri[4] = "1";
                }
                else if (Ration5.IsChecked == true)
                {
                    giatri[4] = "2";
                }
                else
                {
                    giatri[4] = "3";
                }
                dt = cls.LoadLdbf("usp_NdhCT", bien, giatri, thamso);
                if (dt.Rows.Count > 0)
                {
                    if (Ration7.IsChecked == true)
                    {
                        if (Ration6.IsChecked == true)
                        {
                            rpt_NdhCtNewKHB rpt = new rpt_NdhCtNewKHB();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(),
                                             srv.DbUserSerVer(), srv.DbPassSerVer());
                        }
                        else
                        {
                            rpt_NdhCtNew rpt = new rpt_NdhCtNew();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(),
                                             srv.DbUserSerVer(), srv.DbPassSerVer());
                        }
                    }
                    else
                    {
                        FileName = Thumuc + "\\" + giatri[1] + "_" + giatri[2] + "_" + dtpNgay.SelectedDate.Value.ToString("ddMMyyyy") + ".csv";
                        FileStream   fs = new FileStream(FileName, FileMode.Create);
                        StreamWriter sw = new StreamWriter(fs, Encoding.Unicode);

                        str.ToCSV(dt, sw, true);
                        //str.exportDataTableToExcel(dt, FileName);
                        // //str.ExportToExcel(dt, FileName);
                        //MessageBox.Show("Export to Excel : " + FileName, "Thông báo");
                        // str.OpenExcel(FileName);

                        //str.ExportToExcel(dt, FileName);
                        MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK,
                                        MessageBoxImage.Information);
                        str.OpenExcel(FileName);
                    }
                }
                else
                {
                    MessageBox.Show("Không có số liệu", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cls.DongKetNoi();

            #endregion
        }