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

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

            try
            {
                if (str.Right(str.Left(CboPos.SelectedValue.ToString().Trim(), 6), 2) == "00")
                {
                    MessageBox.Show("Không chọn POS tổng hợp", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    cls.ClsConnect();
                    int      thamso = 6;
                    string[] bien   = new string[thamso];
                    object[] giatri = new object[thamso];
                    bien[0] = "@NgayKu";
                    if (dtpNgayKu.SelectedDate != null)
                    {
                        giatri[0] = dtpNgayKu.SelectedDate.Value.ToString("yyyy-MM-dd");
                    }
                    bien[1] = "@NgayBt";
                    if (dtpNgayBt.SelectedDate != null)
                    {
                        giatri[1] = dtpNgayBt.SelectedDate.Value.ToString("yyyy-MM-dd");
                    }
                    bien[2]   = "@MaPos";
                    giatri[2] = str.Left(CboPos.SelectedValue.ToString().Trim(), 6);
                    bien[3]   = "@MaXa";
                    giatri[3] = str.Left(cboXa.SelectedValue.ToString().Trim(), 6);
                    //MessageBox.Show(giatri[3].ToString());
                    bien[4] = "@Nguon";
                    if (Ration1.IsChecked == true)
                    {
                        giatri[4] = "1";
                    }
                    else if (Ration2.IsChecked == true)
                    {
                        giatri[4] = "2";
                    }
                    else
                    {
                        giatri[4] = "3";
                    }
                    bien[5] = "@Mau";
                    if (Ration4.IsChecked == true)
                    {
                        giatri[5] = "1";
                    }
                    else if (Ration5.IsChecked == true)
                    {
                        giatri[5] = "2";
                    }
                    else
                    {
                        giatri[5] = "3";
                    }

                    if (Ration4.IsChecked == true)
                    {
                        dt = cls.LoadLdbf("usp_SlDaily", bien, giatri, thamso);
                        if (Ration6.IsChecked == true)
                        {
                            rpt_SlDaily rpt = new rpt_SlDaily();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                        }
                        else
                        {
                            FileName = Thumuc + "\\" + giatri[2] + "_" + giatri[3] + "_SLTD_XA_" +
                                       dtpNgayBt.SelectedDate.Value.ToString("ddMMyyyy") + ".csv";
                            str.ExportToExcel(dt, FileName);
                            MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK,
                                            MessageBoxImage.Information);
                            //str.OpenExcel(FileName);
                        }
                    }
                    else
                    {
                        if (Ration5.IsChecked == true)
                        {
                            dt = cls.LoadLdbf("usp_SlDailyCT", bien, giatri, thamso);
                            if (Ration6.IsChecked == true)
                            {
                                rpt_SlDailyCt rpt = new rpt_SlDailyCt();
                                RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                            }
                            else
                            {
                                FileName = Thumuc + "\\" + giatri[2] + "_" + giatri[3] + "_SLTD_CHTR_" +
                                           dtpNgayBt.SelectedDate.Value.ToString("ddMMyyyy") + ".csv";
                                str.ExportToExcel(dt, FileName);
                                MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK,
                                                MessageBoxImage.Information);
                                //str.OpenExcel(FileName);
                            }
                        }
                        else
                        {
                            dt = cls.LoadLdbf("usp_SlDailyDvut", bien, giatri, thamso);

                            if (Ration6.IsChecked == true)
                            {
                                rpt_SlDaily rpt = new rpt_SlDaily();
                                RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                            }
                            else
                            {
                                FileName = Thumuc + "\\" + giatri[2] + "_" + giatri[3] + "_SLTD_DVUT_" +
                                           dtpNgayBt.SelectedDate.Value.ToString("ddMMyyyy") + ".csv";
                                str.ExportToExcel(dt, FileName);
                                MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK,
                                                MessageBoxImage.Information);
                                //str.OpenExcel(FileName);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cls.DongKetNoi();

            #endregion
        }