public StaffViewModel AddStaff(StaffViewModel entity) { var data = new tbl_Staff { StaffId = entity.staffId, FirstName = entity.firstName, LastName = entity.lastName, OtherName = entity.otherName, PhoneNo = entity.phoneNo, AlternativePhoneNo = entity.alternativePhoneNo, Address = entity.address, Email = entity.email, AlternativeEmail = entity.alternativeEmail, Designation = entity.designation, IsActive = entity.isActive, CreatedOn = DateTime.Now, CreatedBy = "admin", ModifiedBy = "admin", ModifiedOn = DateTime.Now }; context.tbl_Staff.Add(data); context.SaveChanges(); return(entity); }
public ActionResult ThemMoi(tbl_Staff model) { if (ModelState.IsValid) { if (SessionTypeUser()) { model.Password = Encryption.GetSHA512("espire123"); //model.Image = "/Assets/Admin/images/user.jpg"; model.Status = true; var result = new StaffDAO().ThemMoi(model); if (result) { //Thêm thành công, chuyển hướng về NhanVien/Index return(RedirectToAction("Index")); } else { return(View(model)); } } else { SetAlert("Xin lỗi, bạn không có quyền truy cập", "warning"); return(RedirectToAction("Index", "NhanVien")); } } SetTypeUser(model.TypeUser); return(View(model)); }
/// <summary> /// Thêm mới nhân viên /// </summary> /// <param name="model"></param> /// <returns></returns> public bool ThemMoi(tbl_Staff model) { model.UserID = UserIDAuto(); db.tbl_Staff.Add(model); db.SaveChanges(); return(true); }
public ActionResult CapNhat(tbl_Staff model) { if (ModelState.IsValid) { if (SessionTypeUser()) { var result = new StaffDAO().CapNhat(model); if (result) { SetAlert("Cập nhật thành công", "success"); return(RedirectToAction("Index")); } else { SetAlert("Cập nhật không thành công", "danger"); } } else { SetAlert("Xin lỗi, bạn không có quyền truy cập", "warning"); return(RedirectToAction("Index", "NhanVien")); } } SetTypeUser(model.TypeUser); return(View(model)); }
public static void delete(tbl_Staff staff) { RMSDBEntities db = DBContext.getInstance(); db.tbl_Staff.Remove(staff); db.SaveChanges(); }
public static void insert(tbl_Staff staff) { RMSDBEntities db = DBContext.getInstance(); db.tbl_Staff.Add(staff); db.SaveChanges(); }
public static void update(tbl_Staff staff) { RMSDBEntities db = DBContext.getInstance(); db.Entry(staff).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; }
/// <summary> /// Cập nhật thông tin nhân viên /// </summary> /// <param name="model"></param> /// <returns></returns> public bool CapNhat(tbl_Staff model) { var result = db.tbl_Staff.Find(model.UserID); result.FullName = model.FullName; result.Image = model.Image; result.Emaill = model.Emaill; result.PhoneNumber = model.PhoneNumber; result.Sex = model.Sex; result.BirthDay = model.BirthDay; result.Address = model.Address; db.SaveChanges(); return(true); }
public void Add(StaffModel model) { using (HMSEntities dbContext = new HMSEntities()) { tbl_Staff entity = new tbl_Staff(); entity.Address = model.Address; entity.Category = model.Category; entity.Name = model.Name; entity.PhoneNumber = model.PhoneNumber; entity.Salary = model.Salary; dbContext.tbl_Staff.Add(entity); dbContext.SaveChanges(); } }
public static List <DeliveryQueueModel> getAllNotDeliveredMappedToDeliveryQueueModel() { List <DeliveryQueueModel> list = new List <DeliveryQueueModel>(); foreach (tbl_DeliveryQueue item in getAllNotDelivered()) { DeliveryQueueModel dmq = new DeliveryQueueModel(); dmq.Id = item.Id; dmq.SaleId = (int)item.Sale_Id; dmq.CustomerId = (int)item.Customer_Id; tbl_Sale sale = Sale.getById(dmq.SaleId); dmq.TotalBill = (int)sale.Amount; try { tbl_Staff staff = Staff.getById((int)item.DeliveryBoyId); dmq.DeliveryBoyName = staff.Name; } catch { } list.Add(dmq); } return(list); }