示例#1
0
        private void EditProject_Load(object sender, EventArgs e)
        {
            Prooject p = ProjectUtile.updPro;

            txtTitle.Text       = p.Title1;
            txtDescription.Text = p.Description1;
        }
示例#2
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            selected = dataGridView1.CurrentCell.RowIndex;
            DataGridViewRow row = dataGridView1.Rows[selected];

            if (e.ColumnIndex == 0)
            {
                Prooject p = ProjectUtile.updPro;
                projectid      = (int)row.Cells[2].Value;
                p.Title1       = row.Cells[4].Value.ToString();
                p.Description1 = row.Cells[3].Value.ToString();
                EditProject ep = new EditProject();
                this.Hide();
                ep.Show();
            }
            if (e.ColumnIndex == 1)
            {
                int          Id     = Convert.ToInt32(row.Cells[2].Value);
                string       p_name = row.Cells[4].Value.ToString();
                DialogResult res    = MessageBox.Show("Are you sure you want  to Delete " + p_name, "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (res == DialogResult.OK)
                {
                    try
                    {
                        SqlConnection con = new SqlConnection(conStr);
                        con.Open();
                        if (con.State == ConnectionState.Open)
                        {
                            string     Delete_Project = "DELETE FROM Project WHERE Id = '" + Id + "'";
                            SqlCommand sql            = new SqlCommand(Delete_Project, con);
                            sql.ExecuteNonQuery();
                        }
                        //setGrid();
                        MessageBox.Show("Succesfully Deleted");
                        this.Hide();
                        ViewProject vp = new ViewProject();
                        vp.Show();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error:" + ex);
                    }
                }
            }
        }