Exemple #1
0
        public static MonhocInfo GetInfo(int monhoc_ID)
        {
            MonhocInfo retVal = null;
            var        dbConn = new SqlConnection(AppEnv.ConnectionString);
            var        dbCmd  = new SqlCommand("Solart_Monhoc_GetInfo", dbConn)
            {
                CommandType = CommandType.StoredProcedure
            };

            dbCmd.Parameters.AddWithValue("@Monhoc_ID", monhoc_ID);
            try
            {
                dbConn.Open();
                var dr = dbCmd.ExecuteReader();
                if (dr.Read())
                {
                    retVal             = new MonhocInfo();
                    retVal.Monhoc_ID   = ConvertUtility.ToInt32(dr["Monhoc_ID"]);
                    retVal.Monhoc_Name = ConvertUtility.ToString(dr["Monhoc_Name"]);
                }
                if (dr != null)
                {
                    dr.Close();
                }
            }
            finally
            {
                dbConn.Close();
            }
            return(retVal);
        }
Exemple #2
0
        private static MonhocInfo CreateEntityFromReader(IDataReader reader)
        {
            var item = new MonhocInfo();

            try { if (!reader.IsDBNull(reader.GetOrdinal("Monhoc_ID")))
                  {
                      item.Monhoc_ID = ConvertUtility.ToInt32(reader["Monhoc_ID"]);
                  }
            }
            catch { }
            try { if (!reader.IsDBNull(reader.GetOrdinal("Monhoc_Name")))
                  {
                      item.Monhoc_Name = ConvertUtility.ToString(reader["Monhoc_Name"]);
                  }
            }
            catch { }
            return(item);
        }
Exemple #3
0
        public static void Update(MonhocInfo monhocInfo)
        {
            var dbConn = new SqlConnection(AppEnv.ConnectionString);
            var dbCmd  = new SqlCommand("Solart_Monhoc_Update", dbConn)
            {
                CommandType = CommandType.StoredProcedure
            };

            dbCmd.Parameters.AddWithValue("@Monhoc_ID", monhocInfo.Monhoc_ID);
            dbCmd.Parameters.AddWithValue("@Monhoc_Name", monhocInfo.Monhoc_Name);
            try
            {
                dbConn.Open();
                dbCmd.ExecuteNonQuery();
            }
            finally
            {
                dbConn.Close();
            }
        }
Exemple #4
0
        public static int Insert(MonhocInfo monhocInfo)
        {
            var dbConn = new SqlConnection(AppEnv.ConnectionString);
            var dbCmd  = new SqlCommand("Solart_Monhoc_Insert", dbConn)
            {
                CommandType = CommandType.StoredProcedure
            };

            dbCmd.Parameters.AddWithValue("@Monhoc_Name", monhocInfo.Monhoc_Name);
            dbCmd.Parameters.AddWithValue("@RETURN_VALUE", SqlDbType.Int).Direction = ParameterDirection.ReturnValue;
            try
            {
                dbConn.Open();
                dbCmd.ExecuteNonQuery();
                return((int)dbCmd.Parameters["@RETURN_VALUE"].Value);
            }
            finally
            {
                dbConn.Close();
            }
        }