示例#1
0
        private void saveRouteBtn_Click(object sender, EventArgs e)
        {
            if (numberInput.Text.Length != 0 &&
                stPointInput.Text.Length != 0 &&
                endPointInput.Text.Length != 0 &&
                stTimeInpuut.Text.Length != 0 &&
                endTimeInput.Text.Length != 0 &&
                intervalInput.Text.Length != 0
                )
            {
                string[] stTime  = stTimeInpuut.Text.Split(':');
                string[] endTime = endTimeInput.Text.Split(':');

                var route = database.LoadDocumentById <Route>(collectionName, id);

                route.Number   = Convert.ToInt32(numberInput.Text);
                route.StPoint  = stPointInput.Text;
                route.EndPoint = endPointInput.Text;
                route.StTime   = stTimeInpuut.Text;
                route.EndTime  = endTimeInput.Text;
                route.Interval = Convert.ToInt32(intervalInput.Text);
                route.Length   = (((Convert.ToInt32(endTime[0]) * 60 + Convert.ToInt32(endTime[1])) - (Convert.ToInt32(stTime[0]) * 60 + Convert.ToInt32(stTime[1]))) * 10);

                database.UpdateDocument <Route>("routes", id, route);
                this.Close();
            }
            else
            {
                saveRouteBtn.ForeColor = Color.FromName("red");
                saveRouteBtn.Text      = "Заполните обязательные поля и попробуйте снова!";
            }
        }
示例#2
0
        private void saveDriverBtn_Click(object sender, EventArgs e)
        {
            if (NameInput.Text.Length > 0 &&
                LastNameInput.Text.Length > 0 &&
                GradeInput.SelectedIndex > -1 &&
                ExpInput.Text.Length > 0 &&
                BusInput.SelectedIndex > -1 &&
                RouteInput.SelectedIndex > -1
                )
            {
                var buses_doc  = database.LoadAllDocuments <Bus>("buses");
                var routes_doc = database.LoadAllDocuments <Route>("routes");

                var driver = database.LoadDocumentById <Driver>(collectionName, id);

                driver.Name       = NameInput.Text;
                driver.LastName   = LastNameInput.Text;
                driver.Patronymic = PatronymicInput.Text;
                driver.Grade      = GradeInput.SelectedIndex + 1;
                driver.Experience = Convert.ToInt32(ExpInput.Text);
                driver.BusId      = buses_doc[BusInput.SelectedIndex].Id;
                driver.RouteId    = routes_doc[RouteInput.SelectedIndex].Id;

                driver.Schedule.Clear();

                if (MonCheck.Checked)
                {
                    driver.Schedule.Add("Пн");
                }
                if (TuesCheck.Checked)
                {
                    driver.Schedule.Add("Вт");
                }
                if (WedCheck.Checked)
                {
                    driver.Schedule.Add("Ср");
                }
                if (ThursCheck.Checked)
                {
                    driver.Schedule.Add("Чт");
                }
                if (FriCheck.Checked)
                {
                    driver.Schedule.Add("Пт");
                }
                if (SatCheck.Checked)
                {
                    driver.Schedule.Add("Сб");
                }
                if (SunCheck.Checked)
                {
                    driver.Schedule.Add("Вс");
                }

                driver.Salary = (2000 + 100 * driver.Experience) / driver.Grade * driver.Schedule.Count * 4;

                database.UpdateDocument <Driver>("drivers", id, driver);
                this.Close();
            }
            else
            {
                saveDriverBtn.ForeColor = Color.FromName("red");
                saveDriverBtn.Text      = "Заполните обязательные поля и попробуйте снова!";
            }
        }