public bool UpdateEmployeeWithoutPassword(TblEmployee Employee) { string StoreProc = "spUpdateEmployeeWithoutPass"; object[] parms = new object[] { "@EmpID", Employee.EmployeeID, "@Name", Employee.Name, "@DOB", Employee.DOB, "@Address", Employee.Address, "@Phone", Employee.Phone, "@RoleID", Employee.RoleID }; return(db.Update(StoreProc, parms) > 0); }
/// <summary> /// Posts the employee asynchronous. /// </summary> /// <param name="employee">The employee.</param> /// <returns></returns> public async Task <bool> PostEmployeeAsync(TblEmployee employee) { try { await _context.TblEmployees.AddAsync(employee); await _context.SaveChangesAsync(); return(true); } catch { return(false); } }
//To Delete the record of a particular employee public int DeleteEmployee(int id) { try { TblEmployee emp = db.TblEmployee.Find(id); db.TblEmployee.Remove(emp); db.SaveChanges(); return(1); } catch { throw; } }
/// <summary> /// Deletes the employee asynchronous. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public async Task <bool> DeleteEmployeeAsync(int id) { try { TblEmployee employee = await GetEmployeeById(id); _context.TblEmployees.Remove(employee); await _context.SaveChangesAsync(); return(true); } catch { return(false); } }
public void AddEmployee(TblEmployee employee) { try { IHttpContextAccessor httpContextAccessor = MyServiceLocator.Instance.GetService <IHttpContextAccessor>(); IHostingEnvironment hostingEnvironment = MyServiceLocator.Instance.GetService <IHostingEnvironment>();; string folderName = "UploadFile/"; string sPath = ""; sPath = Path.Combine(_hostingEnvironment.WebRootPath, "~/" + folderName); var hfc = _httpContextAccessor.HttpContext.Request.Form.Files; } catch {} }
public ActionResult Employee([FromBody] Authorization login) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } TblEmployee tblEmployee = _context.TblEmployee.Where(x => x.EmployeeEmail == login.UserName & x.EmployeePassword == login.UserPassword).FirstOrDefault(); if (tblEmployee == null) { return(NotFound()); } return(Ok(tblEmployee)); }
public TblEmployee InsertTblEmployeeToDataBase(TblEmployee nEmp) { try { if (nEmp != null) { this.Context.TblEmployee.Add(nEmp); return(this.Context.SaveChanges() > 0 ? this.GetTblEmployeeWithKey(nEmp.EmployeeId) : null); } } catch (Exception ex) { Debug.WriteLine("Has error " + ex.ToString()); } return(null); }
public ActionResult Delete(int id) { try { TblEmployee ob = uow.Modules.Employee.Get(id); if (ob == null) { return(RedirectToAction("Index", MVCController, new { msg = "ไม่พบข้อมูลที่ต้องการ", msgType = AlertMsgType.Warning })); } uow.Modules.Employee.Delete(ob); uow.SaveChanges(); return(RedirectToAction("Index", MVCController, new { msg = "ลบข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); } catch (Exception ex) { return(RedirectToAction("Index", MVCController, new { msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); } }
public TblEmployee UpdateTblEmployeeToDataBase(int EmployeeID, TblEmployee uEmployee) { try { var dbEmployee = this.Context.TblEmployee.Find(EmployeeID); if (dbEmployee != null) { this.Context.Entry(dbEmployee).CurrentValues.SetValues(uEmployee); return(this.Context.SaveChanges() > 0 ? this.GetTblEmployeeWithKey(EmployeeID) : null); } } catch (Exception ex) { Debug.WriteLine("Has error " + ex.ToString()); } return(null); }
/// <summary> /// /// </summary> /// <param name="nMemoGroupID"></param> public frmReceipientGroupEntries(int nMemoGroupID) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // this.nMemoGroupID = nMemoGroupID; TblEmployee employee = new TblEmployee(); DataTable empTable = employee.SelectAll(); new XtraUtils.LookupEditBuilder.EmployeeIDLookupEditBuilder(lkpEdtStaffID.Properties); }
public bool CreateEmployee(TblEmployee empdata) { bool result = false; try { TblEmployee newEmployee = new TblEmployee(); newEmployee.Name = empdata.Name; newEmployee.Gender = empdata.Gender; newEmployee.City = empdata.City; newEmployee.Department = empdata.Department; dbContext.TblEmployee.Add(newEmployee); dbContext.SaveChanges(); result = true; } catch { } return(result); }
// POST api/values public HttpResponseMessage Post([FromBody] Employee emp) { try { if (emp == null) { return(Request.CreateResponse(HttpStatusCode.OK, "Invalid data")); } else { var table = new TblEmployee(); table.Name = emp.Name; table.City = emp.City; table.Address = emp.Address; db.TblEmployees.Add(table); db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Insertion Successful")); } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, "Error:" + ex.Message)); } }
public int CreateEmployee(TblEmployee model) { try { var IsEmployeeExists = dbContext.TblEmployee.Where(x => x.FullName == model.FullName || x.UserName == model.UserName || x.PhoneNo == model.PhoneNo).FirstOrDefault(); if (IsEmployeeExists != null) { return(0); } else { dbContext.Add(model); return(dbContext.SaveChanges()); } } catch (Exception ex) { StaticHelper.LogException(path: up.GetLogFilePath(), errorMessage: ex.Message, methodName: $"Repository name: {nameof(EmployeeRepository)} - Method name: {nameof(CreateEmployee)}", stackTrace: ex.StackTrace); return(0); } }
public int DeleteEmployee(int id) { try { TblEmployee employee = db.TblEmployee.Find(id); if (employee != null) { db.TblEmployee.Remove(employee); db.SaveChanges(); } else { // Log } return(1); } catch { throw; } }
private ActionResult ViewDetail(TblEmployee ob, string msg, AlertMsgType?msgType) { try { if (ob == null) { throw new Exception("ไม่พบข้อมูลที่ต้องการ, กรุณาลองใหม่อีกครั้ง"); } if (!string.IsNullOrWhiteSpace(msg)) { WidgetAlertModel alert = new WidgetAlertModel() { Message = msg }; if (msgType.HasValue) { alert.Type = msgType.Value; } ViewBag.Alert = alert; } ViewData["optPrefix"] = uow.Modules.Enum.PrefixGets(); ViewData["optDepartment"] = uow.Modules.Department.Gets(); ViewData["optPosition"] = uow.Modules.Position.Gets(1, 0); ViewData["optLead"] = uow.Modules.Employee.Gets(); ViewData["optAccount"] = uow.Modules.Account.Gets(); ViewData["optEmpPermission"] = uow.Modules.EmployeeUserPermission.Gets(src: ob.AccountId.ToString()); return(View(ob)); } catch (Exception ex) { return(RedirectToAction("Index", MVCController, new { area = MVCArea, msg = ex.GetMessage(), msgType = AlertMsgType.Danger })); } }
private void cloneData() { if (Session["HostelID"] != null) { TblHostelinformation obj = new TblHostelinformation(Session["HostelID"]); txtHostelName.Text = obj.HostelName; txtHostelContact.Text = obj.HostelContact; txtHostelFee.Text = obj.HostelFee.ToString(); txtHostelLocation.Text = obj.HostelLocation; ddlStatus.SelectedValue = obj.IsActive.ToString(); LoadDesignation(); TblEmployee objemp = new TblEmployee(obj.EmployeeID); ddlDesignation.SelectedValue = objemp.DesignationID.ToString(); BindEmployees(ddlDesignation.SelectedValue); ddlEmployees.SelectedValue = obj.EmployeeID.ToString(); hfHostelID.Value = obj.HostelID.ToString(); Session["HostelID"] = null; } else { hfHostelID.Value = ""; } }
public int Edit(TblEmployee employee) { return(objemployee.UpdateEmployee(employee)); }
public int Create(TblEmployee employee) { return(objemployee.AddEmployee(employee)); }
public int Edit([FromBody] TblEmployee employee) { return(objemployee.UpdateEmployee(employee)); }
public int Create([FromBody] TblEmployee employee) { return(objemployee.AddEmployee(employee)); }
public int Edit(TblEmployee employee) { return(_employeeService.UpdateEmployee(employee)); }
public int Create(TblEmployee employee) { return(_employeeService.AddEmployee(employee)); }
public int updateEmployee([FromForm] TblEmployee employee) { return(this.objemployee.UpdateEmployee(employee)); }
public bool AddEmployee(TblEmployee Employee) { return(tblEmployeeDAO.AddEmployee(Employee)); }
public bool UpdateEmployeeWithPassword(TblEmployee Employee) { return(tblEmployeeDAO.UpdateEmployeeWithPassword(Employee)); }
public IActionResult Put(string id, [FromBody] TblEmployee uEmployee) { return(new JsonResult(this.repository.UpdateAsync(uEmployee, id).Result, this.DefaultJsonSettings)); }
public IActionResult Post([FromBody] TblEmployee nEmployee) { return(new JsonResult(this.repository.AddAsync(nEmployee).Result, this.DefaultJsonSettings)); }
/// <summary> /// Updates the employee asynchronous. /// </summary> /// <param name="employee">The employee.</param> /// <returns></returns> public async Task <bool> UpdateEmployeeAsync(EmployeeViewModel employee) { TblEmployee Employee = _mapper.Map <TblEmployee>(employee); return(await _employeeRepository.UpdateEmployeeAsync(Employee)); }
public int CreateEmployee([FromForm] TblEmployee employee) { return(this.objemployee.AddNewEmployee(employee)); }
public ActionResult SetDetail() { int accountId = Request.Form["account_id"].ParseInt(); int empId = Request.Form["EmpId"].ParseInt(); SysAccount ob = uow.Modules.Account.Get(accountId); if (ob.AccountId <= 0) { ob.AccountUsername = Request.Form["account_username"]; ob.AccountPassword = Request.Form["account_password"]; ob.AccountEmail = Request.Form["account_email"]; ob.CreatedBy = CurrentUID; ob.CreatedDate = CurrentDate; } ob.AccountFirstName = Request.Form["account_firstname"]; ob.AccountLastName = Request.Form["account_lastname"]; ob.FlagStatus = Request.Form["flag_status"].ParseInt(); ob.UpdatedBy = CurrentUID; ob.UpdatedDate = CurrentDate; int roleId = Request.Form["role_id"].ParseInt(); try { if (!ob.IsValid(out string errMsg)) { throw new Exception(errMsg); } if (Request.Files.Count > 0 && Request.Files["AccountAvatar"] != null && Request.Files["AccountAvatar"].ContentLength > 0) { HttpPostedFileBase uploadedFile = Request.Files["AccountAvatar"]; string FilePath = string.Format("files/avatar/{0}{1}", CurrentDate.ParseString(DateFormat._yyyyMMddHHmmssfff), Path.GetExtension(uploadedFile.FileName)); if (!Directory.Exists(Server.MapPath("~/files"))) { Directory.CreateDirectory(Server.MapPath("~/files")); } if (!Directory.Exists(Server.MapPath("~/files/avatar"))) { Directory.CreateDirectory(Server.MapPath("~/files/avatar")); } uploadedFile.SaveAs(Server.MapPath("~/" + FilePath)); ob.AccountAvatar = FilePath; } if ((ob.AccountId <= 0 && ob.AccountPassword != Request.Form["account_passwordre"]) || (ob.AccountId > 0 && !string.IsNullOrWhiteSpace(Request.Form["account_password"]) && Request.Form["account_password"] != Request.Form["account_passwordre"])) { throw new Exception("รหัสผ่านไม่ตรงกัน"); } //if (!ob.FlagSystem) //{ // SysAccountRole roleMapped = ob.AccountId > 0 ? // ((from d in uow.db.SysAccountRole // join r in uow.db.SysRole on d.RoleId equals r.RoleId // where // d.AccountId == ob.AccountId // && r.SiteId == SITE_ID // select d).FirstOrDefault() ?? new SysAccountRole() { SysAccount = ob }) : // new SysAccountRole() { SysAccount = ob }; // roleMapped.RoleId = Request.Form["role_id"].ParseInt(); // if (roleMapped.Id <= 0) { uow.db.SysAccountRole.Add(roleMapped); } // else { uow.db.Entry(roleMapped).State = System.Data.Entity.EntityState.Modified; } //} if (ob.AccountId <= 0) { ob.AccountPassword = Crypto.HashPassword(ob.AccountPassword); } else if (ob.AccountId > 0 && !string.IsNullOrWhiteSpace(Request.Form["account_password"])) { ob.AccountPassword = Crypto.HashPassword(Request.Form["account_password"]); } uow.Modules.Account.Set(ob); // employee.UpdatedDate = DateTime.Now; uow.Modules.Account.SetRole(SiteId, roleId, ob); uow.SaveChanges(); if (empId > 0) { TblEmployee employee = uow.Modules.Employee.Get(empId); employee.AccountId = ob.AccountId; uow.Modules.Employee.Set(employee); } uow.SaveChanges(); return(RedirectToAction("Index", new { area = "", controller = "Account", msg = "บันทึกข้อมูลเรียบร้อยแล้ว", msgType = AlertMsgType.Success })); } catch (Exception ex) { string msg = ex.GetMessage(); return(ViewDetail(ob, msg, AlertMsgType.Danger)); } }
public void PostEmployee(TblEmployee emp) { obj.TblEmployees.InsertOnSubmit(emp); obj.SubmitChanges(); }