Ejemplo n.º 1
0
 //执行新增(插入)数据,或判断密码是否正确
 public int Insert(Operator operators)
 {
     return SqlHelper.ExecuteNonQuery(@"insert into T_Operator(
         Id,UserName,Password,IsDeleted,IsLocked) values(newid(),@UserName,@Password,0,0)",
         new SqlParameter("@UserName", operators.UserName),
      new SqlParameter("@Password", operators.Password));
 }
Ejemplo n.º 2
0
 //载入数据都DataGrid
 public void LoadData()
 {
     Operator op = new Operator();
     // columnOperator.ItemsSource = new OperatorBLL().ListAll();
     columnItem.ItemsSource = new IdNameBLL().ListAll();
     columnCostType.ItemsSource = new IdNameBLL().GetByCategory("收支类型");
     dataGridShow.ItemsSource = new AccountBLL().GetByOperatorId(LoginWindow.GetOperatorId());
 }
Ejemplo n.º 3
0
 //显示所有用户信息
 public Operator[] ListAll()
 {
     DataTable dt = SqlHelper.ExecuteDataTable("select * from T_Operator where IsDeleted=0");
     Operator[] operators = new Operator[dt.Rows.Count];
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         operators[i] = ToOperator(dt.Rows[i]);
     }
     return operators;
 }
Ejemplo n.º 4
0
 /// <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;
 }
Ejemplo n.º 5
0
        //点击登录按钮,实现登录
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (txtUserName.Text.Length <= 0)
            {
                MessageBox.Show("请输入用户名!");
            }
            else if (pwdPassword.Password.Length <= 0)
            {
                MessageBox.Show("请输入密码!");
            }
            else
            {
                Operator op = new Operator();
                string userName = txtUserName.Text.Trim();

                Application.Current.Properties["OperatorName"] = userName;

                string password = pwdPassword.Password;
                //OperatorBLL bll = new OperatorBLL();
                LoginResult result = new OperatorBLL().UserLoginResult(userName, password);
                OperatorBLL bll = new OperatorBLL();
                if (result == LoginResult.ErrorNameOrPwd)
                {
                    op = bll.GetOperatorByUserName(userName);
                    if (op != null)
                    {
                        new OperationLogBLL().Insert(op.Id, "尝试登陆失败!");
                    }
                        MessageBox.Show("用户名或密码错误");
                }
                else
                {
                    //MessageBox.Show("登录成功");
                    //获得登录用户的Id,存到Application.Current.Properties里面的在程序其他地方也可以取
                    op = bll.GetOperatorByUserName(userName);
                    Application.Current.Properties["OperatorId"] = op.Id;
                    new OperationLogBLL().Insert(op.Id, "登陆成功!");
                    //关闭LoginWindow,进入主窗口
                    DialogResult = true;
                }
            }
        }
Ejemplo n.º 6
0
 //赋值给Operator属性值
 private Operator ToOperator(DataRow row)
 {
     Operator operators = new Operator();
     operators.Id = (Guid)row["Id"];
     operators.UserName = (string)row["UserName"];
     operators.Password = (string)row["Password"];
     operators.IsDeleted = (bool)row["IsDeleted"];
     operators.IsLocked = (bool)row["IsLocked"];
     return operators;
 }