示例#1
0
        private void ShowDrivers()
        {
            ShowBusesBtn.ForeColor   = Color.Black;
            ShowBusesBtn.BackColor   = Color.White;
            ShowRoutesBtn.ForeColor  = Color.Black;
            ShowRoutesBtn.BackColor  = Color.White;
            ShowDriversBtn.ForeColor = Color.White;
            ShowDriversBtn.BackColor = Color.Black;

            Table.Rows.Clear();
            Table.Columns.Clear();
            Table.Refresh();

            collectionName        = "drivers";
            AddNewElementBtn.Text = "Новый водитель";

            var documents = database.LoadAllDocuments <Driver>("drivers");

            Table.ColumnCount = 8;

            Table.Columns[0].Name    = "ID";
            Table.Columns[0].Visible = false;

            Table.Columns[1].Name = "ФИО";
            Table.Columns[2].Name = "Класс";
            Table.Columns[3].Name = "Стаж";
            Table.Columns[4].Name = "ЗП";
            Table.Columns[5].Name = "Автобус";
            Table.Columns[6].Name = "Маршрут";
            Table.Columns[7].Name = "График";

            foreach (var doc in documents)
            {
                string ID = Convert.ToString(doc.Id);

                var drivers_bus   = database.LoadDocumentById <Bus>("buses", doc.BusId);
                var drivers_route = database.LoadDocumentById <Route>("routes", doc.RouteId);

                string fullName = $"{doc.LastName} {doc.Name} {doc.Patronymic}";
                string grade    = Convert.ToString(doc.Grade);
                string exp      = Convert.ToString(doc.Experience);
                string sal      = Convert.ToString(doc.Salary);
                string bus      = $"{drivers_bus.Type} {drivers_bus.Number}";
                string route    = $"{drivers_route.Number}: {drivers_route.StPoint} — {drivers_route.EndPoint}";
                string schedule = "";
                foreach (var day in doc.Schedule)
                {
                    schedule += $" {day}";
                }

                string[] row = { ID, fullName, grade, exp, sal, bus, route, schedule };

                Table.Rows.Add(row);
            }
        }
示例#2
0
        private void saveBusBtn_Click(object sender, EventArgs e)
        {
            var bus = database.LoadDocumentById <Bus>(collectionName, id);

            if (numberInput.Text.Length != 0 &&
                typeInput.SelectedIndex > -1 &&
                capacityInput.Text.Length != 0)
            {
                bus.Number    = numberInput.Text;
                bus.Type      = typeInput.Text;
                bus.Сapacity  = Convert.ToInt32(capacityInput.Text);
                bus.IsWorking = (isWorkingInput.SelectedIndex == 0);
                database.UpdateDocument <Bus>(collectionName, id, bus);
                this.Close();
            }
            else
            {
                saveBusBtn.ForeColor = Color.FromName("red");
                saveBusBtn.Text      = "Заполните обязательные поля и попробуйте снова!";
            }
        }