Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool CidUpdate(ROYcms.Sys.Model.ROYcms_Class_Model model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + PubConstant.date_prefix + "Class_Model set ");
            if (model.Mid != null)
            {
                strSql.Append("Mid=" + model.Mid + ",");
            }
            else
            {
                strSql.Append("Mid= null ,");
            }
            if (model.Cid != null)
            {
                strSql.Append("Cid=" + model.Cid + ",");
            }
            else
            {
                strSql.Append("Cid= null ,");
            }
            if (model.Uid != null)
            {
                strSql.Append("Uid=" + model.Uid + ",");
            }
            else
            {
                strSql.Append("Uid= null ,");
            }
            if (model.ClassID != null)
            {
                strSql.Append("ClassID=" + model.ClassID + ",");
            }
            else
            {
                strSql.Append("ClassID= null ,");
            }
            if (model.TIME != null)
            {
                strSql.Append("TIME='" + model.TIME + "',");
            }
            else
            {
                strSql.Append("TIME= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where Cid=" + model.Cid + "");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ROYcms.Sys.Model.ROYcms_Class_Model model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.Mid != null)
            {
                strSql1.Append("Mid,");
                strSql2.Append("" + model.Mid + ",");
            }
            if (model.Cid != null)
            {
                strSql1.Append("Cid,");
                strSql2.Append("" + model.Cid + ",");
            }
            if (model.Uid != null)
            {
                strSql1.Append("Uid,");
                strSql2.Append("" + model.Uid + ",");
            }
            if (model.ClassID != null)
            {
                strSql1.Append("ClassID,");
                strSql2.Append("" + model.ClassID + ",");
            }
            if (model.TIME != null)
            {
                strSql1.Append("TIME,");
                strSql2.Append("'" + model.TIME + "',");
            }
            strSql.Append("insert into " + PubConstant.date_prefix + "Class_Model(");
            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(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ROYcms.Sys.Model.ROYcms_Class_Model GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" Id,Mid,Cid,Uid,ClassID,TIME ");
            strSql.Append(" from " + PubConstant.date_prefix + "Class_Model ");
            strSql.Append(" where Id=" + Id + "");
            ROYcms.Sys.Model.ROYcms_Class_Model model = new ROYcms.Sys.Model.ROYcms_Class_Model();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Mid"] != null && ds.Tables[0].Rows[0]["Mid"].ToString() != "")
                {
                    model.Mid = int.Parse(ds.Tables[0].Rows[0]["Mid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Cid"] != null && ds.Tables[0].Rows[0]["Cid"].ToString() != "")
                {
                    model.Cid = int.Parse(ds.Tables[0].Rows[0]["Cid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Uid"] != null && ds.Tables[0].Rows[0]["Uid"].ToString() != "")
                {
                    model.Uid = int.Parse(ds.Tables[0].Rows[0]["Uid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ClassID"] != null && ds.Tables[0].Rows[0]["ClassID"].ToString() != "")
                {
                    model.ClassID = int.Parse(ds.Tables[0].Rows[0]["ClassID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TIME"] != null && ds.Tables[0].Rows[0]["TIME"].ToString() != "")
                {
                    model.TIME = DateTime.Parse(ds.Tables[0].Rows[0]["TIME"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }