Esempio n. 1
0
 public TakeMedicationViewModel(TakeMedication takeMedicationWindowOpen)
 {
     loginCurrent         = new vwLoginCurrent();
     medicalStaff         = new vwMedicalStaff();
     patients             = new vwPatients();
     pharmacy             = new vwPharmacy();
     takeMedication       = new vwTakeMedication();
     takeMedicationWindow = takeMedicationWindowOpen;
     using (Service1Client wcf = new Service1Client())
     {
         PharmacyList     = wcf.GetAllPharmacy().ToList();
         MedicalStaffList = wcf.GetAllMedicalStaff().ToList();
         PatientsList     = wcf.GetAllPatients().ToList();
     }
 }
        private void TakeMedicationExecute()
        {
            try
            {
                using (Service1Client wcf = new Service1Client())
                {
                    if (wcf.LoginUserMedicalStaff(UserName, login.txtPass.Password))
                    {
                        int currentMedicalStaffID = wcf.currentMedicalStaffID(UserName, login.txtPass.Password);

                        List <vwMedicalStaff> medicalStaffDetail = wcf.GetMedicalStaffsDetail(currentMedicalStaffID).ToList();
                        string nameOfMedicalStaff = null;

                        foreach (vwMedicalStaff item in medicalStaffDetail)
                        {
                            nameOfMedicalStaff = item.NameAndSurname;
                        }

                        MessageBox.Show("Welcome " + nameOfMedicalStaff + ", you are successfully loged in!");

                        loginCurrent.MedicalStaffID = currentMedicalStaffID;
                        wcf.AddLoginCurrent(LoginCurrent);

                        TakeMedication view = new TakeMedication();
                        view.ShowDialog();
                        login.Close();
                    }
                    else
                    {
                        MessageBox.Show("You did not enter valid data\nor need to register first!");
                        login.txtName.Text     = "";
                        login.txtPass.Password = "";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }