private void label4_Click(object sender, EventArgs e) { ProjectHome pro = new ProjectHome(); this.Hide(); pro.Show(); }
private void button1_Click(object sender, EventArgs e) { try { int key = Convert.ToInt32(textBox1.Text); String str1 = "Data Source=HAIER-PC\\NIMRASQLSERVER;Initial Catalog=ProjectA;Integrated Security=True"; String query = "Update Project Set Description = ('" + textBox2.Text.ToString() + "'), Title=('" + textBox3.Text.ToString() + "')where Id = '" + Convert.ToInt32(textBox1.Text) + "';"; SqlConnection con1 = new SqlConnection(str1); SqlCommand cmd1 = new SqlCommand(query, con1); con1.Open(); cmd1.ExecuteNonQuery(); MessageBox.Show("Data Updated"); con1.Close(); ProjectHome ne = new ProjectHome(); this.Hide(); ne.Show(); } catch (Exception es) { MessageBox.Show(es.Message); } }
private void button1_Click(object sender, EventArgs e) { try { String str = "Data Source=HAIER-PC\\NIMRASQLSERVER;Initial Catalog=ProjectA;Integrated Security=True"; String query = "INSERT INTO Project (Description,Title)VALUES(('" + (textBox1.Text).ToString() + "'),('" + (textBox2.Text).ToString() + "'));"; SqlConnection con = new SqlConnection(str); SqlCommand cmd = new SqlCommand(query, con); con.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Data insert"); con.Close(); ProjectHome sho = new ProjectHome(); this.Hide(); sho.Show(); } catch (Exception es) { MessageBox.Show(es.Message); } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { //label1.Show(); //label2.Show(); //label3.Show(); //textBox1.Show(); //textBox2.Show(); //comboBox1.Show(); String str = "Data Source=HAIER-PC\\NIMRASQLSERVER;Initial Catalog=ProjectA;Integrated Security=True"; SqlConnection con = new SqlConnection(str); con.Open(); if (e.RowIndex >= 0 && e.ColumnIndex == 4) { DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex]; String query = "Delete from Project where Id = '" + row.Cells[0].Value + "';"; SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); MessageBox.Show("Project is deleted"); ProjectHome ne = new ProjectHome(); this.Hide(); ne.Show(); } if (e.RowIndex >= 0 && e.ColumnIndex == 3) { //Editproject edit = new Editproject(); //edit.textBox1.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); //edit.textBox2.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); //edit.textBox3.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); //edit.Show(); panel1.Show(); textBox1.Text = this.dataGridView1.CurrentRow.Cells[0].Value.ToString(); textBox2.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); textBox3.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); } } catch (Exception es) { MessageBox.Show(es.Message); } }