Esempio n. 1
0
        static void Main(string[] args)
        {
            Receiver receiver = new Receiver();
            ICommand command1 = new SetNameCommand();
            ICommand command2 = new SetAddressCommand();

            command1.Receiver = receiver;
            command2.Receiver = receiver;
            Invoker invoker = new Invoker();

            invoker.AddCommand(command1);
            invoker.AddCommand(command2);

            CommandManager    manager  = new CommandManager();
            SQLExcute         excute   = new SQLExcute();
            InsertIntoCommand command1 = new InsertIntoCommand(excute, "1");
            InsertIntoCommand command2 = new InsertIntoCommand(excute, "2");

            manager.Execute(command1);
            manager.Execute(command2);

            Console.WriteLine("undo------------");
            manager.Undo();
            manager.Undo();
            Console.WriteLine("redo------------");
            manager.Redo();
            manager.Redo();
        }
Esempio n. 2
0
        public DataTable getRecordsCommand(string query)
        {
            try
            {
                SQLExcute sqlExecute = new SQLExcute();

                DataTable dt = sqlExecute.GetExcuteQuery(query);

                return(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Get records loi");
                return(null);
            }
        }
Esempio n. 3
0
        public bool insertCommand(string query)
        {
            SQLExcute sqlExecute = new SQLExcute();

            return(sqlExecute.InsertExecuteQuery(query));
        }
Esempio n. 4
0
        public Boolean updateCommand(string query)
        {
            SQLExcute sqlExecute = new SQLExcute();

            return(sqlExecute.UpdateExcuteQuery(query));
        }
Esempio n. 5
0
 public InsertIntoCommand(SQLExcute sqlExcute, string id)
 {
     this.sqlExcute = sqlExcute;
     this.id        = id;
 }