public ActionResult Create(PhuXe e, bool gender)
 {
     e.GioiTinh = gender;
     db.PhuXes.Add(e);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 private void dgvAssistantDriver_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         PhuXe row = (PhuXe)dgvAssistantDriver.SelectedItems[0];
         txtMaPX.Text     = row.mapx;
         txtTenPX.Text    = row.hoten;
         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;
         txtAnh.Text       = row.anh;
     }
     catch (Exception i)
     {
     }
 }
 private void btnXoa_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa phụ xe " + txtTenPX.Text + " không?", "Xóa", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         PhuXe px = new PhuXe();
         px.mapx = txtMaPX.Text;
         PhuXeBUS.Instance.Xoa(px);
         Load(sender, e);
     }
 }
        public ActionResult Edit(int id, PhuXe driver)
        {
            var e = db.PhuXes.SingleOrDefault(x => x.MaPhuXe == 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.MaTuyenXe = driver.MaTuyenXe;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public IEnumerable <PhuXe> TimKiem(string search)
        {
            List <PhuXe> Details = new List <PhuXe>();
            var          result  = db.Search_PhuXe(search).ToList();

            for (int j = 0; j < result.Count; j++)
            {
                PhuXe px = new PhuXe();
                px.mapx      = Convert.ToString(result[j].mapx);
                px.anh       = AppDomain.CurrentDomain.BaseDirectory + @"image\avatar\" + Convert.ToString(result[j].anh);
                px.hoten     = Convert.ToString(result[j].hoten);
                px.ngaysinh  = Convert.ToDateTime(result[j].ngaysinh);
                px.diachi    = Convert.ToString(result[j].diachi);
                px.gioitinh  = Convert.ToString(result[j].gioitinh);
                px.dienthoai = Convert.ToString(result[j].dienthoai);
                px.cmnd      = Convert.ToString(result[j].cmnd);
                Details.Add(px);
            }
            return(Details);
        }
        private void btnLuu_Click(object sender, RoutedEventArgs e)
        {
            PhuXe px = new PhuXe();

            px.anh      = txtAnh.Text;
            px.hoten    = txtTenPX.Text;
            px.ngaysinh = dtpNgaysinh.SelectedDate.Value;
            px.diachi   = txtDiachi.Text;
            if (radNam.IsChecked == true)
            {
                px.gioitinh = radNam.Content.ToString();
            }
            else if (radNu.IsChecked == true)
            {
                px.gioitinh = radNu.Content.ToString();
            }
            px.dienthoai = txtDienthoai.Text;
            px.cmnd      = txtCMND.Text;
            if (themMoi)
            {
                PhuXeBUS.Instance.Them(px);
            }
            else
            {
                if (flag == 1)
                {
                    PhuXeBUS.Instance.CapNhat(px, maPX);
                    flag = 0;
                }
                else
                {
                    PhuXeBUS.Instance.CapNhatNoImg(px, maPX);
                }
            }
            Load(sender, e);
        }
Ejemplo n.º 7
0
 public void Xoa(PhuXe px)
 {
     PhuXeDAO.Instance.Xoa(px);
 }
Ejemplo n.º 8
0
 public void CapNhatNoImg(PhuXe px, string maPX)
 {
     PhuXeDAO.Instance.CapNhatKoImg(px, maPX);
 }
Ejemplo n.º 9
0
 public void Them(PhuXe px)
 {
     PhuXeDAO.Instance.Them(px);
 }
Ejemplo n.º 10
0
 public void Xoa(PhuXe px)
 {
     var result = db.Delete_PhuXe(px.mapx);
 }
Ejemplo n.º 11
0
 public void CapNhatKoImg(PhuXe px, string maPX)
 {
     var result = db.Update_PhuXe_No_IMG(maPX, px.hoten, px.ngaysinh, px.diachi, px.gioitinh, px.dienthoai, px.cmnd);
 }
Ejemplo n.º 12
0
 public void Them(PhuXe px)
 {
     var result = db.Insert_PhuXe(px.anh, px.hoten, px.ngaysinh, px.diachi, px.gioitinh, px.dienthoai, px.cmnd);
 }