Exemplo n.º 1
0
 private void miChange_Click(object sender, EventArgs e)
 {
     Area selectedArea = AreasTree.SelectedNode != null ? AreasTree.SelectedNode.Tag as Area : null;
     if (selectedArea != null)
     {
         InputSingleLine inp = new InputSingleLine() {Text = @"Редактирование названия узла", InputLine = {Text = selectedArea.Description}};
         if (inp.ShowDialog(this) == DialogResult.OK)
         {
             try
             {
                 var pData = _dataContext.Areas.FirstOrDefault(area => area.Description.Equals(inp.InputLine.Text));
                 if (pData == null)
                 {
                     Cursor = Cursors.WaitCursor;
                     string oldValue = selectedArea.Description;
                     selectedArea.Description = inp.InputLine.Text;
                     _dataContext.SaveChanges();
                     RefreshTree();
                     OnHistoryEvent(new HistoryEventArgs("Change AreaDescription", string.Format("[{0}] -> [{1}]", oldValue, inp.InputLine.Text)));
                     OnChanged(EventArgs.Empty);
                     Cursor = Cursors.Default;
                 }
                 else
                 {
                     MessageBox.Show(string.Format(@"Узел '{0}' существует.", inp.InputLine.Text), @"Информация", MessageBoxButtons.OK);
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }
Exemplo n.º 2
0
 private void miChange_Click(object sender, EventArgs e)
 {
     PortType selectedType = PortTypesGrid.SelectedNode != null ? PortTypesGrid.SelectedNode.Tag as PortType : null;
     if (selectedType != null)
     {
         InputSingleLine inp = new InputSingleLine() { Text = @"Редактирование названия узла", InputLine = { Text = selectedType.Description } };
         if (inp.ShowDialog(this) == DialogResult.OK)
         {
             try
             {
                 var pData = _dataContext.PortTypes.FirstOrDefault(pt => pt.Description.Equals(inp.InputLine.Text));
                 if (pData == null)
                 {
                     string oldValue = selectedType.Description;
                     selectedType.Description = inp.InputLine.Text;
                     _dataContext.SaveChanges();
                     OnHistoryEvent(new HistoryEventArgs("Change PortType", string.Format("[{0}] -> [{1}]", oldValue, inp.InputLine.Text)));
                     OnChanged(EventArgs.Empty);
                 }
                 else
                 {
                     MessageBox.Show(string.Format(@"Тип порта '{0}' существует.", inp.InputLine.Text), @"Информация", MessageBoxButtons.OK);
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }
Exemplo n.º 3
0
 private void miAdd_Click(object sender, EventArgs e)
 {
     InputSingleLine input=new InputSingleLine() {Text=@"Добавление нового типа работ"};
     if (input.ShowDialog(this) == DialogResult.OK)
     {
         string typeDescription = input.InputLine.Text;
         if (string.IsNullOrEmpty(typeDescription) && string.IsNullOrWhiteSpace(typeDescription))
             return;
         InstallersWorks_WorkTypes workType = new InstallersWorks_WorkTypes() { Id = Guid.NewGuid(), TypeDescription = typeDescription };
         _dataContexts.IWEntities.InstallersWorks_WorkTypes.Add(workType);
         _dataContexts.IWEntities.SaveChanges();
         LoadData();
     }
 }
Exemplo n.º 4
0
 private void miAdd_Click(object sender, EventArgs e)
 {
     InputSingleLine inp = new InputSingleLine() { Text = @"Введите название типа порта" };
     if (inp.ShowDialog(this) == DialogResult.OK)
     {
         if (!string.IsNullOrEmpty(inp.InputLine.Text))
         {
             try
             {
                 var pData = _dataContext.PortTypes.FirstOrDefault(pt => pt.Description.Equals(inp.InputLine.Text));
                 if (pData == null)
                 {
                     Cursor = Cursors.WaitCursor;
                     PortType newPortType = new PortType()
                     {
                         PortTypeId = Guid.NewGuid(),
                         Description = inp.InputLine.Text,
                     };
                     _dataContext.PortTypes.Add(newPortType);
                     _dataContext.SaveChanges();
                     RefreshTree();
                     OnHistoryEvent(new HistoryEventArgs("Add PortType", inp.InputLine.Text));
                     OnChanged(EventArgs.Empty);
                     Cursor = Cursors.Default;
                 }
                 else
                 {
                     MessageBox.Show(string.Format(@"Тип порта '{0}' существует.", inp.InputLine.Text), @"Информация", MessageBoxButtons.OK);
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }
Exemplo n.º 5
0
 private void miChange_Click(object sender, EventArgs e)
 {
     if (gvWorkTypes.SelectedRows.Count != 1)
         return;
     InstallersWorks_WorkTypes workType = gvWorkTypes.SelectedRows[0].DataBoundItem as InstallersWorks_WorkTypes;
     if (workType == null)
         throw new Exception("Invalid data in grid gvWorkTypes");
     InputSingleLine input = new InputSingleLine {Text = @"Изменение названия типа работ", InputLine = {Text = workType.TypeDescription}};
     if (input.ShowDialog(this) == DialogResult.OK)
     {
         if (input.InputLine.Text != workType.TypeDescription)
         {
             workType.TypeDescription = input.InputLine.Text;
             _dataContexts.IWEntities.SaveChanges();
             LoadData();
         }
     }
 }
Exemplo n.º 6
0
 private void btEdit_Click(object sender, EventArgs e)
 {
     var inp = new InputSingleLine { Text = @"Изменение названия списка рассылки" };
     var selectedList = cbReceiversLists.SelectedItem as NotifyReceiversList;
     if (selectedList == null)
         return;
     inp.InputLine.Text = selectedList.Description;
     if (inp.ShowDialog(this) == DialogResult.OK)
     {
         gvReceivers.EndEdit();
         selectedList.Description = inp.InputLine.Text;
         cbReceiversLists.DataSource = _receiversLists.ToList();
         cbReceiversLists.SelectedValue = selectedList.Id;
     }
 }
Exemplo n.º 7
0
 private void btAdd_Click(object sender, EventArgs e)
 {
     var inp = new InputSingleLine {Text = @"Добавление нового списка рассылки"};
     if (inp.ShowDialog(this)==DialogResult.OK)
     {
         gvReceivers.EndEdit();
         var notifyList = new NotifyReceiversList() {Id = Guid.NewGuid(), Description = inp.InputLine.Text};
         _receiversLists.Add(notifyList);
         cbReceiversLists.DataSource = _receiversLists.ToList();
         cbReceiversLists.SelectedValue = notifyList.Id;
     }
 }
Exemplo n.º 8
0
 private void miAdd_Click(object sender, EventArgs e)
 {
     InputSingleLine inp = new InputSingleLine() {Text = @"Введите название узла"};
     Area selectedArea = AreasTree.SelectedNode != null ? AreasTree.SelectedNode.Tag as Area : null;
     if (inp.ShowDialog(this) == DialogResult.OK)
     {
         if (!string.IsNullOrEmpty(inp.InputLine.Text))
         {
             try
             {
                 Cursor = Cursors.WaitCursor;
                 var pData = _dataContext.Areas.FirstOrDefault(area => area.Description.Equals(inp.InputLine.Text));
                 if (pData == null)
                 {
                     Area newArea = new Area()
                     {
                         AreaId = Guid.NewGuid(),
                         Description = inp.InputLine.Text,
                         ParentAreaId = selectedArea != null ? selectedArea.AreaId : (Guid?) null,
                         ParentArea = selectedArea
                     };
                     _dataContext.Areas.Add(newArea);
                     _dataContext.SaveChanges();
                     RefreshTree();
                     OnHistoryEvent(new HistoryEventArgs("Add AreaDescription", inp.InputLine.Text));
                     OnChanged(EventArgs.Empty);
                     Cursor = Cursors.Default;
                 }
                 else
                 {
                     MessageBox.Show(string.Format(@"Узел '{0}' существует.", inp.InputLine.Text), @"Информация", MessageBoxButtons.OK);
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }
Exemplo n.º 9
0
 private void btAddComment_Click(object sender, EventArgs e)
 {
     InputSingleLine inp = new InputSingleLine() {Text = @"Текст комментария"};
     if (inp.ShowDialog(this) == DialogResult.OK)
     {
         _clonedEvent.EventComments.Add(new EventComment()
         {
             Access_Users = SharedAppData.LoggedUser,
             UserId = SharedAppData.LoggedUser.Id,
             CreationDate = DateTime.Now,
             Description = inp.InputLine.Text,
             Id = Guid.NewGuid(),
             Event = _clonedEvent,
             EventId = _clonedEvent.Id
         });
         _clonedEvent.EventStatusHistories.Add(new EventStatusHistory()
         {
             ChangedDate = DateTime.Now,
             ChangedInfo = @"Добавление комментария",
             ChangedUserId = SharedAppData.LoggedUser.Id,
             Access_Users = SharedAppData.LoggedUser,
             Id = Guid.NewGuid(),
             OldState = _clonedEvent.State,
             NewState = _clonedEvent.State,
             OldType = _clonedEvent.Type,
             NewType = _clonedEvent.Type,
             Event = _clonedEvent,
             EventId = _clonedEvent.Id
         });
         gvEventComments.DataSource = _clonedEvent.EventComments.OrderBy(o => o.CreationDate).ToList();
         gvEventHistory.DataSource = _clonedEvent.EventStatusHistories.OrderBy(o => o.ChangedDate).ToList();
     }
 }