/// <summary>
 /// vuong hung =================lay bang DonDatHang================
 /// </summary>
 /// <returns></returns>
 public Entities.HienThi_KhachHangTraLai[] sp_HoaDonBanHangTheoKhachHang(Entities.TruyenGiaTri lay)
 {
     Entities.HienThi_KhachHangTraLai[] arrC = null;
     try
     {
         string sql = "exec sp_KhachHangTraLaiHang @MaKhachHang ,@MaHDBanHang,@LoaiHoaDon";
         conn = new Connection();
         cn   = conn.openConnection();
         cmd  = new SqlCommand(sql, cn);
         cmd.Parameters.Add("MaKhachHang", SqlDbType.NVarChar, 20).Value = "" + lay.Giatritruyen;
         cmd.Parameters.Add("MaHDBanHang", SqlDbType.VarChar, 20).Value  = "" + lay.Giatriba;
         cmd.Parameters.Add("LoaiHoaDon", SqlDbType.VarChar, 20).Value   = "" + lay.Giatrithuhai;
         dr  = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             Entities.HienThi_KhachHangTraLai bang = new Entities.HienThi_KhachHangTraLai();
             bang.Mahoadonbanhang = dr[0].ToString();
             bang.Ngayban         = DateTime.Parse(dr[1].ToString());
             bang.Tongtien        = dr[2].ToString();
             bang.Nohienthoi      = dr[3].ToString();
             bang.MaKho           = dr[4].ToString();
             arr.Add(bang);
         }
         int n = arr.Count;
         if (n == 0)
         {
             arrC = null;
         }
         arrC = new Entities.HienThi_KhachHangTraLai[n];
         for (int i = 0; i < n; i++)
         {
             arrC[i] = (Entities.HienThi_KhachHangTraLai)arr[i];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); arrC = null; }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return(arrC);
 }
 /// <summary>
 /// vuong hung =================lay hang hoa theo ma tra lai nha cung cap================
 /// </summary>
 /// <returns></returns>
 public Entities.HienThi_KhachHangTraLai[] sp_TimHoaDonNhapTheoMaNhaCungCap(Entities.TruyenGiaTri lay)
 {
     Entities.HienThi_KhachHangTraLai[] arrC = null;
     try
     {
         string sql = "exec sp_TimHoaDonNhapTheoMaNhaCungCap @MaNhaCungCap,@MaHoaDonNhap";
         conn = new Connection();
         cn = conn.openConnection();
         cmd = new SqlCommand(sql, cn);
         cmd.Parameters.Add("MaNhaCungCap", SqlDbType.NVarChar, 20).Value = lay.Giatritruyen;
         cmd.Parameters.Add("MaHoaDonNhap", SqlDbType.VarChar, 20).Value = lay.Giatrithuhai;
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             Entities.HienThi_KhachHangTraLai bang = new Entities.HienThi_KhachHangTraLai();
             bang.Mahoadonbanhang = dr[0].ToString();
             bang.Ngayban = DateTime.Parse(dr[1].ToString());
             bang.Tongtien = dr[2].ToString();
             bang.Nohienthoi = dr[3].ToString();
             bang.MaKho = dr[4].ToString();
             arr.Add(bang);
         }
         int n = arr.Count;
         if (n == 0) { return null; }
         arrC = new Entities.HienThi_KhachHangTraLai[n];
         for (int i = 0; i < n; i++)
         {
             arrC[i] = (Entities.HienThi_KhachHangTraLai)arr[i];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return arrC;
 }