Esempio n. 1
0
        private void btSpecialtyAdd_Click(object sender, EventArgs e)
        {
            if (tbSname.Text.Trim().Length == 0)
            {
                tsslSpecialty.ForeColor = Color.Crimson;
                tsslSpecialty.Text      = "Invalid data";
                return;
            }
            using (var client = new HaServiceClient())
            {
                Specialty specialty = new Specialty();
                var       allsp     = client.GetSpecialties();
                foreach (var item in allsp)
                {
                    if (item.SpecialtyName == tbSname.Text.Trim())
                    {
                        tsslSpecialty.ForeColor = Color.Crimson;
                        tsslSpecialty.Text      = "Specialty alredy exist";
                        return;
                    }
                }

                specialty.SpecialtyName = tbSname.Text.Trim();
                client.AddSpecialty(specialty);

                FillSpecialtyListView();
                FillCbChoseSpesialty();
                tsslSpecialty.ForeColor = Color.DarkGreen;
                tsslSpecialty.Text      = "Specialty added";
                tbSname.Text            = "";
            }
        }