예제 #1
0
        private void btn_add_pro_Click(object sender, EventArgs e)
        {
            if (val() == 0)
            {
                try {
                    SqlConnection con = new SqlConnection(conStr);
                    con.Open();
                    if (con.State == ConnectionState.Open)
                    {
                        string p = "INSERT INTO Project( Description, Title)VALUES( '" + (txt_descrip.Text).ToString() + "', '" + (txt_pro_title.Text).ToString() + "');";


                        SqlCommand cmd = new SqlCommand(p, con);
                        cmd.ExecuteNonQuery();
                        MessageBox.Show("Data Inserted Successfully");
                    }
                    AllProject std = new AllProject();

                    this.Hide();
                    std.Show();
                } catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
예제 #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            AllProject std = new AllProject();

            this.Hide();
            std.Show();
        }
예제 #3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                SqlConnection con = new SqlConnection(conStr);
                con.Open();
                if (e.RowIndex > -1)
                {
                    if (e.ColumnIndex == 0)
                    {
                        EditProject edit = new EditProject();
                        edit.txt_pro_id.Text    = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();
                        edit.txt_descrip.Text   = this.dataGridView1.CurrentRow.Cells[3].Value.ToString();
                        edit.txt_pro_title.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString();

                        edit.ShowDialog();
                    }
                    else if (e.ColumnIndex == 1)
                    {
                        DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
                        string          t   = "DELETE FROM [ProjectA].[dbo].[GroupProject] where [ProjectId] = '" + row.Cells[2].Value + "';";
                        string          m   = "DELETE FROM [ProjectA].[dbo].[ProjectAdvisor] where [ProjectId] = '" + row.Cells[2].Value + "';";

                        string     q   = "DELETE FROM Project where Id = '" + row.Cells[2].Value + "';";
                        SqlCommand cmt = new SqlCommand(t, con);
                        cmt.ExecuteNonQuery();
                        SqlCommand cmtt = new SqlCommand(m, con);
                        cmtt.ExecuteNonQuery();

                        SqlCommand cm = new SqlCommand(q, con);
                        cm.ExecuteNonQuery();



                        MessageBox.Show("Congrats! Record Recorded");
                        SqlDataAdapter sql     = new SqlDataAdapter("SELECT Id, Description, Title from Project;", con);
                        DataTable      datatab = new DataTable();
                        sql.Fill(datatab);
                        dataGridView1.DataSource = datatab;
                        con.Close();
                    }
                    AllProject std = new AllProject();
                    this.Hide();
                    std.Show();
                }
            }
            catch (Exception EX)
            {
                MessageBox.Show(EX.Message);
            }
        }
예제 #4
0
 public EditProject(AllProject all, long id)
 {
     InitializeComponent();
     this.aadv   = all;
     this.advnum = id;
 }