private void btSelectPlaceAddress_Click(object sender, EventArgs e)
 {
     InputSingleLineComboBox inp = new InputSingleLineComboBox
     {
         Text = @"Выбор адреса площадки",
         Label2 = { Text = @"Географический адрес:" },
         Label1 = { Text = @"Дополнительные данные:" },
         ComboBox1 =
         {
             ValueMember = "streetID",
             DisplayMember = "streetNameUkr",
             AutoCompleteSource = AutoCompleteSource.ListItems,
             DropDownStyle = ComboBoxStyle.DropDown,
             AutoCompleteMode = AutoCompleteMode.Suggest
         }
     };
     inp.tlMain.SetRow(inp.tlTextBox, 1);
     inp.tlMain.SetRow(inp.tlComboBox, 0);
     Cursor = Cursors.WaitCursor;
     List<Street> comboData = _dataContexts.NumEquipmentEntities.Streets.OrderBy(item => item.streetNameUkr).Where(item => !string.IsNullOrEmpty(item.streetNameUkr)).ToList();
     inp.ComboBox1.DataSource = comboData;
     if (!string.IsNullOrEmpty(tbPlace.Text))
     {
         var parts = tbPlace.Text.Split(',');
         var singleStreet = comboData.Where(st => st.streetNameUkr.Equals(parts[0])).ToList();
         switch (parts.Count())
         {
             case 0:
                 break;
             case 2:
                 inp.InputLine1.Text = parts[1].Trim();
                 if (singleStreet.Count() == 1)
                     inp.ComboBox1.SelectedItem = singleStreet.Single();
                 break;
             default:
                 if (singleStreet.Count() == 1)
                     inp.ComboBox1.SelectedItem = singleStreet.Single();
                 break;
         }
     }
     inp.ActiveControl = inp.ComboBox1;
     inp.RequireComboBoxValue = true;
     Cursor = Cursors.Default;
     if (inp.ShowDialog(this) == DialogResult.OK)
     {
         var street = inp.ComboBox1.SelectedItem as Street;
         if (street != null)
         {
             tbPlace.Text = street.streetNameUkr.Trim() + ", " + inp.InputLine1.Text.Trim();
         }
         else
         {
             tbPlace.Text = string.Empty;
         }
     }
 }
        public CustomersSideSelectionForm(MainDataContexts dataContexts)
        {
            InitializeComponent();
            _dataContexts = dataContexts;

            Rectangle rect = gvSides.GetCellDisplayRectangle(dcAddress.Index, -1, true);
            rect.Y = 2;
            rect.X = rect.Location.X;
            using (Graphics lGraphics = CreateGraphics())
            {
                const string data = @"Добавить площадку абонента";
                SizeF lSize = lGraphics.MeasureString(data, gvSides.Font);
                Button headerButton = new Button
                {
                    Text = data,
                    AutoSize = true,
                    Size = new Size(Convert.ToInt32(lSize.Width), Convert.ToInt32(lSize.Height)),
                    Location = rect.Location,
                    Enabled = true//TODO:implement right SharedAppData.IsFlagSet(ObjectAccessId, RightsFlags.Add)
                };
                headerButton.Top = headerButton.Top + 2;
                headerButton.Left = gvSides.Width - headerButton.Size.Width - 13;
                headerButton.TextAlign = ContentAlignment.TopCenter;
                headerButton.Click += (s, e) =>
                {
                    InputSingleLineComboBox inp=new InputSingleLineComboBox
                    {
                        Text = @"Добавление адреса площадки абонента",
                        Label2 = {Text = @"Географический адрес:"},
                        Label1 = {Text = @"Дополнительные данные:"},
                        ComboBox1 =
                        {
                            ValueMember = "streetID",
                            DisplayMember = "streetNameUkr",
                            AutoCompleteSource = AutoCompleteSource.ListItems,
                            DropDownStyle = ComboBoxStyle.DropDown,
                            AutoCompleteMode = AutoCompleteMode.Suggest
                        }
                    };
                    inp.tlMain.SetRow(inp.tlTextBox, 1);
                    inp.tlMain.SetRow(inp.tlComboBox, 0);
                    Cursor = Cursors.WaitCursor;
                    List<Street> comboData = _dataContexts.NumEquipmentEntities.Streets.OrderBy(item => item.streetNameUkr).Where(item => !string.IsNullOrEmpty(item.streetNameUkr)).ToList();
                    inp.ComboBox1.DataSource = comboData;
                    inp.ActiveControl = inp.ComboBox1;
                    inp.RequireComboBoxValue = true;
                    Cursor = Cursors.Default;
                    if (inp.ShowDialog(this) == DialogResult.OK)
                    {
                        var street = inp.ComboBox1.SelectedItem as Street;
                        string address;
                        if (street != null)
                        {
                            address = street.streetNameUkr + ", " + inp.InputLine1.Text;
                        }
                        else
                        {
                            address = inp.InputLine1.Text;
                        }
                        var currentCustomer = ((Customer)gvCustomers.SelectedRows[0].DataBoundItem);
                        CustomerSide newSide = new CustomerSide()
                        {
                            Id = Guid.NewGuid(),
                            Description = address,
                            Firmid = ((Firm) cbFirms.SelectedItem).FirmId,
                            CustomerId = Convert.ToInt32(currentCustomer.Customer_id.Trim())
                        };
                        
                        _dataContexts.AccEquipmentV2Entities.CustomerSides.Add(newSide);
                        _dataContexts.AccEquipmentV2Entities.SaveChanges();
                        _cachedCustomerSides = _dataContexts.AccEquipmentV2Entities.CustomerSides.ToList();
                        //_dataContexts.RefreshSideLinkInfos();
                        gvCustomers_SelectionChanged(gvCustomers, new EventArgs());
                        OnHistoryEvent(new HistoryEventArgs("Add CustomerSide", string.Format("{0} {1} {2}", newSide.Firmid, newSide.CustomerId, newSide.Description)));
                        Cursor = Cursors.Default;
                    }

                };

                gvSides.Controls.Add(headerButton);
                gvSides.ColumnHeadersHeight = headerButton.Height + 6;
                gvCustomers.ColumnHeadersHeight = headerButton.Height + 6;
            }
        }
Example #3
0
        private void btSelectAddress_Click(object sender, EventArgs e)
        {
            InputSingleLineComboBox inp = new InputSingleLineComboBox
            {
                Text = @"Добавление адреса площадки абонента",
                Label2 = {Text = @"Географический адрес:"},
                Label1 = {Text = @"Дополнительные данные:"},
                ComboBox1 =
                {
                    ValueMember = "streetID",
                    DisplayMember = "streetNameUkr",
                    AutoCompleteSource = AutoCompleteSource.ListItems,
                    DropDownStyle = ComboBoxStyle.DropDown,
                    AutoCompleteMode = AutoCompleteMode.Suggest
                }
            };
            inp.tlMain.SetRow(inp.tlTextBox, 1);
            inp.tlMain.SetRow(inp.tlComboBox, 0);
            Cursor = Cursors.WaitCursor;
            NumEquipmentsDataContext context=new NumEquipmentsDataContext();
            List<Street> comboData = context.NumEquipmentEntities.Streets.OrderBy(item => item.streetNameUkr).Where(item => !string.IsNullOrEmpty(item.streetNameUkr)).ToList();
            inp.ComboBox1.DataSource = comboData;
            inp.ActiveControl = inp.ComboBox1;
            inp.RequireComboBoxValue = true;
            Cursor = Cursors.Default;
            if (inp.ShowDialog(this) == DialogResult.OK)
            {
                var street = inp.ComboBox1.SelectedItem as Street;
                string address;
                if (street != null)
                {
                    address = street.streetNameUkr + ", " + inp.InputLine1.Text;
                }
                else
                {
                    address = inp.InputLine1.Text;
                }
                tbAddress.Text = address;
                tbAssignment.Text = string.Empty;
                tbEvent.Text = string.Empty;
            }

        }
Example #4
0
 private void btEventTransfer_Click(object sender, EventArgs e)
 {
     if (gvEvents.SelectedRows.Count != 1)
         return;
     EventPlainInfo eventPlainInfo = gvEvents.SelectedRows[0].DataBoundItem as EventPlainInfo;
     if (eventPlainInfo == null || eventPlainInfo.Tag == null)
         throw new Exception(@"Неправильные данные в таблице заявок!!!!");
     var users = _dataContexts.AccEquipmentV2Entities.Access_Users.Where(u => u.Description.Contains("дежурный") & u.DepartmentId != eventPlainInfo.Tag.Access_Users.DepartmentId);
     InputSingleLineComboBox inp = new InputSingleLineComboBox
     {
         Text = @"Передача заявки в другой департамент",
         Label1 = {Text = @"Уведомить по адресу"},
         Label2 = {Text = @"Департаменты"},
         ComboBox1 = {DisplayMember = "Department", ValueMember = "Id", DropDownStyle = ComboBoxStyle.DropDownList}
     };
     inp.ComboBox1.SelectedValueChanged += (_, __) =>
     {
         var selected = inp.ComboBox1.SelectedItem as Access_Users;
         if (selected == null)
             return;
         inp.InputLine1.Text = selected.Email;
     };
     inp.ComboBox1.DataSource = users.ToList();
     if (inp.ShowDialog(this) == DialogResult.OK)
     {
         var selected = inp.ComboBox1.SelectedItem as Access_Users;
         if (selected == null)
             throw new Exception(@"Неправильные данные о заявке!");
         Event transferedEvent = eventPlainInfo.Tag;
         string oldDepartment = transferedEvent.Access_Users.Department.Description;
         transferedEvent.CreationUserId = selected.Id;
         transferedEvent.Access_Users = selected;
         transferedEvent.EventComments.Add(new EventComment()
         {
             Access_Users = SharedAppData.LoggedUser,
             UserId = SharedAppData.LoggedUser.Id,
             CreationDate = DateTime.Now,
             Description = string.Format(@"Заявка передана из [{0}] в [{1}]", oldDepartment, selected.Department.Description),
             Id = Guid.NewGuid(),
             Event = transferedEvent,
             EventId = transferedEvent.Id
         });
         _dataContexts.AccEquipmentV2Entities.SaveChanges();
         RefreshCurrentPage();
         _clientProcessor.SendEventNotify(transferedEvent.Id);
         _manager.SendNotify(transferedEvent, RequestAction.Transfer, null,new string[] {inp.InputLine1.Text});
     }
 }
Example #5
0
 private void cbType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_clonedEvent.Type != (int) cbType.SelectedValue)
     {
         switch ((EventType) cbType.SelectedValue)
         {
             case EventType.StandartEvent:
                 cbSendENotify.Checked = false;
                 break;
             case EventType.RemedyEvent:
                 InputSingleLineComboBox input = new InputSingleLineComboBox()
                 {
                     Text = @"Описание работ по устранению заявки",
                     Label1 = {Text = @"Работы по устранению"},
                     Label2 = {Text = @"Устранил"},
                     ComboBox1 =
                     {
                         DataSource =
                             _dataContexts.AccEquipmentV2Entities.Events.Where(ev => ev.ClosePerson != string.Empty & ev.ClosePerson != null)
                                 .GroupBy(grp => grp.ClosePerson)
                                 .Select(grp => grp.Key)
                                 .ToList(),
                         SelectedIndex = -1
                     }
                 };
                 if (input.ShowDialog(this) == DialogResult.OK)
                 {
                     _remedyPerson = input.ComboBox1.Text;
                     _remedyData = input.InputLine1.Text;
                     _clonedEvent.EventComments.Add(new EventComment()
                     {
                         Access_Users = SharedAppData.LoggedUser,
                         UserId = SharedAppData.LoggedUser.Id,
                         CreationDate = DateTime.Now,
                         Description = @"Устранил: " + input.ComboBox1.Text + " Выполнены работы: " + input.InputLine1.Text,
                         Id = Guid.NewGuid(),
                         Event = _clonedEvent,
                         EventId = _clonedEvent.Id
                     });
                     gvEventComments.DataSource = _clonedEvent.EventComments.OrderBy(o => o.CreationDate).ToList();
                 }
                 else
                 {
                     cbType.SelectedIndexChanged -= cbType_SelectedIndexChanged;
                     cbType.SelectedIndex = _prevIndex;
                     cbType.SelectedIndexChanged += cbType_SelectedIndexChanged;
                     return;
                 }
                 cbSendENotify.Checked = (EventType) _managedEvent.Type != EventType.StandartEvent;
                 break;
             case EventType.TroubleEvent:
                 cbSendENotify.Checked = true;
                 break;
             case EventType.UnknownEvent:
                 cbSendENotify.Checked = false;
                 break;
             case EventType.ComplexRemedyTrouble:
             default:
                 throw new ArgumentOutOfRangeException();
         }
         _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 = (int) cbType.SelectedValue,
             Event = _clonedEvent
         });
         _clonedEvent.Type = (int) cbType.SelectedValue;
         gvEventHistory.DataSource = _clonedEvent.EventStatusHistories.OrderBy(o => o.ChangedDate).ToList();
         _prevIndex = cbType.SelectedIndex;
     }
 }
Example #6
0
 private void cmiPortChange_Click(object sender, EventArgs e)
 {
     EquipmentPort port = lbPorts.SelectedRows[0].DataBoundItem as EquipmentPort;
     if (port == null) return;
     InputSingleLineComboBox input=new InputSingleLineComboBox
     {
         Text = @"Изменение описания порта",
         Label1 = {Text = @"Название порта"},
         InputLine1 = {Text = port.Description},
         ComboBox1 =
         {
             DropDownStyle = ComboBoxStyle.DropDownList,
             DisplayMember = "Description",
             ValueMember = "PortTypeId",
             DataSource = _dataContexts.AccEquipmentV2Entities.PortTypes.OrderBy(portl => portl.Description).ToList(),
             SelectedValue = port.PortType.PortTypeId
         },
         Label2 = {Text = @"Тип порта"}
     };
     //input.ComboBox1.;
     if (input.ShowDialog(this)==DialogResult.OK)
     {
         PortType pt = input.ComboBox1.SelectedItem as PortType;
         if (pt==null)
             throw new Exception("invalid data in combobox");
         port.PortType = pt;
         port.PortTypeId = pt.PortTypeId;
         port.Description = input.InputLine1.Text;
         lbPorts.DataSource = _clonedEquipment.EquipmentPorts.OrderBy(portn => portn, new PortNameComparer()).ThenBy(portl => portl.PortType.Description).ToList();
     }
 }