private void button4_Click(object sender, EventArgs e) { this.Hide(); Evaluation f1 = new Evaluation(); f1.ShowDialog(); this.Close(); }
private void button3_Click(object sender, EventArgs e) { if (textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "") { if (Regex.IsMatch(textBox2.Text, @"^[a-zA-Z\s]+$")) { if (System.Text.RegularExpressions.Regex.IsMatch(textBox3.Text, "^[0-9]*$") && (System.Text.RegularExpressions.Regex.IsMatch(textBox4.Text, "^[0-9]*$"))) { if (Flag3 == 0) { cmd = new SqlCommand("insert into Evaluation (Evaluation.Name, TotalMarks, TotalWeightage) values ('" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "') ", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Inserted Successfully"); DisplayEval(); this.Hide(); Evaluation f1 = new Evaluation(); f1.ShowDialog(); this.Close(); Clear(); } else if (Flag3 > 0) { con.Open(); cmd = new SqlCommand("UPDATE Evaluation set Name = @name, TotalMarks = @TotalMarks, Totalweightage = @Totalweightage where ID = @id", con); cmd.Parameters.AddWithValue("@id", Flag3); cmd.Parameters.AddWithValue("@name", textBox2.Text); cmd.Parameters.AddWithValue("@Totalweightage", textBox3.Text); cmd.Parameters.AddWithValue("@TotalMarks", textBox4.Text); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Updated successfully"); this.Hide(); Evaluation f1 = new Evaluation(); f1.ShowDialog(); this.Close(); Clear(); Flag3 = 0; } } else { MessageBox.Show("Please Enter Valid Marks and weightage"); } } else { MessageBox.Show("Please enter valid name"); } } else { MessageBox.Show("Please enter record"); } con.Close(); }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { con.Open(); int URow = int.Parse(e.RowIndex.ToString()); int URowIndex = int.Parse(e.ColumnIndex.ToString()); ID = Convert.ToInt32(dataGridView1.Rows[URow].Cells[0].Value.ToString()); if (URowIndex == 4) { if (URowIndex == 0) { MessageBox.Show("Click on delete button"); } if (URowIndex != 0) { var askfirst = MessageBox.Show("Are you sure you want to delete this?", "Delete", MessageBoxButtons.YesNo); if (askfirst == DialogResult.Yes) { cmd = new SqlCommand("DELETE FROM Evaluation where ID = @Id", con); cmd.Parameters.AddWithValue("@Id", ID); cmd.ExecuteNonQuery(); con.Close(); MessageBox.Show("Deleted Succesfully"); this.Hide(); Evaluation f1 = new Evaluation(); f1.ShowDialog(); this.Close(); } else { this.Hide(); Evaluation f1 = new Evaluation(); f1.ShowDialog(); this.Close(); } } } else if (URowIndex == 5) { int d1 = (int)dataGridView1.CurrentRow.Cells[0].Value; if (URowIndex == 0) { MessageBox.Show("Click again"); } if (URowIndex != 0) { var askfirst1 = MessageBox.Show("Are you sure you want to Update this?", "Update", MessageBoxButtons.YesNo); if (askfirst1 == DialogResult.Yes) { Flag3 = d1; textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); textBox3.Text = dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(); textBox4.Text = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString(); con.Close(); } else { con.Close(); this.Hide(); Evaluation f2 = new Evaluation(); f2.ShowDialog(); } } } else { con.Close(); } }