private void btn_add_adv_Click(object sender, EventArgs e) { if (val() == 0) { { try { SqlConnection con = new SqlConnection(conStr); con.Open(); if (con.State == ConnectionState.Open) { string p = "INSERT INTO Advisor(Id, Designation, Salary)VALUES('" + (txt_adv_id.Text).ToString() + "',(SELECT Id FROM Lookup WHERE Lookup.Value = '" + (com_desig.Text) + "'), '" + (txt_adv_sal.Text).ToString() + "');"; SqlCommand cmd = new SqlCommand(p, con); cmd.ExecuteNonQuery(); MessageBox.Show("Data Inserted Successfully"); } All_Advisor std = new All_Advisor(); this.Hide(); std.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void button3_Click(object sender, EventArgs e) { All_Advisor std = new All_Advisor(); this.Hide(); std.Show(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { if (e.ColumnIndex == 0) { EditAdvisor edit = new EditAdvisor(); edit.txt_adv_id.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); edit.com_desig.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString(); edit.txt_adv_sal.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); edit.ShowDialog(); } else if (e.ColumnIndex == 1) { DeleteAdvisor edit = new DeleteAdvisor(); edit.txt_adv_id.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); edit.ShowDialog(); } All_Advisor std = new All_Advisor(); this.Hide(); std.Show(); } }
public EditAdvisor(All_Advisor adv, long Id) { InitializeComponent(); this.aadv = adv; this.advnum = Id; }
public DeleteAdvisor(All_Advisor advdel, long Id) { InitializeComponent(); this.aadv = advdel; this.advnum = Id; }