public ActionResult XemThongtin(string id, int idtkb) { if (Session["Login"] == null) { return(RedirectToAction("Login", "Account")); } else { GIANGVIEN b = (GIANGVIEN)Session["Login"]; ViewBag.name = b.TEN; if (b.ROLE == 1 || b.ROLE == 2) { var a = data.DIEMDANHs.Where(x => x.MASINHVIEN.Equals(id) && x.IDTKB == idtkb); var b1 = data.DIEMDANHs.Where(x => x.MASINHVIEN.Equals(id) && x.IDTKB == idtkb).FirstOrDefault(); ViewBag.tensv = b1.SINHVIEN.TEN; ViewBag.tenmh = b1.TKB.MONHOC.TENMONHOC; return(View(a)); } else { return(RedirectToAction("Message", new { tenaction = "Không thể truy cập" })); } } }
public int insert(string magv, string tengv, int gioitinh, DateTime ngaysinh, string diachi, string sdt, string email, string trinhdo, string bangcap, DateTime ngayvaolam, double heso) { try { using (QLTTEntities qltt = new QLTTEntities()) { GIANGVIEN x = new GIANGVIEN() { MAGV = magv, TENGV = tengv, GIOITINH = gioitinh, NGSINH = ngaysinh, DIACHI = diachi, SDT = sdt, EMAIL = email, TRINHDO = trinhdo, BANGCAP = bangcap, NGAYVL = ngayvaolam, HESO = heso }; qltt.GIANGVIENs.Add(x); qltt.SaveChanges(); } return(1); } catch { return(0); } }
public DataTable get(string code) { using (QLTTEntities qltt = new QLTTEntities()) { GIANGVIEN gv = qltt.GIANGVIENs.Where(p => p.MAGV == code).FirstOrDefault(); if (gv != null) { DataTable rtnTable = new DataTable(); rtnTable.Columns.Add("MAGV", typeof(string)); rtnTable.Columns.Add("TENGV", typeof(string)); rtnTable.Columns.Add("GIOITINH", typeof(int)); rtnTable.Columns.Add("NGSINH", typeof(DateTime)); rtnTable.Columns.Add("DIACHI", typeof(string)); rtnTable.Columns.Add("SDT", typeof(string)); rtnTable.Columns.Add("EMAIL", typeof(string)); rtnTable.Columns.Add("TRINHDO", typeof(string)); rtnTable.Columns.Add("BANGCAP", typeof(string)); rtnTable.Columns.Add("NGAYVL", typeof(DateTime)); rtnTable.Columns.Add("HESO", typeof(double)); rtnTable.Rows.Add(gv.MAGV, gv.TENGV, gv.GIOITINH, gv.NGSINH, gv.DIACHI, gv.SDT, gv.EMAIL, gv.TRINHDO, gv.BANGCAP, gv.NGAYVL, gv.HESO); return(rtnTable); } } return(null); }
public int update(string magv, string tengv, int gioitinh, DateTime ngaysinh, string diachi, string sdt, string email, string trinhdo, string bangcap, DateTime ngayvaolam, double heso) { try { using (QLTTEntities qltt = new QLTTEntities()) { GIANGVIEN gv = qltt.GIANGVIENs.Where(p => p.MAGV == magv).FirstOrDefault(); if (gv != null) { gv.TENGV = tengv; gv.GIOITINH = gioitinh; gv.NGSINH = ngaysinh; gv.DIACHI = diachi; gv.SDT = sdt; gv.EMAIL = email; gv.TRINHDO = trinhdo; gv.BANGCAP = bangcap; gv.NGAYVL = ngayvaolam; gv.HESO = heso; qltt.SaveChanges(); return(1); } return(0); } } catch { return(0); } }
public ActionResult TeacherCheckIn(int id, string idmonhoc, string tenmonhoc) { if (Session["Login"] == null) { return(RedirectToAction("Login", "Account")); } else { GIANGVIEN b = (GIANGVIEN)Session["Login"]; if (b.ROLE == 2) { var a = data.NHOMs; ViewBag.a = id; ViewBag.b = b.ID; ViewBag.idmonhoc = idmonhoc; ViewBag.tenmonhoc = tenmonhoc; return(View(a)); } else { return(RedirectToAction("Message", new { tenaction = "Không thể truy cập form điểm danh" })); } } }
public static bool InsertAndTaiKhoan(GIANGVIEN _giangvien, TAIKHOAN taiKhoan) { try { using (TransactionScope ts = new TransactionScope()) { taiKhoan.LOAITAIKHOAN = LoaiTaiKhoanLogic.Select(taiKhoan.LoaiTaiKhoanId ?? 0); taiKhoan.TenDangNhap = taiKhoan.TenDangNhap.ToLower(); taiKhoan.IsRemove = 0; taiKhoan.MatKhau = O2S_Common.EncryptAndDecrypt.MD5EncryptAndDecrypt.Encrypt(taiKhoan.MatKhau, true); Database.TAIKHOANs.InsertOnSubmit(taiKhoan); Database.SubmitChanges(); _giangvien.CreatedDate = DateTime.Now; _giangvien.CreatedBy = GlobalSettings.UserCode; _giangvien.CreatedLog = GlobalSettings.SessionMyIP; _giangvien.IsRemove = 0; _giangvien.TaiKhoanId = taiKhoan.TaiKhoanId; Database.GIANGVIENs.InsertOnSubmit(_giangvien); Database.SubmitChanges(); _giangvien.MaGiangVien = string.Format("{0}{1:D5}", "GV", _giangvien.GiangVienId); Database.SubmitChanges(); ts.Complete(); return(true); } } catch (Exception ex) { return(false); O2S_Common.Logging.LogSystem.Error(ex); } }
public IHttpActionResult PostGIANGVIEN(GIANGVIEN gIANGVIEN) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.GIANGVIENs.Add(gIANGVIEN); try { db.SaveChanges(); } catch (DbUpdateException) { if (GIANGVIENExists(gIANGVIEN.MaGV)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = gIANGVIEN.MaGV }, gIANGVIEN)); }
public static bool Update(GIANGVIEN _hocVien, TAIKHOAN taiKhoan = null) { try { var hocVienCu = SelectSigleTheoKhoaKhoa(_hocVien.GiangVienId); hocVienCu.TenGiangVien = _hocVien.TenGiangVien; hocVienCu.GioiTinh = _hocVien.GioiTinh; hocVienCu.Sdt = _hocVien.Sdt; hocVienCu.Email = _hocVien.Email; hocVienCu.NgaySinh = _hocVien.NgaySinh; hocVienCu.DiaChi = _hocVien.DiaChi; hocVienCu.NgayBatDauLamViec = _hocVien.NgayBatDauLamViec; hocVienCu.GhiChu = _hocVien.GhiChu; hocVienCu.ModifiedDate = DateTime.Now; hocVienCu.ModifiedBy = GlobalSettings.UserCode; hocVienCu.ModifiedLog = GlobalSettings.SessionMyIP; Database.SubmitChanges(); if (taiKhoan != null) { TaiKhoanLogic.Update(taiKhoan); } return(true); } catch (Exception ex) { return(false); O2S_Common.Logging.LogSystem.Error(ex); } }
public static GIANGVIEN GetGiangVienByMa(string maGV) { if (Program.KetNoi() == 0) { return(null); } SqlDataReader myReader; myReader = Program.ExecSqlDataReader(string.Format(KeyConst.Lenh.GetGiangVienByMa, maGV.Trim())); if (myReader == null) { return(null); } myReader.Read(); GIANGVIEN gv = new GIANGVIEN { MAGV = myReader.GetString(0), HO = myReader.GetString(1), TEN = myReader.GetString(2), HOCVI = myReader.GetString(3), MAKH = myReader.GetString(4), EMAIL = myReader.GetString(5) }; myReader.Close(); return(gv); }
public void Put(int id, [FromBody] GIANGVIEN GIANGVIEN) { using (QLGVEntities db = new QLGVEntities()) { var s = db.GIANGVIENs.SingleOrDefault(x => x.MaGV == id); if (s != null) { s.MaGV = GIANGVIEN.MaGV; s.MaBM = GIANGVIEN.MaBM; s.TenGV = GIANGVIEN.TenGV; s.ChucVu = GIANGVIEN.ChucVu; s.NgaySinh = GIANGVIEN.NgaySinh; s.Email = GIANGVIEN.Email; s.GioiTinh = GIANGVIEN.GioiTinh; s.SDT = GIANGVIEN.SDT; s.DiaChi = GIANGVIEN.DiaChi; s.MonHocPhuTrach = GIANGVIEN.MonHocPhuTrach; s.TrinhDoHocVan = GIANGVIEN.TrinhDoHocVan; db.SaveChanges(); } else { } } }
private void LoadPanelControl(GIANGVIEN _giangvien = null) { try { if (_giangvien == null) { ResetPanelControl(); } else { txtMaHV.Text = _giangvien.MaGiangVien; txtHoTen.Text = _giangvien.TenGiangVien; dateNgaySinh.Value = _giangvien.NgaySinh != null ? (DateTime)_giangvien.NgaySinh : dateNgaySinh.MaxDate; cboGioiTinh.Text = _giangvien.GioiTinh; txtDiaChi.Text = _giangvien.DiaChi; txtSDT.Text = _giangvien.Sdt; txtEmail.Text = _giangvien.Email; dateNgayBatDauLamViec.Value = _giangvien.NgayBatDauLamViec != null ? (DateTime)_giangvien.NgayBatDauLamViec : DateTime.Now; txtGhiChu.Text = _giangvien.GhiChu; txtTenDangNhap.Text = _giangvien.TAIKHOAN.IsRemove != 1 ? _giangvien.TAIKHOAN.TenDangNhap : string.Empty; txtMatKhau.Text = _giangvien.TAIKHOAN.IsRemove != 1 ? O2S_Common.EncryptAndDecrypt.MD5EncryptAndDecrypt.Decrypt(_giangvien.TAIKHOAN.MatKhau, true) : string.Empty; } } catch (Exception ex) { ResetPanelControl(); LockAndUnlockPanelControl(false); O2S_Common.Logging.LogSystem.Error(ex); } }
private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { GIANGVIEN gv = new GIANGVIEN(); gv.MAGV = txtMaGv.Text.Trim(); gv.HOTEN = txtHoten.Text.Trim(); gv.MADONVI = cbo_madv.SelectedValue.ToString(); gv.TRINHDO = txtTrinhdo.Text.Trim(); gv.CHUYENMON = txtchuyemon.Text.Trim(); int them = lqGiaovien.themGiangvien(gv); if (them == 1) { MessageBox.Show("Thêm thành công"); loadGiaoVien(); } else if (them == 0) { MessageBox.Show("Thêm thất bại"); return; } else { MessageBox.Show("Giáo viên đã tồn tại.Vui lòng kt lại"); } }
public IHttpActionResult PutGIANGVIEN(int id, GIANGVIEN gIANGVIEN) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != gIANGVIEN.MaGV) { return(BadRequest()); } db.Entry(gIANGVIEN).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GIANGVIENExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void btThem_Click(object sender, EventArgs e) { if (ktKhoa(textBoxX1.Text) > 0) { MessageBox.Show("Trùng mã"); return; } else { GIANGVIEN gv = new GIANGVIEN(); gv.magv = textBoxX1.Text; gv.tengv = textBoxX2.Text; gv.dienthoai = textBoxX3.Text; gv.diachi = textBoxX6.Text; if (radioButton1.Checked == true) { gv.gioitinh = radioButton1.Text; } else { gv.gioitinh = radioButton2.Text; } gv.trinhdo = textBoxX5.Text; gv.ngayvaolam = dateTimeInput1.Value; qlthi.GIANGVIENs.InsertOnSubmit(gv); ClearGroup(panelEx1.Controls); MessageBox.Show("Thêm thành công"); } }
public ActionResult DangNhapGV(FormCollection collection) { var acc = collection["account"]; var mk = collection["pass"]; if (String.IsNullOrEmpty(acc)) { ViewData["loi1"] = "Không được bỏ trống tài khoản"; } else if (String.IsNullOrEmpty(mk)) { ViewData["loi1"] = "Không được bỏ trống mật khẩu !!"; } else { GIANGVIEN gv = db.GIANGVIENs.SingleOrDefault(n => n.TaiKhoan == acc && n.MatKhau == mk); if (gv != null) { Session[SesAdmin] = gv; return(RedirectToAction("Index", "GiangVien")); } else { ViewBag.ThongBao = "Tài khoản hoặc mật khẩu không đúng"; } } return(View()); }
public async Task <IActionResult> PutGIANGVIEN([FromRoute] string id, [FromBody] GIANGVIEN gIANGVIEN) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != gIANGVIEN.MAGV) { return(BadRequest()); } _context.Entry(gIANGVIEN).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GIANGVIENExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public DataTable getGianngVien_All() { GIANGVIEN gVien = new GIANGVIEN(); DAL_GIANGVIEN dao = new DAL_GIANGVIEN(); return(dao.getTeacher_All()); }
public bool Insert(GIANGVIEN GiangVien) { if (baseFunctions.Add(GiangVien) > 0) { return(true); } return(false); }
public bool Update(GIANGVIEN GiangVien) { if (baseFunctions.Update(GiangVien) > 0) { return(true); } return(false); }
public DataTable getGianngVien_LastCode() { GIANGVIEN gVien = new GIANGVIEN(); DAL_GIANGVIEN dao = new DAL_GIANGVIEN(); return(dao.getGingVien_LastCode()); }
public DataTable getGianngVien_ByID(int gVId) { GIANGVIEN gVien = new GIANGVIEN(); gVien.GIV_ID = gVId; DAL_GIANGVIEN dao = new DAL_GIANGVIEN(); return(dao.getDsTeacher_ByID(gVien)); }
public DataTable getGianngVien_ByName(string gVName) { GIANGVIEN gVien = new GIANGVIEN(); gVien.GIV_Name = gVName; DAL_GIANGVIEN dao = new DAL_GIANGVIEN(); return(dao.getDsTeacher_ByID(gVien)); }
private void frmThayDoiThongTinGV_Load(object sender, EventArgs e) { GIANGVIEN gv = GiangVien.Select(GlobalSettings.UserID); txtMaGV.Text = gv.MaGV; txtTenGV.Text = gv.TenGV; cboGioiTinh.Text = gv.GioiTinhGV; txtEmail.Text = gv.EmailGV; txtSDT.Text = gv.SdtGV; }
public ActionResult AddGV(GIANGVIEN gv) { if (ModelState.IsValid) { db.GIANGVIENs.InsertOnSubmit(gv); db.SubmitChanges(); return(RedirectToAction("GV")); } return(View(gv)); }
public void delete(int gVID) { GIANGVIEN gVien = new GIANGVIEN(); gVien.GIV_ID = gVID; DAL_GIANGVIEN dao = new DAL_GIANGVIEN(); dao.delete(gVien); }
public IHttpActionResult GetGIANGVIEN(int id) { GIANGVIEN gIANGVIEN = db.GIANGVIENs.Find(id); if (gIANGVIEN == null) { return(NotFound()); } return(Ok(gIANGVIEN)); }
public ActionResult KhoaHocTheoGiangVien(int giangvien) { GIANGVIEN giangVien = db.GIANGVIENs.SingleOrDefault(n => n.MaGV == giangvien); if (giangVien != null) { return(View(giangVien)); } return(View()); }
public ActionResult Xoagv(int id) { GIANGVIEN gv = db.GIANGVIENs.SingleOrDefault(n => n.MaGV == id); ViewBag.MaGV = gv.MaGV; if (gv == null) { Response.StatusCode = 404; return(null); } return(View(gv)); }
public async Task <IActionResult> PostGIANGVIEN([FromBody] GIANGVIEN gIANGVIEN) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.GIANGVIEN.Add(gIANGVIEN); await _context.SaveChangesAsync(); return(CreatedAtAction("GetGIANGVIEN", new { id = gIANGVIEN.MAGV }, gIANGVIEN)); }
public void layGiangVienByTenDangNhap() { GIANGVIEN gv = linqGv.getGiangVienByTenDangNhap(NguoiDung.TenDangNhap); if (gv != null) { GiangVien = linqGv.getGiangVienByTenDangNhap(NguoiDung.TenDangNhap); } else { return; } }