private void ChangeClassform_Load(object sender, EventArgs e)
        {
            Classform ChangeClassfrm = (Classform)this.Owner;

            txtnameclass.Text = Convert.ToString(ChangeClassfrm.dgvclass.Rows[ChangeClassfrm.dgvclass.CurrentRow.Index].Cells["name"].Value);
            txtMinMargin.Text = Convert.ToString(ChangeClassfrm.dgvclass.Rows[ChangeClassfrm.dgvclass.CurrentRow.Index].Cells["margin_class"].Value);
        }
        private void btnok_Click(object sender, EventArgs e)
        {
            Classform NewClassfrm = (Classform)this.Owner;

            DataTable DTnclass = _SQl.ExecuteSQL("SELECT max(id) FROM Classt");

            if (txtMinMargin.Text != "" && txtnameclass.Text != "")
            {
                if (DTnclass.Rows[0][0].ToString() == "")
                {
                    int    id_classn           = 1;
                    string txtQueryNewClassAdd = "INSERT INTO Classt VALUES('" + id_classn + "','" + txtnameclass.Text + "'," + txtMinMargin.Text.Replace(',', '.') + ")";
                    _SQl.SQL_Query(txtQueryNewClassAdd);
                }
                else
                {
                    int    id_classn           = Convert.ToInt32(DTnclass.Rows[0][0].ToString()) + 1;
                    string txtQueryNewClassAdd = "INSERT INTO Classt VALUES('" + id_classn + "','" + txtnameclass.Text + "'," + txtMinMargin.Text.Replace(',', '.') + ")";
                    _SQl.SQL_Query(txtQueryNewClassAdd);
                }
            }
            else
            {
                MessageBox.Show("Заполните все поля!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Close();

            NewClassfrm.load_class();
        }
        private void btnok_Click(object sender, EventArgs e)
        {
            Classform ChangeClassfrm = (Classform)this.Owner;
            string    id             = Convert.ToString(ChangeClassfrm.dgvclass.Rows[ChangeClassfrm.dgvclass.CurrentRow.Index].Cells["id"].Value);

            if (txtMinMargin.Text != "" && txtnameclass.Text != "")
            {
                string txtQueryChangeClass = "UPDATE ClassT SET name='" + txtnameclass.Text + "',margin_class=" + txtMinMargin.Text.Replace(',', '.') + " WHERE id='" + id + "'";
                _SQl.SQL_Query(txtQueryChangeClass);
            }
            else
            {
                MessageBox.Show("Заполните все поля!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Close();

            ChangeClassfrm.load_class();
        }
Exemple #4
0
        //private void приемкаToolStripMenuItem_Click(object sender, EventArgs e)
        //{

        //}

        private void классификаторToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // проверяем не запущена ли форма
            for (int x = 0; x < this.MdiChildren.Length; x++)
            {
                if (this.MdiChildren[x].Name == "Classform")
                {
                    this.MdiChildren[x].Focus();
                    return;
                }
            }

            // Запускаем форму если она не запущена
            Form Classform = new Classform();

            Classform.StartPosition = FormStartPosition.CenterScreen;
            //указываем владельца для формы
            Classform.WindowState = FormWindowState.Maximized;
            Classform.MdiParent   = this;    // где containerInstance - это экземпляр контейнера или указатель на MainForm
            Classform.Show();
            AttachAsMDIChild(Classform);
        }