FormDanhMucTour.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TourDuLich.BIZ;
namespace TourDuLich
{
public partial class FormDanhMucTour : Form
{
List<BizTour> tours = new List<BizTour>();
public FormDanhMucTour()
{
InitializeComponent();
}
private void btnThem_Click(object sender, EventArgs e)
{
BizTour tour = new BizTour(-1);
FormTour frmTour = new FormTour(tour);
frmTour.Show();
}
private void btnDong_Click(object sender, EventArgs e)
{
this.Close();
}
private void FormDanhMucTour_Load(object sender, EventArgs e)
{
tours = BizTour.GetAllTours();
gvTour.Columns["maTour"].DataPropertyName = "MaTour";
gvTour.Columns["tenTour"].DataPropertyName = "TenTour";
gvTour.Columns["loaiTour"].DataPropertyName = "TenLoaiTour";
gvTour.Columns["tourTN"].DataPropertyName = "LaTourTrongNuoc";
gvTour.AutoGenerateColumns = false;
gvTour.DataSource = tours;
}
private void gvTour_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == gvTour.Columns["xoa"].Index)
{
BizTour tour = tours[e.RowIndex];
if (MessageBox.Show("Bạn chắc chứ?", "Hỏi", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
try
{
tour.Delete();
}
catch (Exception ex)
{
//
MessageBox.Show(ex.Message);
}
tours.Remove(tour);
gvTour.DataSource = null;
gvTour.DataSource = tours;
}
}
else if (e.ColumnIndex == gvTour.Columns["sua"].Index)
{
BizTour tour = tours[e.RowIndex];
FormTour frmTour = new FormTour(tour);
frmTour.Show();
}
}
}
}
Bạn đang đọc truyện trên: Truyen247.Pro