private void btn_assessment_Click(object sender, EventArgs e) { assessment_details d = new assessment_details(); d.Show(); this.Hide(); }
private void btn_level_Click(object sender, EventArgs e) { assessment_details r = new assessment_details(); r.Show(); this.Hide(); }
private void btn_submit_Click(object sender, EventArgs e) { if (txt_title.Text != "" && txt_marks.Text != "" && txt_weightage.Text != "") { SqlConnection conn = new SqlConnection("Data Source=DESKTOP-M9PBVHQ;Initial Catalog=ProjectB;Integrated Security=True"); if (update == 1) { conn.Open(); string query2 = "Update Assessment set Title = '" + txt_title.Text + " ', DateCreated = '" + this.date + "' , TotalMarks = '" + txt_marks.Text + "' ,TotalWeightage = '" + txt_weightage.Text + "' where Id = '" + this.id + "'"; SqlCommand update_command = new SqlCommand(query2, conn); int j = update_command.ExecuteNonQuery(); if (j != 0) { MessageBox.Show("Assessment Record Updated Successfully"); assessment ff = new assessment(); ff.Close(); assessment_details ss = new assessment_details(); ss.Show(); this.Hide(); } conn.Close(); } else { conn.Open(); string query = "Insert into Assessment (Title, DateCreated, TotalMarks, TotalWeightage) values('" + txt_title.Text + "', '" + DateTime.Today + "', '" + txt_marks.Text + "' , '" + txt_weightage.Text + "')"; SqlCommand command = new SqlCommand(query, conn); int i = command.ExecuteNonQuery(); if (i != 0) { MessageBox.Show("Assessment Record Inserted Successfully"); assessment f = new assessment(); f.Close(); assessment_details s = new assessment_details(); this.Hide(); s.Show(); } conn.Close(); } } else { error_msg.Show(); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { SqlConnection conn = new SqlConnection("Data Source=DESKTOP-M9PBVHQ;Initial Catalog=ProjectB;Integrated Security=True"); conn.Open(); var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0 && e.ColumnIndex == 0) { int row_index = e.RowIndex; DataGridViewRow selectedRow = dataGridView1.Rows[row_index]; string a = Convert.ToString(selectedRow.Cells["Id"].Value); string[] values; values = new string[7]; using (SqlConnection con = new SqlConnection("Data Source = DESKTOP - M9PBVHQ; Initial Catalog = ProjectB; Integrated Security = True")) { string oString = "Select * from Assessment where Id='" + a + "'"; SqlCommand oCmd = new SqlCommand(oString, conn); using (SqlDataReader oReader = oCmd.ExecuteReader()) { while (oReader.Read()) { values[0] = oReader["Id"].ToString(); values[1] = oReader["Title"].ToString(); values[2] = oReader["DateCreated"].ToString(); values[3] = oReader["TotalMarks"].ToString(); values[4] = oReader["TotalWeightage"].ToString(); break; } conn.Close(); } } assessment s = new assessment(values[0], values[1], values[2], values[3], values[4]); this.Hide(); s.Show(); } else if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0 && e.ColumnIndex == 1) { int row_index = e.RowIndex; DataGridViewRow selectedRow = dataGridView1.Rows[row_index]; string a = Convert.ToString(selectedRow.Cells["Id"].Value); string q2 = "DELETE FROM AssessmentComponent where AssessmentId = '" + a + "'"; string query = "DELETE FROM Assessment WHERE Id = '" + a + "'"; SqlCommand command = new SqlCommand(query, conn); SqlCommand s = new SqlCommand(q2, conn); s.ExecuteNonQuery(); MessageBox.Show("Assessment deleted of this CLO"); command.ExecuteNonQuery(); MessageBox.Show("Row Deleted"); conn.Close(); SqlConnection cnn = new SqlConnection("Data Source=DESKTOP-M9PBVHQ;Initial Catalog=ProjectB;Integrated Security=True"); conn.Open(); string query1 = "select * from Assessment"; using (SqlDataAdapter am = new SqlDataAdapter(query1, cnn)) { DataTable t = new DataTable(); am.Fill(t); dataGridView1.DataSource = t; } } else if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0 && e.ColumnIndex == 2) { int row_index = e.RowIndex; DataGridViewRow selectedRow = dataGridView1.Rows[row_index]; string a = Convert.ToString(selectedRow.Cells["Id"].Value); assessment_comp r = new assessment_comp(a); this.Hide(); assess_comp_detail rr = new assess_comp_detail(a); rr.Show(); assessment_details c = new assessment_details(); c.Hide(); } }