예제 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (txtId.Text != "")
            {
                //con.Open();

                //cmd = new SqlCommand("DELETE FROM Person WHERE ID=@id", con);
                //cmd.Parameters.Add("@id", txtId.Text);
                //cmd.ExecuteNonQuery();

                //MessageBox.Show("Successfully Deleted");
                //con.Close();

                string query = "DELETE FROM Person WHERE ID='" + txtId.Text + "'";
                cn.operation(query);
                MessageBox.Show("Successfully Deleted");
                DBView ob = new DBView();
                this.Close();
                ob.Show();
            }
        }
예제 #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if(txtId.Text != "")
            {
                con.Open();
                cmd = new SqlCommand("UPDATE Person SET First_Name=@fName, Last_Name=@lName, Gender=@gender, Birth_Date=@dob WHERE ID=@id", con);

                cmd.Parameters.Add("@id", txtId.Text);
                cmd.Parameters.Add("@fName", txtFname.Text);
                cmd.Parameters.Add("@lName", txtLname.Text);
                cmd.Parameters.Add("@gender", cmbGender.SelectedText.ToString());
                cmd.Parameters.Add("@dob", dateTimePicker1.Value.ToString("MM/dd/yyyy"));
                cmd.ExecuteNonQuery();
                con.Close();

                /*string query = "UPDATE Person SET First_Name='" + txtFname.Text + "', Last_Name='" + txtLname.Text + "', Gender='" + cmbGender.SelectedItem.ToString() + "', Birth_Date='" + dateTimePicker1.Value.ToString("MM/dd/yyyy") + "' WHERE ID='" + txtId.Text + "'";
                cn.operation(query);*/
                MessageBox.Show("Successfully Updated");
                DBView ob = new DBView();
                this.Close();
                ob.Show();

            }
        }
예제 #3
0
파일: Form1.cs 프로젝트: cdmarasinghe/Q3
 private void button2_Click(object sender, EventArgs e)
 {
     DBView ob = new DBView();
     this.Close();
     ob.Visible = true;
 }