Exemplo n.º 1
0
        private void Addbutton_Click(object sender, EventArgs e)
        {
            AddEvaluation Add = new AddEvaluation(); // no dialog box and no stuff  would be returned

            Add.Show();
            //if the form gets bad input it would still run which is bad for us and we dont want that to happen
        }
Exemplo n.º 2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            AddEvaluation ev = new AddEvaluation();

            if (e.ColumnIndex == 3)
            {
                ev.setpara("Update", dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(),
                           (int)dataGridView1.Rows[e.RowIndex].Cells[1].Value,
                           (float)Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells[0].Value));

                ev.Show();
            }

            if (e.ColumnIndex == 4)
            {
                var Result = MessageBox.Show("Are you sure to delete this item ??",
                                             "Confirm Delete!!",
                                             MessageBoxButtons.YesNo); //asking for confirmation to deletion

                if (Result == DialogResult.Yes)                        // approving deletion
                {
                    SqlConnection con = new SqlConnection("Data Source = HAIER-PC; Initial Catalog = ProjectA; Integrated Security = True; MultipleActiveResultSets = True");
                    con.Open();

                    String     cmd   = string.Format("Delete from GroupEvaluation where EvaluationId=(Select Id from Evaluation where Name='{0}');Delete from Evaluation where Name='{0}' and TotalMarks={1} and TotalWeightage={2};", dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(), Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells[1].Value), dataGridView1.Rows[e.RowIndex].Cells[2].Value);
                    SqlCommand query = new SqlCommand(cmd, con);

                    query.ExecuteNonQuery();

                    con.Close();


                    MessageBox.Show("Deleted");

                    object    sende = null;
                    EventArgs er    = null;

                    dataGridView1.Rows.Clear();
                    this.Show_Evaluation_Load(sende, er);
                }
                else
                {
                    MessageBox.Show("Not Deleted");
                }
            }
        }
Exemplo n.º 3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            AddEvaluation Pro = new AddEvaluation();

            if (e.ColumnIndex == 3)
            {
                //SqlConnection conn = new SqlConnection("Data Source=TALHAALI;Initial Catalog=ProjectA;User ID=sa;Password=talhaali");
                //conn.Open();
                //string cm3 = string.Format("Select Id from project where Title='{0}'", projectview.Rows[e.RowIndex].Cells[0].Value.ToString());
                //SqlCommand comm3 = new SqlCommand(cm3, conn);



                //int ide = (int)comm3.ExecuteScalar();

                Pro.Change("Update", dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(),
                           (int)Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells[1].Value), (float)Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells[2].Value));

                /* if (Pro.ShowDialog() == DialogResult.OK)
                 * {
                 *   MessageBox.Show("Updated");
                 *   object obj = null;
                 *   EventArgs ev = null;
                 *   projectview.Rows.Clear();
                 *   this.Project_Load(obj, ev);
                 * }*/
                Pro.Show();
            }
            if (e.ColumnIndex == 4)
            {
                var confirmResult = MessageBox.Show("Are you sure to delete this item ??",
                                                    "Confirm Delete!!",
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    //SqlConnection conn = new SqlConnection("Data Source=TALHAALI;Initial Catalog=ProjectA;User ID=sa;Password=talhaali");
                    conn.Open();

                    String     cm4   = string.Format("Delete from GroupEvaluation where EvaluationId=(Select Id from Evaluation where Name='{0}');Delete from Evaluation where Name='{0}' and TotalMarks={1} and TotalWeightage={2};", dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(), Convert.ToDouble(dataGridView1.Rows[e.RowIndex].Cells[1].Value), dataGridView1.Rows[e.RowIndex].Cells[2].Value);
                    SqlCommand comm4 = new SqlCommand(cm4, conn);
                    comm4.ExecuteNonQuery();
                    //SqlDataReader reader2 = comm4.ExecuteReader();
                    //int studentid = 0;
                    //while (reader2.Read())
                    //{
                    //    studentid = Convert.ToInt32(reader2["Id"]);
                    //}
                    conn.Close();

                    /*
                     * conn.Open();
                     *
                     * String cm1 = string.Format("Delete From Student where Id='{0}'", studentid);
                     * SqlCommand comm1 = new SqlCommand(cm1, conn);
                     * comm1.ExecuteNonQuery();
                     *
                     * String cm = string.Format("Delete From Person where Id='{0}'", studentid);
                     * SqlCommand comm = new SqlCommand(cm, conn);
                     * var row = comm.ExecuteNonQuery();
                     * conn.Close();
                     */

                    MessageBox.Show("Deleted");

                    object    sende = null;
                    EventArgs er    = null;
                    dataGridView1.Rows.Clear();
                    this.Evaluation_Load(sende, er);
                }
                else
                {
                    MessageBox.Show("Not Deleted");
                }
            }
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            AddEvaluation Add = new AddEvaluation();

            Add.Show();
        }