public static TimKiem Insert(SqlConnection con, TimKiem item) { var Item = new TimKiem(); var obj = new SqlParameter[5]; obj[0] = new SqlParameter("TK_ID", item.ID); obj[1] = new SqlParameter("TK_PRowId", item.PRowId); obj[2] = new SqlParameter("TK_Loai", item.Loai); obj[3] = new SqlParameter("TK_NoiDung", item.NoiDung); if (item.NgayTao > DateTime.MinValue) { obj[4] = new SqlParameter("TK_NgayTao", item.NgayTao); } else { obj[4] = new SqlParameter("TK_NgayTao", DBNull.Value); } using (IDataReader rd = SqlHelper.ExecuteReader(con, CommandType.StoredProcedure, "sp_tblTimKiem_Insert_InsertNormal_linhnx", obj)) { while (rd.Read()) { Item = getFromReader(rd); } } return(Item); }
public static TimKiem getFromReader(IDataReader rd) { var Item = new TimKiem(); if (rd.FieldExists("TK_ID")) { Item.ID = (Guid)(rd["TK_ID"]); } if (rd.FieldExists("TK_PRowId")) { Item.PRowId = (Guid)(rd["TK_PRowId"]); } if (rd.FieldExists("TK_Loai")) { Item.Loai = (String)(rd["TK_Loai"]); } if (rd.FieldExists("TK_NoiDung")) { Item.NoiDung = (String)(rd["TK_NoiDung"]); } if (rd.FieldExists("TK_NgayTao")) { Item.NgayTao = (DateTime)(rd["TK_NgayTao"]); } return(Item); }
public static TimKiem SelectById(Guid TK_ID) { var Item = new TimKiem(); var obj = new SqlParameter[1]; obj[0] = new SqlParameter("TK_ID", TK_ID); using (IDataReader rd = SqlHelper.ExecuteReader(DAL.con(), CommandType.StoredProcedure, "sp_tblTimKiem_Select_SelectById_linhnx", obj)) { while (rd.Read()) { Item = getFromReader(rd); } } return(Item); }
public static TimKiem Insert(TimKiem item) { return(Insert(DAL.con(), item)); }