Пример #1
0
        public IActionResult TaiXe(string id, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Server error. Please try again or request technical support");
                if (String.IsNullOrEmpty(returnUrl))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Redirect(returnUrl));
                }
            }
            TaiXe res = context.TaiXe.Find(id);

            if (res == null)
            {
                ModelState.AddModelError("", "Không tìm thấy tài xế với mã " + id);
                if (String.IsNullOrEmpty(returnUrl))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(Redirect(returnUrl));
                }
            }
            return(View("TaiXe", res));
        }
Пример #2
0
        public async Task <IActionResult> CreateTaiXe(TaiXe taiXe)
        {
            List <string> messages = new List <string>();

            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Thông tin không hợp lệ");
                }
                await _context.TaiXe.AddAsync(taiXe);

                _context.SaveChanges();
                messages.Add("redirect");
                messages.Add(Url.Action("TaiXe"));
            }
            catch (Exception err)
            {
                messages.Add(err.Message);
                foreach (var value in ModelState.Values)
                {
                    if (value.ValidationState == ModelValidationState.Invalid)
                    {
                        foreach (var modelErr in value.Errors)
                        {
                            messages.Add(modelErr.ErrorMessage);
                        }
                    }
                }
            }
            return(Json(messages.ToArray()));
        }
Пример #3
0
 public ActionResult Create(TaiXe e, bool gender)
 {
     e.GioiTinh = gender;
     db.TaiXes.Add(e);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public IHttpActionResult PutTaiXe(int id, TaiXe taiXe)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != taiXe.id)
            {
                return(BadRequest());
            }

            db.Entry(taiXe).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TaiXeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 private void dgvDriver_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         TaiXe row = (TaiXe)dgvDriver.SelectedItems[0];
         txtMaTX.Text     = row.matx;
         txtTenTaiXe.Text = row.hotentx;
         dtpNgaysinh.Text = row.ngaysinh.ToString();
         txtDiachi.Text   = row.diachi;
         if (row.gioitinh.ToString() == "Nam")
         {
             radNam.IsChecked = true;
         }
         else if (row.gioitinh.ToString() == "Nữ")
         {
             radNu.IsChecked = true;
         }
         txtDienthoai.Text = row.dienthoai;
         txtCMND.Text      = row.cmnd;
         txtBanglai.Text   = row.loaibang;
         txtAnh.Text       = row.anh;
     }
     catch (Exception i)
     {
     }
 }
        public bool UpdateTaiXe(TaiXe tx)
        {
            string query  = string.Format("UPDATE Tai_xe SET TenTaiXe = N'{0}', BangLai = N'{1}' WHERE ID_TaiXe = {2}", tx.Ten, tx.BangLai, tx.ID);
            int    result = DataProvider.ExecuteNonQuery(query);

            return(result > 0);
        }
        public bool InsertTaiXe(TaiXe tx)
        {
            string query  = string.Format("sp_ThemTaiXe @ten , @bang");
            int    result = DataProvider.ExecuteNonQuery(query, new object[] { tx.Ten, tx.BangLai });

            return(result > 0);
        }
Пример #8
0
        public int SuaTaiXe(TaiXe a)
        {
            int       kq     = 0;
            DAO_TaiXe tai_xe = new DAO_TaiXe();

            kq = tai_xe.SuaTaiXe(a);
            return(kq);
        }
        private void dgvChuyen_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dgvChuyen.SelectedCells.Count > 0)
                {
                    int id_TaiXe = (int)dgvChuyen.SelectedCells[0].OwningRow.Cells["Tai_xe_ID_Taixe"].Value;
                    int id_Xe    = (int)dgvChuyen.SelectedCells[0].OwningRow.Cells["Xe_XeID"].Value;
                    int id_Tuyen = (int)dgvChuyen.SelectedCells[0].OwningRow.Cells["Tuyen_ID_Tuyen"].Value;

                    BUS_TuyenXe busTuyenXe = new BUS_TuyenXe();
                    BUS_Xe      busxe      = new BUS_Xe();
                    BUS_TaiXe   bustaixe   = new BUS_TaiXe();

                    TuyenXe tuyenXe = busTuyenXe.getTuyenXeByID(id_Tuyen);
                    Xe      xe      = busxe.getXeByID(id_Xe);
                    TaiXe   taixe   = bustaixe.getTaiXeByID(id_TaiXe);

                    cbbTenTuyen.SelectedItem = tuyenXe;
                    cbbxe.SelectedItem       = xe;
                    cbbTaiXe.SelectedItem    = taixe;

                    int index = -1, index1 = -1, index2 = -1;
                    int i = 0, j = 0, k = 0;
                    foreach (TuyenXe item in cbbTenTuyen.Items)
                    {
                        if (item.ID == tuyenXe.ID)
                        {
                            index = i;
                            break;
                        }
                        i++;
                    }
                    foreach (Xe item in cbbxe.Items)
                    {
                        if (item.ID == xe.ID)
                        {
                            index = j;
                            break;
                        }
                        j++;
                    }
                    foreach (TaiXe item in cbbTaiXe.Items)
                    {
                        if (item.ID == taixe.ID)
                        {
                            index = k;
                            break;
                        }
                        k++;
                    }
                    cbbTenTuyen.SelectedIndex = index;
                    cbbxe.SelectedIndex       = index1;
                    cbbTaiXe.SelectedIndex    = index2;
                }
            }
            catch { }
        }
        void getTaiXe()
        {
            // MessageBox.Show(dgDieuXe.CurrentRow.Cells[3].Value.ToString());
            DateTime dt;

            dt = DateTime.Parse(dgDieuXe.CurrentRow.Cells[3].Value.ToString()).AddMinutes(5);
            dgTaiXe.DataSource  = TaiXe.HienThiLaiXechinh(String.Format("{0:yyyy-MM-dd HH:mm tt}", dt));
            dgLaiPhu.DataSource = TaiXe.HienThiLaiXePhu(String.Format("{0:yyyy-MM-dd HH:mm tt}", dt));
        }
Пример #11
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            TaiXe taiXe = await db.TaiXes.FindAsync(id);

            db.TaiXes.Remove(taiXe);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
 private void btnXoa_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa tài xế " + txtTenTaiXe.Text + " không?", "Xóa", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         TaiXe tx = new TaiXe();
         tx.matx = txtMaTX.Text;
         TaiXeBUS.Instance.Xoa(tx);
         Load(sender, e);
     }
 }
Пример #13
0
        public void TestThemDuLieuTaiXe()
        {
            opr = new Operation();
            TaiXe xe = new TaiXe();

            xe.maTaiXe = "TX1"; //da ton tai
            bool check = opr.themTaiXe(xe);

            Assert.AreEqual(false, check);
        }
Пример #14
0
        public void TestChinhSuaDuLieuTaiXe()
        {
            opr = new Operation();
            TaiXe xe = new TaiXe();

            xe.maXe = "3804982304";
            bool check = opr.suaDuLieuTaiXe(xe);

            Assert.AreEqual(true, check);
        }
Пример #15
0
        public async Task <ActionResult> Edit([Bind(Include = "id,HoTen,Lat,Lng,TrangThai")] TaiXe taiXe)
        {
            if (ModelState.IsValid)
            {
                db.Entry(taiXe).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(taiXe));
        }
        public IHttpActionResult GetTaiXe(int id)
        {
            TaiXe taiXe = db.TaiXes.Find(id);

            if (taiXe == null)
            {
                return(NotFound());
            }

            return(Ok(taiXe));
        }
Пример #17
0
        public async Task <ActionResult> Create([Bind(Include = "id,HoTen,Lat,Lng,TrangThai")] TaiXe taiXe)
        {
            if (ModelState.IsValid)
            {
                db.TaiXes.Add(taiXe);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(taiXe));
        }
        public IHttpActionResult PostTaiXe(TaiXe taiXe)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TaiXes.Add(taiXe);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = taiXe.id }, taiXe));
        }
        public IHttpActionResult DeleteTaiXe(int id)
        {
            TaiXe taiXe = db.TaiXes.Find(id);

            if (taiXe == null)
            {
                return(NotFound());
            }

            db.TaiXes.Remove(taiXe);
            db.SaveChanges();

            return(Ok(taiXe));
        }
Пример #20
0
        // GET: TaiXes/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TaiXe taiXe = await db.TaiXes.FindAsync(id);

            if (taiXe == null)
            {
                return(HttpNotFound());
            }
            return(View(taiXe));
        }
Пример #21
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (KTRONG() == false)
            {
                return;
            }
            else
            {
                TaiXe tai_xe = new TaiXe();
                tai_xe.id_taixe = txtId.Text;
                tai_xe.tentaixe = txtHT.Text;
                tai_xe.banglai  = txtBL.Text;
                BUS_TaiXe busTx = new BUS_TaiXe();

                if (txtId.Enabled == true)
                {
                    if (busTx.ThemTaiXe(tai_xe) == 1)
                    {
                        FormTaiXe qltx = new FormTaiXe();
                        busTx.LoadTaiXe();
                        this.Close();
                    }
                    else if (busTx.ThemTaiXe(tai_xe) == -1)
                    {
                        MessageBox.Show("Không Được Trùng ID");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("Không Thêm Được");
                        return;
                    }
                }
                else
                {
                    if (busTx.SuaTaiXe(tai_xe) == 1)
                    {
                        FormQLXe qlXe = new FormQLXe();
                        qlXe.LoadQLXe();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Không Sửa Được");
                        return;
                    }
                }
                txtId.Enabled = true;
            }
        }
Пример #22
0
 public Boolean suaDuLieuTaiXe(TaiXe tx)
 {
     try
     {
         SqlCommand cmd = new SqlCommand();
         cmd.CommandType = CommandType.Text;
         cmd.CommandText = "update TaiXe set HoVaTen=N'" + tx.hoVaTen + "',NgaySinh=N'" + tx.ngaySinh + "',GioiTinh=N'" + tx.gioiTinh + "',DiaChi=N'" + tx.diaChi + "',QueQuan=N'" + tx.queQuan + "',NgayBDHopDong=N'" + tx.ngayBDHopDong + "',Luong='" + tx.luong + "',BangLai=N'" + tx.bangLai + "',MaXe=N'" + tx.maXe + "' where MaTX='" + tx.maTaiXe + "'";
         db.ExeNonQuery(cmd);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Пример #23
0
        public ActionResult Edit(int id, TaiXe driver)
        {
            var e = db.TaiXes.SingleOrDefault(x => x.MaTaiXe == id);

            e.HoTen     = driver.HoTen;
            e.NgaySinh  = driver.NgaySinh;
            e.GioiTinh  = driver.GioiTinh;
            e.DiaChi    = driver.DiaChi;
            e.DienThoai = driver.DienThoai;
            e.SoCMTND   = driver.SoCMTND;
            e.LoaiBang  = driver.LoaiBang;
            e.MaTuyenXe = driver.MaTuyenXe;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #24
0
 public bool themTaiXe(TaiXe taiXe)
 {
     try
     {
         SqlCommand cmd = new SqlCommand();
         cmd.CommandType = CommandType.Text;
         cmd.CommandText = "insert into TaiXe values(N'" + taiXe.maTaiXe + "',N'" + taiXe.hoVaTen + "',N'" + taiXe.ngaySinh + "',N'" + taiXe.gioiTinh + "',N'" + taiXe.diaChi + "',N'" + taiXe.queQuan + "',N'" + taiXe.ngayBDHopDong + "',N'" + taiXe.luong + "',N'" + taiXe.bangLai + "',N'" + taiXe.maXe + "')";
         db.ExeNonQuery(cmd);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Пример #25
0
        public int ThemTaiXe(TaiXe a)
        {
            int       kq     = 0;
            DAO_TaiXe tai_xe = new DAO_TaiXe();
            DataTable dt     = tai_xe.IDTaiXe();

            foreach (DataRow row in dt.Rows)
            {
                if (a.id_taixe == row[0].ToString())
                {
                    return(-1);
                }
            }
            kq = tai_xe.ThemTaiXe(a);
            return(kq);
        }
        public List <TaiXe> GetTaiXeCbb()
        {
            List <TaiXe> list = new List <TaiXe>();

            string       query    = "SELECT * FROM Tai_xe";
            DataProvider provider = new DataProvider();
            DataTable    data     = provider.ExecuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                TaiXe taiXe = new TaiXe(item);
                list.Add(taiXe);
            }

            return(list);
        }
        public TaiXe GetTaiXeByID(int id)
        {
            TaiXe TaiXe = new TaiXe();

            string       query    = "select * from Tai_xe where  = " + id;
            DataProvider provider = new DataProvider();
            DataTable    data     = provider.ExecuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                TaiXe = new TaiXe(item);
                return(TaiXe);
            }

            return(TaiXe);
        }
Пример #28
0
        public async Task <IActionResult> UpdateTaiXe(TaiXe taiXe)
        {
            List <string> messages = new List <string>();

            try
            {
                if (!ModelState.IsValid)
                {
                    throw new Exception("Thông tin không hợp lệ");
                }
                TaiXe _TaiXe = await _context.TaiXe.FindAsync(taiXe.MaTaiXe);

                if (_TaiXe == null)
                {
                    throw new Exception("Không tìm thấy tài xế");
                }
                _TaiXe.HoDem    = taiXe.HoDem;
                _TaiXe.Ten      = taiXe.Ten;
                _TaiXe.GioiTinh = taiXe.GioiTinh;
                _TaiXe.NoiSinh  = taiXe.NoiSinh;
                _TaiXe.Sdt      = taiXe.Sdt;
                _context.TaiXe.Update(_TaiXe);
                _context.SaveChanges();
                messages.Add("redirect");
                messages.Add(Url.Action("TaiXe"));
            }
            catch (Exception err)
            {
                messages.Add(err.Message);
                foreach (var value in ModelState.Values)
                {
                    if (value.ValidationState == ModelValidationState.Invalid)
                    {
                        foreach (var modelErr in value.Errors)
                        {
                            messages.Add(modelErr.ErrorMessage);
                        }
                    }
                }
            }
            return(Json(messages.ToArray()));
        }
Пример #29
0
        public IEnumerable <TaiXe> TimKiem(string search)
        {
            List <TaiXe> Details = new List <TaiXe>();
            var          result  = db.Search_TaiXe(search).ToList();

            for (int j = 0; j < result.Count; j++)
            {
                TaiXe tx = new TaiXe();
                tx.matx      = Convert.ToString(result[j].matx);
                tx.anh       = AppDomain.CurrentDomain.BaseDirectory + @"image\avatar\" + Convert.ToString(result[j].anh);
                tx.hotentx   = Convert.ToString(result[j].hotentx);
                tx.ngaysinh  = Convert.ToDateTime(result[j].ngaysinh);
                tx.diachi    = Convert.ToString(result[j].diachi);
                tx.gioitinh  = Convert.ToString(result[j].gioitinh);
                tx.dienthoai = Convert.ToString(result[j].dienthoai);
                tx.cmnd      = Convert.ToString(result[j].cmnd);
                tx.loaibang  = Convert.ToString(result[j].loaibang);
                Details.Add(tx);
            }
            return(Details);
        }
Пример #30
0
        public IActionResult TaiXe()
        {
            nhaXe = getAssociatedNhaXe(uManager).Result;
            ViewData["TenNhaXe"] = nhaXe.TenNhaXe;
            var s = from xk in _context.XeKhach
                    from tx in _context.TaiXe
                    where xk.MaNhaXe == nhaXe.MaNhaXe && xk.MaTaiXe == tx.MaTaiXe
                    select tx;
            TaiXe  taiXeCuoi   = _context.TaiXe.LastOrDefault();
            string lastTaiXeId = null;

            if (taiXeCuoi != null)
            {
                lastTaiXeId = taiXeCuoi.MaTaiXe;
            }
            else
            {
                lastTaiXeId = "TX00000000";
            }
            ViewBag.NextTaiXeId = String.Concat("TX", Utils.IncrementString(lastTaiXeId.Substring(2)));
            return(View("TaiXe", s.ToArray()));
        }