private void FormTour_Load(object sender, EventArgs e)
 {
     if (id.HasValue)
     {
         try
         {
             var view = logic.Read(new TourBindingModel {
                 Id = id
             })?[0];
             if (view != null)
             {
                 textBoxName.Text             = view.TourName;
                 textBoxCountry.Text          = view.Country;
                 textBoxDuration.Text         = view.Duration.ToString();
                 textBoxCost.Text             = view.Cost.ToString();
                 textBoxTypeOfAllocation.Text = view.TypeOfAllocation;
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
     }
 }
예제 #2
0
        public FormTravelTour(ITourLogic logic)
        {
            InitializeComponent();
            List <TourViewModel> list = logic.Read(null);

            if (list != null)
            {
                comboBoxTour.DisplayMember = "TourName";
                comboBoxTour.ValueMember   = "Id";
                comboBoxTour.DataSource    = list;
                comboBoxTour.SelectedItem  = null;
            }
        }
 private void LoadData()
 {
     try
     {
         var list = logic.Read(null);
         if (list != null)
         {
             dataGridView.DataSource              = list;
             dataGridView.Columns[0].Visible      = false;
             dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
                         MessageBoxIcon.Error);
     }
 }