Beispiel #1
0
 private void btnCreate_Click(object sender, System.EventArgs e) //triggers the create database event
 {
     if (txtPath.Text != "")
     {
         if (File.Exists(txtPath.Text)) //if the database exists, delete it
         {
             File.Delete(txtPath.Text);
         }//creates the database
         clsDataStorage.db     = clsDataStorage.dbe.CreateDatabase(txtPath.Text, LanguageConstants.dbLangGeneral);
         clsDataStorage.status = true;
         MetroMessageBox.Show(this, "Database created with success!", "New database", MessageBoxButtons.OK, MessageBoxIcon.Information);
         MiniAccess.disableMenu(); //disables the create and open menu
         MiniAccess.enableAdd();   //enables the add fields and display menu
         MiniAccess.tsMenuAdd.Enabled = false;
         this.Close();
     }
     else
     {
         MetroMessageBox.Show(this, "Please check the name of the database.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #2
0
        //function to create the table
        private void createTable(MetroGrid dgv)
        {
            bool error = false;                           //check variable

            if (autoIncr < 2)                             //check if there is more than one auto increment field
            {
                foreach (DataGridViewRow row in dgv.Rows) //loops through the datagridview rows
                {
                    if (row.Index != dgv.RowCount - 1)
                    {
                        createField(dgv, row.Index); //creates a field
                    }
                }
                if (unqcount > 1) //if there are more than one unique value, display error
                {
                    MetroMessageBox.Show(this, "This table already contains a field with the property UNIQUE.\nA table can only contain one UNIQUE field.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    error = true;
                }
                if (pricount > 1) //if there are more than one primary value, display error
                {
                    MetroMessageBox.Show(this, "This table already contains a field with the property PRIMARY.\nA table can only contain one PRIMARY field.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    error = true;
                }
                if (!error) //if no error found, then append table
                {
                    clsDataStorage.tableNames.Add(txtTableName.Text);
                    MetroMessageBox.Show(this, "Table : " + txtTableName.Text + " successfully created.");
                    clsDataStorage.db.TableDefs.Append(table);
                    MiniAccess.disableMenu();
                    MiniAccess.enableAdd();
                    MiniAccess.tsMenuOpen.Enabled = false;
                    autoIncr = 0;
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("A table can only contain ONE auto increment value.");
            }
        }