/// <summary> /// 保存员工档案 /// </summary> /// <param name="staff">需要保存的员工档案</param> /// <returns>是否成功</returns> public bool SaveStaff(Staff staff) { //throw new NotImplementedException(); IStaffDAL dAL = new StaffDAL(); if (dAL.QueryById(staff.Id) != null) { if (dAL.Update(staff) > 0) { return(true); } else { return(false); } } else { if (dAL.Add(staff) > 0) { return(true); } else { return(false); } } }
public ActionResult Create(Deployment deployment) { if (ModelState.IsValid) { deployment.DeploymentID = staffContext.Add(deployment); return(RedirectToAction("Create", "PartTimeStaff")); } else { return(View(deployment)); } }
public ActionResult Create(Staff staff) { if (ModelState.IsValid) { staff.StaffID = staffContext.Add(staff); return(RedirectToAction("Index")); } else { //Input validation fails, return to the Create view //to display error message return(View(staff)); } }
public ActionResult CreatePersonnel(Staff staff) { if (ModelState.IsValid) { staff.Password = "******"; staff.DateEmployed = DateTime.Now; staff.StaffName = staffContext.Add(staff); TempData["Success"] = "New Staff was created"; return(RedirectToActionPermanent("Index", "Staff")); } else { TempData["unsuccessful"] = "User was not able to be created"; return(RedirectToAction("Create")); } }
public ActionResult Create(Staff staff) { // Get country list for drop-down list in case of the need to return to Create.cshtml view ViewData["CountryList"] = GetCountries(); if (ModelState.IsValid) { // Add staff record to database staff.StaffId = staffContext.Add(staff); // Redirect user to Staff/Index view return(RedirectToAction("Index")); } else { // Input validation fails, return to the Create view // to display error message return(View(staff)); } }
public ApiMessage <string> Save(staff user) { if (string.IsNullOrEmpty(user.ID)) { user.ID = Guid.NewGuid().ToString(); user.CreateDate = DateTime.Now; user.Phone = user.Phone; user.PassWord = Encrypt.MD5(user.PassWord); return(_dal.Add(user)); } else { if (user.PassWord.Split('-').Length < 5) { user.PassWord = Encrypt.MD5(user.PassWord); } return(_dal.Edit(user)); } }
/// <summary> /// 点击录入员工 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnAbout_Click(object sender, EventArgs e) { if (textBox1.Text == "") { MessageBoxEx.Show("请填写员工姓名", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Staff model = new Staff(); model.StaffName = textBox1.Text; model.Gender = comboBox1.Text; model.Store_Id = StoreDAL.FindModel(new Store(comboBox2.Text.ToString(), null, null), new List <string>() { "StoreName" }).Id; if (StaffDAL.Add(model)) { ShowDataGird(); MessageBoxEx.Show("新增员工成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }