protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { if (!string.IsNullOrEmpty(this.tName.Value) && !string.IsNullOrEmpty(this.tPassword.Value)) { try { IEmployee biz = new EmployeeBiz(); EmployeeEntity condition_entity = new EmployeeEntity(); condition_entity.EMPLOYEE_ID = this.tName.Value; condition_entity.PASSWORD = this.tPassword.Value; var list = biz.GetEmployeeEntityList(condition_entity); if (list != null && list.Count > 0) { //登陆成功,把用户编号保存到票据中 FormsAuthentication.SetAuthCookie(this.tName.Value, false); var ticket = new FormsAuthenticationTicket(1, list[0].EMPLOYEE_NAME, DateTime.Now, DateTime.Now.AddMonths(2), false, this.tName.Value, FormsAuthentication.FormsCookiePath); var encTicket = FormsAuthentication.Encrypt(ticket); var newCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket); HttpContext.Current.Response.Cookies.Add(newCookie); Response.Redirect(ReturnUrl); } else { this.lMsg.InnerText = "登陆失败,账户或密码错误!"; } } catch (Exception ex) { this.lMsg.InnerText = "登陆失败,原因是:" + ex.ToString(); } } } }
public List<EmployeeEntity> GetEmployeeEntityList(EmployeeEntity condition_entity) { GenericWhereEntity<EmployeeEntity> where_entity = new GenericWhereEntity<EmployeeEntity>(); if (condition_entity.EMPLOYEE_ID != null) where_entity.Where(n => (n.EMPLOYEE_ID == condition_entity.EMPLOYEE_ID)); if (!string.IsNullOrEmpty(condition_entity.PASSWORD)) where_entity.Where(n => (n.PASSWORD == condition_entity.PASSWORD)); return EntityExecution.SelectAll(where_entity); }
public void UpdateEmployeeEntity(EmployeeEntity condition_entity) { condition_entity.Update(); }
public void InsertEmployeeEntity(EmployeeEntity condition_entity) { condition_entity.Insert(); }
public void DeleteEmployeeEntity(EmployeeEntity condition_entity) { condition_entity.Delete(); }
private void Save() { try { IEmployee biz = new EmployeeBiz(); if (CurOperation == "add") { var condition_entity = new EmployeeEntity(); condition_entity.EMPLOYEE_ID = this.tEmployeeId.Value; var list = biz.GetEmployeeEntityList(condition_entity); if (list != null && list.Count > 0) { this.lMsg.InnerText = "保存失败,原因:已存在重复的账号!"; } } var entity = new EmployeeEntity(); entity.EMPLOYEE_ID = this.tEmployeeId.Value; entity.EMPLOYEE_NAME = this.tEmployeeName.Value; entity.RESTAURANT_ID = base.ParseInt(this.ddlRestaurant.SelectedValue); entity.PASSWORD = this.tPassword.Value; entity.OFFICE_PHONE = this.tOfficePhone.Value; entity.MOBILE_PHONE = this.tMobilePhone.Value; entity.SEX = this.hSex.Value; entity.IS_ADMIN = this.cIsAdmin.Checked; if (CurOperation == "add") { entity.CREATE_TIME = DateTime.Now; entity.CREATE_PERSON = base.CurEmployeeEntity.EMPLOYEE_ID; biz.InsertEmployeeEntity(entity); } else if (CurOperation == "edit") { entity.EMPLOYEE_ID = CurId; entity.UPDATE_TIME = DateTime.Now; entity.UPDATE_PERSON = base.CurEmployeeEntity.EMPLOYEE_ID; biz.UpdateEmployeeEntity(entity); } AlertAndTransfer("保存成功!", base.UrlReferrer); } catch (Exception ex) { this.lMsg.InnerText = "保存失败,原因:" + ex.ToString(); } }