/// <summary>
 /// khoi tao gia tri
 /// </summary>
 public ChiTietDonDatHang()
 {
     dh = null;
     Sql = null;
     conn = null;
     cmd = null;
     arr = null;
     dr = null;
     dondathang = null;
     cn = null;
 }
 /// <summary>
 /// vuong hung =================xu ly don dat hang================
 /// </summary>
 /// <returns></returns>
 public int sp_XuLy_ChiTietDonDatHang(Entities.ChiTietDonDatHang ddh)
 {
     int Trave = 0;
     try
     {
         Sql = new Constants.Sql();
         string sql = Sql.sp_XuLy_ChiTietDonDatHang;
         conn = new Connection();
         cn = conn.openConnection();
         dh = new Constants.ChiTietDonDatHang();
         cmd = new SqlCommand(sql, cn);
         cmd.Parameters.Add(dh.HanhDong, SqlDbType.NVarChar, 20).Value = ddh.Hanhdong;
         cmd.Parameters.Add(dh.MaDonDatHang, SqlDbType.NVarChar, 20).Value = ddh.MaDonDatHang;
         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.DonGia, SqlDbType.Float, 20).Value = ddh.DonGia;
         cmd.Parameters.Add(dh.Thue, SqlDbType.Float, 20).Value = ddh.Thue;
         cmd.Parameters.Add(dh.PhanTramChietKhau, SqlDbType.Float, 20).Value = ddh.PhanTramChietKhau;
         cmd.Parameters.Add(dh.GhiChu, SqlDbType.NVarChar).Value = ddh.GhiChu;
         cmd.Parameters.Add(dh.Deleted, SqlDbType.Bit).Value = ddh.Deleted;
         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.ChiTietDonDatHang[] sp_LayBang_ChiTietDonDatHang()
 {
     Entities.ChiTietDonDatHang[] arrC = null;
     try
     {
         dh = new Constants.ChiTietDonDatHang();
         Sql = new Constants.Sql();
         string sql = Sql.sp_LayBang_ChiTietDonDatHang;
         conn = new Connection();
         cn = conn.openConnection();
         cmd = new SqlCommand(sql, cn);
         dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
         arr = new ArrayList();
         while (dr.Read())
         {
             dondathang = new Entities.ChiTietDonDatHang();
             dondathang.MaDonDatHang = dr[dh.MaDonDatHang].ToString();
             dondathang.MaHangHoa = dr[dh.MaHangHoa].ToString();
             dondathang.TenHangHoa = dr["TenHangHoa"].ToString();
             dondathang.SoLuong = int.Parse(0+dr[dh.SoLuong].ToString());
             dondathang.DonGia = Double.Parse(0+dr[dh.DonGia].ToString()).ToString();
             dondathang.Thue = Double.Parse(0 + dr[dh.Thue].ToString()).ToString();
             dondathang.PhanTramChietKhau = Double.Parse(0+dr[dh.PhanTramChietKhau].ToString()).ToString();
             dondathang.GhiChu = ""+dr[dh.GhiChu].ToString();
             dondathang.Deleted = Convert.ToBoolean(dr[dh.Deleted].ToString());
             arr.Add(dondathang);
         }
         int n = arr.Count;
         if (n == 0) { return null; }
         arrC = new Entities.ChiTietDonDatHang[n];
         for (int i = 0; i < n; i++)
         {
             arrC[i] = (Entities.ChiTietDonDatHang)arr[i];
         }
     }
     catch (Exception ex)
     { string s = ex.Message.ToString(); }
     finally
     {
         cmd.Connection.Dispose();
         cn.Close();
         conn.closeConnection();
     }
     return arrC;
 }