Esempio n. 1
0
 private Guid Create(GiangVien item)
 {
     GiangVienDAL itemDAL=new GiangVienDAL();
     item.GiangVienGuid = Guid.NewGuid();
     int rowsAffected = itemDAL.Create(item);
     return rowsAffected > 0 ? item.GiangVienGuid : Guid.Empty;
 }
Esempio n. 2
0
        /// <summary>
        /// Inserts a row in the gv_GiangVien table. Returns rows affected count.
        /// </summary>
        /// <returns>int</returns>
        public int Create(GiangVien item)
        {
            SqlParameterHelper sph = new SqlParameterHelper(ConnectionStringStatic.GetWriteConnectionString(), "gv_GiangVien_Insert", 3);
            sph.DefineSqlParameter("@GiangVienGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, item.GiangVienGuid);
            sph.DefineSqlParameter("@GiangvienName", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.GiangvienName);
            sph.DefineSqlParameter("@GiangVienID", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.GiangVienID);

            int rowsAffected = sph.ExecuteNonQuery();
            return rowsAffected;
        }
Esempio n. 3
0
        public static GiangVien PopulateFromReader(IDataReader reader)
        {
            GiangVien item = new GiangVien();
            if(reader.Read())
            {
                  try{item.GiangVienGuid = new Guid(reader["GiangVienGuid"].ToString());}catch{}
                      item.GiangvienName = reader["GiangvienName"].ToString();
                      item.GiangVienID = reader["GiangVienID"].ToString();
            }

            return item;
        }
Esempio n. 4
0
 public static List<GiangVien> LoadListFromReader(IDataReader reader)
 {
     List<GiangVien> items = new List<GiangVien>();
     try
     {
         while (reader.Read())
         {
             GiangVien item = new GiangVien();
                 try{item.GiangVienGuid = new Guid(reader["GiangVienGuid"].ToString());}catch{}
                     item.GiangvienName = reader["GiangvienName"].ToString();
                     item.GiangVienID = reader["GiangVienID"].ToString();
             items.Add(item);
         }
     }
     catch
     {}
     finally
     {
         reader.Close();
     }
     return items;
 }
Esempio n. 5
0
 private Guid Update(GiangVien item)
 {
     GiangVienDAL itemDAL=new GiangVienDAL();
     return itemDAL.Update(item) ? item.GiangVienGuid : Guid.Empty;
 }
Esempio n. 6
0
 // <summary>
 /// Saves this instance of GiangVien. Returns a new Guid on success.
 /// </summary>
 public Guid Save(GiangVien item)
 {
     if (item.GiangVienGuid == Guid.Empty)
         return Create(item);
     return Update(item);
 }