Esempio n. 1
0
        private void btSpecialtyDelete_Click(object sender, EventArgs e)
        {
            int selectedDoctorssCount = lvSpecialty.SelectedItems.Count;

            if (selectedDoctorssCount != 0)
            {
                ListViewItem selectedSpecialty = lvSpecialty.SelectedItems[0];
                int          selectedId        = int.Parse(selectedSpecialty.SubItems[0].Text);
                var          confirmResult     = MessageBox.Show("Are you sure to delete this Specialty?\nSpecialty :  " + selectedSpecialty.SubItems[1].Text, "Confirm delete!", MessageBoxButtons.YesNo);
                if (confirmResult == DialogResult.Yes)
                {
                    using (var client = new HaServiceClient())
                    {
                        Specialty specialty            = client.GetSpecialtyById(selectedId);
                        var       getAllDocBySpecialty = client.GetDoctorsBySpecialy(selectedId);
                        if (getAllDocBySpecialty.Length != 0)
                        {
                            tsslSpecialty.ForeColor = Color.Crimson;
                            tsslSpecialty.Text      = "Unable to delete, doctors with this sp exist";
                            return;
                        }
                        client.DeleteSpecialty(specialty);
                        FillSpecialtyListView();
                        FillCbChoseSpesialty();
                        tsslSpecialty.ForeColor = Color.Green;
                        tsslSpecialty.Text      = "Specialty sucssesfuly deleted";
                    }
                }
                else
                {
                    //DialogResult = DialogResult.None;
                    return;
                }
            }
        }
Esempio n. 2
0
        private void FillDoctorListView()
        {
            lvDoctors.Items.Clear();

            using (var client = new HaServiceClient())
            {
                Doctor[] doors = client.GetDoctors();


                foreach (var item in doors)
                {
                    var          spesialty = client.GetSpecialtyById(item.Specialty.SpecialtyId);
                    ListViewItem lvItem    = new ListViewItem(spesialty.SpecialtyName);
                    lvItem.SubItems.Add(item.LastName);  //.ToString());
                    lvItem.SubItems.Add(item.FirstName); //.ToString());
                    lvItem.SubItems.Add(item.SecondName);
                    lvItem.SubItems.Add(item.LoginD);
                    lvItem.SubItems.Add(item.DoctorId.ToString());
                    lvDoctors.Items.Add(lvItem);
                }
            }
        }