public void xoaHH(DTO_HH hh)
 {
     try
     {
         sql = "DELETE FROM HANGHOA WHERE MAHH = '" + hh.Mahh + "'";
         conn.Open();
         cmd = new SqlCommand(sql, conn);
         cmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception ex)
     {
     }
 }
 public void capnhatHH(DTO_HH hh)
 {
     try
     {
         sql = "UPDATE HANGHOA SET MANCC = @mancc, TENHH = @tenhh, DONGIA = @dongia WHERE MAHH = '" + hh.Mahh + "'";
         conn.Open();
         cmd = new SqlCommand(sql, conn);
         cmd.Parameters.AddWithValue("@mancc", hh.Mancc);
         cmd.Parameters.AddWithValue("@tenhh", hh.Tenhh);
         cmd.Parameters.AddWithValue("@dongia", hh.Dongia);
         cmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception ex)
     {
     }
 }
 public void themHH(DTO_HH hh)
 {
     try
     {
         sql = "INSERT INTO HANGHOA VALUES (@mancc, @tenhh, @dongia)";
         conn.Open();
         cmd = new SqlCommand(sql, conn);
         cmd.Parameters.AddWithValue("@mancc", hh.Mancc);
         cmd.Parameters.AddWithValue("@tenhh", hh.Tenhh);
         cmd.Parameters.AddWithValue("@dongia", hh.Dongia);
         cmd.ExecuteNonQuery();
         conn.Close();
     }
     catch (Exception ex)
     {
     }
 }
        public List <DTO_HH> autoComplete(DTO_HH hh)
        {
            List <DTO_HH> list = new List <DTO_HH>();

            conn.Open();
            sql = "SELECT TENNCC, MANCC FROM NCC";
            cmd = new SqlCommand(sql, conn);
            SqlDataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                hh.Tenhh = dr[0].ToString();
                hh.Mahh  = int.Parse(dr[1].ToString());
                list.Add(hh);
            }
            conn.Close();
            return(list);
        }
 public List <DTO_HH> auto(DTO_HH hh)
 {
     return(dao.autoComplete(hh));
 }
 public void update(DTO_HH hh)
 {
     dao.capnhatHH(hh);
 }
 public void delete(DTO_HH hh)
 {
     dao.xoaHH(hh);
 }
 public void add(DTO_HH hh)
 {
     dao.themHH(hh);
 }