public static KhoHang getFromReader(IDataReader rd) { var Item = new KhoHang(); if (rd.FieldExists("KH_ID")) { Item.ID = (Guid)(rd["KH_ID"]); } if (rd.FieldExists("KH_Ten")) { Item.Ten = (String)(rd["KH_Ten"]); } if (rd.FieldExists("KH_DiaChi")) { Item.DiaChi = (String)(rd["KH_DiaChi"]); } if (rd.FieldExists("KH_Ma")) { Item.Ma = (String)(rd["KH_Ma"]); } if (rd.FieldExists("KV_Ten")) { Item.KV_Ten = (String)(rd["KV_Ten"]); } if (rd.FieldExists("KV_SoLuong")) { Item.SoLuong = (Int32)(rd["SoLuong"]); } if (rd.FieldExists("KH_KV_ID")) { Item.KV_ID = (Guid)(rd["KH_KV_ID"]); } return(Item); }
public static KhoHang SelectById(Guid KH_ID) { var Item = new KhoHang(); var obj = new SqlParameter[1]; obj[0] = new SqlParameter("KH_ID", KH_ID); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblKhoHang_Select_SelectById_linhnx", obj)) { while (rd.Read()) { Item = getFromReader(rd); } } return(Item); }
public static KhoHang Update(KhoHang item) { var Item = new KhoHang(); var obj = new SqlParameter[5]; obj[0] = new SqlParameter("KH_ID", item.ID); obj[1] = new SqlParameter("KH_Ten", item.Ten); obj[2] = new SqlParameter("KH_DiaChi", item.DiaChi); obj[3] = new SqlParameter("KH_Ma", item.Ma); obj[4] = new SqlParameter("KH_KV_ID", item.KV_ID); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblKhoHang_Update_UpdateNormal_linhnx", obj)) { while (rd.Read()) { Item = getFromReader(rd); } } return(Item); }