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(); }