public Entities.BCDTTheoThoiGian[] Select(int thang, int nam)
        {
            Sql   = new Constants.Sql();
            dtttg = new Constants.BCDTTheoThoiGian();
            string        sql  = Sql.BCDTTheoThang;
            Connection    conn = new Connection();
            SqlConnection cn   = conn.openConnection();
            SqlCommand    cmd  = new SqlCommand(sql, cn);

            cmd.Parameters.Add("@Thang", SqlDbType.Int).Value = thang;
            cmd.Parameters.Add("@Nam", SqlDbType.Int).Value   = nam;
            SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            //Insert Category into ArrayList
            ArrayList arr = new ArrayList();

            while (dr.Read())
            {
                Entities.BCDTTheoThoiGian bcdttg1 = new Entities.BCDTTheoThoiGian();
                bcdttg1.MaHDBanHang          = dr[dtttg.MaHDBanHang].ToString();
                bcdttg1.NgayBan              = Convert.ToDateTime(dr[dtttg.NgayBan].ToString());
                bcdttg1.ThanhToanNgay        = float.Parse(dr[dtttg.ThanhToanNgay].ToString());
                bcdttg1.ThanhToanKhiLapPhieu = double.Parse(dr[dtttg.ThanhToanKhiLapPhieu].ToString());
                bcdttg1.TongTienThanhToan    = double.Parse(dr["TongTienThanhToan"].ToString());
                arr.Add(bcdttg1);
            }
            int n = arr.Count;

            if (n == 0)
            {
                return(null);
            }

            Entities.BCDTTheoThoiGian[] arrC = new Entities.BCDTTheoThoiGian[n];
            for (int i = 0; i < n; i++)
            {
                arrC[i] = (Entities.BCDTTheoThoiGian)arr[i];
            }

            //Giai phong bo nho
            arr = null;
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn   = null;
            conn = null;
            return(arrC);
        }
        public Entities.BCDTTheoThoiGian[] Select(int thang, int nam)
        {
            Sql = new Constants.Sql();
            dtttg = new Constants.BCDTTheoThoiGian();
            string sql = Sql.BCDTTheoThang;
            Connection conn = new Connection();
            SqlConnection cn = conn.openConnection();
            SqlCommand cmd = new SqlCommand(sql, cn);
            cmd.Parameters.Add("@Thang", SqlDbType.Int).Value = thang;
            cmd.Parameters.Add("@Nam", SqlDbType.Int).Value = nam;
            SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);

            //Insert Category into ArrayList
            ArrayList arr = new ArrayList();
            while (dr.Read())
            {
                Entities.BCDTTheoThoiGian bcdttg1 = new Entities.BCDTTheoThoiGian();
                bcdttg1.MaHDBanHang = dr[dtttg.MaHDBanHang].ToString();
                bcdttg1.NgayBan = Convert.ToDateTime(dr[dtttg.NgayBan].ToString());
                bcdttg1.ThanhToanNgay = float.Parse(dr[dtttg.ThanhToanNgay].ToString());
                bcdttg1.ThanhToanKhiLapPhieu = double.Parse(dr[dtttg.ThanhToanKhiLapPhieu].ToString());
                bcdttg1.TongTienThanhToan = double.Parse(dr["TongTienThanhToan"].ToString());
                arr.Add(bcdttg1);
            }
            int n = arr.Count;
            if (n == 0) return null;

            Entities.BCDTTheoThoiGian[] arrC = new Entities.BCDTTheoThoiGian[n];
            for (int i = 0; i < n; i++)
            {
                arrC[i] = (Entities.BCDTTheoThoiGian)arr[i];
            }

            //Giai phong bo nho
            arr = null;
            cmd.Connection.Dispose();
            cn.Close();
            conn.closeConnection();
            cn = null;
            conn = null;
            return arrC;
        }
 public frmBaoCaorpt(DateTime Truoc, DateTime Sau, bool isView, string path, string hanhDong)
 {
     try
     {
         InitializeComponent();
         CongTy();
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.BCDTTheoThoiGian ctxh = new Entities.BCDTTheoThoiGian("SelectTheoKhoang", Truoc, Sau);
         Entities.BCDTTheoThoiGian[] pt1 = new Entities.BCDTTheoThoiGian[1];
         clientstrem = cl.SerializeObj(this.client1, "BCDTTheoThoiGian", ctxh);
         pt1 = (Entities.BCDTTheoThoiGian[])cl.DeserializeHepper1(clientstrem, pt1);
         if (pt1 == null)
         {
             MessageBox.Show("Không có dữ liệu", "Hệ thống cảnh báo");
             return;
         }
         else
         {
             GUI.Report.rptBCDoanhThuTheoThoiGian report = new GUI.Report.rptBCDoanhThuTheoThoiGian();
             report.SetDataSource(pt1);
             crvReport.ReportSource = report;
             report.SetParameterValue("TenCongTy", CT.TenCongTy);
             report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
             report.SetParameterValue("DienThoai", CT.SoDienThoai);
             report.SetParameterValue("FaxCongTy", CT.Fax);
             report.SetParameterValue("Web", CT.Website);
             report.SetParameterValue("TenBaoCao", "Báo Cáo Doanh Thu Theo Khoảng Thời Gian");
             report.SetParameterValue("NgayTao", new Common.Utilities().XuLy(2, DateServer.Date().ToShortDateString()));
             report.SetParameterValue("MaNhanVien", Common.Utilities.User.TenNhanVien);
             report.SetParameterValue("Email", CT.Email);
             report.SetParameterValue("Tu", new Common.Utilities().XuLy(2, Truoc.ToShortDateString()));
             report.SetParameterValue("Den", new Common.Utilities().XuLy(2, Sau.ToShortDateString()));
             if (isView) crvReport.Show();
             else
             {
                 switch (hanhDong)
                 {
                     case "Excel":
                         new Report.ExportCrystalReport().Export(report, path, Report.ExportCrystalReport.TypeBC.Excel);
                         break;
                     case "Word":
                         new Report.ExportCrystalReport().Export(report, path, Report.ExportCrystalReport.TypeBC.WordForWindows);
                         break;
                     case "PDF":
                         new Report.ExportCrystalReport().Export(report, path, Report.ExportCrystalReport.TypeBC.PortableDocFormat);
                         break;
                 }
             }
         }
     }
     catch { }
 }
 public frmBaoCaorpt(int Thang, int Nam)
 {
     try
     {
         InitializeComponent();
         CongTy();
         cl = new Server_Client.Client();
         this.client1 = cl.Connect(Luu.IP, Luu.Ports);
         Entities.BCDTTheoThoiGian ctxh = new Entities.BCDTTheoThoiGian("SelectTheoThang", Thang, Nam);
         Entities.BCDTTheoThoiGian[] pt1 = new Entities.BCDTTheoThoiGian[1];
         clientstrem = cl.SerializeObj(this.client1, "BCDTTheoThoiGian", ctxh);
         pt1 = (Entities.BCDTTheoThoiGian[])cl.DeserializeHepper1(clientstrem, pt1);
         if (pt1 == null)
         {
             MessageBox.Show("Không có dữ liệu", "Hệ thống cảnh báo");
             return;
         }
         else
         {
             GUI.Report.rptBCDoanhThuTheoThoiGian report = new GUI.Report.rptBCDoanhThuTheoThoiGian();
             report.SetDataSource(pt1);
             crvReport.ReportSource = report;
             report.SetParameterValue("TenCongTy", CT.TenCongTy);
             report.SetParameterValue("DiaChiCongTy", CT.DiaChi);
             report.SetParameterValue("DienThoai", CT.SoDienThoai);
             report.SetParameterValue("FaxCongTy", CT.Fax);
             report.SetParameterValue("Web", CT.Website);
             report.SetParameterValue("TenBaoCao", "Báo Cáo Doanh Thu Theo Tháng " + Thang + "/" + Nam);
             report.SetParameterValue("NgayTao", new Common.Utilities().XuLy(2, DateServer.Date().ToShortDateString()));
             report.SetParameterValue("MaNhanVien", Common.Utilities.User.TenNhanVien);
             report.SetParameterValue("Email", CT.Email);
             report.SetParameterValue("Tu", "");
             report.SetParameterValue("Den", "");
             crvReport.Show();
         }
     }
     catch { }
 }