private void miChange_Click(object sender, EventArgs e) { Department selectedDepartment = DepartmentsGrid.SelectedNode != null ? DepartmentsGrid.SelectedNode.Tag as Department : null; if (selectedDepartment != null) { InputDualLine inp = new InputDualLine() { Text = @"Редактирование подразделения", Label1 = {Text = @"Название"}, InputLine1 = {Text = selectedDepartment.Description}, Label2 = {Text = @"Краткий ID для СМС , MAX 3-и символа"}, InputLine2 = {Text = selectedDepartment.ShortId} }; if (inp.ShowDialog(this) == DialogResult.OK) { try { selectedDepartment.Description = inp.InputLine1.Text; selectedDepartment.ShortId = inp.InputLine2.Text; _dataContext.SaveChanges(); OnChanged(EventArgs.Empty); } catch (Exception) { throw; } } } }
private void miAdd_Click(object sender, EventArgs e) { InputDualLine inp = new InputDualLine() {Text = @"Введите название подразделения", Label1 = {Text = @"Название"}, Label2 = {Text = @"Краткий ID для СМС, MAX 3-и символа"}}; if (inp.ShowDialog(this) == DialogResult.OK) { if (!string.IsNullOrEmpty(inp.InputLine1.Text)) { try { var pData = _dataContext.Departments.FirstOrDefault(pt => pt.Description.Equals(inp.InputLine1.Text)); if (pData == null) { Cursor = Cursors.WaitCursor; Department newDepartment = new Department() { Id = Guid.NewGuid(), Description = inp.InputLine1.Text, ShortId = inp.InputLine2.Text }; _dataContext.Departments.Add(newDepartment); _dataContext.SaveChanges(); RefreshTree(); OnChanged(EventArgs.Empty); Cursor = Cursors.Default; } else { MessageBox.Show(string.Format(@"Подразделение '{0}' существует.", inp.InputLine1.Text), @"Информация", MessageBoxButtons.OK); } } catch (Exception) { throw; } } } }
private void cmiCardChange_Click(object sender, EventArgs e) { Equipment card = lbCards.SelectedRows[0].DataBoundItem as Equipment; if (card == null) return; InputDualLine input = new InputDualLine { Label1 = {Text = @"Название линейной карты"}, Label2 = {Text = @"Серийный номер"}, Text = @"Изменение названия карты", InputLine1 = {Text = card.Description}, InputLine2 = {Text = card.SerialNumber} }; if (input.ShowDialog(this) == DialogResult.OK) { card.Description = input.InputLine1.Text; card.SerialNumber = input.InputLine2.Text; } lbCards.DataSource = _clonedEquipment.ChildEquipments.OrderBy(equ => equ.Description).ToList(); }
private void cmiCardAdd_Click(object sender, EventArgs e) { InputDualLine input = new InputDualLine {Label1 = {Text = @"Название линейной карты"}, Label2 = {Text = @"Серийный номер"}, Text = @"Добавление новой карты"}; if (input.ShowDialog(this) == DialogResult.OK) { Equipment newCard=new Equipment { EquipmentId = Guid.NewGuid(), Description = !string.IsNullOrEmpty(input.InputLine1.Text) ? input.InputLine1.Text : @"Новое название", SerialNumber = input.InputLine2.Text, Area = _area, ParentEquipment = _clonedEquipment }; _clonedEquipment.ChildEquipments.Add(newCard); lbCards.DataSource = _clonedEquipment.ChildEquipments.OrderBy(equ => equ.Description).ToList(); } }