private void button1_Click(object sender, EventArgs e) { Hide(); AddTimeTable add = new AddTimeTable(); add.ShowDialog(); Close(); }
private void insertbtn_Click(object sender, EventArgs e) { string id = Login.id; DataGridViewRow dr = dataGridView1.SelectedRows[0]; string subject = dr.Cells[2].Value.ToString(); string sbno = dr.Cells[3].Value.ToString(); string day = dr.Cells[4].Value.ToString(); string time = dr.Cells[5].Value.ToString(); GetConnection(); conn.Open(); MySqlCommand time1 = new MySqlCommand("select time from ttresult where day='" + day + "' and id='" + id + "'", conn); string time_1 = Convert.ToString(time1.ExecuteScalar()); MySqlCommand day1 = new MySqlCommand("select day from ttresult where day='" + day + "' and id='" + id + "'", conn); string day_1 = Convert.ToString(day1.ExecuteScalar()); int a = time_1.IndexOf(time); int b = time.IndexOf(time_1); if (day == day_1) { if (a != -1 || b != -1 || time.Contains(time_1) || time_1.Contains(time)) { MessageBox.Show("시간이 겹치는 수업이 있습니다"); } else { string sql = "insert into ttresult(id, sbno,day,time) values ('" + id + "','" + sbno + "','" + day + "','" + time + "')"; MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.ExecuteNonQuery(); MessageBox.Show("'" + subject + "'이/가 추가되었습니다."); } } else { string sql = "insert into ttresult(id, sbno,day,time) values ('" + id + "','" + sbno + "','" + day + "','" + time + "')"; MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.ExecuteNonQuery(); MessageBox.Show("'" + subject + "'이/가 추가되었습니다."); } conn.Close(); this.Hide(); AddTimeTable add = new AddTimeTable(); add.ShowDialog(); this.Close(); }
private void deletebtn_Click(object sender, EventArgs e) { GetConnection(); string id = Login.id; DataGridViewRow dr = dataGridView2.SelectedRows[0]; string sbno = dr.Cells[3].Value.ToString(); string sql = "delete from ttresult where id='" + id + "' and sbno='" + sbno + "'"; MySqlCommand cmd = new MySqlCommand(sql, conn); conn.Open(); cmd.ExecuteNonQuery(); MySqlCommand Sub = new MySqlCommand(" select subject from timetable where sbno='" + sbno + "'", conn); string subject = Convert.ToString(Sub.ExecuteScalar()); conn.Close(); MessageBox.Show("'" + subject + "'이/가 삭제되었습니다."); this.Hide(); AddTimeTable add = new AddTimeTable(); add.ShowDialog(); this.Close(); }