private void DeleteGroup(object sender, EventArgs e) { Messages msg = new Messages(); conn.Open(); iin = TextIIN.Text; if (TextIIN.Text == "") { msg.DataError("Заполните ИИН!"); } else { sql = "UPDATE PERSON SET SOCIAL_GROUP_ID_SOCIAL_GROUP = NULL WHERE PERSON_IIN = '" + iin + "'"; MySqlCommand upd2 = new MySqlCommand(sql, conn); if (upd2.ExecuteNonQuery() == 1) { msg.DropSuccess(); this.Close(); DoctorMode doctorMode = new DoctorMode(did); doctorMode.Show(); conn.Close(); } else { msg.DropSuccess(); conn.Close(); } } }
private void ModifyAssignmen(object sender, EventArgs e) { conn.Close(); Messages msg = new Messages(); conn.Open(); iin = TextIIN.Text; switch (sw) { case 0: sql = "SELECT COUNT(*) " + "FROM PERSON_HAS_ASSIGNMENT INNER JOIN ASSIGNMENT " + "ON PERSON_HAS_ASSIGNMENT.ASSIGNMENT_ID_ASSIGNMENT = ASSIGNMENT.ID_ASSIGNMENT " + "WHERE ASSIGNMENT.ASSIGNMENT_NAME = '" + CBSetAssign.Text + "'" + "AND PERSON_HAS_ASSIGNMENT.PERSON_PERSON_IIN = '" + iin + "'"; MySqlCommand check = new MySqlCommand(sql, conn); COUNT = Convert.ToInt32(check.ExecuteScalar()); if (COUNT == 0) { sql = "INSERT INTO PERSON_HAS_ASSIGNMENT (PERSON_PERSON_IIN, ASSIGNMENT_ID_ASSIGNMENT) " + "VALUES('" + iin + "', (SELECT ID_ASSIGNMENT FROM ASSIGNMENT " + "WHERE ASSIGNMENT_NAME = '" + CBSetAssign.Text + "'))"; MySqlCommand insert = new MySqlCommand(sql, conn); if (insert.ExecuteNonQuery() == 1) { msg.WriteSuccess(); conn.Close(); ChoosePanel.Visible = false; CBSetAssign.Items.Clear(); } else { msg.WriteError(); conn.Close(); } } else { msg.WriteError(); conn.Close(); } break; case 1: sql = "DELETE FROM PERSON_HAS_ASSIGNMENT " + "WHERE ASSIGNMENT_ID_ASSIGNMENT = (SELECT ID_ASSIGNMENT FROM ASSIGNMENT " + "WHERE ASSIGNMENT_NAME = '" + CBSetAssign.Text + "') " + "AND PERSON_PERSON_IIN = '" + iin + "'"; MySqlCommand del = new MySqlCommand(sql, conn); if (del.ExecuteNonQuery() == 1) { msg.DropSuccess(); conn.Close(); ChoosePanel.Visible = false; CBSetAssign.Items.Clear(); } else { msg.DropError(); conn.Close(); } break; } }