Example #1
0
 private void rdOppening_CheckedChanged(object sender, EventArgs e)
 {
     if (rdOppening.Checked)
     {
         lvTrips_Load(ListTrips.FindByStatus(1));
     }
 }
Example #2
0
 //Close
 private void radioButton2_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButton2.Checked)
     {
         lvTrips_Load(ListTrips.FindByStatus(0));
     }
 }
Example #3
0
        void UpdateTable(TimeTableModel timeTableModel)
        {
            var curTrip = ListTrips.Where(i => i.idRoute == timeTableModel.idRoute).FirstOrDefault();
            var idx     = ListTrips.IndexOf(curTrip);

            ListTrips.Remove(curTrip);
            ListTrips.Insert(idx, timeTableModel);
        }
Example #4
0
        private void controls_BindData(KhachHang _cus)
        {
            txtCode.Text      = _cus.ID;
            txtName.Text      = _cus.Ten;
            txtFirstName.Text = _cus.Ho;
            txtAddress.Text   = _cus.DiaChi;
            txtPhone.Text     = _cus.SoDT;
            txtAccount.Text   = _cus.SoTaiKhoan;
            if (_cus.GTinh)
            {
                rdMale.Checked = true;
            }
            else
            {
                rdFemale.Checked = true;
            }
            int i = 0;

            foreach (var item in cbbCountries.Items)
            {
                if (item.ToString().ToUpper() == _cus.QuocGia.ToUpper())
                {
                    cbbCountries.SelectedIndex = i;
                    break;
                }
                i++;
            }
            cbbCity.SelectedIndex = 0;
            if (cbbCity.Enabled)
            {
                i = 0;
                foreach (var item in cbbCity.Items)
                {
                    if (item.ToString().ToUpper() == _cus.ThanhPho.ToUpper())
                    {
                        cbbCity.SelectedIndex = i;
                        break;
                    }
                    i++;
                }
            }

            List <DatCho> temp = ListOrd.Find(Code);

            //Lấy danh sách đặt chỗ đang mở cua khach hang hien taij
            listOrder = ListTrips.Find(temp, 1);

            lvTripsOrders_Load(listOrder);
            dtpBirth.Value = _cus.NgaySinh;
        }
Example #5
0
        private bool AddTrip(int _codeTrip)
        {
            Chuyen newTrip = ListTrips.Single(_codeTrip);

            if (newTrip != null)
            {
                foreach (Chuyen item in listOrder)
                {
                    if (item.TrangThai == 1 && ((item.NgayDi >= newTrip.NgayDi && item.NgayVe >= newTrip.NgayVe) || (item.NgayDi <= newTrip.NgayDi && item.NgayVe >= newTrip.NgayVe) ||
                                                (item.NgayDi <= newTrip.NgayDi && item.NgayVe <= newTrip.NgayVe)))
                    {
                        return(false);
                    }
                }
                listOrder.Add(newTrip);
                return(true);
            }
            return(false);
        }
Example #6
0
        private void tvTours_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node, child;

            if (tvTours.SelectedNode.Level == 0)
            {
                node = tvTours.SelectedNode;
            }
            else
            {
                node = tvTours.SelectedNode.Parent;
            }
            child = node.Nodes[0];
            string[] s = child.Text.ToString().Split(' ');
            selectTour = MyConvert.ToInt32(s[1]);
            lvTrips_Load(ListTrips.FindByCodeTour(selectTour));
            rdAll.Checked        = false;
            rdOppening.Checked   = false;
            radioButton2.Checked = false;
        }
Example #7
0
        private void btnRequireOrder_Click(object sender, EventArgs e)
        {
            if (ListCus.Single(txtCode.Text) != null)
            {
                if (listOrder.Count > 0)
                {
                    //Tao ra danh sach dat cho
                    List <DatCho> temp = new List <DatCho>();
                    DatCho        t    = new DatCho();
                    foreach (Chuyen item in listOrder)
                    {
                        t.MChuyen = item.MChuyen;
                        t.MKHang  = txtCode.Text;
                        temp.Add(t);
                    }

                    //Tim danh sach dat cho da ton tai va co trang thai chuyen di la dang cho
                    List <Chuyen> oldTrip = ListTrips.Find(ListOrd.Find(Code), 1);//Tim ds chuyen dang mo cua ds dat cho cua khach hang
                    //Tao ds dat cho cua khach hang da ton tai va trang thai dang mo
                    List <DatCho> old = new List <DatCho>();
                    foreach (Chuyen item in oldTrip)
                    {
                        DatCho tp = new DatCho();
                        tp.MKHang  = txtCode.Text;
                        tp.MChuyen = item.MChuyen;
                        old.Add(tp);
                    }

                    // So sanh voi temp de lay ra nhung cai them moi va nhung cai can xoa di
                    List <DatCho> nw = new List <DatCho>(); //danh sach can them moi
                    List <DatCho> dl = new List <DatCho>(); //danh sach can xoa di
                    foreach (DatCho i in temp)
                    {
                        bool s = true;
                        foreach (DatCho j in old)
                        {
                            if (i.MChuyen == j.MChuyen)//da ton tai, bo qua
                            {
                                s = false;
                                break;
                            }
                        }
                        if (s)
                        {
                            nw.Add(i);//Chua ton tai nen them duoc
                        }
                    }

                    foreach (DatCho i in old)
                    {
                        bool r = true;
                        foreach (DatCho j in temp)
                        {
                            if (i.MChuyen == j.MChuyen)
                            {
                                r = false;
                                break;
                            }
                        }
                        if (r)//co trong cai cu nhung khong co trong cai moi nen xoa di
                        {
                            dl.Add(i);
                        }
                    }
                    // duong nhien ca hai old va temp deu la danh sach dat cho cua chuyen dang mo
                    // Thuc hien xoa tren old va add tren nw la OK

                    foreach (DatCho i in nw)
                    {
                        if (ListOrd.Add(i))
                        {
                            MessageBox.Show(String.Format("You have add the trip which has code {0}!", i.MChuyen), "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            MessageBox.Show(String.Format("You had been faile the trip which has code {0}!", i.MChuyen), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }

                    foreach (DatCho i in dl)
                    {
                        if (ListOrd.Delete(i))
                        {
                            MessageBox.Show(String.Format("You have delete the trip which has code {0}!", i.MChuyen), "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            MessageBox.Show(String.Format("You had been faile the trip which has code {0}!", i.MChuyen), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    btnRequireOrder.Enabled = false;
                }
                else
                {
                    MessageBox.Show("You have not add the trips! Please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("You have not add this customer! Please try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #8
0
 private void btnSearchTime_Click(object sender, EventArgs e)
 {
     lvTrips_Load(ListTrips.FindByPerodTime(dtpStart.DateTime, dtpEnd.DateTime));
 }
Example #9
0
 private void txtPrice_TextChanged(object sender, EventArgs e)
 {
     lvTrips_Load(ListTrips.FindByLessThanPrice(MyConvert.ToDouble(txtPrice.Text)));
 }