Beispiel #1
0
 public giatourdto(giatour o)
 {
     ID      = o.id;
     tent    = o.tour.tentour;
     gia     = (decimal)o.gia;
     tungay  = (DateTime)o.tungay;
     denngay = (DateTime)o.denngay;
 }
Beispiel #2
0
        public bool add(giatour _gt)
        {
            bool s = giatourrespository.Add(_gt);

            //load du lieu reference chua co
            _gt.tour = tourrespository.First(c => c.id == _gt.idtour);
            return(s);
        }
Beispiel #3
0
        public bool update(giatour _gt)
        {
            giatour gt = giatourrespository.First(c => c.id == _gt.id);

            gt.idtour  = _gt.idtour;
            gt.gia     = _gt.gia;
            gt.tungay  = _gt.tungay;
            gt.denngay = _gt.denngay;
            return(giatourrespository.Update(gt));
        }
Beispiel #4
0
        private void suagtbtn_Click(object sender, EventArgs e)
        {
            giatour gt = new giatour();

            gt.gia     = giatournud.Value;
            gt.idtour  = Convert.ToInt32(((KeyValuePair <string, string>)tentcbb.SelectedItem).Key);
            gt.tungay  = tungaydtp.Value;
            gt.denngay = denngaydtp.Value;
            bool s = gtbus.update(gt);

            helpers.successorerror(s);
            if (s)
            {
                exiteditingmode();
                loadgiatourdgv();
            }
        }
Beispiel #5
0
        private void themgtbtn_Click(object sender, EventArgs e)
        {
            giatour gt = new giatour();

            gt.gia     = giatournud.Value;
            gt.idtour  = Convert.ToInt32(((KeyValuePair <string, string>)tentcbb.SelectedItem).Key);
            gt.tungay  = tungaydtp.Value.Date;
            gt.denngay = denngaydtp.Value.Date;
            bool s = gtbus.add(gt);

            helpers.successorerror(s);
            if (s)
            {
                helpers.ClearOnlyTextBoxes(giatourpanel);
                loadgiatourdgv();
            }
        }
Beispiel #6
0
 public bool them(int idtour, decimal gia, DateTime tungay, DateTime denngay)
 {
     try {
         giatour g = new giatour();
         g.idtour  = idtour;
         g.gia     = gia;
         g.tungay  = tungay;
         g.denngay = denngay;
         db.giatours.Add(g);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi : " + ex);
         return(false);
     }
 }
Beispiel #7
0
 public bool sua(int id, int idtour, decimal gia, DateTime tungay, DateTime denngay)
 {
     try
     {
         giatour g = db.giatours.First(o => o.id == id);
         g.idtour          = idtour;
         g.gia             = gia;
         g.tungay          = tungay;
         g.denngay         = denngay;
         db.Entry(g).State = EntityState.Modified;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi " + ex);
         return(false);
     }
 }
Beispiel #8
0
        public List <giatour> listgiatourhientai()
        {
            DateTime       a   = DateTime.Now;
            List <giatour> gts = new List <giatour>();

            foreach (tour t in db.tours)
            {
                giatour gt = new giatour();
                if (db.giatours.Any(o => o.tungay < a && o.denngay > a && o.idtour == t.id))
                {
                    gt = db.giatours.Where(o => o.tungay <a && o.denngay> a && o.idtour == t.id).OrderByDescending(o => o.id).FirstOrDefault();
                }
                else
                {
                    gt.id      = 0;
                    gt.tentour = t.tentour;
                    gt.gia     = 0;
                    gt.tungay  = a;
                    gt.denngay = a;
                }
                gts.Add(gt);
            }
            return(gts);
        }