public Main()
        {
            InitializeComponent();
            dbc = new DatabaseController();

            collectionPanel.Hide();
            updateCollectionList();

            if (collectionList.Count() > 0)
            {
                Button defaultButton = flowLayoutPanel1.Controls[0] as Button;
                selectedCollection = collectionList.First();
                updateItemList(selectedCollection);
            }
        }
        public AddCollection(Main mainForm)
        {
            InitializeComponent();

            dbc           = new DatabaseController();
            this.mainForm = mainForm;

            comboBox1.Items.Add("text");
            comboBox1.Items.Add("number");
            comboBox1.Items.Add("date");

            comboBox1.SelectedItem = "text";

            listBox1.DisplayMember = "desc";
        }
Example #3
0
        public EditItem(Main mainForm, CustomCollection customCol, DataGridViewRow selectedRow)
        {
            InitializeComponent();
            dbc = new DatabaseController();

            this.mainForm    = mainForm;
            this.customCol   = customCol;
            this.selectedRow = selectedRow;

            tableLayoutPanel1.Controls.Clear();

            tableLayoutPanel1.ColumnStyles.Clear();
            tableLayoutPanel1.RowStyles.Clear();

            tableLayoutPanel1.ColumnCount = 2;
            tableLayoutPanel1.RowCount    = customCol.attributes.Count;


            tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));
            tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize));

            for (int y = 0; y < customCol.attributes.Count; y++)
            {
                tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F));

                Label fieldName = new Label();
                fieldName.Text      = customCol.attributes[y].name;
                fieldName.TextAlign = ContentAlignment.MiddleRight;
                fieldName.Anchor    = (AnchorStyles.Left | AnchorStyles.Right);
                tableLayoutPanel1.Controls.Add(fieldName, 0, y);



                if (customCol.attributes[y].type == "text")
                {
                    TextBox fieldTextBox = new TextBox();
                    fieldTextBox.Text   = selectedRow.Cells[customCol.attributes[y].name].Value.ToString();
                    fieldTextBox.Tag    = customCol.attributes[y].name;
                    fieldTextBox.Anchor = (AnchorStyles.Left | AnchorStyles.Right);
                    tableLayoutPanel1.Controls.Add(fieldTextBox, 1, y);
                }
                else if (customCol.attributes[y].type == "number")
                {
                    TextBox fieldTextBox = new TextBox();
                    fieldTextBox.Text   = selectedRow.Cells[customCol.attributes[y].name].Value.ToString();
                    fieldTextBox.Tag    = customCol.attributes[y].name;
                    fieldTextBox.Anchor = (AnchorStyles.Left | AnchorStyles.Right);
                    tableLayoutPanel1.Controls.Add(fieldTextBox, 1, y);
                }
                else if (customCol.attributes[y].type == "date")
                {
                    DateTimePicker fieldDate = new DateTimePicker();

                    fieldDate.Text = selectedRow.Cells[customCol.attributes[y].name].Value.ToString();

                    fieldDate.Tag    = customCol.attributes[y].name;
                    fieldDate.Anchor = (AnchorStyles.Left | AnchorStyles.Right);
                    tableLayoutPanel1.Controls.Add(fieldDate, 1, y);
                }
            }

            tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F));
            tableLayoutPanel1.Controls.Add(new Label(), 0, customCol.attributes.Count);
            tableLayoutPanel1.Controls.Add(new Label(), 1, customCol.attributes.Count);
        }