Example #1
0
        // Кнопка редактирования отношений
        void ToolStripButton2Click(object sender, EventArgs e)
        {
            RegEdit = true;
            RelationsEdit re = new RelationsEdit();

            re.label1.Text    = "Текущий первичный ключ: " + this.dataGridView1.CurrentRow.Cells[6].Value.ToString();
            re.label2.Text    = "Текущий внешний ключ: " + this.dataGridView1.CurrentRow.Cells[10].Value.ToString();
            re.textBox1.Text  = this.dataGridView1.CurrentRow.Cells[12].Value.ToString();
            re.textBox2.Text  = this.dataGridView1.CurrentRow.Cells[13].Value.ToString();
            re.textBox3.Text  = this.dataGridView1.CurrentRow.Cells[14].Value.ToString();
            re.textBox4.Text  = this.dataGridView1.CurrentRow.Cells[15].Value.ToString();
            re.comboBox1.Text = this.dataGridView1.CurrentRow.Cells[16].Value.ToString();
            re.comboBox2.Text = this.dataGridView1.CurrentRow.Cells[17].Value.ToString();
            re.ShowDialog();
        }
Example #2
0
        // Кнопка добавления отношений
        void ToolStripButton4Click(object sender, EventArgs e)
        {
            int  ispol = 0;
            bool sootv = false;

            for (int i = 0; i < MainForm.Main_Form.my_properties.Length; i++)
            {
                if (MainForm.Main_Form.my_properties[i].ClmnFK == true)
                {
                    ispol++;
                }
            }

            ispol -= this.dataGridView1.Rows.Count;

            if (ispol == 0)
            {
                MessageBox.Show("Коллекция отношений полная.", "Внимание!",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                RelationsEdit re = new RelationsEdit();
                re.dataGridView1.Rows.Clear();
                re.dataGridView2.Rows.Clear();
                for (int i = 0; i < MainForm.Main_Form.my_properties.Length; i++)
                {
                    if (MainForm.Main_Form.my_properties[i].ClmnPK == true)
                    {
                        int nRow = re.dataGridView1.Rows.Add();
                        re.dataGridView1.Rows[nRow].Cells[0].Value =
                            MainForm.Main_Form.my_properties[i].TbNum.ToString();
                        re.dataGridView1.Rows[nRow].Cells[1].Value =
                            MainForm.Main_Form.my_properties[i].ClmnNum.ToString();
                        re.dataGridView1.Rows[nRow].Cells[2].Value =
                            MainForm.Main_Form.my_Tables[MainForm.Main_Form.my_properties[i].TbNum - 1].TbName;
                        re.dataGridView1.Rows[nRow].Cells[3].Value =
                            MainForm.Main_Form.my_Tables[MainForm.Main_Form.my_properties[i].TbNum - 1].TbComment;
                        re.dataGridView1.Rows[nRow].Cells[4].Value =
                            MainForm.Main_Form.my_Columns[MainForm.Main_Form.my_properties[i].ClmnNum - 1].ClmnName;
                        re.dataGridView1.Rows[nRow].Cells[5].Value =
                            MainForm.Main_Form.my_Columns[MainForm.Main_Form.my_properties[i].ClmnNum - 1].ClmnComment;
                    }

                    if (MainForm.Main_Form.my_properties[i].ClmnFK == true)
                    {
                        if (this.dataGridView1.Rows.Count == 0)
                        {
                            int nRow = re.dataGridView2.Rows.Add();
                            re.dataGridView2.Rows[nRow].Cells[0].Value =
                                MainForm.Main_Form.my_properties[i].TbNum.ToString();
                            re.dataGridView2.Rows[nRow].Cells[1].Value =
                                MainForm.Main_Form.my_properties[i].ClmnNum.ToString();
                            re.dataGridView2.Rows[nRow].Cells[2].Value =
                                MainForm.Main_Form.my_Tables[MainForm.Main_Form.my_properties[i].TbNum - 1].TbName;
                            re.dataGridView2.Rows[nRow].Cells[3].Value =
                                MainForm.Main_Form.my_Tables[MainForm.Main_Form.my_properties[i].TbNum - 1].TbComment;
                            re.dataGridView2.Rows[nRow].Cells[4].Value =
                                MainForm.Main_Form.my_Columns[MainForm.Main_Form.my_properties[i].ClmnNum - 1].ClmnName;
                            re.dataGridView2.Rows[nRow].Cells[5].Value =
                                MainForm.Main_Form.my_Columns[MainForm.Main_Form.my_properties[i].ClmnNum - 1].ClmnComment;
                        }
                        else
                        {
                            for (int k = 0; k < this.dataGridView1.Rows.Count; k++)
                            {
                                if (this.dataGridView1.Rows[k].Cells[3].Value.ToString() == MainForm.Main_Form.my_properties[i].ClmnNum.ToString())
                                {
                                    sootv = true;
                                    break;
                                }
                                else
                                {
                                    sootv = false;
                                }
                            }
                            if (!sootv)
                            {
                                int nRow = re.dataGridView2.Rows.Add();
                                re.dataGridView2.Rows[nRow].Cells[0].Value =
                                    MainForm.Main_Form.my_properties[i].TbNum.ToString();
                                re.dataGridView2.Rows[nRow].Cells[1].Value =
                                    MainForm.Main_Form.my_properties[i].ClmnNum.ToString();
                                re.dataGridView2.Rows[nRow].Cells[2].Value =
                                    MainForm.Main_Form.my_Tables[MainForm.Main_Form.my_properties[i].TbNum - 1].TbName;
                                re.dataGridView2.Rows[nRow].Cells[3].Value =
                                    MainForm.Main_Form.my_Tables[MainForm.Main_Form.my_properties[i].TbNum - 1].TbComment;
                                re.dataGridView2.Rows[nRow].Cells[4].Value =
                                    MainForm.Main_Form.my_Columns[MainForm.Main_Form.my_properties[i].ClmnNum - 1].ClmnName;
                                re.dataGridView2.Rows[nRow].Cells[5].Value =
                                    MainForm.Main_Form.my_Columns[MainForm.Main_Form.my_properties[i].ClmnNum - 1].ClmnComment;
                            }
                        }
                    }
                }
                RegEdit = false;
                re.comboBox1.SelectedIndex = 0;
                re.comboBox2.SelectedIndex = 0;
                re.ShowDialog();
            }
        }