public List <BanDoc> List_SelectDocGia() { List <BanDoc> list = new List <BanDoc>(); try { dt = dh.ExecuteDataSet("usp_Reader_Select", new SqlParameter[0]).Tables[0]; if (dt.Rows.Count != 0) { foreach (DataRow dr in dt.Rows) { BanDoc sl = new BanDoc { ID = dr["ID"] == DBNull.Value ? "" : dr["ID"].ToString(), Name = dr["NAME"] == DBNull.Value ? "" : dr["NAME"].ToString(), DateCreate = dr["DATECREATE"] == DBNull.Value ? DateTime.MinValue : DateTime.Parse(dr["DATECREATE"].ToString()), PhoneNumber = dr["PHONENUMBER"] == DBNull.Value ? "" : dr["PHONENUMBER"].ToString(), UUID = dr["UUID"] == DBNull.Value ? "" : dr["UUID"].ToString(), }; list.Add(sl); } } } catch (Exception ex) { throw ex; } return(list); }
public ActionResult DangKy(Register model) { var i = from p in db.BanDocs select p; int sothe = i.Count() + 1; if (ModelState.IsValid) { var bandoc = new BanDoc(); if (sothe <= 10) { bandoc.BD_SoThe = "TV0" + sothe; } else { bandoc.BD_SoThe = "TV" + sothe; } bandoc.BD_HoVaTen = model.BD_HoVaTen; bandoc.BD_NgaySinh = model.BD_NgaySinh; bandoc.BD_TrinhDo = model.BD_TrinhDo; bandoc.BD_NgheNghiep = model.BD_NgheNghiep; bandoc.BD_DiaChiNoiLamViec = model.BD_NoiCongTacHocTap; bandoc.BD_DTDIDong = model.BD_DTDIDong; bandoc.BD_ChoOHienTai = model.BD_ChoOHienTai; bandoc.BD_Email = model.BD_Email; db.BanDocs.Add(bandoc); db.SaveChanges(); return(Redirect("/RegisterBanDoc/ThanhCong")); } else { ModelState.AddModelError("", "Đăng ký không thành công."); } return(View(model)); }
public int addnewBD(BanDoc bd) { DateTime ngaysinh = Convert.ToDateTime(bd.Ngaysinh); DateTime ngaylap = Convert.ToDateTime(bd.Ngaylap); string sql = "insert into BanDoc values('" + bd.Id + "',N'" + bd.Name + "','" + bd.Address + "',N'" + bd.Cmnd + "','" + ngaysinh.ToString("MM-dd-yyyy") + "','" + bd.Email + "',N'" + ngaylap.ToString("MM-dd-yyyy") + "','" + bd.Nguoilap + "')"; return(data.add(sql)); }
public ActionResult DeleteConfirmed(string id) { BanDoc banDoc = db.BanDocs.Find(id); db.BanDocs.Remove(banDoc); db.SaveChanges(); return(RedirectToAction("Index")); }
public int edit(BanDoc bd) { DateTime ngaysinh = Convert.ToDateTime(bd.Ngaysinh); DateTime ngaylap = Convert.ToDateTime(bd.Ngaylap); string sql = "update BanDoc set Name=N'" + bd.Name + "',Address='" + bd.Address + "',CMND='" + bd.Cmnd + "',DateOfBirth='" + ngaysinh.ToString("MM-dd-yyyy") + "',Email='" + bd.Email + "',DateCreated='" + ngaylap.ToString("MM-dd-yyyy") + "',Creator='" + bd.Nguoilap + "' where ID ='" + bd.Id + "'"; if (data.Edit(sql) > 0) { return(1); } return(0); }
public List <BanDoc> getlist() { List <BanDoc> list = new List <BanDoc>(); DataTable data = bd.Data(); foreach (DataRow item in data.Rows) { BanDoc nv = new BanDoc(item); list.Add(nv); } return(list); }
public BanDoc searchBD(string id) { BanDoc sNV = null; string sql = "select * from BanDoc nv where nv.ID = '" + id + "'"; DataTable table = data.getData(sql); foreach (DataRow item in table.Rows) { sNV = new BanDoc(item); return(sNV); } return(sNV); }
// POST: BanDoc/Edit/5 // To protect from overposting attacks, please enable the specific properties you want to bind to, for // more details see https://go.microsoft.com/fwlink/?LinkId=317598. public RedirectToRouteResult ChuyenTrangThai(string id) { BanDoc banDoc = db.BanDocs.FirstOrDefault(m => m.BD_SoThe == id); if (banDoc != null) { banDoc.BD_NgayCapThe = DateTime.Now; banDoc.BD_THSDThe = DateTime.Now.AddYears(+1); banDoc.BD_ThoiGianMuon = DateTime.Now.AddMonths(+2); db.SaveChanges(); } return(RedirectToAction("")); }
// GET: BanDoc/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BanDoc banDoc = db.BanDocs.Find(id); if (banDoc == null) { return(HttpNotFound()); } return(View(banDoc)); }
public ActionResult Create([Bind(Include = "BD_SoThe,BD_HoVaTen,BD_NgaySinh,BD_SoCMND,BD_CapNgay,BD_NoiCap,BD_TrinhDo,BD_NoiCongTacHocTap,BD_NgheNghiep,BD_HopDongLaoDong,BD_DiaChiNoiLamViec,BD_DTDIDong,BD_Email,BD_ChoOHienTai,BD_GioiHanMuon,BD_HinhAnh,BD_NgayCapThe,BD_THSDThe,BD_ThoiGianMuon")] BanDoc banDoc, HttpPostedFileBase fileUpload) { try { if (ModelState.IsValid) { var fileimg = Request.Files["fileUpload"]; string sothe = Request["BD_SoThe"]; var listmathe = from s in db.BanDocs select s.BD_SoThe; bool kq = listmathe.Contains(sothe); //bool success = false; if (kq == true) { ViewBag.kq = "<div class ='text-danger'> Số thẻ đã tồn tại! </div>"; } else { if (fileimg.FileName.Length != 0) { //Upload file var fileName = Path.GetFileName(fileUpload.FileName); //Lưu đường dẫn file ảnh var path = Path.Combine(Server.MapPath("~/Content/AvtBanDoc"), fileName); //Kiểm tra file đã tồn tại if (System.IO.File.Exists(path)) { ViewBag.ThongBao = "Hình ảnh đã tồn tại"; } else { fileUpload.SaveAs(path); } banDoc.BD_HinhAnh = fileUpload.FileName; } db.BanDocs.Add(banDoc); db.SaveChanges(); ViewBag.Success = "<div class='alert alert-success' id='success - alert'> <button type = 'button' class='close' data-dismiss='alert'>x</button><strong>Tạo thành công! </strong>Trở về trang chủ để xem lại danh sách. <a href='/BanDoc'>Nhấp vào đây</a></div>"; //return Redirect("/BanDoc"); } } } catch (RetryLimitExceededException) { ModelState.AddModelError("", "Error Save Data"); } var list = from s in db.BanDocs select s; return(View()); }
private void btnTim_Click(object sender, EventArgs e) { bdBUS bdB = new bdBUS(); nvBUS nvB = new nvBUS(); BanDoc bd = bdB.searchBD(txtMaSo.Text); txtMaSo.Text = bd.Id; txtTenBD.Text = bd.Name; txtDiaChi.Text = bd.Address; txtCMND.Text = bd.Cmnd; txtNgaySinh.Text = bd.Ngaysinh; txtEmail.Text = bd.Email; txtNgayLap.Text = bd.Ngaylap; txtNguoiLap.Text = nvB.getFullNamebyID(bd.Nguoilap).TenNV; }
// GET: BanDoc/Edit/5 public ActionResult Edit(string id) { ViewBag.BD_SoThe = id; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BanDoc banDoc = db.BanDocs.Find(id); if (banDoc == null) { return(HttpNotFound()); } return(View(banDoc)); }
private void btnLuu_Click(object sender, EventArgs e) { nvBUS nvB = new nvBUS(); bdBUS bdB = new bdBUS(); string IdNguoiLap = nvB.getIDbyUsername(Form1.username).IdNV; BanDoc bd = new BanDoc(txtMaSo.Text, txtTenBD.Text, txtDiaChi.Text, txtCMND.Text, txtNgaySinh.Text, txtEmail.Text, txtNgayLap.Text, IdNguoiLap); if (check == true) { bdB.addBD(bd); } else { bdB.editBD(bd); disable(); } grvBanDoc.DataSource = bdB.getData(); }
public ActionResult Edit([Bind(Include = "BD_SoThe,BD_HoVaTen,BD_NgaySinh,BD_SoCMND,BD_CapNgay,BD_NoiCap,BD_TrinhDo,BD_NoiCongTacHocTap,BD_NgheNghiep,BD_HopDongLaoDong,BD_DiaChiNoiLamViec,BD_DTDIDong,BD_Email,BD_ChoOHienTai,BD_GioiHanMuon,BD_HinhAnh,BD_NgayCapThe,BD_THSDThe,BD_ThoiGianMuon")] BanDoc banDoc, HttpPostedFileBase fileUpload) { try { if (ModelState.IsValid) { var fileimg = Request.Files["fileUpload"]; string ha = fileimg.FileName; if (fileimg.FileName.Length != 0) { //Upload file var fileName = Path.GetFileName(fileUpload.FileName); //Lưu đường dẫn file ảnh var path = Path.Combine(Server.MapPath("~/Content/AvtBanDoc"), fileName); //Kiểm tra file đã tồn tại if (System.IO.File.Exists(path)) { ViewBag.ThongBao = "Hình ảnh đã tồn tại"; } else { fileUpload.SaveAs(path); } banDoc.BD_HinhAnh = fileUpload.FileName; db.Entry(banDoc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { db.Entry(banDoc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } } catch (RetryLimitExceededException) { ModelState.AddModelError("", "Error Save Data"); } return(View(banDoc)); }
public ActionResult SearchSoThe(string id) { ViewBag.SoThe = Session["SoThe"]; if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BanDoc result = db.BanDocs.Find(id); if (result != null) { Session["SoThe"] = id; return(View(result)); } else { ViewBag.info = "Không tìm thấy dữ liệu bạn đọc !"; return(View()); } }
public int addBD(BanDoc bandoc) { return(bd.addnewBD(bandoc)); }
public int editBD(BanDoc bandoc) { return(bd.edit(bandoc)); }