private void Student_Details_Load(object sender, EventArgs e) { string cmd = "Select Person.Id, Student.RegistrationNo,Person.FirstName,Person.LastName,Person.Contact,Person.Email,Person.Gender as g,Person.DateOfBirth from Person join Student on Student.Id = Person.Id"; dbConnection.getInstance().fill(cmd, dataGridView1); Advisor ad = new Advisor(); ad.fillgender(dataGridView1); }
private void AllAdvisors_Load(object sender, EventArgs e) { tableLayoutPanel1.Visible = false; panel2.Visible = false; string s = "Select a.Id, p.Gender as g, p.FirstName,p.LastName,p.Contact,p.Email,a.Salary,a.Designation,p.DateOfBirth from Advisor as a join Person as p on p.Id = a.Id "; dbConnection.getInstance().fill(s, dataGridView1); Advisor ad = new Advisor(); ad.fillgender(dataGridView1); string f = "Select Value from Lookup where Category = 'DESIGNATION'"; ad.load(f, comboBox1); }
private void button1_Click_1(object sender, EventArgs e) { if (comboBox1.Text == "") { lblerror.Text = "Select Designation"; lblerror.Show(); } if (lblsalary.Text == "" && lbllastname.Text == "" && lblerror.Text == "" && lblFirstname.Text == "" && lblemail.Text == "" && lbldob.Text == "" && lblcontact.Text == "" && lblgender.Text == "") { try { string k = "Select Count(Id) from Person where FirstName ='" + txtfirstname.Text + "' and LastName = '" + txtlastname.Text + "' and Contact = '" + txtcontact.Text + "'and Id != '" + Convert.ToInt32(dataGridView1.CurrentRow.Cells["Id"].Value) + "'"; Advisor ad = new Advisor(); bool ry = ad.uniqueperson(txtfirstname.Text, txtlastname.Text, txtcontact.Text, k); if (ry == false) { lblerror.Text = "This Person has already been added in Record"; lblerror.Visible = true; } else if (ry == true) { int id = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Id"].Value); int y = dbConnection.getInstance().getScalerData("Select Id from Lookup where Value = '" + comboBox1.Text + "'"); int yy = dbConnection.getInstance().getScalerData("Select Id from Lookup where Value = '" + comboBox2.Text + "'"); dbConnection.getInstance().exectuteQuery("Update Advisor SET Designation = '" + y + "', Salary = '" + txtsalary.Text + "' where Id = '" + id + "' "); dbConnection.getInstance().exectuteQuery("Update Person SET FirstName = '" + txtfirstname.Text + "', LastName = '" + txtlastname.Text + "',Contact = '" + txtcontact.Text + "',Email = '" + txtemail.Text + "',DateOfBirth = '" + dateTimePicker1.Value + "',Gender = '" + yy + "' where Id = '" + id + "' "); MessageBox.Show("Updated"); this.Hide(); AllAdvisors frm = new AllAdvisors(); frm.Show(); } } catch (Exception et) { throw (et); } } }
private void btninsert_Click(object sender, EventArgs e) { if (comboBox2.Text == "" && comboBox3.Text == "ADVISOR") { lblerror.Text = "Select Designation Please"; lblerror.Visible = true; } else if (comboBox2.Text != "" && comboBox3.Text == "ADVISOR" || comboBox2.Text == "" && comboBox3.Text == "STUDENT") { lblerror.Text = ""; } if (lbllastname.Text == "" && lblFirstname.Text == "" && lblcontact.Text == "" && lblemail.Text == "" && lblerror.Text == "" && lbldob.Text == "") { try { string s = "Select Count(Id) from Person where FirstName = '" + txtfirstname.Text + "' and LastName = '" + txtlastname.Text + "' and Contact = '" + txtcontact.Text + "'"; bool ry = st.uniqueperson(txtfirstname.Text, txtlastname.Text, txtcontact.Text, s); string ios = "Select Count(Id) from Student where RegistrationNo ='" + txtregno.Text + "'"; bool v = st.uniqueregno(txtregno.Text, ios); int y = st.maxid(); if (ry == false) { lblerror.Visible = true; lblerror.Text = "This Person has already been added in Record"; } else if (v == false) { lblerror.Visible = true; lblerror.Text = "This RegistrationNo is already in Record"; } else if (ry == true && v == true) { st.Addperson(txtfirstname.Text, txtlastname.Text, txtcontact.Text, txtemail.Text, cmbgender.Text, dateTimePicker1.Value); if (comboBox3.Text == "STUDENT" && txtregno.Text.Length == 11 && st.REGNO(txtregno.Text) == true) { txtregno.Visible = true; st.addstindb(txtregno.Text); st.AddStudent(txtfirstname.Text, txtlastname.Text, txtcontact.Text, txtemail.Text, cmbgender.Text, dateTimePicker1.Value, txtregno.Text); MessageBox.Show("Student has been added"); } else if (comboBox3.Text == "ADVISOR" && st.Alldigits(txtsalary.Text) == true) { txtsalary.Visible = true; Advisor ad = new Advisor(); ad.AddAdvisor(comboBox2.Text, Convert.ToInt32(txtsalary.Text)); ad.Addadvisorindb(); MessageBox.Show("Advisor has been added"); } } else { MessageBox.Show("Enter Correct Data"); } } catch (Exception et) { throw (et); } } else { lblerror.Text = "Enter Correct Data"; lblerror.Visible = true; } }