Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Club.Model.T_STB model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.STBMC != null)
            {
                strSql1.Append("STBMC,");
                strSql2.Append("'" + model.STBMC + "',");
            }
            if (model.BZID != null)
            {
                strSql1.Append("BZID,");
                strSql2.Append("" + model.BZID + ",");
            }
            if (model.CYRS != null)
            {
                strSql1.Append("CYRS,");
                strSql2.Append("" + model.CYRS + ",");
            }
            if (model.MOBILE != null)
            {
                strSql1.Append("MOBILE,");
                strSql2.Append("'" + model.MOBILE + "',");
            }
            if (model.STZN != null)
            {
                strSql1.Append("STZN,");
                strSql2.Append("'" + model.STZN + "',");
            }
            if (model.BZ != null)
            {
                strSql1.Append("BZ,");
                strSql2.Append("'" + model.BZ + "',");
            }
            if (model.STF != null)
            {
                strSql1.Append("STF,");
                strSql2.Append("" + model.STF + ",");
            }
            strSql.Append("insert into T_STB(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(-1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Club.Model.T_STB GetModel(int STBID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" STBID,STBMC,BZID,CYRS,MOBILE,STZN,BZ,STF ");
            strSql.Append(" from T_STB ");
            strSql.Append(" where STBID=" + STBID + " ");
            Club.Model.T_STB model = new Club.Model.T_STB();
            DataSet          ds    = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["STBID"].ToString() != "")
                {
                    model.STBID = int.Parse(ds.Tables[0].Rows[0]["STBID"].ToString());
                }
                model.STBMC = ds.Tables[0].Rows[0]["STBMC"].ToString();
                if (ds.Tables[0].Rows[0]["BZID"].ToString() != "")
                {
                    model.BZID = int.Parse(ds.Tables[0].Rows[0]["BZID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["CYRS"].ToString() != "")
                {
                    model.CYRS = int.Parse(ds.Tables[0].Rows[0]["CYRS"].ToString());
                }
                model.MOBILE = ds.Tables[0].Rows[0]["MOBILE"].ToString();
                model.STZN   = ds.Tables[0].Rows[0]["STZN"].ToString();
                model.BZ     = ds.Tables[0].Rows[0]["BZ"].ToString();
                if (ds.Tables[0].Rows[0]["STF"].ToString() != "")
                {
                    model.STF = int.Parse(ds.Tables[0].Rows[0]["STF"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(Club.Model.T_STB model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update T_STB set ");
            if (model.STBMC != null)
            {
                strSql.Append("STBMC='" + model.STBMC + "',");
            }
            if (model.BZID != null)
            {
                strSql.Append("BZID=" + model.BZID + ",");
            }
            if (model.CYRS != null)
            {
                strSql.Append("CYRS=" + model.CYRS + ",");
            }
            if (model.MOBILE != null)
            {
                strSql.Append("MOBILE='" + model.MOBILE + "',");
            }
            if (model.STZN != null)
            {
                strSql.Append("STZN='" + model.STZN + "',");
            }
            if (model.BZ != null)
            {
                strSql.Append("BZ='" + model.BZ + "',");
            }
            if (model.STF != null)
            {
                strSql.Append("STF=" + model.STF + ",");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where STBID=" + model.STBID + " ");
            return(DbHelperSQL.ExecuteSql(strSql.ToString()));
        }