Пример #1
0
        private void addbutton_Click(object sender, EventArgs e)
        {
            //open the addprojectadvisore page
            AddProjectAdvisor a = new AddProjectAdvisor();

            a.Show();
        }
Пример #2
0
        private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
            AddProjectAdvisor form5 = new AddProjectAdvisor();

            //when edit button clicked
            if (e.ColumnIndex == 4)
            {
                form5.Change("Update", dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(),
                             dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(),
                             dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString()
                             );
                form5.Show();
            }
            if (e.ColumnIndex == 5)
            {
                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("Select Id from Person where Email='{0}'", dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString());
                    //SqlCommand comm4 = new SqlCommand(cm4, conn);
                    //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 ProjectAdvisor where ProjectId=ANY(Select Id from Project where Title='{0}') and AdvisorId=ANY(Select Advisor.Id from Advisor INNER join Person On Advisor.Id=Person.Id where FirstName+' '+LastName='{1}' )", dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(), dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
                    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.ProjectAdvisor_Load(sende, er);
                }
                else
                {
                    MessageBox.Show("Not Deleted");
                }
            }
        }
Пример #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            AddProjectAdvisor a = new AddProjectAdvisor();


            if (e.ColumnIndex == 4) // if we want to update

            {
                a.setpara("Update",
                          dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(),
                          dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(),
                          dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString()
                          );

                a.Show();
            }

            if (e.ColumnIndex == 5) //deleting stuff
            {
                var ConfirmResult = MessageBox.Show("really want to delete this",
                                                    "Confirm Delete!!",
                                                    MessageBoxButtons.YesNo);


                if (ConfirmResult == DialogResult.Yes)
                {
                    con.Open();

                    String cmd2 = string.Format("DELETE From ProjectAdvisor WHERE ProjectId = ANY(Select Id from Project where Title='{0}') and AdvisorId = ANY(Select Advisor.Id from Advisor INNER join Person On Advisor.Id = Person.Id WHERE FirstName+' '+LastName='{1}' )",
                                                dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(),
                                                dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
                    SqlCommand query2 = new SqlCommand(cmd2, con);

                    query2.ExecuteNonQuery();

                    con.Close();

                    //after deletion
                    MessageBox.Show("Deleted");
                    object    sende = null;
                    EventArgs er    = null;
                    dataGridView1.Rows.Clear();
                    //load the project advisor again
                    this.ProjectAdvisor_Load(sende, er);
                }
                else
                {
                    MessageBox.Show("Not Deleted");
                }
            }
        }
Пример #4
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            AddProjectAdvisor ADP = new AddProjectAdvisor();

            ADP.Show();
        }