Example #1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (AddSurname.Text.Length != 0 &&
                AddPhone.Text.Length != 0 &&
                AddPrice.Text.Length != 0 &&
                AddDuration.Text.Length != 0
                )
            {
                if (!Regex.IsMatch(AddPrice.Text, "^[0-9,.]+$"))
                {
                    MessageBox.Show("В поле цена должно быть указано число с запятой или точкой в формате 0,00 либо 0.00",
                                    "Ошибка ввода");
                }
                else
                {
                    var    priceT   = AddPrice.Text.Contains(".") ? AddPrice.Text.Replace('.', ',') : AddPrice.Text;
                    double price    = Convert.ToDouble(priceT);
                    var    duration = int.Parse(AddDuration.Text);


                    //проверить!!
                    IntercityCallModel model = new IntercityCallModel
                                                   (AddSurname.Text,
                                                   AddPhone.Text,
                                                   AddDatePicker.Value.Date,
                                                   duration,
                                                   price
                                                   );

                    Reqester req = new Reqester();
                    req.setAddRequest(new AddIntercityCall());
                    req.setGetRequest(new GetIntercityCalls());
                    req.AddReqest(model);

                    IntercityCallsForm form = Application.OpenForms.OfType <IntercityCallsForm>().Single();
                    form.UpdateAllView();
                }
            }
            else
            {
                MessageBox.Show("Заполните все поля и повторите попытку", "Ошибка");
            }
        }
Example #2
0
 private void AppendButton_Click(object sender, EventArgs e)
 {
     if (EventText.Text != "")
     {
         EventModel newEvent = new EventModel(
             DatePicker.Value.Date, EventText.Text);
         Reqester reqester = new Reqester();
         reqester.setAddRequest(new AddEvent());
         reqester.AddReqest(newEvent);
         var EventView =
             (Application.OpenForms["MainForm"].Controls["LayoutPanel"].Controls["EventView"]
              as DataGridView);
         EventView.Rows.Clear();
         reqester.setGetRequest(new GetTodayEvents());
         var eventsList = reqester.GetReqest();
         foreach (EventModel row in eventsList)
         {
             EventView.Rows.Add(row.ID, row.DateOfEvent, row.Event);
         }
     }
 }