Exemplo n.º 1
0
        private void Save_Click(object sender, EventArgs e)
        {
            string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
                                "Data Source=E:\\ITS245\\STEFPROJ\\Database11.accdb";

            OleDbConnection connection = new OleDbConnection(connString);
            OleDbCommand    cmd        = connection.CreateCommand();

            connection.Open();

            cmd.Connection = connection;


            cmd.CommandText = "Update generalmedicalhistorytable set Pregnancies =" + "'" + Preg.Text + "'" + ",Tobacco =" + "'" + Tab.Text + "'" + ",Alcohol=" + "'" + Alcohol.Text + "'" + " where GeneralMedicalhistoryID=" + listBox1.SelectedItem.ToString();
            OleDbDataReader reader2 = cmd.ExecuteReader();

            reader2.Read();
            reader2.Close();


            this.BackColor = Color.LightBlue;


            Preg.ReadOnly    = true;
            Tab.ReadOnly     = true;
            Alcohol.ReadOnly = true;

            Save.Hide();
            Add.Hide();
        }
Exemplo n.º 2
0
        private void Add_Click(object sender, EventArgs e)
        {
            string connString = "Provider=Microsoft.ACE.OLEDB.12.0;" +
                                "Data Source=E:\\ITS245\\STEFPROJ\\Database11.accdb";

            OleDbConnection connection = new OleDbConnection(connString);
            OleDbCommand    cmd        = connection.CreateCommand();

            connection.Open();

            cmd.CommandText = "Insert into generalmedicalhistorytable (PatientID, Pregnancies, Tobacco, Alcohol) VALUES" + "(" + "'" + PatientID.Text + "'" + "," + "'" + Preg.Text + "'" + "," + "'" + Tab.Text + "'" + "," + "'" + Alcohol.Text + "'" + ")";
            cmd.Connection  = connection;


            OleDbDataReader reader = cmd.ExecuteReader();

            connection.Close();
            this.BackColor   = Color.LightBlue;
            Preg.ReadOnly    = true;
            Tab.ReadOnly     = true;
            Alcohol.ReadOnly = true;
            listBox1.Update();

            Add.Hide();
            Save.Hide();
        }