Exemple #1
0
        public string GetPNmameByPnumber(string pNumber, int item)
        {
            //构造sql语句及参数
            string sql = "SELECT Product_C FROM Products WHERE ProductID = @ProductID";

            SqlParameter[] ps =
            {
                new SqlParameter("@ProductID", pNumber),
            };
            //执行并返回
            return((string)MSSqlHelper.ExecuteScalar(sql, ps));
        }
Exemple #2
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));
        }
Exemple #3
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));
        }
Exemple #4
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));
        }
Exemple #5
0
        public List <ProductsModel> GetList()
        {
            //构造查询sql语句
            string sql = "SELECT ProductID, Product_E, Product_C FROM Products";
            //执行查询
            DataTable dt = MSSqlHelper.GetDataTable(sql);
            //定义list,完成转存
            List <ProductsModel> list = new List <ProductsModel>();

            foreach (DataRow row in dt.Rows)
            {
                list.Add(new ProductsModel()
                {
                    ProductID = Convert.ToInt32(row["ProductID"]),
                    Product_E = row["Product_E"].ToString(),
                    Product_C = row["Product_C"].ToString(),
                });
            }
            return(list);
        }
Exemple #6
0
        public UsersModel GetByName(string username)
        {
            //定义一个对象
            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)
            {
                //用户名是存在的
                user = new UsersModel()
                {
                    UserName    = username,
                    DisplayName = dt.Rows[0]["DisplayName"].ToString(),
                    PassWord    = dt.Rows[0]["PassWord"].ToString(),
                };
            }
            return(user);
        }
Exemple #7
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));
        }
Exemple #8
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));
        }