private void button4_Click(object sender, EventArgs e) { AllEvaluations std = new AllEvaluations(); this.Hide(); std.Show(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { SqlConnection con = new SqlConnection(conStr); con.Open(); if (e.RowIndex > -1) { if (e.ColumnIndex == 0) { EditEvaluation edit = new EditEvaluation(); edit.txt_eval_id.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); edit.txt_name.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString(); edit.txt_mark.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); edit.txt_totwet.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString(); edit.ShowDialog(); } else if (e.ColumnIndex == 1) { DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex]; string q = "DELETE FROM GroupEvaluation where EvaluationId = '" + row.Cells[2].Value + "';"; string t = "DELETE FROM Evaluation where Id = '" + row.Cells[2].Value + "';"; SqlCommand cm = new SqlCommand(q, con); cm.ExecuteNonQuery(); SqlCommand cmt = new SqlCommand(t, con); cmt.ExecuteNonQuery(); MessageBox.Show("Congrats! Record Deletded"); SqlDataAdapter sql = new SqlDataAdapter("SELECT * from Evaluation;", con); DataTable datatab = new DataTable(); sql.Fill(datatab); dataGridView1.DataSource = datatab; con.Close(); } AllEvaluations std = new AllEvaluations(); this.Hide(); std.Show(); } }
private void btn_evaluate_Click(object sender, EventArgs e) { if (val() == 0) { try { SqlConnection con = new SqlConnection(conStr); con.Open(); if (con.State == ConnectionState.Open) { string q = "INSERT INTO Evaluation(Name, TotalMarks,TotalWeightage)VALUES('" + (txt_name.Text).ToString() + "', '" + Convert.ToInt32(txt_mark.Text) + "' ,'" + Convert.ToInt32(txt_totwet.Text) + "');"; SqlCommand cmd = new SqlCommand(q, con); cmd.ExecuteNonQuery(); MessageBox.Show("Data Inserted Successfully"); } AllEvaluations std = new AllEvaluations(); this.Hide(); std.Show(); }catch (Exception ex) { MessageBox.Show(ex.Message); } } }