예제 #1
0
        public void loadData()
        {
            ItemTable1 t1 = new ItemTable1();

            t1                  = (ItemTable1)mainWin.dgvOutbound.SelectedItem;
            lbFrom.Content      = t1.Col1;
            lbTo.Content        = t1.Col2;
            lbCabin.Content     = mainWin.cbbCabinType.Text;
            lbDate.Content      = t1.Col3;
            lbFlightNum.Content = t1.Col5;
            if (mainWin.rdbtnreturn.IsChecked == true)
            {
                t1 = (ItemTable1)mainWin.dgvReturn.SelectedItem;
                lbFrom2.Content      = t1.Col1;
                lbTo2.Content        = t1.Col2;
                lbCabin2.Content     = mainWin.cbbCabinType.Text;
                lbDate2.Content      = t1.Col3;
                lbFlightNum2.Content = t1.Col5;
            }
            else
            {
                var v = Visibility.Hidden;
                lbFrom2.Visibility      = v;
                lbTo2.Visibility        = v;
                lbCabin2.Visibility     = v;
                lbDate2.Visibility      = v;
                lbFlightNum2.Visibility = v;
                v1.Visibility           = v;
                v2.Visibility           = v;
                v3.Visibility           = v;
                v4.Visibility           = v;
                v5.Visibility           = v;
                v6.Visibility           = v;
            }
        }
예제 #2
0
        public void removeByDate(DataGrid dg, DateTime date)
        {
            TimeSpan tp = new TimeSpan();

            tp = TimeSpan.FromDays(3);
            for (int i = 0; i < dg.Items.Count; i++)
            {
                ItemTable1 x = new ItemTable1();
                x = (ItemTable1)dg.Items[i];
                var d = DateTime.ParseExact(x.Col3, "MM/dd/yyyy", null);
                if (date < d.Subtract(tp))
                {
                    dg.Items.RemoveAt(i);
                    i--;
                }
            }
        }
예제 #3
0
        public bool checkDataRoute()
        {
            ItemTable1 x1 = new ItemTable1();
            ItemTable1 x2 = new ItemTable1();

            var x01 = dgvOutbound.SelectedItems.OfType <ItemTable1>().ToList();
            var x02 = dgvOutbound.SelectedItems.OfType <ItemTable1>().ToList();

            x1 = (ItemTable1)dgvOutbound.SelectedItem;
            x2 = (ItemTable1)dgvReturn.SelectedItem;
            if (x01.Count == 0 || (x02.Count == 0 && rdbtnreturn.IsChecked == true))
            {
                return(false);
            }
            var t1 = DateTime.ParseExact(x1.Col3, "MM/dd/yyyy", null);
            var t2 = DateTime.ParseExact(x2.Col3, "MM/dd/yyyy", null);

            return(t1 < t2);
        }
예제 #4
0
        private ItemTable1 get1Path(List <int> path, int id, ComboBox cb1, ComboBox cb2)
        {
            var        db   = new Session3Entities();
            var        row  = db.Schedules.Where(p => p.ID == id);
            double     cost = 0;
            ItemTable1 x    = new ItemTable1();

            x.Col1 = cb1.Text;
            x.Col2 = cb2.Text;
            x.Col3 = row.Select(p => p.Date).FirstOrDefault().ToString("MM/dd/yyyy");
            DateTime dt = new DateTime();

            dt      = DateTime.ParseExact(x.Col3, "MM/dd/yyyy", null);
            x.Col4  = row.Select(p => p.Time).FirstOrDefault().ToString();
            x.Col5 += row.Select(p => p.FlightNumber).FirstOrDefault().ToString();
            cost   += double.Parse(row.Select(p => p.EconomyPrice).FirstOrDefault().ToString());
            for (int i = 1; i < path.Count - 1; i++)
            {
                int idRoute = getIdRouter(path[i], path[i + 1]);
                id = db.Schedules.Where(p => (p.Date >= dt && p.RouteID == idRoute)).Select(p => p.ID).FirstOrDefault();
                if (id == 0)
                {
                    return(null);
                }
                dt      = db.Schedules.Where(p => p.ID == id).Select(p => p.Date).FirstOrDefault();
                x.Col5 += "-" + db.Schedules.Where(p => p.ID == id).Select(p => p.FlightNumber).FirstOrDefault();
                cost   += double.Parse(db.Schedules.Where(p => p.ID == id).Select(p => p.EconomyPrice).FirstOrDefault().ToString());
            }
            int idCabinType = db.CabinTypes.Where(p => p.Name == cbbCabinType.Text).Select(p => p.ID).FirstOrDefault();

            if (idCabinType == 2)
            {
                cost = cost + (cost * 0.35);
            }
            else if (idCabinType == 3)
            {
                cost = cost + (cost + (cost * 0.35)) * 0.3;
            }
            x.Col6 = Convert.ToDecimal(cost).ToString("C0");
            x.Col7 = x.Col5.Count(p => p == '-').ToString();
            return(x);
        }
예제 #5
0
        public void loadDataDefaul()
        {
            dgvOutbound.Items.Clear();
            dgvReturn.Items.Clear();

            using (var db = new Session3Entities())
            {
                var data = db.Schedules;
                foreach (var i in data)
                {
                    ItemTable1 tb     = new ItemTable1();
                    int        rID    = i.RouteID;
                    int        airID1 = db.Routes.Where(p => p.ID == rID).Select(p => p.DepartureAirportID).FirstOrDefault();
                    tb.Col1 = db.Airports.Where(p => p.ID == airID1).Select(p => p.IATACode).FirstOrDefault();
                    int airID2 = db.Routes.Where(p => p.ID == rID).Select(p => p.ArrivalAirportID).FirstOrDefault();
                    tb.Col2 = db.Airports.Where(p => p.ID == airID2).Select(p => p.IATACode).FirstOrDefault();
                    tb.Col3 = i.Date.ToString("MM/dd/yyyy");
                    tb.Col4 = i.Time.ToString();
                    tb.Col5 = i.FlightNumber;
                    int    idCabinType = db.CabinTypes.Where(p => p.Name == cbbCabinType.Text).Select(p => p.ID).FirstOrDefault();
                    double cost        = double.Parse(i.EconomyPrice.ToString());
                    if (idCabinType == 2)
                    {
                        cost = cost + (cost * 0.35);
                    }
                    else if (idCabinType == 3)
                    {
                        cost = cost + (cost + (cost * 0.35)) * 0.3;
                    }
                    tb.Col6 = Convert.ToDecimal(cost).ToString("C0");
                    tb.Col7 = "0";
                    dgvOutbound.Items.Add(tb);
                    dgvReturn.Items.Add(tb);
                }
            }
        }
예제 #6
0
        public void getPath(List <int> path, string dt, DataGrid dg, ComboBox cb1, ComboBox cb2, int chose)
        {
            var        db              = new Session3Entities();
            DateTime   cmp             = DateTime.ParseExact(dt, "MM/dd/yyyy", null);
            int        idrou           = getIdRouter(path[0], path[1]);
            List <int> listIdSchedules = new List <int>();

            if (chose == 1)
            {
                listIdSchedules = db.Schedules.Where(p => p.Date >= cmp && p.RouteID == idrou).Select(p => p.ID).ToList();
            }
            else
            {
                listIdSchedules = db.Schedules.Where(p => p.Date == cmp && p.RouteID == idrou).Select(p => p.ID).ToList();
            }
            foreach (int id in listIdSchedules)
            {
                ItemTable1 newItem = get1Path(path, id, cb1, cb2);
                if (newItem != null)
                {
                    dg.Items.Add(newItem);
                }
            }
        }