示例#1
0
 protected void Save()
 {
     progress          = ProgressDialog.Show(this, "Обработка...", "Пожалуйста, подождите.", true);
     doctor.SecondName = SNameTextEdit.Text;
     doctor.FirstName  = FNameTextEdit.Text;
     doctor.ThirdName  = TNameTextEdit.Text;
     doctor.IsChosen   = false;
     doctor.Tel        = TelTextEdit.Text;
     doctor.Email      = EmailTextEdit.Text;
     doctor.Cabinet    = CabinetTextEdit.Text;
     doctor.Speciality = SpecTextEdit.Text;
     doctor.Position   = PosTextEdit.Text;
     DoctorManager.SaveDoctor(doctor);
     DoctorSpecialitys.SaveSpeciality(doctor.Speciality);
     DoctorPositions.SavePosition(doctor.Position);
     progress.Dismiss();
     Finish();
 }
示例#2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create your application here
            int doctorID = Intent.GetIntExtra("DoctorID", 0);

//			if(doctorID > 0) {
            doctor = DoctorManager.GetDoctor(doctorID);
//			}

            // set our layout to be the home screen
            SetContentView(Resource.Layout.DoctorDetails);

            SNameTextEdit   = FindViewById <EditText> (Resource.Id.txtSecondName);
            FNameTextEdit   = FindViewById <EditText> (Resource.Id.txtFirstName);
            TNameTextEdit   = FindViewById <EditText> (Resource.Id.txtThirdName);
            TelTextEdit     = FindViewById <EditText> (Resource.Id.txtTel);
            EmailTextEdit   = FindViewById <EditText> (Resource.Id.txtEmail);
            CabinetTextEdit = FindViewById <EditText> (Resource.Id.txtCabinet);

            SpecTextEdit = FindViewById <AutoCompleteTextView> (Resource.Id.actxtSpeciality);
            ArrayAdapter SpecTextEditAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, DoctorSpecialitys.GetSpecialitys());

            SpecTextEdit.Adapter = SpecTextEditAdapter;

            PosTextEdit = FindViewById <AutoCompleteTextView> (Resource.Id.txtPosition);
            ArrayAdapter PosTextEditAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, DoctorPositions.GetPositions());

            PosTextEdit.Adapter = PosTextEditAdapter;

            saveButton         = FindViewById <Button> (Resource.Id.btnSave);
            cancelDeleteButton = FindViewById <Button>(Resource.Id.btnCancelDelete);
            chIsDays           = FindViewById <CheckBox> (Resource.Id.chIsDays);
            lstWorkTime        = FindViewById <ListView> (Resource.Id.lstWorkTime);


            // set the cancel delete based on whether or not it's an existing task
            if (cancelDeleteButton != null)
            {
                cancelDeleteButton.Text = (doctor.ID == 0 ? "Отмена" : "Удалить");
            }

            // SecondName
            if (SNameTextEdit != null)
            {
                SNameTextEdit.Text = doctor.SecondName;
            }

            // FirstName
            if (FNameTextEdit != null)
            {
                FNameTextEdit.Text = doctor.FirstName;
            }

            // ThirdName
            if (TNameTextEdit != null)
            {
                TNameTextEdit.Text = doctor.ThirdName;
            }

            // Telephone
            if (TelTextEdit != null)
            {
                TelTextEdit.Text = doctor.Tel;
            }

            // E-mail
            if (EmailTextEdit != null)
            {
                EmailTextEdit.Text = doctor.Email;
            }

            // Cabinet
            if (CabinetTextEdit != null)
            {
                CabinetTextEdit.Text = doctor.Cabinet;
            }

            // Speciality
            if (SpecTextEdit != null)
            {
                SpecTextEdit.Text = doctor.Speciality;
            }

            // Position
            if (PosTextEdit != null)
            {
                PosTextEdit.Text = doctor.Position;
            }

            // button clicks
            cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
            saveButton.Click         += (sender, e) => { Save(); };

            workTimeItems = new List <Tuple <String, DateTime, WorkTime_Type, DateTime, WorkTime_Type> >();

            if (doctorID == 0)
            {
                chIsDays.Checked = true;
                doctor.wtKind    = WorkTime_Kind.Days;
            }
            else
            {
                switch (doctor.wtKind)
                {
                case WorkTime_Kind.OddEven: { chIsDays.Checked = false; break; }

                case WorkTime_Kind.Days: { chIsDays.Checked = true; break; }
                }
            }

            UpdateWorkTimeList();

            chIsDays.CheckedChange += (sender, e) => {
                if (chIsDays.Checked)
                {
                    doctor.wtKind = WorkTime_Kind.Days;
                }
                else
                {
                    doctor.wtKind = WorkTime_Kind.OddEven;
                }
                UpdateWorkTimeList();
            };

            /////////////////new code///////////////
            spnHospital = FindViewById <Spinner> (Resource.Id.spnHospital);
            hospitals   = HospitalManager.GetHospitals();

            hospitalList        = new Adapters.HospitalSpinnerAdapter(this, hospitals);
            spnHospital.Adapter = hospitalList;

            for (int i = 0; i < hospitals.Count; i++)
            {
                if (hospitals [i].ID == doctor.HospitalID)
                {
                    spnHospital.SetSelection(i + 1);
                }
            }

            spnHospital.ItemSelected += (sender, e) => {
                var s = sender as Spinner;
                if (e.Position == 0)
                {
                    doctor.HospitalID = -1;
                }
                else
                {
                    doctor.HospitalID = hospitals[e.Position - 1].ID;
                }
            };
            /////////////////new code///////////////
        }