示例#1
0
        private bool CopyFields()
        {
            int idTypeLPU = Convert.ToInt32(cbTypeLpu.SelectedValue);

            _lpu.TypeLPU = _typeLPUList.GetItem(idTypeLPU) as TypeLPU;

            int idOwnership = Convert.ToInt32(cbOwnership.SelectedValue);

            _lpu.Ownership = _ownershipList.GetItem(idOwnership) as Ownership;

            int idAdmLevel = Convert.ToInt32(cbAdmLevel.SelectedValue);

            _lpu.AdmLevel = _admLevelList.GetItem(idAdmLevel) as AdmLevel;

            int idMainSpec = Convert.ToInt32(cbMainSpec.SelectedValue);

            _lpu.MainSpec = _mainSpecList.GetItem(idMainSpec) as MainSpec;

            int idTypeFin = Convert.ToInt32(cbTypeFin.SelectedValue);

            _lpu.TypeFin = _typeFinList.GetItem(idTypeFin) as TypeFin;

            /*
             * int idSubRegion = Convert.ToInt32(cbSubRegion.SelectedValue);
             * _lpu.SubRegion = _subRegionList.GetItem(idSubRegion) as SubRegion;
             */
            ClassForForm.CheckFilled(tbName.Text, "Официальное название");
            ClassForForm.CheckFilled(tbShortName.Text, "Сокращенное название");
            ClassForForm.CheckFilled(tbINN.Text, "ИНН");
            if (_parentLPU != null)
            {
                ClassForForm.CheckFilled(tbKPP.Text, "КПП");
            }

            ClassForForm.CheckFilled(tbStreet.Text, "Уличный адрес");

            ClassForForm.CheckINN(_lpu, tbINN.Text);

            _lpu.Name      = tbName.Text;
            _lpu.ShortName = tbShortName.Text;

            _lpu.City = tbCity.Text;

            _lpu.INN = (_parentLPU == null) ? tbINN.Text : string.Empty;

            _lpu.KPP       = tbKPP.Text;
            _lpu.PostIndex = tbPostIndex.Text;

            string email = _lpu.Email;

            _lpu.Email = tbEmail.Text;

            if (!ClassForForm.IsEmail(tbEmail.Text))
            {
                MessageBox.Show("Ошибка в электронном адресе. Пожалуйста, исправьте.", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                _lpu.Email = email;
                return(false);
            }

            string website = _lpu.Website;

            _lpu.Website = tbWebSite.Text;

            if (!ClassForForm.IsWebSite(tbWebSite.Text))
            {
                MessageBox.Show("Ошибка в адресе веб-сайта. Пожалуйста, исправьте.", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                _lpu.Website = website;
                return(false);
            }

            _lpu.Phone  = tbPhone.Text;
            _lpu.Street = tbStreet.Text;

            string bedsTotal, bedsIC, bedsSurgical;

            bedsTotal    = _lpu.BedsTotal;
            bedsIC       = _lpu.BedsIC;
            bedsSurgical = _lpu.BedsSurgical;

            _lpu.BedsTotal    = tbBedsTotal.Text;
            _lpu.BedsIC       = tbBedsIC.Text;
            _lpu.BedsSurgical = tbBedsSurgical.Text;

            if (_lpu.IsTotalLessThenSum())
            {
                MessageBox.Show("Общее количество коек меньше, чем сумма реанимационных и хирургических коек.\nПожалуйста, исправьте.", "Ошибка ввода", MessageBoxButtons.OK, MessageBoxIcon.Warning);

                _lpu.BedsTotal    = bedsTotal;
                _lpu.BedsIC       = bedsIC;
                _lpu.BedsSurgical = bedsSurgical;

                return(false);
            }

            _lpu.Operating = tbOperating.Text;

            if (_lpu.IsHaveDepartment())
            {
                _lpu.MachineGD   = string.Empty;
                _lpu.MachineGDF  = string.Empty;
                _lpu.MachineCRRT = string.Empty;
                _lpu.Shift       = string.Empty;
                _lpu.PatientGD   = string.Empty;
                _lpu.PatientPD   = string.Empty;
                _lpu.PatientCRRT = string.Empty;
            }
            else
            {
                _lpu.MachineGD   = tbMachineGD.Text;
                _lpu.MachineGDF  = tbMachineGDF.Text;
                _lpu.MachineCRRT = tbMachineCRRT.Text;
                _lpu.Shift       = tbShift.Text;
                _lpu.PatientGD   = tbPatientGD.Text;
                _lpu.PatientPD   = tbPatientPD.Text;
                _lpu.PatientCRRT = tbPatientCRRT.Text;
            }

            if (cbLpuRR.Enabled)
            {
                int idLpuRR;
                int.TryParse(cbLpuRR.SelectedValue.ToString(), out idLpuRR);

                LpuRR lpuRR = _lpuRRList.GetItem(idLpuRR) as LpuRR;

                if (lpuRR != null)
                {
                    _lpu.LpuRR = lpuRR;
                }
            }

            if (cbLpuRR2.Enabled)
            {
                int idLpuRR2;
                int.TryParse(cbLpuRR2.SelectedValue.ToString(), out idLpuRR2);

                LpuRR lpuRR2 = _lpuRRList.GetItem(idLpuRR2) as LpuRR;

                if (lpuRR2 != null)
                {
                    _lpu.LpuRR2 = lpuRR2;
                }
            }

            return(true);
        }