コード例 #1
0
        private void EditDepartmentButtonClick(object sender, EventArgs e)
        {
            if (NoFoundRegionText.Visible)
            {
                MessageBox.Show("Редактирование невозможно, нет региона");
                return;
            }

            RegionResultText.Hide();
            RegionText.Hide();
            DepartmentResultText.Hide();
            DepartmentText.Hide();
            MainDepartmentResultText.Hide();
            MainDepartmentText.Hide();
            SelectRegionField.Show();
            SelectRegionText.Show();
        }
コード例 #2
0
        private void InitFields()
        {
            var context     = new PSOConnect();
            var coordinator = context.coordinator.FirstOrDefault(coord => coord.idTeam == Login.CurrentUser.idTeam);

            var departments = from region in context.region
                              join department in context.department on region.idDepartment equals department.idDepartment
                              join mainDepartment in context.mainDepartment on department.idMainDepartment equals mainDepartment.idMainDepartment
                              select new
            {
                Id                    = region.idRegion,
                AddressRegion         = region.address,
                AddressDepartment     = department.address,
                AddressMainDepartment = mainDepartment.address
            };

            foreach (var dep in departments)
            {
                SelectRegionField.Items.Add($"{dep.Id}-АДРЕС РЕГИОНА: {dep.AddressRegion} АДРЕС ДЕПАРТАМЕНТА: {dep.AddressDepartment} АДРЕС ГЛАВНОГО ДЕПАРТАМЕНТА: {dep.AddressMainDepartment}");

                if (coordinator.idRegion == null || coordinator.idRegion != dep.Id)
                {
                    continue;
                }

                SelectRegionField.SelectedItem = SelectRegionField.Items[SelectRegionField.Items.Count - 1];

                RegionResultText.Text         = dep.AddressRegion;
                DepartmentResultText.Text     = dep.AddressDepartment;
                MainDepartmentResultText.Text = dep.AddressMainDepartment;
            }

            NoFoundRegionText.Hide();

            if (coordinator.idRegion == null)
            {
                RegionResultText.Hide();
                RegionText.Hide();
                DepartmentResultText.Hide();
                DepartmentText.Hide();
                MainDepartmentResultText.Hide();
                MainDepartmentText.Hide();
                SelectRegionField.Show();
                SelectRegionText.Show();

                if (SelectRegionField.Items.Count > 0)
                {
                    SelectRegionField.SelectedIndex = 0;
                }
                else
                {
                    SelectRegionField.Hide();
                    NoFoundRegionText.Show();
                }
            }
            else
            {
                RegionResultText.Show();
                RegionText.Show();
                DepartmentResultText.Show();
                DepartmentText.Show();
                MainDepartmentResultText.Show();
                MainDepartmentText.Show();
                SelectRegionField.Hide();
                SelectRegionText.Hide();
            }

            if (SelectRegionField.Items.Count == 0)
            {
                SelectRegionField.Hide();
                NoFoundRegionText.Show();
            }
        }