コード例 #1
0
        public void SetSQlData(string stringConnection, StorageDiscriptionEvent test)
        {
            SqlConnection conn = new SqlConnection(stringConnection);
            conn.Open();
            Logger logger = LogManager.GetCurrentClassLogger();
            logger.Info("Inside");

            string strInsert = @"insert into Person (Age_Limit,Location_Event,Person,Access_Level,Discription_Events,Time_Begin,Time_End)
            values('@_Age_Limit','@_Location_Event','@_Person','@_Access_Level','@_Discription_Events','@_Time_Begin','@_Time_End')";
            SqlCommand cmd = new SqlCommand(strInsert, conn);
            cmd.Parameters.AddWithValue("@_Age_Limit", test.Age_Limit);
            cmd.Parameters.AddWithValue("@_Location_Event", test.Location_Event);
            cmd.Parameters.AddWithValue("@_Person", test.Person);
            cmd.Parameters.AddWithValue("@_Access_Level", test.Access_Level);
            cmd.Parameters.AddWithValue("@_Discription_Events", test.Discription_Events);
            cmd.Parameters.AddWithValue("@_Time_Begin", test.Time_Begin);
            cmd.Parameters.AddWithValue("@_Time_End", test.Time_End);
            cmd.ExecuteNonQuery();
            if (conn != null)
            {
                conn.Close();
                conn.Dispose();
            }
            else
            {
                logger.Warn("SQlConnection not close");
            }
        }
コード例 #2
0
        public StorageDiscriptionEvent GetSQlData(string stringConnection, int _Id)
        {
            SqlConnection conn = new SqlConnection(stringConnection);
            conn.Open();
            Logger logger = LogManager.GetCurrentClassLogger();
            logger.Info("Inside");

            string sqlGetCmd = @"select Age_Limit,Location_Event,Person,Access_Level,Discription_Events,Time_Begin,Time_End
            from DiscriptionEvent where IdDiscriptionEvent = @_IdDiscriptionEvent";
            StorageDiscriptionEvent discriptionEvent = new StorageDiscriptionEvent();
            SqlCommand cmd = new SqlCommand(sqlGetCmd, conn);
            cmd.Parameters.AddWithValue("_IdDiscriptionEvent", _Id);
            SqlDataReader rdb = cmd.ExecuteReader();
            rdb.Read();
            discriptionEvent.IdDiscriptionEvent = _Id;
            discriptionEvent.Age_Limit = (int)GetUnoSQlValue(rdb,"Age_Limit");
            discriptionEvent.Location_Event = (int)GetUnoSQlValue(rdb,"Location_Event");
            discriptionEvent.Person = (int)GetUnoSQlValue(rdb,"Person");
            discriptionEvent.Access_Level = (int)GetUnoSQlValue(rdb,"Access_Level");
            discriptionEvent.Discription_Events = (string)GetUnoSQlValue(rdb,"Discription_Events");
            discriptionEvent.Time_Begin = (DateTime)GetUnoSQlValue(rdb,"Time_Begin");
            //discriptionEvent.Time_Begin = rdb.GetDateTime(rdb.GetOrdinal("Time_Begin"));
            discriptionEvent.Time_End = (DateTime)GetUnoSQlValue(rdb,"Time_End");
            if (conn != null)
            {
                conn.Close();
                conn.Dispose();
            }
            else
            {
                logger.Warn("SQlConnection not close");
            }
            if (rdb != null)
            {
                rdb.Close();
            }
            return discriptionEvent;
        }