private void button1_Click(object sender, EventArgs e) { //SmtpClient client = new SmtpClient(); //client.Port = 587; //client.Host = "smtp.gmail.com"; //client.EnableSsl = true; //client.Timeout = 10000; //client.DeliveryMethod = SmtpDeliveryMethod.Network; //client.UseDefaultCredentials = false; //client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "12261994"); //MailAddress from = new MailAddress("*****@*****.**", "Student Registration"); //MailAddress to = new MailAddress(textBox9.Text, textBox2.Text); //MailMessage mm = new MailMessage(from, to); //mm.Subject = "You have successfully registered"; //mm.Body = "Hello " + textBox2.Text; //mm.BodyEncoding = UTF8Encoding.UTF8; //mm.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure; //client.Send(mm); string bday = bdayM.Text + " " + bdayD.Text + " " + bdayY.Text; try { SqlDataAdapter sda = new SqlDataAdapter(); SqlCommandBuilder cmd = new SqlCommandBuilder(sda); sda.InsertCommand = new SqlCommand("INSERT INTO Student_Info (studentID, FirstName, MiddleName, LastName, Address, BirthDate, Gender, Contact, Email, YearLevel, Course) VALUES (@stud_id, @stud_fname, @stud_mname, @stud_lname, @stud_address, @BirthDate, @Gender, @Contact, @Email, @stud_year, @stud_course)", connect); sda.InsertCommand.Parameters.Add("@stud_id", SqlDbType.VarChar).Value = txtStudId.Text; sda.InsertCommand.Parameters.Add("@stud_fname", SqlDbType.VarChar).Value = txtFname.Text; sda.InsertCommand.Parameters.Add("@stud_mname", SqlDbType.VarChar).Value = txtMname.Text; sda.InsertCommand.Parameters.Add("@stud_lname", SqlDbType.VarChar).Value = txtLname.Text; sda.InsertCommand.Parameters.Add("@stud_address", SqlDbType.VarChar).Value = txtAdd.Text; sda.InsertCommand.Parameters.Add("@stud_course", SqlDbType.VarChar).Value = cmbCourse.Text; sda.InsertCommand.Parameters.Add("@stud_year", SqlDbType.VarChar).Value = cmbYr.Text; sda.InsertCommand.Parameters.Add("@BirthDate", SqlDbType.VarChar).Value = bday; sda.InsertCommand.Parameters.Add("@Gender", SqlDbType.VarChar).Value = txtGender.Text; sda.InsertCommand.Parameters.Add("@Contact", SqlDbType.VarChar).Value = txtContact.Text; sda.InsertCommand.Parameters.Add("@Email", SqlDbType.VarChar).Value = txtEmail.Text; connect.Open(); sda.InsertCommand.ExecuteNonQuery(); connect.Close(); ClearEntry(); SqlDataAdapter da = new SqlDataAdapter(); // when new student is added, the current id in the database will be incremented by 1 da.UpdateCommand = new SqlCommand("UPDATE id_increment SET ID = " + (id_inc + 1) + " WHERE ID = " + id_inc, connect); connect.Open(); da.UpdateCommand.ExecuteNonQuery(); connect.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Close(); viewInfo obj = new viewInfo(); obj.Show(); MessageBox.Show("Record is already added!"); }
private void StudentInfo_FormClosed(object sender, FormClosedEventArgs e) { // if editing is true and form is closed open the view student form if (this.edit == true) { viewInfo vv = new viewInfo(); vv.Show(); vv.TopMost = true; } }
private void viewInformationToolStripMenuItem_Click(object sender, EventArgs e) { viewInfo info = new viewInfo(); info.Show(); }
private void printInd_FormClosed(object sender, FormClosedEventArgs e) { viewInfo view = new viewInfo(); view.Show(); }