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