public IndexForm() { InitializeComponent(); ButtonShowLoginForm.Click += OnButtonShowLoginFormOnClick; var plans = PlanController.GetPlans(true); var localities = LocalityController.GetLocalities(); foreach (var locality in localities) { comboBox1.Items.Add(new ComboBoxItem() { Value = locality.Id, Text = locality.Name }); } foreach (var plan in plans) { dataGridView1.Rows.Add( plan.Id, plan.Year, plan.Month, (comboBox1.Items[plan.Locality_id - 1] as ComboBoxItem).Text, "Утверждён в ОМСУ", plan.Date ); } }
public PlanForm(int primaryKey = -1, bool is_public = false) { InitializeComponent(); for (int i = 1; i <= 31; i++) { dataGridView1.Columns.Add("column" + i.ToString(), i.ToString()); } this.primaryKey = primaryKey; var localities = LocalityController.GetLocalities(); foreach (var locality in localities) { comboBox1.Items.Add(new ComboBoxItem() { Value = locality.Id, Text = locality.Name }); } if (primaryKey != -1) { currentPlan = PlanController.GetPlanByPK(primaryKey); var districts = PlanDistrictController.GetDistrictsByPlan(currentPlan).GroupBy(x => x.Address); foreach (var district in districts) { DataGridViewRow row = dataGridView1.Rows[dataGridView1.RowCount - 1].Clone() as DataGridViewRow; row.Cells[0].Value = district.Key.ToString(); foreach (var day in district) { row.Cells[day.Day].Value = "+"; } dataGridView1.Rows.Add(row); } numericUpDown1.Text = currentPlan.Year.ToString(); numericUpDown2.Text = currentPlan.Month.ToString(); comboBox1.SelectedIndex = currentPlan.Locality_id - 1; checkBox1.Checked = currentPlan.Published; DisableElements(); if (currentPlan.File_id != null) { button2.Enabled = false; button4.Enabled = true; } } if (is_public || (Program.CurrentUser != null && Program.CurrentUser.Id == 3)) { textBox1.Enabled = false; checkBox1.Enabled = false; button4.Enabled = false; button2.Enabled = false; button1.Enabled = false; } }
public async Task GetSingleLocalities() { var mockService = new Mock <ILocalityService>(); mockService.Setup(service => service.GetAll(null)).Returns(GetTestLocalities()); var controller = new LocalityController(mockService.Object); var result = controller.Get("23TplPdS"); Assert.NotNull(result); }
public async Task GetAllLocalities() { var mockService = new Mock <ILocalityService>(); mockService.Setup(service => service.GetAll(null)).Returns(GetTestLocalities()); var controller = new LocalityController(mockService.Object); var result = controller.Get(); Assert.Equal(2, result.Count); }
private void btnSaveModify_Click(object sender, EventArgs e) { try { this.errorProvider.Clear(); List <ControlErrorProvider> errorsProvider = FormValidators.validFormTest(getValidators()); bool isNew = selectedLocality == null; bool isValid = errorsProvider == null; if (isValid) { Localidade localidade = new Localidade { idLocalidad = isNew ? 0 : selectedLocality.idLocalidad, nombre = txtName.Text, domicilioCorrespondencia = txtDescription.Text, baja = isNew ? true : chbStatus.Checked, }; LocalityController controller = new LocalityController(); Operation <Localidade> operation = isNew ? controller.addRecord(localidade) : controller.updateRecord(localidade); if (operation.State) { loadTable(this.getLocations()); clearForm(); MessageBox.Show(isNew ? "Nuevo localidad registrada" : "Localidad modificada"); return; } MessageBox.Show(operation.Error); } else { MessageBox.Show("Algunos datos proporcionados son inválidos. Pase el puntero sobre los íconos de error para ver los detalles de cada campo.", "ERROR DE VALIDACIÓN", MessageBoxButtons.OK, MessageBoxIcon.Warning); foreach (ControlErrorProvider errorProvider in errorsProvider) { this.errorProvider.SetError(errorProvider.ControlName, errorProvider.ErrorMessage); } } } catch (Exception ex) { FormUtils.defaultErrorMessage(ex); } }
private async void button3_Click(object sender, EventArgs e) { var addForm = new AddLocalityForm(); if (addForm.ShowDialog() != DialogResult.OK) { return; } var locality = new Locality() { Name = addForm.LocalityName }; await LocalityController.AddLocality(locality); await FillLocalitesTable(); }
public MainForm() { InitializeComponent(); var localities = LocalityController.GetLocalities(); foreach (var locality in localities) { comboBox1.Items.Add(new ComboBoxItem() { Value = locality.Id, Text = locality.Name }); } if (Program.CurrentUser.Id == 3) { comboBox1.SelectedIndex = Program.CurrentUser.Locality_id.GetValueOrDefault() - 1; } button1_Click(null, null); }
private void frmGroups_Load(object sender, EventArgs e) { try { DistricController districController = new DistricController(); LocalityController localityController = new LocalityController(); Operation <Distrito> getDistrictOperation = districController.getRecords(); Operation <Localidade> getLocalitiesOperation = localityController.getRecords(); bool dataIsRetrieved = getLocalitiesOperation.State && getDistrictOperation.State; if (dataIsRetrieved) { // set data districts = getDistrictOperation.Data; localities = getLocalitiesOperation.Data; // load data cmbDistricts.DataSource = districts; cmbLocations.DataSource = localities; loadTable(this.getGroups()); cmbDistricts.SelectedIndex = -1; cmbLocations.SelectedIndex = -1; } else { MessageBox.Show(getDistrictOperation.Error); } chbStatus.Checked = true; chbRegistration.Checked = true; setReadOnly(); } catch (Exception ex) { FormUtils.defaultErrorMessage(ex); } }