コード例 #1
0
        private void btnOdustani_Click(object sender, EventArgs e)
        {
            NewTableController controller   = new NewTableController();
            LoadProjects       loadProjects = new LoadProjects();

            if (brojAtributa < 1 || !controller.CheckPrimaryKey(dirPath1))
            {
                controller.DeleteTable(dirPath1);
                loadProjects.DeleteTableDependece(projectName1, tableName1 + ".dat");
            }
            this.Close();
        }
コード例 #2
0
        private void btnSpremi_Click(object sender, EventArgs e)
        {
            NewTableController controller   = new NewTableController();
            LoadProjects       loadProjects = new LoadProjects();

            if (brojAtributa < 1)
            {
                controller.DeleteTable(dirPath1);
                loadProjects.DeleteTableDependece(projectName1, tableName1 + ".dat");
                this.Close();
            }
            else
            {
                if (!controller.CheckPrimaryKey(dirPath1))
                {
                    MessageBox.Show("There is no primary key");
                }
                else
                {
                    this.Close();
                }
            }
        }
コード例 #3
0
        private void btnUnosStupca_Click(object sender, EventArgs e)
        {
            NewTableController kontroler = new NewTableController();
            DataTypes          dataTypes = new DataTypes();

            if (kontroler.CheckForSameAtributes(dirPath1, txtName.Text))
            {
                if (kontroler.CheckTextInput(txtName.Text) && kontroler.CheckDataType(txtType.Text))
                {
                    if (chcBoxNotNull.Checked == false && chcoxPrimaryKey.Checked == true)
                    {
                        MessageBox.Show("Primary key can not be null!");
                    }
                    else if ((kontroler.CheckPrimaryKey(dirPath1) && chcoxPrimaryKey.Checked == true))
                    {
                        MessageBox.Show("Primary key already exists!");
                    }
                    else if (kontroler.CheckPrimaryKeyType(txtType.Text) && chcoxPrimaryKey.Checked == true)
                    {
                        MessageBox.Show("Primary key is wrong type!");
                    }
                    else
                    {
                        dgvStupci.Rows.Add(1);
                        dgvStupci.Rows[brojAtributa].Cells[0].Value = kontroler.ProvjeraImena(txtName.Text);
                        dgvStupci.Rows[brojAtributa].Cells[1].Value = txtType.Text;
                        dgvStupci.Rows[brojAtributa].Cells[2].Value = chcboxAutoInc.Checked;
                        dgvStupci.Rows[brojAtributa].Cells[3].Value = chcBoxNotNull.Checked;
                        dgvStupci.Rows[brojAtributa].Cells[4].Value = chcoxPrimaryKey.Checked;
                        brojAtributa++;
                        string foreingName = string.Empty;
                        foreingName += txtForeignName.Text;
                        kontroler.InsertDataIntoTextFile(dirPath1, dgvStupci.NewRowIndex, kontroler.ProvjeraImena(txtName.Text), txtType.Text, chcBoxNotNull.Checked, chcboxAutoInc.Checked, chcboxUnique.Checked, chcoxPrimaryKey.Checked, foreingName);
                        cmbColumnAtribut.DataSource         = kontroler.ListOfTableAtributesForPrimaryKey(dirPath1);
                        cmbCurrentTableAtributes.DataSource = kontroler.ListOfAtributesInCurrentTable(dirPath1);
                        if (chcoxPrimaryKey.Checked)
                        {
                            dgvKeys.Rows.Add(1);
                            dgvKeys.Rows[rowIndex].Cells[0].Value = kontroler.ProvjeraImena(txtName.Text);
                            dgvKeys.Rows[rowIndex].Cells[1].Value = txtType.Text;
                            dgvKeys.Rows[rowIndex].Cells[2].Value = true;
                            rowIndex++;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Wrong input");
                }
            }
            else
            {
                MessageBox.Show("Attribute already exists");
            }
            //Reset fields
            txtName.Clear();
            txtType.Clear();
            chcboxAutoInc.Checked   = false;
            chcoxPrimaryKey.Checked = false;
            chcBoxNotNull.Checked   = false;
            chcboxUnique.Checked    = false;
        }