コード例 #1
0
        private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SqlConnection con = new SqlConnection(conURL);

            con.Open();

            int currentRow         = int.Parse(e.RowIndex.ToString());
            int currentColumnIndex = int.Parse(e.ColumnIndex.ToString());
            int gid    = Convert.ToInt32(dataGridView2.Rows[currentRow].Cells[1].Value.ToString());
            int projid = Convert.ToInt32(dataGridView2.Rows[currentRow].Cells[3].Value.ToString());

            if (currentColumnIndex == 0)
            {
                var confirmResult = MessageBox.Show("Are you sure to delete this item ??",
                                                    "Confirm Delete!!",
                                                    MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    string     delete = "DELETE FROM GroupProject WHERE ProjectId = @val1 AND GroupId = @val2";
                    SqlCommand cmd1   = new SqlCommand(delete, con);
                    cmd1.Parameters.AddWithValue("@val1", projid);
                    cmd1.Parameters.AddWithValue("@val2", gid);
                    cmd1.ExecuteNonQuery();
                    MessageBox.Show("Record deleted succesfully");
                    ManageGroupProjects form = new ManageGroupProjects();
                    this.Close();
                    form.Show();
                }
            }
        }
コード例 #2
0
        private void ManageGroupProjects_Click(object sender, EventArgs e)
        {
            ManageGroupProjects E8 = new ManageGroupProjects();

            E8.Show();
            this.Hide();
        }
コード例 #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SqlConnection con = new SqlConnection(conURL);

            con.Open();
            int currentRow         = int.Parse(e.RowIndex.ToString());
            int currentColumnIndex = int.Parse(e.ColumnIndex.ToString());
            int prjid = Convert.ToInt32(dataGridView1.Rows[currentRow].Cells[1].Value.ToString());

            if (currentColumnIndex == 0)
            {
                string     groupproject = "INSERT INTO GroupProject(ProjectId, GroupId, AssignmentDate) values(@ProjectId, @GroupId, @AssignmentDate)";
                SqlCommand cmd1         = new SqlCommand(groupproject, con);
                cmd1.Parameters.AddWithValue("@ProjectId", prjid);
                cmd1.Parameters.AddWithValue("@GroupId", flag);
                cmd1.Parameters.AddWithValue("@AssignmentDate", DateTime.Today);
                cmd1.ExecuteNonQuery();
                MessageBox.Show("Project Assigned to Group");
                ManageGroupProjects f3 = new ManageGroupProjects();
                this.Close();
                f3.Show();
            }
        }