예제 #1
0
        public bool create(DB_objects.Operation o, DB_objects.Attribute a)
        {
            SqlCommand comm = new SqlCommand("INSERT INTO operation_attributes(type, language, value) VALUES(@type, @language, @value)", myConnection);

            comm.Parameters.Add("@type", a.type);
            comm.Parameters.Add("@language", a.language);
            comm.Parameters.Add("@value", a.value);

            comm = new SqlCommand("SELECT attribute_code FROM operation_attributes WHERE type LIKE @type AND language LIKE @language AND value LIKE @value ORDER BY attribute_code DESC", myConnection);
            comm.Parameters.Add("@type", a.type);
            comm.Parameters.Add("@language", a.language);
            comm.Parameters.Add("@value", a.value);
            SqlDataReader reader = comm.ExecuteReader();
            int           id     = -1;

            reader.Read();
            id = Int32.Parse(reader[0].ToString());
            if (id == -1)
            {
                return(false);
            }
            reader.Close();

            comm = new SqlCommand("INSERT INTO operation_contains(attribute_code, operation_code) VALUES(@attribute_code, @operation_code)", myConnection);
            comm.Parameters.Add("@attribute_code", id);
            comm.Parameters.Add("@operation_code", o.operation_code);
            return(comm.ExecuteNonQuery() == 1);
        }
예제 #2
0
        public List <DB_objects.Operation> getAvailable(int check_code)
        {
            List <DB_objects.Operation> result = new List <DB_objects.Operation>();
            SqlCommand comm = new SqlCommand("SELECT operation_code, name, description " +
                                             "FROM operation " +
                                             "WHERE operation_code NOT IN (SELECT operation_code " +
                                             "FROM check_operations " +
                                             "WHERE check_code=@check_code)", myConnection);

            comm.Parameters.Add("@check_code", check_code);

            SqlDataReader reader = comm.ExecuteReader();

            DB_objects.Operation o;
            while (reader.Read())
            {
                o = new DB_objects.Operation();
                o.operation_code = Int32.Parse(reader[0].ToString());
                o.name           = reader[1].ToString();
                o.description    = reader[2].ToString();
                result.Add(o);
            }
            reader.Close();
            return(result);
        }
예제 #3
0
        public SortedList <int, DB_objects.Operation> getOperations(int check_code)
        {
            SortedList <int, DB_objects.Operation> result = new SortedList <int, DB_objects.Operation>();
            SqlCommand comm = new SqlCommand("SELECT o.operation_code, o.name, o.description, t.[order] " +
                                             "FROM operation o, (SELECT operation_code, [order] " +
                                             "FROM check_operations " +
                                             "WHERE check_code=@check_code) t " +
                                             "WHERE o.operation_code=t.operation_code", myConnection);

            comm.Parameters.Add("@check_code", check_code);

            SqlDataReader reader = comm.ExecuteReader();

            DB_objects.Operation o;
            while (reader.Read())
            {
                o = new DB_objects.Operation();
                o.operation_code = Int32.Parse(reader[0].ToString());
                o.name           = reader[1].ToString();
                o.description    = reader[2].ToString();
                result.Add(Int32.Parse(reader[3].ToString()), o);
            }
            reader.Close();
            return(result);
        }
예제 #4
0
        public void delete(DB_objects.Operation o)
        {
            SqlCommand comm = new SqlCommand("DELETE FROM operation WHERE operation_code=@operation_code", myConnection);

            comm.Parameters.Add("@operation_code", o.operation_code);
            comm.ExecuteNonQuery();
        }
예제 #5
0
        public void create(DB_objects.Operation o)
        {
            SqlCommand comm = new SqlCommand("INSERT INTO operation(name, description) VALUES(@name, @description)", myConnection);

            comm.Parameters.Add("@name", o.name);
            comm.Parameters.Add("@description", o.description);
        }
예제 #6
0
        public bool update(DB_objects.Operation o)
        {
            SqlCommand comm = new SqlCommand("UPDATE operation SET name=@name, description=@description WHERE operation_code=@operation_code", myConnection);

            comm.Parameters.Add("@name", o.name);
            comm.Parameters.Add("@description", o.description);
            comm.Parameters.Add("@operation_code", o.operation_code);
            return(comm.ExecuteNonQuery() == 1);
        }
예제 #7
0
        private static void fillOperations(string language, SqlConnection connection)
        {
            SqlCommand cmd = new SqlCommand("sp_connectOperation", connection);

            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add("@selectedLanguage", System.Data.SqlDbType.NVarChar).Value = language;
            SqlDataReader reader = cmd.ExecuteReader();

            DB_objects.Operation o;
            while (reader.Read())
            {
                o = new DB_objects.Operation(reader[1].ToString(), reader[2].ToString());
                o.addAttribute(reader[3].ToString(), reader[4].ToString(), reader[5].ToString());
                operations[reader[0].ToString()] = o;
            }
            reader.Close();
        }
예제 #8
0
        public List <DB_objects.Operation> retrieve()
        {
            List <DB_objects.Operation> result = new List <DB_objects.Operation>();
            SqlCommand comm = new SqlCommand("SELECT operation_code, name, description " +
                                             "FROM operation ", myConnection);
            SqlDataReader reader = comm.ExecuteReader();

            DB_objects.Operation o;
            while (reader.Read())
            {
                o = new DB_objects.Operation();
                o.operation_code = Int32.Parse(reader[0].ToString());
                o.name           = reader[1].ToString();
                o.description    = reader[2].ToString();
                result.Add(o);
            }
            reader.Close();
            return(result);
        }