private void btnok_Click(object sender, EventArgs e) { Groupform ChangeGRPfrm = (Groupform)this.Owner; string id = Convert.ToString(ChangeGRPfrm.dgvgroup.Rows[ChangeGRPfrm.dgvgroup.CurrentRow.Index].Cells["id"].Value); string txtQueryChangeClass = "UPDATE groupt SET name='" + txtnamegrp.Text + "' WHERE id='" + id + "'"; _SQl.SQL_Query(txtQueryChangeClass); this.Close(); ChangeGRPfrm.load_group(); }
private void btnok_Click(object sender, EventArgs e) { Groupform NewGRPsfrm = (Groupform)this.Owner; DataTable DTngrp = _SQl.ExecuteSQL("SELECT max(id) FROM Groupt"); if (DTngrp.Rows[0][0].ToString() == "") { int id_grpn = 1; string txtQueryNewClassAdd = "INSERT INTO groupt VALUES('" + id_grpn + "','" + txtnamegrp.Text + "')"; _SQl.SQL_Query(txtQueryNewClassAdd); } else { int id_grpn = Convert.ToInt32(DTngrp.Rows[0][0].ToString()) + 1; string txtQueryNewClassAdd = "INSERT INTO groupt VALUES('" + id_grpn + "','" + txtnamegrp.Text + "')"; _SQl.SQL_Query(txtQueryNewClassAdd); } this.Close(); NewGRPsfrm.load_group(); }