Example #1
0
        private void Add()
        {
            //Add row
            DTO.DataRow row = new DTO.DataRow();
            row.ColumnStructure = this.table.ColumnStructure;
            foreach (Control ctrl in this.pnlValues.Controls)
            {
                ColumnStructure cs = (ColumnStructure)ctrl.Tag;
                if (ctrl is TextBox)
                {
                    row.Attributes.Add(new Flag(cs.ColumnName, ctrl.Text, cs.DataType));
                }
                else if (ctrl is ComboBox)
                {
                    string value = string.Empty;
                    if (!string.IsNullOrEmpty(ctrl.Text))
                    {
                        value = ctrl.Text.Split(';')[0];
                    }
                    row.Attributes.Add(new Flag(cs.ColumnName, value, cs.DataType));
                }
            }
            this.table.DataRows.Add(row);

            //Clear fields
            if (this.ctrlToIncrement != null)
            {
                Int32.TryParse(this.ctrlToIncrement.Text, out int id);

                this.ClearFields();
                this.ctrlToIncrement.Text = (id + 1).ToString();
            }
            else
            {
                this.ClearFields();
            }

            //Generate query
            this.txtQuery.Text = InsertStatement.GetQuery(table);
        }