示例#1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ZQUSR.Model.sr_Publish GetModel(int PL_PID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 PL_PID,Publisher,UnitName from sr_Publish ");
            strSql.Append(" where PL_PID=@PL_PID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PL_PID", SqlDbType.Int, 4)
            };
            parameters[0].Value = PL_PID;

            ZQUSR.Model.sr_Publish model = new ZQUSR.Model.sr_Publish();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["PL_PID"].ToString() != "")
                {
                    model.PL_PID = int.Parse(ds.Tables[0].Rows[0]["PL_PID"].ToString());
                }
                model.Publisher = ds.Tables[0].Rows[0]["Publisher"].ToString();
                model.UnitName  = ds.Tables[0].Rows[0]["UnitName"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ZQUSR.Model.sr_Publish model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into sr_Publish(");
            strSql.Append("Publisher,UnitName)");
            strSql.Append(" values (");
            strSql.Append("@Publisher,@UnitName)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Publisher", SqlDbType.NVarChar, 20),
                new SqlParameter("@UnitName",  SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = model.Publisher;
            parameters[1].Value = model.UnitName;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(ZQUSR.Model.sr_Publish model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update sr_Publish set ");
            strSql.Append("Publisher=@Publisher,");
            strSql.Append("UnitName=@UnitName");
            strSql.Append(" where PL_PID=@PL_PID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PL_PID",    SqlDbType.Int,       4),
                new SqlParameter("@Publisher", SqlDbType.NVarChar, 20),
                new SqlParameter("@UnitName",  SqlDbType.NVarChar, 20)
            };
            parameters[0].Value = model.PL_PID;
            parameters[1].Value = model.Publisher;
            parameters[2].Value = model.UnitName;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
示例#4
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public ZQUSR.Model.sr_Publish GetModel(int PL_PID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 PL_PID,Publisher,UnitName from sr_Publish ");
            strSql.Append(" where PL_PID=@PL_PID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@PL_PID", SqlDbType.Int,4)};
            parameters[0].Value = PL_PID;

            ZQUSR.Model.sr_Publish model=new ZQUSR.Model.sr_Publish();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["PL_PID"].ToString()!="")
                {
                    model.PL_PID=int.Parse(ds.Tables[0].Rows[0]["PL_PID"].ToString());
                }
                model.Publisher=ds.Tables[0].Rows[0]["Publisher"].ToString();
                model.UnitName=ds.Tables[0].Rows[0]["UnitName"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }