Exemplo n.º 1
0
        private void Addbutton_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 illnesshistorytable (Illness,PatientID,IllnessDate, Resolution) VALUES" + "(" + "'" + illy.Text + "'" + "," + "'" + PatientID.Text + "'" + "," + "'" + DOI.Text + "'" + "," + "'" + Resolve.Text + "'" + ")";
            cmd.Connection  = connection;


            OleDbDataReader reader = cmd.ExecuteReader();

            connection.Close();
            this.BackColor   = Color.LightBlue;
            illy.ReadOnly    = true;
            DOI.ReadOnly     = true;
            Resolve.ReadOnly = true;
            listBox1.Update();

            save.Hide();
            Addbutton.Hide();
        }
Exemplo n.º 2
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 illnesshistorytable set Illness =" + "'" + illy.Text + "'" + ",IllnessDate =" + "'" + DOI.Text + "'" + ",Resolution=" + "'" + Resolve.Text + "'" + " where IllnessID=" + listBox1.SelectedItem.ToString();
            OleDbDataReader reader2 = cmd.ExecuteReader();

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


            this.BackColor = Color.LightBlue;


            illy.ReadOnly    = true;
            DOI.ReadOnly     = true;
            Resolve.ReadOnly = true;

            save.Hide();
            Addbutton.Hide();
        }