Esempio n. 1
0
        private void btnTourEdit_Click(object sender, EventArgs e)
        {
            if (TourMode != OperationType.Edit)
            {
                LoadTourMode(OperationType.Edit);
                return;
            }
            try
            {
                var tour = new Core.Models.Tour(tbTourName.Text,
                                                Int32.Parse(tbTourPrice.Text == "" ? "-1" : tbTourPrice.Text),
                                                tbTourDescription.Text,
                                                Int32.Parse(cbTourType.SelectedValue.ToString()));
                int id = Int32.Parse(tbTourID.Text);
                tour.Id = id;
                TourBLL.Update(tour);
                MessageBox.Show($"Sửa tour {id} thành công");
                LoadTourMode(OperationType.View);

                Thread threadLoadTourDataGridView = new Thread(new ThreadStart(() => LoadTourDataGridView()));
                threadLoadTourDataGridView.Start();
            }
            catch (FormatException)
            {
                MessageBox.Show("Giá tour không được chứa chữ");
            }
            catch (Exception ex)
            {
                GUIExtensionMethod.HandleError(ex);
            }
        }
Esempio n. 2
0
 private void btnTourAdd_Click(object sender, EventArgs e)
 {
     if (TourMode != OperationType.Add)
     {
         LoadTourMode(OperationType.Add);
         return;
     }
     try
     {
         var tour = new Core.Models.Tour(tbTourName.Text,
                                         Int32.Parse(tbTourPrice.Text.Equals("") ? "-1" : tbTourPrice.Text),
                                         tbTourDescription.Text,
                                         Int32.Parse(cbTourType.SelectedValue.ToString()));
         TourBLL.Add(tour);
         MessageBox.Show($"Thêm tour thành công");
         LoadTourMode(OperationType.View);
         Thread threadLoadTourDataGridView = new Thread(new ThreadStart(() => LoadTourDataGridView()));
         threadLoadTourDataGridView.Start();
     }
     catch (FormatException)
     {
         MessageBox.Show("Giá tiền không được để số");
     }
     catch (Exception ex)
     {
         GUIExtensionMethod.HandleError(ex);
     }
 }