コード例 #1
0
        public static KhoahocCosoInfo GetInfo(int khoahoc_ID, int cosoId)
        {
            KhoahocCosoInfo retVal = null;
            var             dbConn = new SqlConnection(AppEnv.ConnectionString);
            var             dbCmd  = new SqlCommand("Solart_KhoahocCoso_GetInfo", dbConn)
            {
                CommandType = CommandType.StoredProcedure
            };

            dbCmd.Parameters.AddWithValue("@Khoahoc_ID", khoahoc_ID);
            dbCmd.Parameters.AddWithValue("@Coso_ID", cosoId);
            try
            {
                dbConn.Open();
                var dr = dbCmd.ExecuteReader();
                if (dr.Read())
                {
                    retVal            = new KhoahocCosoInfo();
                    retVal.Khoahoc_ID = ConvertUtility.ToInt32(dr["Khoahoc_ID"]);
                    retVal.Coso_ID    = ConvertUtility.ToInt32(dr["Coso_ID"]);
                }
                if (dr != null)
                {
                    dr.Close();
                }
            }
            finally
            {
                dbConn.Close();
            }
            return(retVal);
        }
コード例 #2
0
        private static KhoahocCosoInfo CreateEntityFromReader(IDataReader reader)
        {
            var item = new KhoahocCosoInfo();

            try { if (!reader.IsDBNull(reader.GetOrdinal("Khoahoc_ID")))
                  {
                      item.Khoahoc_ID = ConvertUtility.ToInt32(reader["Khoahoc_ID"]);
                  }
            }
            catch { }
            try { if (!reader.IsDBNull(reader.GetOrdinal("Coso_ID")))
                  {
                      item.Coso_ID = ConvertUtility.ToInt32(reader["Coso_ID"]);
                  }
            }
            catch { }
            return(item);
        }
コード例 #3
0
        public static void Update(KhoahocCosoInfo khoahocCosoInfo)
        {
            var dbConn = new SqlConnection(AppEnv.ConnectionString);
            var dbCmd  = new SqlCommand("Solart_KhoahocCoso_Update", dbConn)
            {
                CommandType = CommandType.StoredProcedure
            };

            dbCmd.Parameters.AddWithValue("@Khoahoc_ID", khoahocCosoInfo.Khoahoc_ID);
            dbCmd.Parameters.AddWithValue("@Coso_ID", khoahocCosoInfo.Coso_ID);
            try
            {
                dbConn.Open();
                dbCmd.ExecuteNonQuery();
            }
            finally
            {
                dbConn.Close();
            }
        }
コード例 #4
0
        public static int Insert(KhoahocCosoInfo khoahocCosoInfo)
        {
            var dbConn = new SqlConnection(AppEnv.ConnectionString);
            var dbCmd  = new SqlCommand("Solart_KhoahocCoso_Insert", dbConn)
            {
                CommandType = CommandType.StoredProcedure
            };

            dbCmd.Parameters.AddWithValue("@Khoahoc_ID", khoahocCosoInfo.Khoahoc_ID);
            dbCmd.Parameters.AddWithValue("@Coso_ID", khoahocCosoInfo.Coso_ID);
            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();
            }
        }