Example #1
0
        private void tvtours_Load(List <Tour> list)
        {
            TreeNode node, nodeDS, nodeStatus;

            tvtours.Nodes.Clear();
            foreach (Tour item in list)
            {
                node = tvtours.Nodes.Add(item.TenTour);
                node.Nodes.Add("Mã số: " + item.ID).ImageIndex           = 1;
                node.Nodes.Add("Xuất phát: " + item.XuatPhat).ImageIndex = 2;
                nodeStatus = node.Nodes.Add("Trạng thái: " + item.TrangThai);
                if (nodeStatus.Text == "Trạng thái: Đang mở")
                {
                    nodeStatus.ImageIndex = 4;
                }
                else
                {
                    nodeStatus.ImageIndex = 5;
                }
                nodeDS            = node.Nodes.Add("Danh sách điểm đến: ");
                nodeDS.ImageIndex = 3;
                List <DiemDen> listDD = DiemDen.FindByMTour(item.ID);
                foreach (DiemDen i in listDD)
                {
                    nodeDS.Nodes.Add(i.TenDiem);
                    nodeDS.Expand();
                }
                node.ImageIndex = 0;
                node.Expand();
                node.ForeColor = Color.DeepPink;
            }
        }
Example #2
0
        private void btnAddDes_Click(object sender, EventArgs e)
        {
            DiemDL ddl = cbbScenic.SelectedItem as DiemDL;

            listScenic.Add(ddl);
            cbbScenic.Items.Remove(ddl);
            ListViewItem i = lvDestination.Items.Add(ddl.TenDD);

            i.SubItems.Add(ddl.TenDiem);

            KhachSan ks = cbbHotel.SelectedItem as KhachSan;

            i.SubItems.Add(ks.TenKS);

            PhuongTien pt = cbbVehical.SelectedItem as PhuongTien;

            i.SubItems.Add(pt.TenPT);
            i.SubItems.Add(pt.TenNCC);

            DiemDen dd = new DiemDen();

            dd.MTour   = 0;
            dd.MDiemDL = ddl.ID;
            dd.MaKS    = ks.ID;

            dd.MaPT = pt.ID;
            listDes.Add(dd);
            btnAddDes.Enabled = false;
        }
Example #3
0
 private void lvVehicles_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lvVehicles.SelectedItems.Count > 0)
     {
         lvTours_Load(Tour.FindByVehicleCode(MyConvert.ToInt32(lvVehicles.SelectedItems[0].SubItems[0].Text)));
         trvDestination_Load(DiemDen.FindByMaPT(MyConvert.ToInt32(lvVehicles.SelectedItems[0].SubItems[0].Text)));
         tvSupplier_Load(NCCPTien.FindByVehicleCode(MyConvert.ToInt32(lvVehicles.SelectedItems[0].SubItems[0].Text)));
     }
     else
     {
         lvTours.Items.Clear();
         trvDestination.Nodes.Clear();
         tvSupplier.Nodes.Clear();
     }
 }
Example #4
0
        private void btnAddTour_Click(object sender, EventArgs e)
        {
            if (Tour.FindByName(txtName.Text).Count > 0)
            {
                MessageBox.Show("This tour had been exited!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (lvDestination.Items.Count == 0)
            {
                MessageBox.Show("Do not choose the destinations!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult dlg = MessageBox.Show("Do you want to adding this tour?", "Question!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dlg == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            int affected = Tour.Add(controls_Load());

            if (affected > 0)
            {
                //Thêm danh sách điểm đến
                //Gán mã tour cho danh sách điểm đến
                foreach (DiemDen item in listDes)
                {
                    item.MTour = affected;
                }

                DiemDen.Add(listDes);

                listDes    = new List <DiemDen>();
                listScenic = new List <DiemDL>();
                lvDestination.Items.Clear();
                txtName.Text       = "";
                txtStartPlace.Text = "";
                tvtours_Load(Tour.All());

                MessageBox.Show("Adding is successful!", "Message!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
Example #5
0
        private void Controls_LoadUp()
        {
            Tour t = Tour.Single(_ID);

            txtCode.Text       = t.ID.ToString();
            txtName.Text       = t.TenTour;
            txtStartPlace.Text = t.XuatPhat;
            int i = 0;

            foreach (var item in cbbStatus.Items)
            {
                if (item.ToString() == t.TrangThai)
                {
                    cbbStatus.SelectedIndex = i;
                    break;
                }
                i++;
            }
            btnAddTour.Enabled    = false;
            btnUpdateTour.Enabled = true;
            //btnDeleteTour.Enabled = true;

            //
            listScenic = new List <DiemDL>();
            listDes    = DiemDen.FindByMTour(ID);
            lvDestination.Items.Clear();
            foreach (DiemDen j in listDes)
            {
                ListViewItem item = lvDestination.Items.Add(j.TenDD);
                item.SubItems.Add(j.TenDiem);
                item.SubItems.Add(j.TenKS);
                item.SubItems.Add(j.TenPT);
                item.SubItems.Add(j.TenNCC);
                listScenic.Add(DiemDL.Single(j.MDiemDL));
            }
            cbbLocal_Load(DiaDiemDL.All());
            cbbLocal.SelectedIndex = 0;
            cbbHotel.Items.Clear();
            cbbHotel.Text = "";
            tvHotel.Nodes.Clear();
        }
Example #6
0
        private void btnUpdateTour_Click(object sender, EventArgs e)
        {
            Tour exited   = Tour.Single(ID);
            Tour newToour = controls_Load();

            if (exited.TenTour != newToour.TenTour)
            {
                if (Tour.FindByName(txtName.Text).Count > 0)
                {
                    MessageBox.Show("This tour had been exited!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (lvDestination.Items.Count == 0)
            {
                MessageBox.Show("Do not choose the destinations!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            DialogResult dlg = MessageBox.Show("Do you want to update this tour?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dlg == System.Windows.Forms.DialogResult.Yes)
            {
                Tour.Update(newToour);
                DiemDen.DeleteByMTour(ID);
                //Gán mã tour cho danh sách điểm đến
                foreach (DiemDen item in listDes)
                {
                    item.MTour = ID;
                }
                DiemDen.Add(listDes);
                tvtours_Load(Tour.All());
                MessageBox.Show("Updating had been successful!", "Message!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }