Ejemplo n.º 1
0
        public static GiaBUS getGiaHienTai(TourBUS tour)
        {
            GiaBUS     gia        = new GiaBUS();
            Connection connection = new Connection();

            using (SqlCommand command = new SqlCommand("proc_getGiaHienTai", connection.getConnection()))
            {
                connection.open();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@matour", tour.MaTour);
                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    gia.Id          = int.Parse(reader["id"].ToString());
                    gia.Tien        = long.Parse(reader["tien"].ToString());
                    gia.NgayBatDau  = DateTime.Parse(reader["ngayBatDau"].ToString());
                    gia.NgayKetThuc = DateTime.Parse(reader["ngayKetThuc"].ToString());
                    gia.MaTour      = tour.MaTour;
                }
                reader.Close();
                connection.close();
            }

            return(gia);
        }
Ejemplo n.º 2
0
        private void LoadData()
        {
            LoaiTourBUS loaiTourBus = new LoaiTourBUS();

            cbo_LoaiTour.DisplayMember = "TenLoaiTour";
            cbo_LoaiTour.ValueMember   = "MaLoaiTour";
            cbo_LoaiTour.DataSource    = loaiTourBus.LoadLoaiTourToCombobox();
            DiaDiemBUS diaDiemBus = new DiaDiemBUS();
            DataTable  table      = diaDiemBus.LoadDiaDiem();

            cbo_NoiDen.DisplayMember = "TenDiaDiem";
            cbo_NoiDen.ValueMember   = "MaDiaDiem";
            cbo_NoiDen.DataSource    = table;
            cbo_NoiDi.DisplayMember  = "TenDiaDiem";
            cbo_NoiDi.ValueMember    = "MaDiaDiem";
            cbo_NoiDi.DataSource     = diaDiemBus.LoadDiaDiem();
            HuongDanVienBUS huongDanVienBus = new HuongDanVienBUS();

            cbo_HuongDanVien.ValueMember   = "MaHDV";
            cbo_HuongDanVien.DisplayMember = "TenHDV";
            cbo_HuongDanVien.DataSource    = huongDanVienBus.LoadHuongDanVienToCombobox();
            KhachSanBUS khachSanBus = new KhachSanBUS();

            cbo_KhachSan.DisplayMember = "TenKS";
            cbo_KhachSan.ValueMember   = "MaKS";
            cbo_KhachSan.DataSource    = khachSanBus.LoadKhachSan();
            TourBUS tourBus = new TourBUS();

            gridControl_Tour.DataSource = tourBus.LoadTourToDataGridView();
        }
Ejemplo n.º 3
0
        public static List <GiaBUS> getGiaByTour(TourBUS tour)
        {
            List <GiaBUS> dsGia      = new List <GiaBUS>();
            String        query      = "select * from Gia where maTour=@tour";
            Connection    connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();
                command.Parameters.AddWithValue("@tour", tour.MaTour);
                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    GiaBUS gia = new GiaBUS();
                    gia.Id          = int.Parse(reader["id"].ToString());
                    gia.Tien        = long.Parse(reader["tien"].ToString());
                    gia.NgayBatDau  = DateTime.Parse(reader["ngayBatDau"].ToString());
                    gia.NgayKetThuc = DateTime.Parse(reader["ngayKetThuc"].ToString());
                    gia.MaTour      = tour.MaTour;

                    dsGia.Add(gia);
                }
                reader.Close();
                connection.close();
            }

            return(dsGia);
        }
Ejemplo n.º 4
0
        public static List <TourBUS> timkiemTour(String keyword)
        {
            List <TourBUS> tours      = new List <TourBUS>();
            Connection     connection = new Connection();

            using (SqlCommand command = new SqlCommand("proc_timkiemTour", connection.getConnection()))
            {
                connection.open();
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@keyword", keyword.ToUpper());
                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    TourBUS tour = new TourBUS();
                    tour.MaTour           = reader["maTour"].ToString();
                    tour.TenTour          = reader["tenTour"].ToString();
                    tour.LoaiTour.MaLoai  = reader["maLoai"].ToString();
                    tour.LoaiTour.TenLoai = reader["tenLoai"].ToString();
                    tour.DsDiaDiem        = DiaDiemDAO.getDiaDiemByTour(tour);
                    tour.GiaHienTai       = GiaDAO.getGiaHienTai(tour);
                    tour.DsGia            = GiaDAO.getGiaByTour(tour);

                    tours.Add(tour);
                }
                reader.Close();
                connection.close();
            }

            return(tours);
        }
        private void LoadData()
        {
            TourBUS tourBus = new TourBUS();

            tourChiTiet                  = tourBus.TimTour(frm_Tour.BookedTour.MaTour);
            lbl_GiaKS.Text               = tourChiTiet.GiaKhachSan.ToString();
            lbl_GiaNguoiLon.Text         = tourChiTiet.Tour.GiaNguoiLon.ToString();
            lbl_GiaTreEm.Text            = tourChiTiet.Tour.GiaTreEm.ToString();
            lbl_MaTour.Text              = tourChiTiet.Tour.MaTour;
            lbl_NgayKH.Text              = tourChiTiet.Tour.NgayKH.Value.ToShortDateString();
            lbl_NgayKT.Text              = tourChiTiet.Tour.NgayKT.Value.ToShortDateString();
            lbl_NoiDen.Text              = tourChiTiet.Tour.DiemDen;
            lbl_NoiDi.Text               = tourChiTiet.Tour.DiemDi;
            lbl_TenKS.Text               = tourChiTiet.Tour.TenKhachSan;
            txt_NguoiLon.Text            = frm_Tour.BookedTour.NguoiLon.ToString();
            txt_TreEm.Text               = frm_Tour.BookedTour.TreEm.ToString();
            frm_Tour.BookedTour.TongTien = tourChiTiet.Tour.GiaNguoiLon * frm_Tour.BookedTour.NguoiLon * tourChiTiet.Tour.GiaTreEm * frm_Tour.BookedTour.TreEm;
            //txt_TongTien.Text = ().ToString();
            txt_TongTien.Text = frm_Tour.BookedTour.TongTien.ToString();

            var sex = new BindingList <KeyValuePair <string, int> >();

            sex.Add(new KeyValuePair <string, int>("Nam", 1));
            sex.Add(new KeyValuePair <string, int>("Nữ", 0));
            cbo_GioiTinh.DisplayMember = "Key";
            cbo_GioiTinh.ValueMember   = "Value";
            cbo_GioiTinh.DataSource    = sex;
        }
        public static List <DiaDiemBUS> getDiaDiemByTour(TourBUS tour)
        {
            List <DiaDiemBUS> dsDiaDiem  = new List <DiaDiemBUS>();
            String            query      = "select * from DiaDiem d,ChiTietTour c where d.maDiaDiem=c.maDiaDiem and c.maTour=@tour";
            Connection        connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();
                command.Parameters.AddWithValue("@tour", tour.MaTour);
                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    DiaDiemBUS diadiem = new DiaDiemBUS();
                    diadiem.MaDiaDiem  = reader["maDiaDiem"].ToString();
                    diadiem.TenDiaDiem = reader["tenDiaDiem"].ToString();
                    diadiem.Diaphuong  = reader["diaphuong"].ToString();

                    dsDiaDiem.Add(diadiem);
                }
                reader.Close();
                connection.close();
            }

            return(dsDiaDiem);
        }
        public frmTourGroupManager()
        {
            InitializeComponent();

            _tourGroupBus = new TourGroupBUS();

            _tourBus = new TourBUS();

            _passengerBus = new PassengerBUS();

            _customerBus = new CustomerBUS();

            _employeeTourGroupBus = new EmployeeTourGroupBUS();

            _transportTourGroupBus = new TransportTourGroupBUS();

            _transportBus = new TransportBUS();

            _employeeBus = new EmployeeBUS();

            _transportPresenter = new TransportPresenter(this);

            _tourGroupSearchPresenter = new TourGroupSearchPresenter(this);

            init();
        }
Ejemplo n.º 8
0
 public QLTour()
 {
     tourBUS     = new TourBUS();
     loaiHinhBUS = new LoaiHinhBUS();
     InitializeComponent();
     dgvTour.AutoGenerateColumns = false;
     dgvTour.DataSource          = null;
 }
Ejemplo n.º 9
0
        private void Save_Click(object sender, EventArgs e)
        {
            int k = 0;

            if (textBox_matour.Text == "")
            {
                k = 1;
                errorProvider1.SetError(textBox_matour, "Mã tour không được để trống!");
            }
            if (textBox_tentour.Text == "")
            {
                k = 1;
                errorProvider1.SetError(textBox_tentour, "Tên tour không được để trống!");
            }
            if (textBox_thongtintour.Text == "")
            {
                k = 1;
                errorProvider1.SetError(textBox_thongtintour, "Thông tin tour không được để trống!");
            }
            if (textBox_giatour.Text == "")
            {
                k = 1;
                errorProvider1.SetError(textBox_giatour, "Giá tour không được để trống!");
            }
            if (k == 0)
            {
                TourBUS tour = new TourBUS();
                TourDTO t    = new TourDTO();
                t.MaTour       = int.Parse(textBox_matour.Text);
                t.TenTour      = textBox_tentour.Text;
                t.ThongTinTour = textBox_thongtintour.Text;
                t.GiaTour      = int.Parse(textBox_giatour.Text);
                foreach (ListViewItem item in listView1.Items)
                {
                    if (item.Selected)
                    {
                        if (tour.suaTour(t) == 1)
                        {
                            MessageBox.Show("Lưu thành công!", "Thông báo");
                            item.Text             = textBox_matour.Text;
                            item.SubItems[1].Text = textBox_tentour.Text;
                            item.SubItems[2].Text = textBox_thongtintour.Text;
                            item.SubItems[3].Text = textBox_giatour.Text;
                        }
                        else
                        {
                            MessageBox.Show("Thêm thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Dispose();
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private void Delete_Click(object sender, EventArgs e)
        {
            TourBUS tour = new TourBUS();

            foreach (ListViewItem item in listView1.Items)
            {
                if (item.Checked || item.Selected)
                {
                    tour.xoaTour(int.Parse(item.SubItems[0].Text));
                    item.Remove();
                }
            }
        }
Ejemplo n.º 11
0
        private void btn_Tim_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txt_NguoiLon.Text))
            {
                errorProvider1.SetError(txt_NguoiLon, MessageBoxConstants.EMPTY);
            }
            if (String.IsNullOrEmpty(txt_TreEm.Text))
            {
                errorProvider2.SetError(txt_NguoiLon, MessageBoxConstants.EMPTY);
            }
            TourBUS tourBus = new TourBUS();

            dgv_Tour.DataSource = tourBus.TimTour(dateEdit_NgayDi.DateTime.Date, int.Parse(cbo_NoiDi.SelectedValue.ToString()), int.Parse(cbo_NoiDen.SelectedValue.ToString()));
        }
Ejemplo n.º 12
0
        public static bool Xoa(TourBUS tour)
        {
            int        result     = 0;
            String     query      = "delete from Tour where  maTour = @maTour ";
            Connection connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();
                command.Parameters.AddWithValue("@maTour", tour.MaTour);
                result = command.ExecuteNonQuery();
                connection.close();
            }
            return(result == 1);
        }
Ejemplo n.º 13
0
        private void LoaData()
        {
            TourBUS tourBus = new TourBUS();

            dgv_Tour.DataSource = tourBus.LoadTourToDataGridView();
            DataTable diaDiem = tourBus.LoadDiaDiem();

            cbo_NoiDi.DisplayMember = "TenDiaDiem";
            cbo_NoiDi.ValueMember   = "MaDiaDiem";
            cbo_NoiDi.DataSource    = diaDiem;

            cbo_NoiDen.DisplayMember = "TenDiaDiem";
            cbo_NoiDen.ValueMember   = "MaDiaDiem";
            cbo_NoiDen.DataSource    = tourBus.LoadDiemDen(int.Parse(cbo_NoiDi.SelectedValue.ToString()));
        }
Ejemplo n.º 14
0
        public static void ThemVaoTour(DiaDiemBUS diadiem, TourBUS tour)
        {
            String     query      = "insert into ChiTietTour (maTour,maDiaDiem) values (@matour,@madiadiem)";
            Connection connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();

                command.Parameters.AddWithValue("@matour", tour.MaTour);
                command.Parameters.AddWithValue("@madiadiem", diadiem.MaDiaDiem);
                command.ExecuteNonQuery();

                connection.close();
            }
        }
Ejemplo n.º 15
0
        public static void XoaTrongTour(DiaDiemBUS diadiem, TourBUS tour)
        {
            String     query      = "delete ChiTietTour where maDiaDiem=@madiadiem and maTour=@matour";
            Connection connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();

                command.Parameters.AddWithValue("@matour", tour.MaTour);
                command.Parameters.AddWithValue("@madiadiem", diadiem.MaDiaDiem);
                command.ExecuteNonQuery();

                connection.close();
            }
        }
Ejemplo n.º 16
0
        public static bool kiemtraTourTonTai(TourBUS tour)
        {
            String     query      = "select COUNT(*) as counts from Tour where maTour=@maTour";
            Connection connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();
                command.Parameters.AddWithValue("@maTour", tour.MaTour);
                var reader = command.ExecuteReader();
                reader.Read();
                int count = int.Parse(reader["counts"].ToString());

                connection.close();
                return(count == 1);
            }
        }
Ejemplo n.º 17
0
 private void updateDataGridView()
 {
     // new lai cho no cap nhat lai. ma vay so no cham.
     _tourBus     = new TourBUS();
     _destination = _tourBus.getAllDestination();
     _tour        = _tourBus.getEntries();
     //bsListTour.DataSource = null;
     bsListTour.DataSource    = _tour;
     bsDestination.DataSource = _destination;
     //((DataGridView)dgvListTour).DataSource = bsListTour;
     //dgvListTour.Refresh();
     tbTourName.Clear();
     tbTourPrice.Clear();
     ckbSelectAll.Checked = false;
     dtpStart_date.Value  = DateTime.Now;
     dtpEnd_date.Value    = DateTime.Now.AddYears(1);
     btnAddTour.Text      = "Add";
 }
Ejemplo n.º 18
0
        public static bool Sua(TourBUS tourcu, TourBUS tourmoi)
        {
            int        result     = 0;
            String     query      = "update Tour set maTour=@maTour, tenTour=@tenTour,maLoai=@maLoai where  maTour = @maTourCu ";
            Connection connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();
                command.Parameters.AddWithValue("@maTour", tourmoi.MaTour);
                command.Parameters.AddWithValue("@tenTour", tourmoi.TenTour);
                command.Parameters.AddWithValue("@maLoai", tourmoi.LoaiTour.MaLoai);
                command.Parameters.AddWithValue("@maTourCu", tourcu.MaTour);
                result = command.ExecuteNonQuery();
                connection.close();
            }
            return(result == 1);
        }
Ejemplo n.º 19
0
        public static bool Them(TourBUS tour)
        {
            int        result     = 0;
            String     query      = "insert into Tour (maTour,tenTour,maLoai) values (@maTour,@tenTour,@maLoai)";
            Connection connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();
                command.Parameters.AddWithValue("@maTour", tour.MaTour);
                command.Parameters.AddWithValue("@tenTour", tour.TenTour);
                command.Parameters.AddWithValue("@maLoai", tour.LoaiTour.MaLoai);

                result = command.ExecuteNonQuery();
                connection.close();
            }

            return(result == 1);
        }
        public static LoaiTourBUS getLoaiTourByTour(TourBUS tour)
        {
            LoaiTourBUS loaiTour   = new LoaiTourBUS();
            String      query      = "select tenLoai,LoaiTour.maLoai from LoaiTour,Tour where Tour.maLoai=LoaiTour.maLoai and maTour=@maTour";
            Connection  connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();
                command.Parameters.AddWithValue("@maTour", tour.MaTour);
                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    loaiTour.MaLoai  = reader["maLoai"].ToString();
                    loaiTour.TenLoai = reader["tenLoai"].ToString();
                }
                reader.Close();
                connection.close();
            }

            return(loaiTour);
        }
Ejemplo n.º 21
0
        public static List <TourBUS> getAll()
        {
            List <TourBUS> tours      = new List <TourBUS>();
            String         query      = "select * from Tour";
            Connection     connection = new Connection();

            using (SqlCommand command = new SqlCommand(query, connection.getConnection()))
            {
                connection.open();
                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    TourBUS tour = new TourBUS();
                    tour.MaTour  = reader["maTour"].ToString();
                    tour.TenTour = reader["tenTour"].ToString();
                    tours.Add(tour);
                }
                reader.Close();
                connection.close();
            }

            return(tours);
        }
Ejemplo n.º 22
0
 public fmTourManager()
 {
     InitializeComponent();
     postInit();
     _tourBus        = new TourBUS();
     _categoryBus    = new TourCategoryBUS();
     _destinationBus = new DestinationBUS();
     _toursiteBus    = new TourSiteBUS();
     _priceBus       = new TourPriceBUS();
     _tour           = _tourBus.getEntries();
     _category       = _categoryBus.getEntries();
     //_destination = _destinationBus.getEntries();
     _destination          = _tourBus.getAllDestination();
     _isAdd                = true;
     _currentTour          = new Tour();
     _currentTour          = null;
     _minDate              = new DateTime(2000, 1, 1);
     _maxDate              = new DateTime(2100, 1, 1);
     dtpStart_date.MinDate = _minDate;
     dtpStart_date.MaxDate = _maxDate;
     dtpEnd_date.MinDate   = _minDate;
     dtpEnd_date.MaxDate   = _maxDate;
     dtpEnd_date.Value     = DateTime.Now.AddYears(1);
 }
Ejemplo n.º 23
0
        private void Save_Click(object sender, EventArgs e)
        {
            if (TestInput() == true)
            {
                TourBUS tour = new TourBUS();
                TourDTO t    = new TourDTO();
                foreach (ListViewItem item in listView_dstour.Items)
                {
                    if (item.Selected)
                    {
                        t.MaTour       = int.Parse(item.SubItems[0].Text);
                        t.TenTour      = textBox_tentour.Text;
                        t.ThongTinTour = textBox_thongtintour.Text;
                        string str = textBox_giatour.Text;
                        if (str.Contains("₫"))
                        {
                            while (str.IndexOf("₫") != -1)
                            {
                                str = str.Remove(str.IndexOf("₫"), 1);
                            }
                        }
                        if (str.Contains(" "))
                        {
                            while (str.IndexOf(" ") != -1)
                            {
                                str = str.Remove(str.IndexOf(" "), 1);
                            }
                        }


                        if (str.Contains("."))
                        {
                            while (str.IndexOf(".") != -1)
                            {
                                str = str.Remove(str.IndexOf("."), 1);
                            }
                        }
                        Regex regex = new Regex(@"^\d+$");
                        if (!regex.IsMatch(str))
                        {
                            MessageBox.Show("Thêm thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            t.GiaTour = int.Parse(str);
                            if (tour.suaTour(t) == 1)
                            {
                                MessageBox.Show("Lưu thành công!", "Thông báo");
                                ChiTietTourBUS ctt = new ChiTietTourBUS();
                                ctt.xoaChiTiet(int.Parse(item.SubItems[0].Text));
                                foreach (ListViewItem item1 in listView_dd.Items)
                                {
                                    DiaDiemBUS     dd = new DiaDiemBUS();
                                    int            ma = dd.search_madd(item1.SubItems[0].Text);
                                    ChiTietTourDTO ct = new ChiTietTourDTO();
                                    ct.MaTour    = int.Parse(item.SubItems[0].Text);
                                    ct.MaDiaDiem = ma;
                                    ChiTietTourBUS chitiet = new ChiTietTourBUS();
                                    chitiet.themChiTiet(ct);
                                }
                                item.SubItems[1].Text = textBox_tentour.Text;
                                item.SubItems[2].Text = textBox_thongtintour.Text;
                                item.SubItems[3].Text = textBox_giatour.Text;
                            }

                            else
                            {
                                MessageBox.Show("Thêm thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                Dispose();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 24
0
        private void Add1_Click(object sender, EventArgs e)
        {
            if (TestInput() == true)
            {
                TourDTO t = new TourDTO();
                t.TenTour      = textBox_tentour.Text;
                t.ThongTinTour = textBox_thongtintour.Text;
                string str = textBox_giatour.Text;
                if (str.Contains("₫"))
                {
                    while (str.IndexOf("₫") != -1)
                    {
                        str = str.Remove(str.IndexOf("₫"), 1);
                    }
                }
                if (str.Contains(" "))
                {
                    while (str.IndexOf(" ") != -1)
                    {
                        str = str.Remove(str.IndexOf(" "), 1);
                    }
                }


                if (str.Contains("."))
                {
                    while (str.IndexOf(".") != -1)
                    {
                        str = str.Remove(str.IndexOf("."), 1);
                    }
                }
                Regex regex = new Regex(@"^\d+$");
                if (!regex.IsMatch(str))
                {
                    MessageBox.Show("Thêm thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    t.GiaTour = int.Parse(str);
                    TourBUS tour = new TourBUS();
                    int     kq   = tour.themTour(t);
                    if (kq != 0)
                    {
                        MessageBox.Show("Thêm thành công!", "Thông báo");
                        ListViewItem item = new ListViewItem(new String[] {
                            textBox_matour.Text = kq.ToString(),
                            textBox_tentour.Text,
                            textBox_thongtintour.Text,
                            textBox_giatour.Text
                        });
                        this.listView_dstour.Items.AddRange(new ListViewItem[] {
                            item
                        });
                        foreach (ListViewItem item1 in listView_dd.Items)
                        {
                            DiaDiemBUS     dd = new DiaDiemBUS();
                            int            ma = dd.search_madd(item1.SubItems[0].Text);
                            ChiTietTourDTO ct = new ChiTietTourDTO();
                            ct.MaTour    = kq;
                            ct.MaDiaDiem = ma;
                            ChiTietTourBUS chitiet = new ChiTietTourBUS();
                            chitiet.themChiTiet(ct);
                        }
                        textBox_tentour.Text      = "";
                        textBox_thongtintour.Text = "";
                        textBox_giatour.Text      = "";
                        listView_dd.Items.Clear();
                    }
                    else
                    {
                        MessageBox.Show("Thêm thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Dispose();
                    }
                }
            }
        }
Ejemplo n.º 25
0
        private void btn_Reset_Click(object sender, EventArgs e)
        {
            TourBUS tourBus = new TourBUS();

            dgv_Tour.DataSource = tourBus.LoadTourToDataGridView();
        }
Ejemplo n.º 26
0
        private void cbo_NoiDi_SelectedIndexChanged(object sender, EventArgs e)
        {
            TourBUS tourBus = new TourBUS();

            cbo_NoiDen.DataSource = tourBus.LoadDiemDen(int.Parse(cbo_NoiDi.SelectedValue.ToString()));
        }
Ejemplo n.º 27
0
        private void btnRefesh_Click(object sender, EventArgs e)
        {
            TourBUS tourBus = new TourBUS();

            gridControl_Tour.DataSource = tourBus.LoadTourToDataGridView();
        }
Ejemplo n.º 28
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            bool    isError = ThongBaoLoi();
            TourBUS tourBus = new TourBUS();

            switch (Onclicked)
            {
                #region Them Tour
            case 1:
            {
                if (!isError)
                {
                    string       maHT;
                    HanhTrinhBUS hanhTrinhBus = new HanhTrinhBUS();
                    HanhTrinhDTO hanhTrinhDTO = hanhTrinhBus.TimHanhTrinh(int.Parse(cbo_NoiDi.SelectedValue.ToString()),
                                                                          int.Parse(cbo_NoiDen.SelectedValue.ToString()));
                    //string maHT = new Random().Next(1, 10000).ToString();
                    if (hanhTrinhDTO == null)      //Kiem tra thong tin Hanh Trinh da ton tai
                    {
                        DialogResult result = MessageBox.Show("Hành trình này chưa có sẵn", "Bạn có muốn tạo mới", MessageBoxButtons.YesNo);
                        maHT = new Random().Next(1, 10000).ToString();
                        if (result == DialogResult.OK)        //Them hanh trinh moi
                        {
                            hanhTrinhBus.ThemHanhTrinhMoi(new HanhTrinhDTO()
                                {
                                    MaHanhTrinh = maHT,
                                    MaNoiDen    = int.Parse(cbo_NoiDen.SelectedValue.ToString()),
                                    MaNoiDi     = int.Parse(cbo_NoiDi.SelectedValue.ToString())
                                });
                        }
                    }
                    else
                    {
                        maHT = hanhTrinhDTO.MaHanhTrinh;
                    }
                    ThemTourDTO tourDTO = new ThemTourDTO()
                    {
                        //AnhDiaDiem=,
                        MaHDV       = int.Parse(cbo_HuongDanVien.SelectedValue.ToString()),
                        MaKS        = cbo_KhachSan.SelectedValue.ToString(),
                        MaLoaiTour  = cbo_LoaiTour.SelectedValue.ToString(),
                        MaHanhTrinh = maHT,

                        TourDTO = new TourDTO()
                        {
                            DiemDen     = cbo_NoiDen.SelectedValue.ToString(),
                            DiemDi      = cbo_NoiDi.SelectedValue.ToString(),
                            GiaNguoiLon = decimal.Parse(txt_GiaNguoiLon.Text),
                            GiaTreEm    = decimal.Parse(txt_GiaTreEm.Text),
                            NgayKH      = dateEdit_NgayKH.Value,
                            NgayKT      = dateEdit_NgayKT.Value,
                            MaTour      = new Random().Next(0, 10000).ToString(),
                            TenTour     = txt_TenTour.Text,
                            LoaiTour    = cbo_LoaiTour.SelectedValue.ToString(),
                        }
                    };
                    if (tourBus.TimTour(tourDTO.TourDTO.MaTour) != null)
                    {
                        MessageBox.Show(MessageBoxConstants.TRUNGKHOACHINH, "Mã tour này đã tồn tại");
                    }
                    else
                    {
                        try
                        {
                            tourBus.ThemTour(tourDTO);
                            MessageBox.Show(MessageBoxConstants.THEMTHANHCONG, "Thêm tour du lịch thành công");
                            gridControl_Tour.DataSource = tourBus.LoadTourToDataGridView();
                        }
                        catch (Exception)
                        {
                            MessageBox.Show("Lỗi khóa ngoại", MessageBoxConstants.LOIKHOANGOAI);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(MessageBoxConstants.THIEUTHONGTIN, "Nhập lại thông tin");
                }
            }
            break;

                #endregion
                #region Xoa tour
            case 3:
            {
                string maTour = gridView_Tour.GetFocusedRowCellValue("MaTour").ToString();
                try
                {
                    tourBus.XoaTour(maTour);
                    MessageBox.Show(MessageBoxConstants.XOATHANHCONG, "Tour nay đã bị xóa đi");
                    gridControl_Tour.DataSource = tourBus.LoadTourToDataGridView();
                }
                catch (Exception)
                {
                    MessageBox.Show(MessageBoxConstants.LOITHAOTAC, "Xóa chỉ được đổi trạng thái");
                }
            }
            break;

                #endregion
                #region Chinh sua Tour
            case 2:
            {
                string       maHT;
                HanhTrinhBUS hanhTrinhBus = new HanhTrinhBUS();
                HanhTrinhDTO hanhTrinhDTO = hanhTrinhBus.TimHanhTrinh(int.Parse(cbo_NoiDi.SelectedValue.ToString()),
                                                                      int.Parse(cbo_NoiDen.SelectedValue.ToString()));
                if (hanhTrinhDTO == null)        //Kiem tra thong tin Hanh Trinh da ton tai
                {
                    maHT = new Random().Next(1, 10000).ToString();
                    DialogResult result = MessageBox.Show("Hành trình này chưa có sẵn", "Bạn có muốn tạo mới", MessageBoxButtons.YesNo);
                    if (result == DialogResult.OK)        //Them hanh trinh moi
                    {
                        hanhTrinhBus.ThemHanhTrinhMoi(new HanhTrinhDTO()
                            {
                                MaHanhTrinh = maHT,
                                MaNoiDen    = int.Parse(cbo_NoiDen.SelectedValue.ToString()),
                                MaNoiDi     = int.Parse(cbo_NoiDi.SelectedValue.ToString())
                            });
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    //maHT = new Random().Next(1, 10000).ToString();
                    maHT = hanhTrinhDTO.MaHanhTrinh;
                }
                string      maTour  = gridView_Tour.GetFocusedRowCellValue("MaTour").ToString();
                ThemTourDTO tourDTO = new ThemTourDTO()
                {
                    //AnhDiaDiem=,
                    MaHDV       = int.Parse(cbo_HuongDanVien.SelectedValue.ToString()),
                    MaKS        = cbo_KhachSan.SelectedValue.ToString(),
                    MaLoaiTour  = cbo_LoaiTour.SelectedValue.ToString(),
                    MaHanhTrinh = maHT,
                    TourDTO     = new TourDTO()
                    {
                        DiemDen     = cbo_NoiDen.SelectedValue.ToString(),
                        DiemDi      = cbo_NoiDi.SelectedValue.ToString(),
                        GiaNguoiLon = decimal.Parse(txt_GiaNguoiLon.Text),
                        GiaTreEm    = decimal.Parse(txt_GiaTreEm.Text),
                        NgayKH      = dateEdit_NgayKH.Value,
                        NgayKT      = dateEdit_NgayKT.Value,
                        MaTour      = maTour
                    }
                };
                try
                {
                    tourBus.ChinhSuaTour(tourDTO);
                    MessageBox.Show(MessageBoxConstants.CHINHSUATHANHCONG, "Chỉnh sửa thông tin tour thành công");
                    gridControl_Tour.DataSource = tourBus.LoadTourToDataGridView();
                }
                catch (Exception)
                {
                    MessageBox.Show(MessageBoxConstants.LOITHAOTAC, "Chỉnh sửa thông tin tour không thành công, vui lòng thử lại");
                }
            }
            break;

                #endregion
            default:
                break;
            }
            btn_Sua.Enabled = true;
            btnThem.Enabled = true;
            btn_Xoa.Enabled = true;
        }
Ejemplo n.º 29
0
        private void btn_DatTour_Click(object sender, EventArgs e)
        {
            if (KTraThongTinNhap())
            {
                TourBUS      datTourBUS = new TourBUS();
                Random       random     = new Random();
                string       maKH       = random.Next(0, 1000000).ToString();
                string       maHD       = random.Next(0, 1000000).ToString();
                KhachHangDTO khachHang  = new KhachHangDTO()
                {
                    DiaChi   = txt_DiaChi.Text,
                    Email    = txt_Email.Text,
                    GioiTinh = int.Parse(cbo_GioiTinh.SelectedValue.ToString()),
                    MaKH     = maKH,
                    MaloaiKH = "1",
                    NgaySinh = dateTime_NamSinh.Value,
                    Sdt      = txt_Sdt.Text,
                    TenKH    = txt_HoTen.Text
                };
                HopDongDTO hopDong = new HopDongDTO()
                {
                    MaHD        = maHD,
                    MaKH        = maKH,
                    TongTien    = frm_Tour.BookedTour.TongTien,
                    ThoiGianDat = DateTime.Now
                };
                ChiTietHopDongDTO chiTietHopDong = new ChiTietHopDongDTO()
                {
                    MaCT_HopDong    = random.Next(-100, 10000).ToString(),
                    MaHopDong       = maHD,
                    MaTour          = frm_Tour.BookedTour.MaTour,
                    SoLuongNguoiLon = int.Parse(txt_NguoiLon.Text),
                    SoLuongTreEm    = int.Parse(txt_TreEm.Text),

                    ThanhTien = frm_Tour.BookedTour.GiaNguoiLon * int.Parse(txt_NguoiLon.Text) + frm_Tour.BookedTour.GiaTreEm * int.Parse(txt_TreEm.Text)
                };
                try
                {
                    datTourBUS.ThanhToanTour(khachHang, hopDong, chiTietHopDong);
                    MessageBox.Show("Thông báo", "Đặt tour thành công", MessageBoxButtons.OK);
                    this.Close();
                    DialogResult xemHopDong = MessageBox.Show("Đặt hợp đồng thành công",
                                                              "Bạn có muốn in hợp đồng không?", MessageBoxButtons.YesNo);
                    if (xemHopDong == DialogResult.Yes)
                    {
                        DateTime nowValue = DateTime.Now;
                        Dictionary <string, string> dsThamSo = new Dictionary <string, string>
                        {
                            ["MaHD"]        = maHD,
                            ["HoTen"]       = khachHang.TenKH,
                            ["DiaChi"]      = khachHang.DiaChi,
                            ["NgaySinh"]    = khachHang.NgaySinh.ToShortDateString(),
                            ["SoDienThoai"] = khachHang.Sdt,
                            ["NoiDi"]       = tourChiTiet.Tour.DiemDi,
                            ["NoiDen"]      = tourChiTiet.Tour.DiemDen,
                            ["KhachSan"]    = tourChiTiet.Tour.TenKhachSan,
                            ["ThoiGian"]    = (tourChiTiet.TGDen - tourChiTiet.TGDi).Value.TotalDays.ToString(),
                            ["TGDi"]        = tourChiTiet.TGDi.Value.ToShortDateString(),
                            ["TGDen"]       = tourChiTiet.TGDen.Value.ToShortDateString(),
                            ["TongTien"]    = frm_Tour.BookedTour.TongTien.ToString(),
                            ["TienTamUng"]  = ((decimal)HopDongConstants.PHANTRAMTAMUNG * frm_Tour.BookedTour.TongTien).Value.ToString(),
                            ["NgayHD"]      = nowValue.Day.ToString(),
                            ["ThangHD"]     = nowValue.Month.ToString(),
                            ["NamHD"]       = nowValue.Year.ToString(),
                            ["TongSoNguoi"] = (frm_Tour.BookedTour.TreEm + frm_Tour.BookedTour.NguoiLon).ToString(),
                            ["NguoiLon"]    = frm_Tour.BookedTour.NguoiLon.ToString(),
                            ["TreEm"]       = frm_Tour.BookedTour.TreEm.ToString(),
                        };

                        WordReportDTO wordReport   = new WordReportDTO(dsThamSo);
                        string        srcReport    = @"D:\Download\winforms_QLTourDulich_perfect\winforms_QLTourDulich_perfect\QLTour\QLTour\Report\report.docx";
                        string        outputReport = @"C:\Users\tranthibay\Desktop\HopDong.docx";
                        wordReport.XuatReportWord(srcReport, outputReport);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Chú ý", MessageBoxConstants.LOIDULIEU, MessageBoxButtons.OK);
                }
            }
        }
Ejemplo n.º 30
0
        private void Add1_Click(object sender, EventArgs e)
        {
            int k = 0;

            if (textBox_matour.Text == "")
            {
                k = 1;
                errorProvider1.SetError(textBox_matour, "Mã tour không được để trống!");
            }
            if (textBox_tentour.Text == "")
            {
                k = 1;
                errorProvider1.SetError(textBox_tentour, "Tên tour không được để trống!");
            }
            if (textBox_thongtintour.Text == "")
            {
                k = 1;
                errorProvider1.SetError(textBox_thongtintour, "Thông tin tour không được để trống!");
            }
            if (textBox_giatour.Text == "")
            {
                k = 1;
                errorProvider1.SetError(textBox_giatour, "Giá tour không được để trống!");
            }
            if (k == 0)
            {
                TourDTO t = new TourDTO();
                t.MaTour       = int.Parse(textBox_matour.Text);
                t.TenTour      = textBox_tentour.Text;
                t.ThongTinTour = textBox_thongtintour.Text;
                t.GiaTour      = int.Parse(textBox_giatour.Text);

                TourBUS tour = new TourBUS();
                int     kq   = tour.themTour(t);
                if (kq == t.MaTour)
                {
                    MessageBox.Show("Mã tour đã tồn tại.", "Thông báo");
                }
                else
                if (kq == 1)
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo");
                    ListViewItem item = new ListViewItem(new String[] {
                        textBox_matour.Text,
                        textBox_tentour.Text,
                        textBox_thongtintour.Text,
                        textBox_giatour.Text
                    });
                    this.listView1.Items.AddRange(new ListViewItem[] {
                        item
                    });
                    textBox_matour.Text       = "";
                    textBox_tentour.Text      = "";
                    textBox_thongtintour.Text = "";
                    textBox_giatour.Text      = "";
                }
                else
                {
                    MessageBox.Show("Thêm thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Dispose();
                }
            }
        }