public int Update(LichBay LichBay)
        {
            string sql = string.Format("Update LichBay Set MaChuyenBay='{1}', Ngay='{2}', GioKhoiHanh='{3}', GioKetThuc='{4}', TinhTrang=N'{5}'  Where MaLichBay='{0}'",
                                       LichBay.MaLichBay, LichBay.MaChuyenBay, LichBay.Ngay, LichBay.GioKhoiHanh, LichBay.GioKetThuc, LichBay.TinhTrang);
            var rs = ProcessData.ExecuteNonQuery(sql);

            return(rs);
        }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            LichBay lichbay = GetInfo();

            lichchuyenbay.UpdateAll(grvData.DataSource as DataTable);

            onAdd?.Invoke(lichbay);
            onEdit?.Invoke(lichbay);
            this.Close();
        }
        public async Task <IActionResult> Create([Bind("id_LichBay,id_HangBay,GioBay,ThoiGianBay,MoTa,id_SanBayDi,id_SanBayDen")] LichBay lichBay, int Gio, int Phut)
        {
            if (ModelState.IsValid)
            {
                lichBay.ThoiGianBay = Gio + (float)Phut / 60;
                _context.Add(lichBay);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction("Index"));
        }
        public FightScheduleDetail(LichBay lichbay)
        {
            InitializeComponent();

            lblFight.Text = lichbay.MaChuyenBay;
            lblDate.Text  = lichbay.Ngay;
            lblStart.Text = lichbay.GioKhoiHanh;
            lblEnd.Text   = lichbay.GioKetThuc;
            lblState.Text = lichbay.TinhTrang;

            grvData.DataSource = lichchuyenbay.LoadDetail(lichbay.MaLichBay);
        }
        private LichBay GetInfo()
        {
            LichBay inf = new LichBay();

            inf.MaLichBay   = idlich;
            inf.MaChuyenBay = cmbFight.SelectedItem.ToString();
            inf.Ngay        = dpkDate.Value.ToShortDateString();
            inf.GioKhoiHanh = dpkStart.Value.ToShortTimeString();
            inf.GioKetThuc  = dpkEnd.Value.ToShortTimeString();
            inf.TinhTrang   = cmbState.SelectedItem.ToString();

            return(inf);
        }
Пример #6
0
        private void ucFightSchedule_DetailClick(object sender, EventArgs e)
        {
            LichBay lichbay = new LichBay();

            lichbay.MaLichBay   = ucFightSchedule.GridView.CurrentRow.Cells[0].Value.ToString();
            lichbay.MaChuyenBay = ucFightSchedule.GridView.CurrentRow.Cells[1].Value.ToString();
            lichbay.Ngay        = ucFightSchedule.GridView.CurrentRow.Cells[2].Value.ToString();
            lichbay.GioKhoiHanh = ucFightSchedule.GridView.CurrentRow.Cells[3].Value.ToString();
            lichbay.GioKetThuc  = ucFightSchedule.GridView.CurrentRow.Cells[4].Value.ToString();
            lichbay.TinhTrang   = ucFightSchedule.GridView.CurrentRow.Cells[5].Value.ToString();

            FightScheduleDetail frm = new FightScheduleDetail(lichbay);

            frm.ShowDialog();
        }
Пример #7
0
        public async Task <IActionResult> AddNewSchedule([Bind("id_LichBay,id_HangBay,GioBay,ThoiGianBay,MoTa,id_SanBayDi,id_SanBayDen")] LichBay lichBay)
        {
            bool exists = _context.LichBay.Any(s => s.id_HangBay == lichBay.id_HangBay && s.id_SanBayDi == lichBay.id_SanBayDi && s.id_SanBayDen == s.id_SanBayDen && TimeSpan.Compare((TimeSpan)s.GioBay, (TimeSpan)lichBay.GioBay) == 0);

            if (exists)
            {
                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                _context.Add(lichBay);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", new { id = lichBay.id_HangBay }));
            }
        }
 public async Task <IActionResult> Edit([Bind("id_LichBay,id_HangBay,GioBay,ThoiGianBay,MoTa,id_SanBayDi,id_SanBayDen")] LichBay lichBay, int Gio, int Phut)
 {
     if (ModelState.IsValid)
     {
         try
         {
             lichBay.ThoiGianBay = Gio + (float)Phut / 60;
             _context.Update(lichBay);
             await _context.SaveChangesAsync();
         }
         catch (Exception) {}
         return(RedirectToAction(nameof(Index)));
     }
     ViewBag.SanBayDi  = new SelectList(_context.SanBay, "id_SanBay", "TenSanBay", lichBay.id_SanBayDi);
     ViewBag.SanBayDen = new SelectList(_context.SanBay, "id_SanBay", "TenSanBay", lichBay.id_SanBayDen);
     ViewBag.HangBay   = new SelectList(_context.HangBay, "id_HangBay", "TenHangBay", 1);
     return(View(lichBay));
 }
        public Add_EditFightSchedule(LichBay lichbay)
        {
            InitializeComponent();

            dpkStart.Format = DateTimePickerFormat.Time;
            dpkEnd.Format   = DateTimePickerFormat.Time;
            GetIDList();
            cmbFight.SelectedIndex = 1;
            cmbState.SelectedIndex = 1;

            idlich = lichbay.MaLichBay;
            cmbFight.SelectedIndex = cmbFight.Items.IndexOf(lichbay.MaChuyenBay);
            dpkDate.Text           = lichbay.Ngay;
            dpkStart.Text          = lichbay.GioKhoiHanh;
            dpkEnd.Text            = lichbay.GioKetThuc;
            cmbState.SelectedIndex = cmbState.Items.IndexOf(lichbay.TinhTrang);

            grvData.DataSource = lichchuyenbay.LoadDetail(lichbay.MaLichBay);
        }
Пример #10
0
        public int Insert(LichBay LichBay)
        {
            string path = @"Data Source=.\SQLEXPRESS;Initial Catalog=QLBanvechuyenbay;Integrated Security=True";

            SqlConnection conn = new SqlConnection(path);
            string        sql  = string.Format("Select MAX(MaLichBay) From LichBay");

            SqlCommand command = new SqlCommand(sql, conn);

            conn.Open();

            var rd = command.ExecuteReader();

            string tmp = "";

            if (rd.Read())
            {
                tmp = rd.GetString(0);
            }

            conn.Close();


            int id = int.Parse(tmp.Remove(0, 2));

            id++;
            tmp = "LB";
            if (id < 10)
            {
                tmp += "00";
            }
            else if (id < 100)
            {
                tmp += "0";
            }
            tmp += id;
            sql  = string.Format("Insert into LichBay(MaLichBay, MaChuyenBay, Ngay, GioKhoiHanh, GioKetThuc, TinhTrang)  Values('{0}','{1}','{2}','{3}','{4}',N'{5}')",
                                 tmp, LichBay.MaChuyenBay, LichBay.Ngay, LichBay.GioKhoiHanh, LichBay.GioKetThuc, LichBay.TinhTrang);
            var rs = ProcessData.ExecuteNonQuery(sql);

            return(rs);
        }
Пример #11
0
 private void Frm_onEdit1(LichBay lichbay)
 {
     lichchuyenbay.Update(lichbay);
     ReloadData();
 }
Пример #12
0
 private void Frm_onAdd1(LichBay lichbay)
 {
     lichchuyenbay.Insert(lichbay);
     ReloadData();
 }
 public int Update(LichBay lb)
 {
     return(lichbayDAO.Update(lb));
 }
 public int Insert(LichBay lb)
 {
     return(lichbayDAO.Insert(lb));
 }