public void Update(Employee employee, int id) { string str = "UPDATE employees SET department = '" + employee.Department + "', " + "firstname = '" + employee.FirstName + "', lastname = '" + employee.LastName + "', " + "salary = " + (int)employee.Salary + " WHERE employeeid = " + id + ";"; _session.Execute(str); }
public void Add(Employee employee) { if (!_employees.TryAdd(employee.EmployeeId, employee)) { throw new Exception("ERROR: Couldn't add Employee to the dictionary."); } }
private static async Task SendEmployee(Employee employee, string dataFormat, int portNumber) { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Clear(); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("DataUpdatePort", portNumber.ToString()); httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", dataFormat); // Construct the request. string url = "http://*****:*****@"Employee with ID = " + employee.EmployeeId + "was sent to the DataWarehouse."); } else { Console.WriteLine(@"Warning: Unable to send employee with ID = " + employee.EmployeeId + " to the DataWarehouse."); } } }
public void Update(Employee employee) { Employee employeeToUpdate = null; if (_employees.TryGetValue(employee.EmployeeId, out employeeToUpdate)) { employeeToUpdate = employee; } else { throw new Exception("ERROR: Couldn't find the Employee to update."); } }
/// <summary> /// 添加修改视图 /// </summary> /// <param name="employeename">如果是添加:当前查看的页面的员工的等级,如果是修改:员工的帐号</param> /// <returns></returns> public ActionResult EditEmployee(string parameter, string edit) { string employeeRankName = "";//当前对哪个等级下的员工进行操作 string action = "";//动作描述 Models.Employee emp = new Models.Employee(); if (parameter == null && edit == null)//修改密码 { action = "修改帳號"; ViewBag.action = "修改"; ViewData["Pwd"] = "Pwd"; emp = _IEmployeeService.GetEmployeeByName(_IUser.UserName); } else { //修改视图返回一条员工信息 if (edit == "update") { emp = _IEmployeeService.GetEmployeeByName(parameter); employeeRankName = AppData.GetEmployeeRankName(emp.Rank); action = "修改帳號"; ViewBag.action = "修改"; } else { employeeRankName = AppData.GetEmployeeRankName(parameter); action = "新增帳號"; ViewBag.action = "添加"; ViewBag.Rank = parameter; } } ViewBag.navigation = new Navigation { Level = new List<string> { AppData.GetGameTypeName("AcMa"), employeeRankName, action }, HaveButton = false }; return View(emp); }
public void Update(Employee employee, int id) { _session.Execute($"UPDATE employees SET department = '{employee.Department}', " + $"firstname = '{employee.FirstName}', lastname = '{employee.LastName}', " + $"salary = {employee.Salary} WHERE employeeid = {id};"); }
public void Add(Employee employee) { _session.Execute("INSERT INTO employees (EmployeeId, Department, FirstName, LastName, salary) " + $"VALUES ({employee.EmployeeId}, '{employee.Department}', " + $"'{employee.FirstName}', '{employee.LastName}', {employee.Salary});"); }
public ActionResult EditEmployee(string NewName, string Pwd, string Rank, string OldName, string edit) { Models.Employee emp = new Models.Employee(){EmployeeName=NewName,Password = Pwd,Rank=Rank}; return Json(_IEmployeeService.UpdateEmployee(emp, OldName, edit)); }
public IHttpActionResult Post(Employee employee, int id) { _repository.Update(employee, id); return Ok(); }
public IHttpActionResult Put(Employee employee) { _repository.Add(employee); string uri = Url.Route("DefaultApi", new { id = employee.EmployeeId }); return Created(uri, employee); }