Beispiel #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rpt_SlVungBienCt rpt = new rpt_SlVungBienCt();

            rpt.Site = this.Site;
            return(rpt);
        }
Beispiel #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();
                    if (Ration1.IsChecked == true)
                    {
                        int      thamso = 2;
                        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]   = "@MaPos";
                        giatri[1] = str.Left(CboPos.SelectedValue.ToString().Trim(), 6);
                        dt        = cls.LoadLdbf("usp_SlVungBien", bien, giatri, thamso);
                        if (dt.Rows.Count > 0)
                        {
                            rpt_SlVungBien rpt = new rpt_SlVungBien();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                        }
                        else
                        {
                            MessageBox.Show("Không có dữ liệu", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                    else if (Ration2.IsChecked == true)
                    {
                        int      thamso1 = 3;
                        string[] bien    = new string[thamso1];
                        object[] giatri  = new object[thamso1];
                        bien[0] = "@NgayKu";
                        if (dtpNgayKu.SelectedDate != null)
                        {
                            giatri[0] = dtpNgayKu.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);
                        dt        = cls.LoadLdbf("usp_SlVungBienCT", bien, giatri, thamso1);
                        if (dt.Rows.Count > 0)
                        {
                            rpt_SlVungBienCt rpt = new rpt_SlVungBienCt();
                            RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer());
                        }
                        else
                        {
                            MessageBox.Show("Không có dữ liệu", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                    else
                    {
                        int      thamso2 = 1;
                        string[] bien    = new string[thamso2];
                        object[] giatri  = new object[thamso2];
                        bien[0] = "@NgayKu";
                        if (dtpNgayKu.SelectedDate != null)
                        {
                            giatri[0] = dtpNgayKu.SelectedDate.Value.ToString("yyyy-MM-dd");
                        }
                        dt = cls.LoadLdbf("usp_SlVungBienTH", bien, giatri, thamso2);
                        if (dt.Rows.Count > 0)
                        {
                            FileName = Thumuc + "\\" + str.Left(CboPos.SelectedValue.ToString().Trim(), 6) + "_SoLieuXaVungBien_" + dtpNgayKu.SelectedDate.Value.ToString("ddMMyyyy") + ".csv";
                            str.ExportToExcel(dt, FileName);
                            //bll.ExportDTToExcel(dt,FileName);
                            //bll.WriteDataTableToExcel(dt, "Details", FileName, "tutm : 0985165777");
                            //bll.ToCSV(dt, sw, true);
                            MessageBox.Show("Copy Excel to : " + FileName, "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                            //bll.OpenCSVWithExcel(FileName);
                            str.OpenExcel(FileName);
                        }
                        else
                        {
                            MessageBox.Show("Không có dữ liệu", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            cls.DongKetNoi();

            #endregion
        }