예제 #1
0
        public UsersModel CheckByName(string username, string displayName, string password)
        {
            //定义一个对象
            UsersModel user = null;
            //构造要查询的sql语句
            string       sql = "SELECT UserName, DisplayName, PassWord FROM Users WHERE UserName=@UserName";
            SqlParameter p   = new SqlParameter("@UserName", username);
            //使用helper进行查询,得到结果
            DataTable dt = MSSqlHelper.GetDataTable(sql, p);

            //判断是否查找到了
            if (dt.Rows.Count == 0)
            {
                //构造insert语句
                string INSERT = "INSERT INTO Users (UserName, DisplayName, PassWord) VALUES(@UserName,@DisplayName,@PassWord)";
                //构造sql语句的参数
                SqlParameter[] ps = //使用数组初始化器
                {
                    new SqlParameter("@UserName",    username),
                    new SqlParameter("@DisplayName", displayName),
                    new SqlParameter("@PassWord",    password),
                };
                //执行插入操作
                MSSqlHelper.ExecuteNonQuery(INSERT, ps);
            }
            return(user);
        }
예제 #2
0
        public UsersModel CheckByDName(string displayName, string newpassword)
        {
            //定义一个对象
            UsersModel user = null;
            //构造要查询的sql语句
            string       sql = "SELECT UserName, DisplayName, PassWord FROM Users WHERE DisplayName=@DisplayName";
            SqlParameter p   = new SqlParameter("@DisplayName", displayName);
            //使用helper进行查询,得到结果
            DataTable dt = MSSqlHelper.GetDataTable(sql, p);

            //判断是否查找到了
            if (dt.Rows.Count > 0)
            {
                user = new UsersModel()
                {
                    PassWord = dt.Rows[0]["PassWord"].ToString(),
                };
                if (user.OK)
                {
                    //构造Update语句
                    string Update = "UPDATE Users SET PassWord=@PassWord WHERE DisplayName=@DisplayName";
                    //构造sql语句的参数
                    SqlParameter[] ps = //使用数组初始化器
                    {
                        new SqlParameter("@DisplayName", displayName),
                        new SqlParameter("@PassWord",    newpassword)
                    };
                    //执行插入操作
                    MSSqlHelper.ExecuteNonQuery(Update, ps);
                }
            }
            return(user);
        }
예제 #3
0
        public int Delete(WorkLogsModel workLog)
        {
            //构造sql语句及参数
            string sql = "Delete From Works WHERE ID=@ID";

            SqlParameter[] ps =
            {
                new SqlParameter("@ID", workLog.ID)
            };
            //执行并返回
            return(MSSqlHelper.ExecuteNonQuery(sql, ps));
        }
예제 #4
0
        public int Updata(ProductsModel products)
        {
            //构造sql语句及参数
            string sql = "UPDATE Products SET Product_E=@Product_E, Product_C=@Product_C WHERE ProductID=@ProductID";

            SqlParameter[] ps =
            {
                new SqlParameter("@ProductID", products.ProductID),
                new SqlParameter("@Product_E", products.Product_E),
                new SqlParameter("@Product_C", products.Product_C),
            };
            //执行并返回
            return(MSSqlHelper.ExecuteNonQuery(sql, ps));
        }
예제 #5
0
        public int Insert(ProductsModel products)
        {
            //构造insert语句
            string sql = "INSERT INTO Products (Product_E, Product_C) VALUES (@Product_E,@Product_C)";

            //构造sql语句的参数
            SqlParameter[] ps = //使用数组初始化器
            {
                new SqlParameter("@Product_E", products.Product_E),
                new SqlParameter("@Product_C", products.Product_C),
            };
            //执行插入操作
            return(MSSqlHelper.ExecuteNonQuery(sql, ps));
        }
예제 #6
0
        /// <summary>
        /// 修改数据
        /// </summary>
        /// <param name="workLog"></param>
        /// <returns></returns>
        public int Updata(WorkLogsModel workLog)
        {
            //构造sql语句及参数
            string sql = "UPDATE Works SET DateTime= @DateTime, Name=@Name, ProductName=@ProductName, Version=@Version, Stage=@Stage, Type=@Type, Progress=@Progress, Whours=@Whours, TProgress=@TProgress, Workout=@Workout, Problem=@Problem WHERE ID=@ID";

            SqlParameter[] ps =
            {
                new SqlParameter("@ID",          workLog.ID),
                new SqlParameter("@DateTime",    workLog.DateTime),
                new SqlParameter("@Name",        workLog.Name),
                new SqlParameter("@ProductName", workLog.ProductName),
                new SqlParameter("@Version",     workLog.Version),
                new SqlParameter("@Stage",       workLog.Stage),
                new SqlParameter("@Type",        workLog.Type),
                new SqlParameter("@Task",        workLog.Task),
                new SqlParameter("@Progress",    workLog.Progress),
                new SqlParameter("@Whours",      workLog.Whours),
                new SqlParameter("@TProgress",   workLog.TProgress),
                new SqlParameter("@Workout",     workLog.Workout),
                new SqlParameter("@Problem",     workLog.Problem)
            };
            //执行并返回
            return(MSSqlHelper.ExecuteNonQuery(sql, ps));
        }
예제 #7
0
        public int Insert(WorkLogsModel workLog)
        {
            //构造insert语句
            string sql = "INSERT INTO Works (DateTime, Name, ProductName, Version, Stage, Type, Task, Progress, Whours, TProgress, Workout, Problem) VALUES(@DateTime, @Name, @ProductName, @Version, @Stage, @Type, @Task, @Progress, @Whours, @TProgress, @Workout, @Problem)";

            //构造sql语句的参数
            SqlParameter[] ps = //使用数组初始化器
            {
                new SqlParameter("@DateTime",    workLog.DateTime),
                new SqlParameter("@Name",        workLog.Name),
                new SqlParameter("@ProductName", workLog.ProductName),
                new SqlParameter("@Version",     workLog.Version),
                new SqlParameter("@Stage",       workLog.Stage),
                new SqlParameter("@Type",        workLog.Type),
                new SqlParameter("@Task",        workLog.Task),
                new SqlParameter("@Progress",    workLog.Progress),
                new SqlParameter("@Whours",      workLog.Whours),
                new SqlParameter("@TProgress",   workLog.TProgress),
                new SqlParameter("@Workout",     workLog.Workout),
                new SqlParameter("@Problem",     workLog.Problem)
            };
            //执行插入操作
            return(MSSqlHelper.ExecuteNonQuery(sql, ps));
        }