Example #1
0
        public ServerToClient UpdateTreatment(Treatments t)
        {
            ServerToClient sc  = new ServerToClient();
            OleDbCommand   cmd = new OleDbCommand("UPDATE Treatments SET PatientID=@PID, MainComplain=@CMP, Examination=@EXM, Treatment=@TRM, Medicine=@MED, TreatmentDate=@TDT, Amount=@AMT WHERE ID=" + t.ID, cm);

            cmd.Parameters.AddWithValue("@PID", t.PatientID);
            cmd.Parameters.AddWithValue("@CMP", t.MainComplain);
            cmd.Parameters.AddWithValue("@EXM", t.Examination);
            cmd.Parameters.AddWithValue("@TRM", t.Treatment);
            cmd.Parameters.AddWithValue("@MED", t.Medicine);
            cmd.Parameters.AddWithValue("@TDT", t.TreatmentDate);
            cmd.Parameters.AddWithValue("@AMT", t.Amount);
            try
            {
                cm.Open();
                cmd.ExecuteNonQuery();
                cmd      = new OleDbCommand("SELECT DMAX('ID', 'Treatments')", cm);
                sc.Count = Convert.ToInt32(cmd.ExecuteScalar());
            }
            catch (Exception ex) { sc.Message = ex.Message; }
            finally { cm.Close(); }
            return(sc);
        }
Example #2
0
        public Treatments GetTreatments(int TreatmentID)
        {
            Treatments   t   = new Treatments();
            OleDbCommand cmd = new OleDbCommand("SELECT ID, PatientID, MainComplain, Examination, Treatment, Medicine, TreatmentDate, Amount FROM Treatments WHERE ID=" + TreatmentID, cm);

            try
            {
                cm.Open();
                OleDbDataReader rd = cmd.ExecuteReader();
                rd.Read();
                t.ID            = TreatmentID;
                t.PatientID     = rd[1].ToString();
                t.MainComplain  = rd[2].ToString();
                t.Examination   = rd[3].ToString();
                t.Treatment     = rd[4].ToString();
                t.Medicine      = rd[5].ToString();
                t.TreatmentDate = DateTime.Parse(rd[6].ToString());
                t.Amount        = Convert.ToDouble(rd[7]);
            }
            catch {; }
            finally { cm.Close(); }
            return(t);
        }
Example #3
0
        public ServerToClient AddTreatment(Treatments t)
        {
            ServerToClient sc  = new ServerToClient();
            OleDbCommand   cmd = new OleDbCommand("INSERT INTO Treatments(PatientID, MainComplain, Examination, Treatment, Medicine, TreatmentDate, Amount) VALUES (@PID, @CMP, @EXM, @TRM, @MED, @TDT, @AMT)", cm);

            cmd.Parameters.AddWithValue("@PID", t.PatientID);
            cmd.Parameters.AddWithValue("@CMP", t.MainComplain);
            cmd.Parameters.AddWithValue("@EXM", t.Examination);
            cmd.Parameters.AddWithValue("@TRM", t.Treatment);
            cmd.Parameters.AddWithValue("@MED", t.Medicine);
            cmd.Parameters.AddWithValue("@TDT", t.TreatmentDate);
            cmd.Parameters.AddWithValue("@AMT", t.Amount);
            try
            {
                cm.Open();
                cmd.ExecuteNonQuery();
                cmd      = new OleDbCommand("SELECT DMAX('ID', 'Treatments')", cm);
                sc.Count = Convert.ToInt32(cmd.ExecuteScalar());
            }
            catch (Exception ex) { sc.Message = ex.Message; }
            finally { cm.Close(); }
            return(sc);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            ServerToClient   sc = new ServerToClient();
            TreatmentContext tx = new TreatmentContext();
            Treatments       t  = new Treatments();

            t.ID           = TID;
            t.PatientID    = PID;
            t.MainComplain = txtCMP.Text;
            t.Examination  = txtEXM.Text;
            t.Treatment    = txtTRM.Text;
            string med = null;

            for (int i = 0; i < lstMED.Items.Count; i++)
            {
                med += lstMED.Items[i].ToString() + ",";
            }
            med.Remove(med.Length - 1);
            t.Medicine      = med;
            t.TreatmentDate = dtpVST.DateTime;
            t.Amount        = Convert.ToDouble(txtAMT.Text);

            sc = tx.AddTreatment(t);

            if (sc.Message == null)
            {
                if (XtraMessageBox.Show("Patient data updated!\nDo you want to print?", "Print Report?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    new rptClinicReport(sc.Count).ShowPreviewDialog();
                    Close();
                }
                else
                {
                    XtraMessageBox.Show(sc.Message);
                }
            }
        }