Example #1
0
        private void patiencesDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(patiencesDataGridView.CurrentRow.Cells[0].Value);

            //7.8
            if (e.ColumnIndex == 7) //MessageBox.Show("Edit", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            {
                patient locp = db.patients.Find(id);
                using (patientEdit frm = new patientEdit(locp))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        //Edit
                        string familyName = frm.familyNameTextBox.Text;
                        string name       = frm.nameTextBox.Text;
                        string fatherName = frm.fatherNameTextBox.Text;
                        familyName = cutSpacesAndUnprintChars(familyName);
                        name       = cutSpacesAndUnprintChars(name);
                        fatherName = cutSpacesAndUnprintChars(fatherName);
                        if (dbm.EditPatient(id, familyName, name, fatherName, frm.birthDateTimePicker.Value, db.social_status.Where(p => p.soc_status.Equals(frm.socStatusComboBox.SelectedItem.ToString())).First().id, db.current_status.Where(p => p.curr_status.Equals(frm.currStatusComboBox.SelectedItem.ToString())).First().id))
                        {
                            MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        //patiencesDataGridView.DataSource = db.patients.ToList();
                        //patiencesDataGridView.DataSource = dbm.GetExtPatients();
                        reloadData();
                        patiencesDataGridView.DataSource = db.ExtPatients.ToList();
                    }
                }
            }
            if (e.ColumnIndex == 8) //MessageBox.Show("Delete", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            {
                // Delete
                if (dbm.DeletePatient(id))
                {
                    MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //patiencesDataGridView.DataSource = db.patients.ToList();
                //patiencesDataGridView.DataSource = dbm.GetExtPatients();
                reloadData();
                patiencesDataGridView.DataSource = db.ExtPatients.ToList();
            }
        }
Example #2
0
 private void patientAddBtn_Click(object sender, EventArgs e)
 {
     using (patientEdit frm = new patientEdit())
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             string familyName = frm.familyNameTextBox.Text;
             string name       = frm.nameTextBox.Text;
             string fatherName = frm.fatherNameTextBox.Text;
             familyName = cutSpacesAndUnprintChars(familyName);
             name       = cutSpacesAndUnprintChars(name);
             fatherName = cutSpacesAndUnprintChars(fatherName);
             if (dbm.AddPatient(familyName, name, fatherName, frm.birthDateTimePicker.Value, db.social_status.Where(p => p.soc_status.Equals(frm.socStatusComboBox.SelectedItem.ToString())).First().id, db.current_status.Where(p => p.curr_status.Equals(frm.currStatusComboBox.SelectedItem.ToString())).First().id) == null)
             {
                 MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             //patiencesDataGridView.DataSource = db.patients.ToList();
             //patiencesDataGridView.DataSource = dbm.GetExtPatients();
             reloadData();
             patiencesDataGridView.DataSource = db.ExtPatients.ToList();
         }
     }
 }