コード例 #1
0
        private void updateTour()
        {
            var category    = cbTourCategory.SelectedItem as TourCategory;
            var destination = cbDestination.SelectedItem as Destination;

            if (tbTourName.Text.Trim() == "" || tbTourPrice.Text.Trim() == "")
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin, bạn đã bỏ sót thông tin nào đó!");
                return;
            }
            try
            {
                _currentTour.TourPrice.price = decimal.Parse(tbTourPrice.Text.Trim());
            }
            catch
            {
                MessageBox.Show("Giá tiền không hợp lệ");
                return;
            }
            if (!checkDateTime(dtpStart_date.Value, dtpEnd_date.Value))
            {
                MessageBox.Show("Ngày hết hạn không được nhỏ hơn ngày áp dụng!");
                return;
            }
            _currentTour.name                 = tbTourName.Text.ToString();
            _currentTour.category_id          = category.id;
            _currentTour.destination_id       = destination.id;
            _currentTour.TourPrice.start_date = dtpStart_date.Value;
            _currentTour.TourPrice.end_date   = dtpEnd_date.Value;
            var _newtoursite = clbTourSite.CheckedItems.Cast <TourSite>();

            foreach (var site in _newtoursite)
            {
                _currentTour.TourSites.Add(site);
            }
            _tourBus.update(_currentTour);
            MessageBox.Show("Cập nhật thành công");
            _isAdd          = true;
            btnAddTour.Text = "Add";
            updateDataGridView();
        }