public ManageProject() { InitializeComponent(); Edit_Panel.Hide(); try { SqlCommand cm = new SqlCommand("Select Id, Title, Description From Project ", conn); SqlDataReader dr; dr = cm.ExecuteReader(); while (dr.Read()) { int n = dataGridView1.Rows.Add(); dataGridView1.Rows[n].Cells[0].Value = (int)dr.GetValue(0); dataGridView1.Rows[n].Cells[1].Value = dr.GetString(1); dataGridView1.Rows[n].Cells[2].Value = dr.GetString(2); } ; } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.Close(); }
public Eval_Dashboards() { InitializeComponent(); Edit_Panel.Hide(); try { SqlCommand cm = new SqlCommand("Select Id, Name, TotalMarks, TotalWeightage From Evaluation ", conn); dr = cm.ExecuteReader(); while (dr.Read()) { int n = dataGridView1.Rows.Add(); dataGridView1.Rows[n].Cells[0].Value = (int)dr.GetValue(0); dataGridView1.Rows[n].Cells[1].Value = dr.GetString(1); dataGridView1.Rows[n].Cells[2].Value = dr.GetValue(2); dataGridView1.Rows[n].Cells[3].Value = dr.GetValue(3); } ; conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public ManageAdviser() { InitializeComponent(); Edit_Panel.Hide(); try { SqlCommand cm = new SqlCommand("Select P.Id, P.FirstName, P.LastName, P.Contact, P.Email, P.DateofBirth, P.Gender, S.Designation, S.Salary from Person P Inner join Advisor S on P.Id = S.Id ", conn); dr = cm.ExecuteReader(); while (dr.Read()) { int n = dataGridView1.Rows.Add(); dataGridView1.Rows[n].Cells[0].Value = (int)dr.GetValue(0); dataGridView1.Rows[n].Cells[1].Value = dr.GetString(1); dataGridView1.Rows[n].Cells[2].Value = dr.GetString(2); dataGridView1.Rows[n].Cells[3].Value = dr.GetValue(3); dataGridView1.Rows[n].Cells[4].Value = dr.GetValue(4); dataGridView1.Rows[n].Cells[5].Value = dr.GetValue(5); //dataGridView1.Rows[n].Cells[6].Value = dr.GetValue(6); if (Convert.ToInt16(dr.GetValue(6)) == 1) { dataGridView1.Rows[n].Cells[6].Value = "Male"; } else { dataGridView1.Rows[n].Cells[6].Value = "Female"; } // dataGridView1.Rows[n].Cells[7].Value = dr.GetString(7); if (Convert.ToInt16(dr.GetValue(7)) == 6) { dataGridView1.Rows[n].Cells[8].Value = "Professor"; } if (Convert.ToInt16(dr.GetValue(7)) == 7) { dataGridView1.Rows[n].Cells[8].Value = "Associate Professor"; } if (Convert.ToInt16(dr.GetValue(7)) == 8) { dataGridView1.Rows[n].Cells[8].Value = "Assisstant Professor"; } if (Convert.ToInt16(dr.GetValue(7)) == 9) { dataGridView1.Rows[n].Cells[8].Value = "Lecturer"; } if (Convert.ToInt16(dr.GetValue(7)) == 10) { dataGridView1.Rows[n].Cells[8].Value = "Industry Professional"; } dataGridView1.Rows[n].Cells[7].Value = (Decimal)dr.GetValue(8); } ; conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Submit_Click(object sender, EventArgs e) { Evaluation C1 = new Evaluation(); C1.set_Name(nametxt.Text); C1.set_Total_Marks(markstxt.Text); C1.set_Total_Weitage(Weightaetxt.Text); if ((C1.Get_Name() != null) && (C1.Get_Total_Marks() != 0) && (C1.Get_Total_Weitage() != 0)) { try { conn.Open(); int ID = Convert.ToInt32(textBox1.Text); string cmd2 = String.Format("UPDATE Evaluation SET Name = @Name, TotalMarks=@TotalMarks, TotalWeightage=@TotalWeightage Where Id = @Id "); SqlCommand command2 = new SqlCommand(cmd2, conn); command2.Parameters.Add(new SqlParameter("@Id", ID)); command2.Parameters.Add(new SqlParameter("@TotalWeightage", SqlDbType.Int)); command2.Parameters["@TotalWeightage"].Value = C1.Get_Total_Weitage(); command2.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar)); command2.Parameters["@Name"].Value = C1.Get_Name(); command2.Parameters.Add(new SqlParameter("@TotalMarks", SqlDbType.Int)); command2.Parameters["@TotalMarks"].Value = C1.Get_Total_Marks(); int rows2 = command2.ExecuteNonQuery(); if (rows2 != 0) { MessageBox.Show("Evaluations Details Updated"); Edit_Panel.Hide(); this.Hide(); Eval_Dashboards D = new Eval_Dashboards(); D.Show(); } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Invalid Data!." + "Please Enter Valid Data"); } }
private void Submit_Click(object sender, EventArgs e) { Project C1 = new Project(); C1.set_Description(DescriptionTxt.Text); C1.set_Title(TitleTxt.Text); if ((C1.Get_Description() != null) && (C1.Get_Title() != null)) { try { conn.Open(); int ID = Convert.ToInt32(textBox1.Text); string cmd2 = String.Format("UPDATE Project SET Description = @Description, Title=@Title Where Id = @Id "); SqlCommand command2 = new SqlCommand(cmd2, conn); command2.Parameters.Add(new SqlParameter("@Id", ID)); command2.Parameters.Add(new SqlParameter("@Description", SqlDbType.VarChar)); command2.Parameters["@Description"].Value = C1.Get_Description(); command2.Parameters.Add(new SqlParameter("@Title", SqlDbType.VarChar)); command2.Parameters["@Title"].Value = C1.Get_Title(); int rows2 = command2.ExecuteNonQuery(); if (rows2 != 0) { MessageBox.Show("Project Details Updated"); Edit_Panel.Hide(); this.Close(); //ManageProject o = new ManageProject(); ManageProject D = new ManageProject(); D.Show(); } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Invalid Data!." + "Please Enter Valid Data"); conn.Close(); } }
public Dashboard() { InitializeComponent(); Edit_Panel.Hide(); try { SqlCommand cm = new SqlCommand("Select P.Id, P.FirstName, P.LastName, P.Contact, P.Email, P.DateofBirth, P.Gender, S.RegistrationNo from Person P Inner join Student S on P.Id = S.Id ", conn); dr = cm.ExecuteReader(); while (dr.Read()) { int n = dataGridView1.Rows.Add(); dataGridView1.Rows[n].Cells[0].Value = (int)dr.GetValue(0); dataGridView1.Rows[n].Cells[1].Value = dr.GetString(1); dataGridView1.Rows[n].Cells[2].Value = dr.GetString(2); dataGridView1.Rows[n].Cells[3].Value = dr.GetValue(3); dataGridView1.Rows[n].Cells[4].Value = dr.GetValue(4); dataGridView1.Rows[n].Cells[5].Value = dr.GetValue(5); if ((int)dr.GetValue(6) == 1) { dataGridView1.Rows[n].Cells[6].Value = "Male"; } else { dataGridView1.Rows[n].Cells[6].Value = "Female"; } dataGridView1.Rows[n].Cells[7].Value = dr.GetString(7); } ; conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Columns[e.ColumnIndex].Name == "Delete" && (e.RowIndex >= 0)) { try { conn.Open(); if (MessageBox.Show("Are You Sure You Want to Delete this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value); int rows1 = 0; int rows2 = 0; string m1 = String.Format("DELETE FROM GroupProject Where ProjectId = @Id "); SqlCommand command1 = new SqlCommand(m1, conn); command1.Parameters.Add(new SqlParameter("@Id", id)); if (command1.ExecuteNonQuery() > 0) { rows1 = command1.ExecuteNonQuery(); } string m2 = String.Format("DELETE FROM ProjectAdvisor Where ProjectId = @Id "); SqlCommand command2 = new SqlCommand(m2, conn); command2.Parameters.Add(new SqlParameter("@Id", id)); if (command2.ExecuteNonQuery() > 0) { rows2 = command1.ExecuteNonQuery(); } string m = String.Format("DELETE FROM Project Where Id = @Id "); SqlCommand command = new SqlCommand(m, conn); command.Parameters.Add(new SqlParameter("@Id", id)); int rows = command.ExecuteNonQuery(); if (rows != 0 || (rows1 > 0 && rows2 > 0)) { MessageBox.Show("Data deleted!"); this.Close(); ManageProject D = new ManageProject(); D.Show(); } } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (dataGridView1.Columns[e.ColumnIndex].Name == "Edit" && (e.RowIndex >= 0)) { if (MessageBox.Show("Are You Sure You Want to Update this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Edit_Panel.Show(); conn.Open(); int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value); SqlCommand cm = new SqlCommand("Select P.Id, P.Title, P.Description from Project P where P.Id=@Id ", conn); cm.Parameters.Add(new SqlParameter("@Id", id)); SqlDataReader dr; dr = cm.ExecuteReader(); try { while (dr.Read()) { TitleTxt.Text = dr.GetString(1); DescriptionTxt.Text = dr.GetString(2); textBox1.Text = Convert.ToString(dr.GetValue(0)); } dr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.Close(); } else { // MessageBox.Show(""); } } }
private void button2_Click(object sender, EventArgs e) { Edit_Panel.Hide(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Columns[e.ColumnIndex].Name == "Delete" && (e.RowIndex >= 0)) { try { conn.Open(); if (MessageBox.Show("Are You Sure You Want to Delete this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value); string m1 = String.Format("DELETE FROM GroupEvaluation Where EvaluationId = @Id "); SqlCommand command1 = new SqlCommand(m1, conn); command1.Parameters.Add(new SqlParameter("@Id", id)); int rows2 = 0; if (command1.ExecuteNonQuery() > 0) { rows2 = command1.ExecuteNonQuery(); } //int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value); string m = String.Format("DELETE FROM Evaluation Where Id = @Id "); SqlCommand command = new SqlCommand(m, conn); command.Parameters.Add(new SqlParameter("@Id", id)); int rows = command.ExecuteNonQuery(); if (rows > 0 || rows2 > 0) { MessageBox.Show("Data deleted!"); this.Hide(); Eval_Dashboards D = new Eval_Dashboards(); D.Show(); } } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (dataGridView1.Columns[e.ColumnIndex].Name == "Edit" && (e.RowIndex >= 0)) { if (MessageBox.Show("Are You Sure You Want to Update this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Edit_Panel.Show(); conn.Open(); int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value); SqlCommand cm = new SqlCommand("Select Id, Name, TotalMarks, TotalWeightage from Evaluation where Id=@Id ", conn); cm.Parameters.Add(new SqlParameter("@Id", id)); SqlDataReader dr; dr = cm.ExecuteReader(); try { while (dr.Read()) { nametxt.Text = dr.GetString(1); markstxt.Text = Convert.ToString(dr.GetValue(2)); Weightaetxt.Text = Convert.ToString(dr.GetValue(3)); textBox1.Text = Convert.ToString(dr.GetValue(0)); } dr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } conn.Close(); } else { MessageBox.Show("This is the header row"); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Columns[e.ColumnIndex].Name == "DELETE" && (e.RowIndex >= 0)) { conn.Open(); try { if (MessageBox.Show("Are You Sure You Want to Delete this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value); string m = String.Format("Update GroupStudent SET Status=@Status Where StudentId = @Id "); SqlCommand command = new SqlCommand(m, conn); command.Parameters.Add(new SqlParameter("@Id", id)); //command.Parameters.Add(new SqlParameter("@Status", id)); command.Parameters.Add(new SqlParameter("@Status", SqlDbType.Int)); command.Parameters["@Status"].Value = 4; int rows = command.ExecuteNonQuery(); /**string m1 = String.Format("DELETE FROM Person Where Id = @Id "); * SqlCommand command1 = new SqlCommand(m1, conn); * command1.Parameters.Add(new SqlParameter("@Id", id)); * int rows1 = command1.ExecuteNonQuery();**/ if (rows != 0) { MessageBox.Show("Status Updated!"); this.Hide(); Dashboard D = new Dashboard(); D.Show(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.Close(); } else if (dataGridView1.Columns[e.ColumnIndex].Name == "Edit" && (e.RowIndex >= 0)) { if (MessageBox.Show("Are You Sure You Want to Update this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Edit_Panel.Show(); conn.Open(); int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value); SqlCommand cm = new SqlCommand("Select P.Id, P.FirstName, P.LastName, P.Contact, P.Email, P.DateofBirth, P.Gender, S.RegistrationNo from Person P Inner join Student S on P.Id = S.Id where P.Id=@Id ", conn); cm.Parameters.Add(new SqlParameter("@Id", id)); dr = cm.ExecuteReader(); try { while (dr.Read()) { FirstName.Text = dr.GetString(1); Last_Name.Text = dr.GetString(2); ContactTextBox.Text = dr.GetString(3); EmailTxtBox.Text = dr.GetString(4); dateTimePicker1.Value = (DateTime)dr.GetValue(5); if ((int)dr.GetValue(6) == 1) { radioButton1.Checked = true; } else { radioButton2.Checked = true; } registrationtxt.Text = dr.GetString(7); textBox1.Text = Convert.ToString(dr.GetValue(0)); } dr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.Close(); } } }
private void Submit_Click(object sender, EventArgs e) { try { string value = ""; bool isChecked = radioButton1.Checked; if (isChecked) { value = radioButton1.Text; } else { value = radioButton2.Text; } Student C1 = new Student(); C1.set_First_Name(FirstName.Text); C1.set_Reg_No(registrationtxt.Text); C1.set_Last_Name(Last_Name.Text); C1.set_Contact(ContactTextBox.Text); C1.set_Email(EmailTxtBox.Text); C1.set_Gender(value); C1.set_DOB(dateTimePicker1.Value); bool a = false; bool b = false; bool c = false; bool d = false; bool f = false; bool g = false; bool h = false; if (C1.Get_First_Name() == null) { a = true; } if (C1.Get_Reg_No() == null) { b = true; } if (C1.Get_Last_Name() == null) { c = true; } if (C1.Get_Contact() == null) { d = true; } if (C1.Get_Email() == null) { f = true; } if (C1.Get_Gender() == null) { g = true; } if (C1.Get_DOB() == null) { h = true; } if (a == true || b == true || c == true || d == true || f == true || g == true || h == true) { MessageBox.Show("Invalid Data!." + "Please Enter Valid Data"); } else { conn.Open(); string ab = "GENDER"; string cmd = String.Format("SELECT Id FROM dbo.Lookup WHERE Category = @Category and Value=@Value"); SqlCommand command = new SqlCommand(cmd, conn); command.Parameters.Add(new SqlParameter("@Category", ab)); command.Parameters.Add(new SqlParameter("@Value", value)); int id = (int)command.ExecuteScalar(); //String cmd1 = String.Format("INSERT INTO Person(FirstName, LastName, Contact, Email, DateofBirth, Gender) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", C1.Get_First_Name(), C1.Get_Last_Name(), C1.Get_Contact(), C1.Get_Email(), C1.Get_DOB(), id); String cmd1 = String.Format("UPDATE Person SET FirstName = @FirstName, LastName = @LastName, Contact=@Contact, Email=@Email, DateofBirth=@DateofBirth, Gender=@Gender Where Id = @Id"); SqlCommand command1 = new SqlCommand(cmd1, conn); command1.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.VarChar)); command1.Parameters["@FirstName"].Value = C1.Get_First_Name(); command1.Parameters.Add(new SqlParameter("@LastName", SqlDbType.VarChar)); command1.Parameters["@LastName"].Value = C1.Get_Last_Name(); command1.Parameters.Add(new SqlParameter("@Contact", SqlDbType.VarChar)); command1.Parameters["@Contact"].Value = C1.Get_Contact(); command1.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar)); command1.Parameters["@Email"].Value = C1.Get_Email(); command1.Parameters.Add(new SqlParameter("@DateofBirth", SqlDbType.DateTime)); command1.Parameters["@DateofBirth"].Value = C1.Get_DOB(); command1.Parameters.Add(new SqlParameter("@Gender", id)); //command.Parameters["@conditionName"].Value = C1.Get_First_Name(); int ID = Convert.ToInt32(textBox1.Text); command1.Parameters.Add(new SqlParameter("@Id", ID)); int rows = command1.ExecuteNonQuery(); string cmd2 = String.Format("UPDATE Student SET RegistrationNo = @RegistrationNo Where Id = @Id "); SqlCommand command2 = new SqlCommand(cmd2, conn); command2.Parameters.Add(new SqlParameter("@Id", ID)); command2.Parameters.Add(new SqlParameter("@RegistrationNo", SqlDbType.VarChar)); command2.Parameters["@RegistrationNo"].Value = C1.Get_Reg_No(); int rows2 = command2.ExecuteNonQuery(); if (rows != 0 && rows2 != 0) { MessageBox.Show("Data Updated Succesfully"); Cancel_Click(sender, e); Edit_Panel.Hide(); this.Close(); Dashboard D = new Dashboard(); D.Show(); } conn.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Columns[e.ColumnIndex].Name == "DELETE" && (e.RowIndex >= 0)) { try { if (MessageBox.Show("Are You Sure You Want to Delete this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { conn.Open(); int rows1 = 0; int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value); string m1 = String.Format("DELETE FROM ProjectAdvisor Where AdvisorId = @Id "); SqlCommand command1 = new SqlCommand(m1, conn); command1.Parameters.Add(new SqlParameter("@Id", id)); if (command1.ExecuteNonQuery() > 0) { rows1 = command1.ExecuteNonQuery(); } string m = String.Format("DELETE FROM Advisor Where Id = @Id "); SqlCommand command = new SqlCommand(m, conn); command.Parameters.Add(new SqlParameter("@Id", id)); int rows = command.ExecuteNonQuery(); string m2 = String.Format("DELETE FROM Person Where Id = @Id "); SqlCommand command2 = new SqlCommand(m2, conn); command2.Parameters.Add(new SqlParameter("@Id", id)); int rows2 = command2.ExecuteNonQuery(); if (rows > 0 && rows2 > 0 || rows1 > 0) { MessageBox.Show("Data deleted!"); this.Hide(); ManageAdviser r = new ManageAdviser(); r.Show(); } conn.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.Close(); } else if (dataGridView1.Columns[e.ColumnIndex].Name == "Edit" && (e.RowIndex >= 0)) { if (MessageBox.Show("Are You Sure You Want to Update this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Edit_Panel.Show(); conn.Open(); int id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value); SqlCommand cm = new SqlCommand("Select P.Id, P.FirstName, P.LastName, P.Contact, P.Email, P.DateofBirth, P.Gender, S.Designation, S.Salary from Person P Inner join Advisor S on P.Id = S.Id where P.Id=@Id ", conn); cm.Parameters.Add(new SqlParameter("@Id", id)); dr = cm.ExecuteReader(); try { while (dr.Read()) { FirstName.Text = dr.GetString(1); Last_Name.Text = dr.GetString(2); ContactTextBox.Text = dr.GetString(3); EmailTxtBox.Text = dr.GetString(4); dateTimePicker1.Value = (DateTime)dr.GetValue(5); if ((int)dr.GetValue(6) == 1) { radioButton1.Checked = true; } else { radioButton2.Checked = true; } registrationtxt.Text = Convert.ToString(dr.GetValue(8)); if ((int)dr.GetValue(7) == 6) { advisercombo.Text = "Professor"; } if ((int)dr.GetValue(7) == 7) { advisercombo.Text = "Associate Professor"; } if ((int)dr.GetValue(7) == 8) { advisercombo.Text = "Assisstant Professor"; } if ((int)dr.GetValue(7) == 9) { advisercombo.Text = "Lecturer"; } if ((int)dr.GetValue(7) == 10) { advisercombo.Text = "Industry Professional"; } //advisercombo.Text = Convert.ToString(dr.GetValue(7)); textBox1.Text = Convert.ToString(dr.GetValue(0)); } dr.Close(); conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } else { MessageBox.Show("No data Availiable"); } }
private void Submit_Click(object sender, EventArgs e) { try { string value = ""; bool isChecked = radioButton1.Checked; if (isChecked) { value = radioButton1.Text; } else { value = radioButton2.Text; } Adviser C1 = new Adviser(); C1.set_First_Name(FirstName.Text); C1.set_Salary(registrationtxt.Text); C1.set_Last_Name(Last_Name.Text); C1.set_Contact(ContactTextBox.Text); C1.set_Email(EmailTxtBox.Text); C1.set_Gender(value); C1.set_DOB(dateTimePicker1.Value); C1.set_Designation(advisercombo.Text); bool a = false; bool b = false; bool c = false; bool d = false; bool f = false; bool g = false; bool h = false; bool i = false; if (C1.Get_First_Name() == null) { a = true; } if (C1.Get_Salary() == Decimal.Zero) { b = true; } if (C1.Get_Last_Name() == null) { c = true; } if (C1.Get_Contact() == null) { d = true; } if (C1.Get_Email() == null) { f = true; } if (C1.Get_Gender() == null) { g = true; } if (C1.Get_DOB() == null) { h = true; } if (C1.Get_Designation() == null) { i = true; } if (a == true || b == true || c == true || d == true || f == true || g == true || h == true) { MessageBox.Show("Invalid Data!." + "Please Enter Valid Data"); } else { //int id8 = Convert.ToInt32(dataGridView1.Rows[t].Cells["Id"].Value); conn.Open(); string ab = "GENDER"; string cmd = String.Format("SELECT Id FROM dbo.Lookup WHERE Category = @Category and Value=@Value"); SqlCommand command = new SqlCommand(cmd, conn); command.Parameters.Add(new SqlParameter("@Category", ab)); command.Parameters.Add(new SqlParameter("@Value", value)); int id = (int)command.ExecuteScalar(); //String cmd1 = String.Format("INSERT INTO Person(FirstName, LastName, Contact, Email, DateofBirth, Gender) values('{0}', '{1}', '{2}', '{3}', '{4}', '{5}')", C1.Get_First_Name(), C1.Get_Last_Name(), C1.Get_Contact(), C1.Get_Email(), C1.Get_DOB(), id); String cmd1 = String.Format("UPDATE Person SET FirstName = @FirstName, LastName = @LastName, Contact=@Contact, Email=@Email, DateofBirth=@DateofBirth, Gender=@Gender Where Id = @Id"); SqlCommand command1 = new SqlCommand(cmd1, conn); command1.Parameters.Add(new SqlParameter("@FirstName", SqlDbType.VarChar)); command1.Parameters["@FirstName"].Value = C1.Get_First_Name(); command1.Parameters.Add(new SqlParameter("@LastName", SqlDbType.VarChar)); command1.Parameters["@LastName"].Value = C1.Get_Last_Name(); command1.Parameters.Add(new SqlParameter("@Contact", SqlDbType.VarChar)); command1.Parameters["@Contact"].Value = C1.Get_Contact(); command1.Parameters.Add(new SqlParameter("@Email", SqlDbType.VarChar)); command1.Parameters["@Email"].Value = C1.Get_Email(); command1.Parameters.Add(new SqlParameter("@DateofBirth", SqlDbType.DateTime)); command1.Parameters["@DateofBirth"].Value = C1.Get_DOB(); command1.Parameters.Add(new SqlParameter("@Gender", id)); //command.Parameters["@conditionName"].Value = C1.Get_First_Name(); int ID = Convert.ToInt32(textBox1.Text); command1.Parameters.Add(new SqlParameter("@Id", ID)); int rows = command1.ExecuteNonQuery(); string cd = "DESIGNATION"; string cmd4 = String.Format("SELECT Id FROM dbo.Lookup WHERE Category = @Category and Value=@Value"); SqlCommand command4 = new SqlCommand(cmd4, conn); command4.Parameters.Add(new SqlParameter("@Category", cd)); command4.Parameters.Add(new SqlParameter("@Value", advisercombo.Text)); int id_lookup = (int)command4.ExecuteScalar(); string cmd2 = String.Format("UPDATE Advisor SET Designation = @Designation, Salary=@Salary Where Id = @Id "); SqlCommand command2 = new SqlCommand(cmd2, conn); command2.Parameters.Add(new SqlParameter("@Id", ID)); command2.Parameters.Add(new SqlParameter("@Designation", SqlDbType.Int)); command2.Parameters["@Designation"].Value = id_lookup; command2.Parameters.Add(new SqlParameter("@Salary", SqlDbType.Decimal)); command2.Parameters["@Salary"].Value = C1.Get_Salary(); int rows2 = command2.ExecuteNonQuery(); if (rows != 0 && rows2 != 0) { MessageBox.Show("Data Updated Succesfully"); Edit_Panel.Hide(); this.Close(); ManageAdviser r = new ManageAdviser(); r.Show(); } conn.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }