private void btnSave_Click(object sender, RoutedEventArgs e) { Guid operatorId = CommonHelper.GetOperatorId(); if (IsInsert) { Operator op = new Operator(); op.UserName = txtUserName.Text; op.RealName = txtRealName.Text; op.Password = pdxPassword.Password; OperatorDAL.Insert(op); T_OperationLogDAL.Insert(operatorId, "插入操作员" + op.UserName); } else { string password = pdxPassword.Password; string userName = txtUserName.Text; if (password.Length <= 0) { OperatorDAL.Update(EditId, txtUserName.Text, txtRealName.Text); //OperatorDAL.Update(EditId, null, txtRealName.Text); } else { //OperatorDAL.Update(EditId, txtUserName.Text, txtRealName.Text, pdxPassword.Password); OperatorDAL.Update(EditId, null, txtRealName.Text, pdxPassword.Password); } T_OperationLogDAL.Insert(operatorId, "修改操作员" + userName); } DialogResult = true; }
private void btnLogin_Click(object sender, RoutedEventArgs e) { string username = txtUserName.Text; string pwd = pwdPassword.Password; Operator op = new OperatorDAL().GetByUserName(username); if (op == null) { MessageBox.Show("用户名或者密码错误!"); } else { string dbMd5 = op.Password; //数据库中存储的密码值 string mymd5 = CommonHelper.GetMD5(pwd + CommonHelper.GetPasswordSalt()); if (dbMd5 == mymd5) { new T_OperationLogDAL().Insert(op.Id, "登录成功"); //MessageBox.Show("登录成功"); //把登录操作者的Id保存到全局的“Session” //存到Application.Current.Properties里面的在程序其他地方也可以取 Application.Current.Properties["OperatorId"] = op.Id; DialogResult = true; } else { new T_OperationLogDAL().Insert(op.Id, "尝试登录失败"); MessageBox.Show("用户名或者密码错误!"); } } }
/// <summary> /// 用户登录的判断 /// </summary> /// <param name="userName"></param> /// <param name="password"></param> /// <returns></returns> public LoginResult UserLoginResult(string userName, string password) { OperatorDAL dal = new OperatorDAL(); Operator model = dal.GetByUserName(userName); //获得用户登录的Id if (model == null) { return(LoginResult.ErrorNameOrPwd); } else { //判断密码是否相等 string dbMd5 = model.Password; //数据库中存储的密码值 string mymd5 = CommonHelper.GetMD5(password + CommonHelper.GetPasswordSalt()); if (dbMd5 == mymd5) { return(LoginResult.LoginSuccessful); } else { //密码不正确,返回ErrorNameOrPwd密码或用户名错误 return(LoginResult.ErrorNameOrPwd); } } }
public UnifyApiResult Add(OperatorModel model) { if (model == null) { return(UnifyApiResult.Error("参数不能为空。")); } if (string.IsNullOrEmpty(model.LoginName)) { return(UnifyApiResult.Error("用户名不能为空。")); } if (string.IsNullOrEmpty(model.Password)) { return(UnifyApiResult.Error("密码不能为空。")); } OperatorDAL dal = new OperatorDAL(); if (dal.GetData(model.LoginName) == null) { return(UnifyApiResult.Error("用户名不允许重复。")); } model.Password = EncryptionHelper.UserMd5(model.Password); dynamic result = dal.Insert(model); return(UnifyApiResult.Sucess(result)); }
public UnifyApiResult LoginResult(string username, string password) { if (string.IsNullOrEmpty(username)) { return(UnifyApiResult.Error("用户名不允许为空。")); } if (string.IsNullOrEmpty(password)) { return(UnifyApiResult.Error("密码不允许为空。")); } OperatorDAL dal = new OperatorDAL(); dynamic operatorData = dal.GetUserPwd(username, EncryptionHelper.UserMd5(password)); if (operatorData != null) { //固定角色的方法 角色只有 admin,system 2种,根据2种角色分别限制不同的Controller,不够灵活 LoginData data = new LoginData() { Sid = operatorData.OperatorID.ToString(), Name = operatorData.LoginName, Role = "admin" }; return(UnifyApiResult.Sucess(new { result = operatorData, token = this.Login(data, _permissionRequirement) })); } return(UnifyApiResult.Error("用户名密码输入不正确。")); }
private void btnLogin_Click(object sender, RoutedEventArgs e) { string userName = tbxUserName.Text; string password = pdxPassword.Password; Operator op = OperatorDAL.GetByUserName(userName); if (op == null) { MessageBox.Show("用户名或密码错误"); return; } else if (op.Password == password) { T_OperationLogDAL.Insert(op.Id, op.RealName + "登录成功!"); Application.Current.Properties["OperatorID"] = op.Id; // MessageBox.Show("登录成功!"); //DialogResult = true; MainWindow mainWin = new MainWindow(); mainWin.Login = this; this.Hide(); mainWin.Show(); } else { T_OperationLogDAL.Insert(op.Id, op.RealName + "登录失败!"); MessageBox.Show("用户名或密码错误"); } // DialogResult = false; }
//编辑用户信息,修改密码 public int EditOperator(Guid operatorId, string password) { OperatorDAL dal = new OperatorDAL(); string md5password = CommonHelper.GetMD5(password + CommonHelper.GetPasswordSalt()); int i = dal.Update(operatorId, md5password); return(i); }
public UnifyApiResult FindPageList(string name, int currentPageIndex, int pageSize) { OperatorDAL dal = new OperatorDAL(); int total; IEnumerable <dynamic> result = dal.FindPageList(name, currentPageIndex, pageSize, out total); var enumerable = result as dynamic[] ?? result.ToArray(); return(UnifyApiResult.PageResult(enumerable, total)); }
/// <summary> /// 添加用户 /// </summary> /// <param name="name"></param> /// <param name="password"></param> /// <returns></returns> public int AddOpertator(string name, string password) { OperatorDAL dal = new OperatorDAL(); string dbPassword = CommonHelper.GetMD5(password + CommonHelper.GetPasswordSalt()); Operator operators = new Operator(); operators.UserName = name; operators.Password = dbPassword; int i = dal.Insert(operators); return(i); }
public UnifyApiResult Remove(string id) { if (string.IsNullOrEmpty(id)) { return(UnifyApiResult.Error("参数不能为空。")); } OperatorDAL dal = new OperatorDAL(); dynamic result = dal.Remove(id); return(UnifyApiResult.Sucess(result)); }
//恢复删除用户 public bool ReuseOperator(Guid operatorId) { int i = new OperatorDAL().ReuseOperator(operatorId); if (i > 0) { return(true); } else { return(false); } }
//删除用户 public bool DeleteOperator(Guid operatorId) { int i = new OperatorDAL().DeleteById(operatorId); if (i > 0) { return(true); } else { return(false); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (IsInsert) { } else { Operator op = OperatorDAL.GetById(EditId); txtUserName.Text = op.UserName; txtRealName.Text = op.RealName; pdxPassword.Password = op.Password; } }
private void Window_Loaded(object sender, RoutedEventArgs e) { if (IsInsert) { } else { OperatorDAL dal = new OperatorDAL(); Operator op = dal.GetById(EditingId); txtUserName.Text = op.UserName; txtRealName.Text = op.RealName; } }
/// <summary> /// 根据用户名获得用户信息 /// </summary> /// <param name="userName"></param> /// <returns></returns> public Operator GetOperatorByUserName(string userName) { OperatorDAL dal = new OperatorDAL(); Operator model = dal.GetByUserName(userName); //获得用户登录的Id if (model == null) { return(null); } else { return(model); } }
public UnifyApiResult Edit(OperatorModel model) { if (model == null) { return(UnifyApiResult.Error("参数不能为空。")); } if (!string.IsNullOrEmpty(model.Password)) { model.Password = EncryptionHelper.UserMd5(model.Password); } OperatorDAL dal = new OperatorDAL(); dynamic result = dal.Modify(model); return(UnifyApiResult.Sucess(result)); }
private void btnDelete_Click(object sender, RoutedEventArgs e) { Operator op = (Operator)gridOperator.SelectedItem; if (op == null) { MessageBox.Show("请选择要删除的对象!"); return; } if (MessageBox.Show("你真的要删除" + op.RealName + "吗?", "提醒", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Guid OperatorId = CommonHelper.GetOperatorId(); T_OperationLogDAL.Insert(OperatorId, "删除" + op.UserName); OperatorDAL.DeleteById(op.Id); LoadData(); } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { Operator op = (Operator)gridOperators.SelectedItem; if (op == null) { MessageBox.Show("没有选中任何行!"); return; } if (MessageBox.Show("真的要删除" + op.UserName + "吗?", "提醒", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { OperatorDAL dal = new OperatorDAL(); dal.DeleteById(op.Id);//软删除 Guid operatorId = CommonHelper.GetOperatorId(); new T_OperationLogDAL().Insert(operatorId, "删除管理员" + op.UserName); LoadData(); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { OperatorDAL dal = new OperatorDAL(); Operator[] operators = dal.ListAll(); ReportOperator[] rptOperators = new ReportOperator[operators.Length]; for (int i = 0; i < rptOperators.Length; i++) { ReportOperator rptOp = new ReportOperator(); rptOp.RealName = operators[i].RealName; rptOp.UserName = operators[i].UserName; rptOperators[i] = rptOp; } TestCrystalReport1 rpt = new TestCrystalReport1(); rpt.SetDataSource(rptOperators); rpt.SetParameterValue("部门名称", "产品开发部"); crystalReportsViewer1.ViewerCore.ReportSource = rpt; //设计rpt报表,从BLL层取数据,扔给rpt实例,然后通过crystalReportsViewer展示 }
private void LoadData() { OperatorDAL dal = new OperatorDAL(); gridOperators.ItemsSource = dal.ListAll(); }
public OperatorBO() { operatorDAL = new OperatorDAL(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Operator[] operators = OperatorDAL.ListAll(); cmbOperator.ItemsSource = operators; operatorColumn.ItemsSource = operators; }
private void LoadData() { gridOperator.ItemsSource = OperatorDAL.ListAll(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { Operator[] operators = new OperatorDAL().ListAll(); cmbOperator.ItemsSource = operators; colOperator.ItemsSource = operators; }