private void දහමපසලToolStripMenuItem1_Click(object sender, EventArgs e) { Search_Students_By_Dahampasala ssbdp = Search_Students_By_Dahampasala.getInstance(); ssbdp.MdiParent = this; ssbdp.Show(); ssbdp.WindowState = FormWindowState.Maximized; ssbdp.FormBorderStyle = FormBorderStyle.FixedSingle; }
private void edit_student_FormClosed(object sender, FormClosedEventArgs e) { Search_Student ss = Search_Student.getInstance(); Search_Students_By_Dahampasala ssd = Search_Students_By_Dahampasala.getInstance(); ssd.Enabled = true; ssd.updateDatagridview(); ss.updateDatagridview(); ss.Enabled = true; }
public static Search_Students_By_Dahampasala getInstance() { if (inst6 == null || inst6.IsDisposed) { inst6 = new Search_Students_By_Dahampasala(); return(inst6); } else { return(inst6); } }
private void button1_Click(object sender, EventArgs e) { if (avail_lbl.Text == "Unavailable") { MessageBox.Show("තරග අංකය භාවිතයේ පවතී", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (textBox1.Text == "") { MessageBox.Show("නම ඇතුලත් කර නොමැත", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (dateTimePicker1.Value == DateTime.Today) { MessageBox.Show("උපන්දිනය ඇතුලත් කර නොමැත", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (textBox2.Text == "") { MessageBox.Show("ඉංග්රීසි නම ඇතුලත් කර නොමැත", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (comboBox1.SelectedItem == null) { MessageBox.Show("ශ්රේණියක් තෝරා නොමැත", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (comboBox2.SelectedItem == null) { MessageBox.Show("තරගයක් තෝරා නොමැත", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { String competitionID = getCompetitionID(comboBox1.Text, comboBox2.Text); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = SqlCon.con; DateTime max_birthday = getMaximumAge(comboBox1.Text); //get the maximum date for the selected student try { if (dateTimePicker1.Value >= max_birthday) //checking for over age students { cmd.CommandText = "INSERT INTO `studentstable`(`StudentID`, `Name`, `Birthday`, `Name_english`, `Telephone`, `CompetitionID`, `dahampasala`) VALUES('" + numericUpDown1.Value.ToString() + "','" + textBox1.Text + "','" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "','" + textBox2.Text + "','" + textBox3.Text + "','" + competitionID + "','" + comboBox3.Text + "');"; SqlCon.con.Open(); cmd.ExecuteNonQuery(); SqlCon.con.Close(); Search_Student ss = Search_Student.getInstance(); ss.updateDatagridview(); Search_Students_By_Dahampasala ssd = Search_Students_By_Dahampasala.getInstance(); ssd.updateDatagridview(); MessageBox.Show("දත්ත ඇතුලත් කිරීම සාර්ථකයි", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); resetValues(); //reset values numericUpDown1_ValueChanged(sender, e); } else //adding one to the over age students { cmd.CommandText = "INSERT INTO `studentstable`(`StudentID`, `Name`, `Birthday`, `Name_english`, `Telephone`, `CompetitionID`, `dahampasala`,`overage`) VALUES('" + numericUpDown1.Value.ToString() + "','" + textBox1.Text + "','" + dateTimePicker1.Value.ToString("yyyy-MM-dd") + "','" + textBox2.Text + "','" + textBox3.Text + "','" + competitionID + "','" + comboBox3.Text + "',1);"; SqlCon.con.Open(); cmd.ExecuteNonQuery(); SqlCon.con.Close(); Search_Student ss = Search_Student.getInstance(); Search_Students_By_Dahampasala ssd = Search_Students_By_Dahampasala.getInstance(); ssd.updateDatagridview(); ss.updateDatagridview(); MessageBox.Show("දත්ත ඇතුලත් කිරීම සාර්ථකයි", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); resetValues(); numericUpDown1_ValueChanged(sender, e); } } catch (Exception ex) { MessageBox.Show(ex.Message); SqlCon.con.Close(); } } //resetValues(); //reset values }