private void Submit_Click(object sender, EventArgs e) { //conn.Open(); label5.Visible = false; label6.Visible = false; label7.Visible = false; Evaluation C1 = new Evaluation(); C1.set_Name(Nametxt.Text); C1.set_Total_Marks(TotalmarksTxt.Text); C1.set_Total_Weitage(totalweightagetxt.Text); if ((C1.Get_Name() != null) && (C1.Get_Total_Marks() != 0) && (C1.Get_Total_Weitage() != 0)) { try { String cmd1 = String.Format("INSERT INTO Evaluation(Name, TotalMarks, TotalWeightage ) values('{0}', '{1}', '{2}')", C1.Get_Name(), C1.Get_Total_Marks(), C1.Get_Total_Weitage()); int rows = DatabaseConnection.getInstance().exectuteQuery(cmd1); if (rows != 0) { MessageBox.Show("Data Recorded Succesfully"); Cancel_Click(sender, e); } if (MessageBox.Show("Do you Want to Add Another Student's Data?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.Show(); } else { this.Close(); Eval_Dashboards t = new Eval_Dashboards(); t.Show(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } conn.Close(); } else { label5.Text = "Invalid Name"; label6.Text = "Invalid TotalMarks"; label7.Text = "Invalid Total Weightage"; label5.Visible = true; label6.Visible = true; label7.Visible = true; } }
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 ManageEvaluation_Click(object sender, EventArgs e) { Eval_Dashboards r = new Eval_Dashboards(); r.Show(); }
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"); } }