Пример #1
0
        public static List <Secsdatatype> load(string query)
        {
            List <Secsdatatype> list = new List <Secsdatatype>();
            MySqlDataReader     rd   = null;

            try
            {
                MySqlConnection conn = Main.getConnection();
                if (conn == null)
                {
                    return(list);
                }
                if (query == null || query.Length == 0)
                {
                    query = "select * from secsdatatype";
                }
                Log.Info("Query: " + query);
                MySqlCommand cmd = new MySqlCommand(query, conn);

                rd = cmd.ExecuteReader();

                while (rd.Read())
                {
                    Secsdatatype obj = new Secsdatatype();
                    obj.sdt_id   = Convert.ToInt32(rd["sdt_id"].ToString()); // Primary
                    obj.sdt_name = rd["sdt_name"].ToString();
                    obj.sdt_type = Convert.ToInt32(rd["sdt_type"].ToString());
                    obj.sts      = Convert.ToInt32(rd["sts"].ToString());
                    list.Add(obj);
                }
                rd.Close();
            }
            catch (MySqlException e)
            {
                Log.Error("Error: " + e.Message);
            }
            finally
            {
                if (rd != null)
                {
                    rd.Close();
                }
            }
            return(list);
        }
Пример #2
0
        public static Secsdatatype load(int sdt_id)
        {
            MySqlDataReader rd = null;

            try
            {
                MySqlConnection conn = Main.getConnection();
                if (conn == null)
                {
                    return(null);
                }
                string query = "select * from secsdatatype where sdt_id='" + sdt_id + "'";
                Log.Info("Query: " + query);
                MySqlCommand cmd = new MySqlCommand(query, conn);

                rd = cmd.ExecuteReader();
                Secsdatatype obj = new Secsdatatype();

                while (rd.Read())
                {
                    obj.sdt_id   = Convert.ToInt32(rd["sdt_id"].ToString()); // Primary
                    obj.sdt_name = rd["sdt_name"].ToString();
                    obj.sdt_type = Convert.ToInt32(rd["sdt_type"].ToString());
                    obj.sts      = Convert.ToInt32(rd["sts"].ToString());
                    break;
                }
                rd.Close();

                return(obj);
            }
            catch (MySqlException e)
            {
                Log.Error("Query: " + e.Message);
            }
            finally
            {
                if (rd != null)
                {
                    rd.Close();
                }
            }
            return(null);
        }