Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            AddProject pro = new AddProject();

            pro.Show();


            /*
             * if (pro.ShowDialog() == DialogResult.OK)
             * {
             *  MessageBox.Show("Project is Added");
             *  object obj = null;
             *  EventArgs ev = null;
             *  projectview.Rows.Clear();
             *  this.Project_Load(obj, ev);
             * }*/
        }
Example #2
0
        private void projectsview_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            AddProject Pro = new AddProject();

            if (e.ColumnIndex == 2)
            {
                //SqlConnection conn = new SqlConnection("Data Source=TALHAALI;Initial Catalog=ProjectA;User ID=sa;Password=talhaali");
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ProjectA"].ToString());

                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);

                //string cm2 = string.Format("Update Project set Title='{0}', Description='{1}'", title.Text, description.Text);
                //SqlCommand comm2 = new SqlCommand(cm2, conn);
                //comm2.Parameters.AddWithValue("@Title", title.Text);
                //comm2.Parameters.AddWithValue("@Description", description.Text);

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

                Pro.Change("Update", ide, projectview.Rows[e.RowIndex].Cells[0].Value.ToString(), projectview.Rows[e.RowIndex].Cells[1].Value.ToString());

                /* 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 == 3)
            {
                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 GroupProject where ProjectId=(Select Id from Project where Title='{0}');Delete from ProjectAdvisor where ProjectId=(Select Id from Project where Title='{0}');Delete from Project where Id=(Select Id from Project where Title='{0}');", projectview.Rows[e.RowIndex].Cells[0].Value.ToString());
                    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();


                    MessageBox.Show("Deleted");

                    object    sende = null;
                    EventArgs er    = null;
                    projectview.Rows.Clear();
                    this.Project_Load(sende, er);
                }
                else
                {
                    MessageBox.Show("Not Deleted");
                }
            }
        }
Example #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            AddProject proj = new AddProject();

            if (e.ColumnIndex == 2)
            {
                SqlConnection con = new SqlConnection("Data Source = HAIER-PC; Initial Catalog = ProjectA; Integrated Security = True; MultipleActiveResultSets = True");
                con.Open();
                string cmd = string.Format("Select Id from project where Title='{0}'", dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());

                SqlCommand query = new SqlCommand(cmd, con);


                int ide = (int)query.ExecuteScalar();
                //conn.Close();

                proj.setpara("Update",
                             ide,
                             dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString(),
                             dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString()
                             );

                proj.Show();
            }

            if (e.ColumnIndex == 3)
            {
                var Result = MessageBox.Show("Delete This Item ?",
                                             "Delete",
                                             MessageBoxButtons.YesNo);

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

                    String cmd2 = string.Format("Delete from GroupProject where ProjectId=(Select Id from Project where Title='{0}');Delete from ProjectAdvisor where ProjectId=(Select Id from Project where Title='{0}');Delete from Project where Id=(Select Id from Project where Title='{0}');", dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());

                    SqlCommand query1 = new SqlCommand(cmd2, con);

                    SqlDataReader reader2 = query1.ExecuteReader();
                    int           stdid   = 0;
                    while (reader2.Read())
                    {
                        stdid = Convert.ToInt32(reader2["Id"]);
                    }
                    con.Close();


                    MessageBox.Show("Deleted");

                    object sende = null;

                    EventArgs er = null;
                    dataGridView1.Rows.Clear();
                    this.Project_Load(sende, er);
                }
                else
                {
                    MessageBox.Show("Not Deleted");
                }
            }
        }
Example #4
0
        private void add_Click(object sender, EventArgs e)
        {
            AddProject proj = new AddProject();

            proj.Show();
        }