Beispiel #1
0
        public static void InsertActionwordCurrentRow(Actionword aw)
        {
            var sh = (Excel.Worksheet)application.ActiveSheet;
            var cur = (Excel.Range)application.ActiveCell;
            long c;

            if (!IsTestdataSheet(sh)) return;

            long row = cur.Row;
            string cont_str = "&Cont";

            sh.Rows[row].Insert();
            sh.Rows[row].Insert();
            row++;
            sh.Cells[row-1, 1].Style = "actionword";
            sh.Cells[row, 1].Style = "actionword";

            sh.Cells[row, 1].Value = aw.Name;
            sh.Cells[row, 1].Activate();

            long maxnr = TFDatabase.Active.Settings.ArgumentsPerRow + 1;

            c = 2;
            foreach (var arg in aw.Arguments)
            {

                sh.Cells[row - 1, c].Value = arg.Name;
                sh.Cells[row - 1, c].Style = "argument";

                sh.Cells[row, c].Style = "testdata";
                sh.Cells[row, c].Value = arg.DefaultValue;

                c++;
                if (c == maxnr)
                {
                    sh.Cells[row, c].Value = cont_str;
                    sh.Cells[row, c].Style = "testdata";

                    c = 2;

                    row++;
                    sh.Rows[row].Insert();
                    sh.Cells[row, 1].Style = "actionword";
                    row++;
                    sh.Rows[row].Insert();
                    sh.Cells[row, 1].Style = "actionword";
                    sh.Cells[row, 1].Value = cont_str;
                }
            }
        }
 internal static Nullable<bool> ShowEditActionword(Actionword aw)
 {
     var dlg = new EditActionword();
     dlg.CurrentActionword = aw;
     return dlg.ShowDialog();
 }
Beispiel #3
0
 public static Actionword New(Element element, string name)
 {
     var actionword = new Actionword() {  Element = element, Name = name };
     actionword._isnew = true;
     return actionword;
 }
Beispiel #4
0
        public static Argument New(Actionword actionword, string name)
        {
            var argument = new Argument();
            var conn = TFDatabase.Active.Connection;

            int arg_nr = actionword.Arguments.Count + 2;

            var cmd = new OleDbCommand("INSERT INTO [argument] ([actionword_id], [argument_number], [name]) VALUES (@Parent, @Number, @Name)", conn);

            cmd.Parameters.AddWithValue("@Parent", actionword.ID);
            cmd.Parameters.AddWithValue("@Number", arg_nr);
            cmd.Parameters.AddWithValue("@Name", name);
            cmd.ExecuteNonQuery();

            cmd = new OleDbCommand("SELECT @@IDENTITY AS IDVal", conn);
            object o = cmd.ExecuteScalar();

            var id = Convert.ToInt32(o.ToString());

            argument.ID = id;
            argument.Name = name;
            argument.Number = arg_nr;
            argument.Actionword = actionword;
            return argument;
        }
Beispiel #5
0
        public static List<Actionword> GetList(Element element = null)
        {
            var list = new List<Actionword>();
            var conn = TFDatabase.Active.Connection;
            OleDbCommand cmd;

            if (element == null)
            {
                cmd = new OleDbCommand("SELECT * FROM [actionword]", conn);
            }
            else
            {
                cmd = new OleDbCommand("SELECT * FROM [actionword] WHERE [element]=@ID", conn);
                cmd.Parameters.AddWithValue("@ID", element.ID);
            }

            var reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                var aw = new Actionword() {
                    ID = Convert.ToInt32(reader["actionword_ID"].ToString())
                    , Name = reader["actionword"].ToString()
                    , Description = reader["description"].ToString()
                    , Actions = reader["actions"].ToString()
                    , PreCondition = reader["precondition"].ToString()
                    , PostCondition = reader["postcondition"].ToString()
                    , Element = element
                };
                aw.Dirty = false;
                if ( reader["start_screen"]==null )
                    aw.StartScreen = int.Parse(reader["start_screen"].ToString());

                if (reader["end_screen"] == null)
                    aw.EndScreen = int.Parse(reader["end_screen"].ToString());

                list.Add(aw);
            }

            cmd.Dispose();
            return list;
        }