public static Buser_Securety TimKiemNhanVien_MaBaoMatTheoIDNhanVien_Ngay(string idNhanVien, DateTime ngay) { try { var ngaygannhat = (from bm in db.Buser_Secureties from q in db.Busers2s where bm.UserID == q.USERID && bm.UserID == idNhanVien && DateTime.Compare(bm.ngay.Value, ngay) <= 0 select bm.ngay.Value).ToList().Max(); if (ngaygannhat != null) { return(db.Buser_Secureties.Where(cd => cd.UserID == idNhanVien && DateTime.Compare(cd.ngay.Value, (DateTime)ngaygannhat) == 0).SingleOrDefault()); } else { return(new Buser_Securety()); } } catch (Exception ex) { Until.WriteFileLogServer("TimKiemNhanVien_MaBaoMatTheoIDNhanVien_Ngay\t\t" + "\tMessage Error:\t\t" + ex.Message); return(new Buser_Securety()); } finally { if (db != null) { db.ToString(); } } }
public static bool CapNhatTinhTrangVanBan(string idVanBan, int tinhTrang, bool kiemTraBiXoa = true) { var list = (from p in db.Abcons from q in db.pdnas where p.pdno == q.pdno && q.pdno == idVanBan select q).FirstOrDefault(); DateTime date = DateTime.Now; // string ngaythang = DateTime.Parse(date.ToShortDateString()).ToString("yyyy/MM/dd"); pdna vanban = new pdna(); //if (kiemTraBiXoa) // //vanban = db.pdnas.Where(v => v.pdno == idVanBan && v.bixoa == false).FirstOrDefault(); // vanban = list; //else // vanban = db.pdnas.Where(v => v.pdno == idVanBan).FirstOrDefault(); if (vanban == null) { return(false); } try { vanban = list; { vanban.pdno = idVanBan; vanban.YN = tinhTrang; vanban.CFMDate1 = DateTime.Today; } db.SubmitChanges(); return(true); } catch (Exception) { return(false); } finally { if (db != null) { db.ToString(); } } }
public static Busers2 KiemTraDangNhap(string tenDangNhap, string matKhau, string macongty, bool kiemTraBiXoa = true) { Busers2 nNhanVien = new Busers2(); try { if (kiemTraBiXoa) { nNhanVien = db.Busers2s.Where(nv => nv.USERID == tenDangNhap && nv.PWD == matKhau && nv.GSBH == macongty).FirstOrDefault(); // var login = from p in db.Busers.Where(p => p.USERID.Equals(tenDangNhap) && p.PWD.Equals(matKhau)) select p; //return login.FirstOrDefault(); } else { nNhanVien = db.Busers2s.Where(nv => nv.USERID == tenDangNhap && nv.PWD == matKhau && nv.GSBH == macongty).FirstOrDefault(); } return(nNhanVien); } catch (Exception) { } finally { if (db != null) { db.ToString(); } } return(null); }