/// <summary>
 /// khoi tao gia tri
 /// </summary>
 public ChiTietKhachHangTraLai()
 {
     dh = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     khachhangtralai = null;
     cn = null;
 }
 /// <summary>
 /// vuong hung =================xu ly don dat hang================
 /// </summary>
 /// <returns></returns>
 public int sp_XuLy_ChiTietKhachHangTraLai(Entities.ChiTietKhachHangTraLai ddh)
 {
     int Trave = 0;
     try
     {
         Sql = new Constants.Sql();
         string sql = Sql.sp_XuLy_ChiTietKhachHangTraLai;
         conn = new Connection();
         cn = conn.openConnection();
         dh = new Constants.ChiTietKhachHangTraLai();
         cmd = new SqlCommand(sql, cn);
         cmd.Parameters.Add(dh.HanhDong, SqlDbType.NVarChar).Value = ddh.Hanhdong;
         cmd.Parameters.Add(dh.MaKhachHangTraLai, SqlDbType.NVarChar).Value = ddh.MaKhachHangTraLai;
         cmd.Parameters.Add(dh.MaHangHoa, SqlDbType.NVarChar).Value = ddh.MaHangHoa;
         cmd.Parameters.Add("TenHangHoa", SqlDbType.NVarChar, 200).Value = ddh.TenHangHoa;
         cmd.Parameters.Add(dh.SoLuong, SqlDbType.Int).Value = ddh.SoLuong;
         cmd.Parameters.Add(dh.PhanTramChietKhau, SqlDbType.Float).Value = ddh.PhanTramChietKhau;
         cmd.Parameters.Add(dh.DonGia,SqlDbType.Float).Value = ddh.DonGia;
         cmd.Parameters.Add(dh.Thue, SqlDbType.Float).Value = ddh.Thue;
         cmd.Parameters.Add(dh.GhiChu, SqlDbType.NVarChar).Value = ddh.GhiChu;
         cmd.Parameters.Add(dh.Deleted, SqlDbType.Bit).Value = ddh.Deleted;
         cmd.Parameters.Add(dh.MaKho, SqlDbType.VarChar).Value = ddh.Makho;
         Trave = cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return Trave;
 }
 /// <summary>
 /// vuong hung =================lay bang DonDatHang================
 /// </summary>
 /// <returns></returns>
 public Entities.ChiTietKhachHangTraLai[] sp_LayBang_ChiTietKhachHangTraLai()
 {
     Entities.ChiTietKhachHangTraLai[] arrC = null;
     try
     {
         dh = new Constants.ChiTietKhachHangTraLai();
         Sql = new Constants.Sql();
         string sql = Sql.sp_LayBang_ChiTietKhachHangTraLai;
         conn = new Connection();
         cn = conn.openConnection();
         cmd = new SqlCommand(sql, cn);
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             khachhangtralai = new Entities.ChiTietKhachHangTraLai();
             khachhangtralai.MaKhachHangTraLai = dr[dh.MaKhachHangTraLai].ToString();
             khachhangtralai.MaHangHoa = dr[dh.MaHangHoa].ToString();
             khachhangtralai.SoLuong = Convert.ToInt32(0+dr[dh.SoLuong].ToString());
             khachhangtralai.PhanTramChietKhau = 0+dr[dh.PhanTramChietKhau].ToString();
             khachhangtralai.DonGia = dr[dh.DonGia].ToString();
             khachhangtralai.Thue = dr[dh.Thue].ToString();
             khachhangtralai.GhiChu = dr[dh.GhiChu].ToString();
             khachhangtralai.Deleted = Convert.ToBoolean(dr[dh.Deleted].ToString());
             arr.Add(khachhangtralai);
         }
         int n = arr.Count;
         if (n == 0) { return null; }
         arrC = new Entities.ChiTietKhachHangTraLai[n];
         for (int i = 0; i < n; i++)
         {
             arrC[i] = (Entities.ChiTietKhachHangTraLai)arr[i];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return arrC;
 }