• 登录注册D


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    namespace Login.DAL
    {
    using System.Data;
    using System.Data.SqlClient;
    using Login.Model;
    using Newtonsoft.Json;
    public class UserDal
    {
    /// <summary>
    /// 注册用户
    /// </summary>
    /// <param name="user"></param>
    /// <returns></returns>
    public int AddUser(User user)
    {
    SqlParameter[] parameters = new SqlParameter[]
    {
    new SqlParameter("@UserName",user.UserName),
    new SqlParameter("@UserPassword",user.UserPassword)
    };
    return DBhelper.SqlExecuteNonQuery("p_Add", CommandType.StoredProcedure, parameters);
    }
    /// <summary>
    /// 登陆
    /// </summary>
    /// <param name="Name"></param>
    /// <param name="Password"></param>
    /// <returns></returns>
    public int UserLogin(string Name, string Password)
    {
    SqlParameter[] parameters = new SqlParameter[]
    {
    new SqlParameter("@UserName",Name),
    new SqlParameter("@UserPassword",Password)
    };
    var dt = DBhelper.GetTable("p_Login", CommandType.StoredProcedure, parameters);
    if (dt.Rows.Count > 0)
    {
    return (int)dt.Rows[0]["UserID"];
    }
    else {
    //修改user表的用户名的错误字段+1

    var ero = DBhelper.SqlExecuteNonQuery("p_Error", CommandType.StoredProcedure, new SqlParameter("@UserName", Name));
    }
    return 0;
    }
    /// <summary>
    /// 修改密码
    /// </summary>
    /// <param name="ID"></param>
    /// <param name="Password"></param>
    /// <returns></returns>
    public int UserUpdate(int ID, string Password)
    {
    SqlParameter[] parameters = new SqlParameter[]
    {
    new SqlParameter("@UserID",ID),
    new SqlParameter("@UserPassword",Password)
    };
    var result = DBhelper.SqlExecuteNonQuery("p_Update", CommandType.StoredProcedure, parameters);
    return result;
    }
    /// <summary>
    /// 获取数据
    /// </summary>
    /// <returns></returns>
    public List<User> GetUser()
    {
    var result = DBhelper.GetTable("p_Get", CommandType.StoredProcedure);
    var jar = JsonConvert.DeserializeObject<List<User>>(JsonConvert.SerializeObject(result));
    return jar;
    }
    }
    }

  • 相关阅读:
    Redis为什么要自己实现一个SDS
    Redis中的数据结构
    编程题
    设计模式-代理模式
    设计模式-原型模式
    设计模式-工厂模式(简单工厂,工厂方法,抽象工厂)
    Redis基础
    Windows提高_1.4进程通信
    Windows提高_1.3文件操作
    Windows提高_1.2遍历进程、遍历模块
  • 原文地址:https://www.cnblogs.com/hianb/p/10003126.html
Copyright © 2020-2023  润新知