private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            int con = Convert.ToInt32(txtContact.Text);

            BIZ.Patient patient = db.Patient.Where(p => p.Contact == con).FirstOrDefault();
            patient.Contact = Convert.ToInt32(txtContact.Text);
            patient.Name    = txtName.Text;
            patient.Email   = txtEmail.Text;
            patient.DOB     = dtpDate.SelectedDate.ToString();
            patient.NIC     = txtNIC.Text;

            db.Patient.Attach(patient);
            var entry = db.Entry(patient);

            entry.State = System.Data.Entity.EntityState.Modified;
            var res = db.SaveChanges();

            if (res == 1)
            {
                MessageBox.Show("Success");
            }
            else
            {
                MessageBox.Show("Failed");
            }
        }
Beispiel #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            BIZ.Patient patient = new BIZ.Patient();
            patient.Contact = Convert.ToInt32(txtContact.Text);
            patient.Name    = txtName.Text;
            patient.Email   = txtEmail.Text;
            patient.DOB     = dtpDate.SelectedDate.ToString();
            patient.NIC     = txtNIC.Text;

            try
            {
                var patie = db.Patient.Where(p => p.Contact == patient.Contact).FirstOrDefault();
                if (patie != null)
                {
                    MessageBox.Show("The Number : " + patient.Contact + " is already registered please Use that number for appointments. thnak you...");
                }
                else
                {
                    db.Patient.Add(patient);
                    var res = db.SaveChanges();
                    if (res == 1)
                    {
                        MessageBox.Show("Success");
                    }
                    else
                    {
                        MessageBox.Show("Failed");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public AppoinmnetPage(int num)
        {
            InitializeComponent();
            contact = num;
            BIZ.Patient patient = db.Patient.Where(p => p.Contact == num).FirstOrDefault();

            txtContact.Text      = patient.Contact.ToString();
            txtName.Text         = patient.Name;
            txtEmail.Text        = patient.Email;
            dtpDate.SelectedDate = Convert.ToDateTime(patient.DOB);
            txtNIC.Text          = patient.NIC;

            cmbDocs.ItemsSource = db.Doctor.ToList();
        }
        private void btnGO_Click(object sender, RoutedEventArgs e)
        {
            int contact = Convert.ToInt32(txtContact.Text);

            BIZ.Patient p = db.Patient.Where(ps => ps.Contact == contact).FirstOrDefault();
            if (p != null)
            {
                AppoinmnetPage appoinmnetPage = new AppoinmnetPage(p.Contact);
                MainFrame.Content = appoinmnetPage;
                //Functions functions = new Functions(p.Contact);
                //MainFrame.Content = functions;
            }
            else
            {
                if (MainFrame.Content != null)
                {
                    MainFrame.Content = null;
                }
                MessageBox.Show("Invalid Contact Number. Please Register First.");
            }
        }