Пример #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rpt_QlyNguon rpt = new rpt_QlyNguon();

            rpt.Site = this.Site;
            return(rpt);
        }
Пример #2
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            #region

            try
            {
                cls.ClsConnect();
                int      thamso = 5;
                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[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_QlyNnguon", bien, giatri, thamso);
                if (dt.Rows.Count > 0)
                {
                    if (Ration7.IsChecked == true)
                    {
                        if (Ration6.IsChecked == true)
                        {
                            rpt_QlyNguonKHB rpt = new rpt_QlyNguonKHB();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(),
                                             srv.DbUserSerVer(), srv.DbPassSerVer());
                        }
                        else
                        {
                            rpt_QlyNguon rpt = new rpt_QlyNguon();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(),
                                             srv.DbUserSerVer(), srv.DbPassSerVer());
                            rpt_QlyNguonB rptb = new rpt_QlyNguonB();
                            RPUtility.ShowRp(rptb, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(),
                                             srv.DbUserSerVer(), srv.DbPassSerVer());
                            rpt_QlyNguonC rptc = new rpt_QlyNguonC();
                            RPUtility.ShowRp(rptc, 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
        }