예제 #1
0
        public static List <Eqpdatatype> load(string query)
        {
            List <Eqpdatatype> list = new List <Eqpdatatype>();
            MySqlDataReader    rd   = null;

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

                rd = cmd.ExecuteReader();

                while (rd.Read())
                {
                    Eqpdatatype obj = new Eqpdatatype();
                    obj.ed_type = Convert.ToInt32(rd["ed_type"].ToString());   // Primary
                    obj.ed_name = rd["ed_name"].ToString();
                    obj.ed_desc = rd["ed_desc"].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 Eqpdatatype load(int ed_type)
        {
            MySqlDataReader rd = null;

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

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

                while (rd.Read())
                {
                    obj.ed_type = Convert.ToInt32(rd["ed_type"].ToString());   // Primary
                    obj.ed_name = rd["ed_name"].ToString();
                    obj.ed_desc = rd["ed_desc"].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);
        }