Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            chart1.Visible = true;
            var startTicks = dateTimePicker1.Value.Date.Ticks;
            var endTicks   = dateTimePicker2.Value.Date.AddDays(1).Ticks;

            var eventList = MongoRepositoryOrgEvent.GetByDate(startTicks, endTicks, new List <EventType>
            {
                EventType.DISASSEMBLY,
                EventType.INSTALL,
                EventType.REVISION,
                EventType.VERIFICATION
            });

            var implementers = MongoRepositoryImplementers.GetAll();

            chart1.Series.Clear();
            chart1.Series.Add(new Series(""));
            chart1.Series[0].ChartType = SeriesChartType.Pie;

            foreach (var imp in implementers)
            {
                var count = eventList.Count(c => c.ImplementerId == imp.Id);
                var perc  = eventList.Count != 0 ? decimal.Round((decimal)count / (decimal)eventList.Count * 100, 2) : 0;
                chart1.Series[0].Points.AddXY(imp.Name + " (" + perc + "%)", count);
            }
        }
Ejemplo n.º 2
0
        private void EventForm_Load(object sender, EventArgs e)
        {
            var implementers = MongoRepositoryImplementers.GetAll();

            foreach (var imp in implementers)
            {
                comboBox_implementer.Items.Add(new ComboBoxItem(imp.Name, imp.Id));
            }
            if (OrgEvent == null)
            {
                comboBox_implementer.SelectedIndex = 0;
                comboBox_eventType.SelectedIndex   = 0;
                comboBox_counterType.SelectedIndex = 0;
            }
            else
            {
                textBox_street.Text                = Address?.Street;
                textBox_house.Text                 = Address?.House;
                textBox_building.Text              = Address?.Building;
                textBox_apartment.Text             = Address?.Apartment;
                comboBox_eventType.SelectedIndex   = (int)OrgEvent.EventType;
                textBox_place.Text                 = OrgEvent.Place;
                dateTimePicker_date.Value          = new DateTime(OrgEvent.DateTime);
                comboBox_counterType.SelectedIndex = (int)OrgEvent.CounterType;
                textBox_count.Text                 = OrgEvent.Count.ToString(CultureInfo.InvariantCulture);

                var impId = OrgEvent.ImplementerId;
                //var index = comboBox_implementer.Items.

                //var impIndex = ((ComboBoxItem)comboBox_implementer.SelectedItem).HiddenValue,
                //comboBox_implementer.SelectedIndex = comboBox_implementer
            }
        }
Ejemplo n.º 3
0
        private void button_update_Click(object sender, EventArgs e)
        {
            var selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
            var selectedRow      = dataGridView1.Rows[selectedrowindex];
            var id  = Guid.Parse(selectedRow.Cells["Id"].Value.ToString());
            var imp = MongoRepositoryImplementers.Get(id);

            new ImplementerForm(imp).ShowDialog();
        }
Ejemplo n.º 4
0
        private void ImplementersForm_Load(object sender, EventArgs e)
        {
            var implementers = MongoRepositoryImplementers.GetAll();

            foreach (var imp in implementers)
            {
                dataGridView1.Rows.Add(imp.Id, imp.ContactName, imp.Name, imp.Phone);
            }
        }
Ejemplo n.º 5
0
        private void RefreshForm()
        {
            dataGridView1.Rows.Clear();
            var implementers = MongoRepositoryImplementers.GetAll();

            foreach (var imp in implementers)
            {
                dataGridView1.Rows.Add(imp.Id, imp.Name, imp.ContactName, imp.Phone);
            }
        }
Ejemplo n.º 6
0
        private void button_delete_Click(object sender, EventArgs e)
        {
            var selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
            var selectedRow      = dataGridView1.Rows[selectedrowindex];
            var id = Guid.Parse(selectedRow.Cells["Id"].Value.ToString());

            MongoRepositoryImplementers.Remove(id);
            dataGridView1.Rows.Remove(selectedRow);
            dataGridView1.Refresh();
        }
Ejemplo n.º 7
0
        //private void MainForm_Load(object sender, EventArgs e)
        //{
        //    //DGVBind();

        //    //var bindingList = new BindingList<Implementer>(implementers);
        //    //var source = new BindingSource(bindingList, null);
        //    //dataGridView1.DataSource = source;
        //}

        private void MainForm_Activated(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            var eventList    = MongoRepositoryOrgEvent.GetAll();
            var addressList  = MongoRepositoryAddresses.GetAll();
            var implementers = MongoRepositoryImplementers.GetAll();

            foreach (var orgEvent in eventList)
            {
                var address       = addressList.First(w => w.Id == orgEvent.AddressId);
                var addressString = string.Join(", ", new List <string> {
                    address.Street, address.House, address.Building, address.Apartment
                });

                var implementer = implementers.First(a => a.Id == orgEvent.ImplementerId).Name;

                var counterType = String.Empty;
                switch (orgEvent.CounterType)
                {
                case Models.CounterType.COLD:
                    counterType = "Холодная вода";
                    break;

                case Models.CounterType.HOT:
                    counterType = "Горячая вода";
                    break;

                case Models.CounterType.ELECTRO:
                    counterType = "Электрический";
                    break;
                }

                var eventType = string.Empty;
                switch (orgEvent.EventType)
                {
                case Models.EventType.INSTALL:
                    eventType = "Установка";
                    break;

                case Models.EventType.REVISION:
                    eventType = "Переустановка";
                    break;

                case Models.EventType.VERIFICATION:
                    eventType = "Поверка";
                    break;

                case Models.EventType.DISASSEMBLY:
                    eventType = "Демонтаж";
                    break;
                }

                dataGridView1.Rows.Add(orgEvent.Id, orgEvent.AddressId, addressString, counterType, orgEvent.Place, new DateTime(orgEvent.DateTime).ToString("D"), implementer, eventType);
            }
        }
Ejemplo n.º 8
0
        private void button_add_Click(object sender, EventArgs e)
        {
            var implementer = new Implementer
            {
                Id                                     = Implementer == null?Guid.NewGuid() : Implementer.Id,
                                           Name        = textBox_name.Text,
                                           ContactName = textBox_contactName.Text,
                                           Phone       = textBox_phone.Text
            };

            MongoRepositoryImplementers.Upsert(implementer);
            Close();
        }