예제 #1
0
        public EditWindow(Constants.Tablename_PKs tablename_PKs, List <Util.Header_Datatype> Headers_Datatypes, string[] ItemData)
        {
            InitializeComponent();
            this.tablename_PKs     = tablename_PKs;
            this.Headers_Datatypes = Headers_Datatypes;
            this.oldItemData       = ItemData;
            this.textboxes         = new List <TextBox>();

            controller = new Controller();

            modifiedItem = new Util.ModifiedItem
            {
                TableName          = tablename_PKs.TableName,
                ChangesCount       = 0,
                PrimaryKeysHeaders = tablename_PKs.PrimaryKeys,
                PrimaryKeysValues  = new List <string>(new string[tablename_PKs.PrimaryKeys.Count]),
                DeletedHeaders     = new List <string>(),
                ChangedHeaders     = new List <string>(),
                ChangedValues      = new List <string>()
            };

            //get primary keys values
            modifiedItem = Util.GetPKValues(modifiedItem, Headers_Datatypes, oldItemData);

            Add_Labels_Textboxes();
        }
        public AddWindow(Constants.Tablename_PKs tablename_PKs, List <Util.Header_Datatype> Headers_Datatypes)
        {
            InitializeComponent();
            this.tablename_PKs       = tablename_PKs;
            this.Headers_Datatypes   = Headers_Datatypes;
            this.textboxes           = new List <TextBox>();
            roleComboBox.ItemsSource = new string[] { "admin", "employee", "client" };            //user types

            controller = new Controller();

            addedItem = new Util.ModifiedItem
            {
                TableName          = tablename_PKs.TableName,
                ChangesCount       = 0,
                PrimaryKeysHeaders = tablename_PKs.PrimaryKeys,
                PrimaryKeysValues  = new List <string>(new string[tablename_PKs.PrimaryKeys.Count]),
                ChangedHeaders     = new List <string>(),
                ChangedValues      = new List <string>()
            };

            //if the the table has an associated user
            if (Constants.tablesWithUsers.Contains(tablename_PKs.TableName))
            {
                this.NextButton.Visibility = Visibility.Visible;
            }
            else
            {
                this.CommitNoUserButton.Visibility = Visibility.Visible;
            }

            Add_Labels_Textboxes();
        }
        ///Generic for all tables
        //Open an Edit Window giving them the table name, primary keys, Columns names, data types, and the present selected data (in case of editing)
        private void Edit_Window(List <Util.Header_Datatype> Headers_Datatypes, string[] ItemData, string TableName)
        {
            //get the primary keys of the current table from the Constants class
            Constants.Tablename_PKs tablename_PKs = Util.GetTablePk(TableName);

            EditWindow editwindow = new EditWindow(tablename_PKs, Headers_Datatypes, ItemData);

            // Connects the EmployeeChanged method to the EmployeeChanged event.
            editwindow.RefreshTable += new RefreshDataEventArgs.RefreshDataEventHandler(ItemChanged);

            editwindow.Show();
        }