Пример #1
0
        public static int AddPanrameter(Model.px_PanrameterModel model)
        {
            string        maxid  = @"declare @i int;
                                SELECT @i=max([SerialID])  FROM [px_Panrameter];
                                if @i is null
                                    begin
                                        set @i=1
                                    end
                                else
                                    begin
                                        set @i=@i+1
                                    end;
                                ";
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into px_Panrameter(");
            strSql.Append("SerialID,Name,Number)");
            strSql.Append(" values (");
            strSql.Append("@i,@Name,@Number)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",   SqlDbType.NVarChar),
                new SqlParameter("@Number", SqlDbType.Int)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Number;
            int rows = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, System.Data.CommandType.Text, maxid + strSql, parameters);

            return(rows);
        }
Пример #2
0
        public static int UpdatePanrameter(Model.px_PanrameterModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update px_Panrameter set ");
            strSql.Append("Name=@Name,");
            strSql.Append("Number=@Number");
            strSql.Append(" where SerialID=@SerialID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",     SqlDbType.NVarChar),
                new SqlParameter("@Number",   SqlDbType.Int),
                new SqlParameter("@SerialID", SqlDbType.Int)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Number;
            parameters[2].Value = model.SerialID;

            int rows = SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnString, System.Data.CommandType.Text, strSql.ToString(), parameters);

            return(rows);
        }