Esempio n. 1
0
 /// <summary>
 /// 输出智能表单   返回一个字段的HTML的描述 方法
 /// </summary>
 /// <param name="Model"></param>
 /// <returns></returns>
 public static string FormPut(ROYcms.Sys.Model.ROYcms_Field Model)
 {
     return(FormPut("", "", Model.Name, Model.Lable, Model.Len.ToString(), Model.FieldType.ToString(), Model.IsNull.ToString(), Model.DefaultVal, Model.Display.ToString(), Model.InputType.ToString(), Model.InputLen.ToString()));
 }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ROYcms.Sys.Model.ROYcms_Field GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" Id,Rid,Name,Lable,Len,FieldType,IsNull,IsKey,DefaultVal,Display,Expression,InputType,InputLen,OrderBy,TIME ");
            strSql.Append(" from " + PubConstant.date_prefix + "Field ");
            strSql.Append(" where Id=" + Id + "");
            ROYcms.Sys.Model.ROYcms_Field model = new ROYcms.Sys.Model.ROYcms_Field();
            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]["Rid"] != null && ds.Tables[0].Rows[0]["Rid"].ToString() != "")
                {
                    model.Rid = int.Parse(ds.Tables[0].Rows[0]["Rid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Lable"] != null && ds.Tables[0].Rows[0]["Lable"].ToString() != "")
                {
                    model.Lable = ds.Tables[0].Rows[0]["Lable"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Len"] != null && ds.Tables[0].Rows[0]["Len"].ToString() != "")
                {
                    model.Len = int.Parse(ds.Tables[0].Rows[0]["Len"].ToString());
                }
                if (ds.Tables[0].Rows[0]["FieldType"] != null && ds.Tables[0].Rows[0]["FieldType"].ToString() != "")
                {
                    model.FieldType = int.Parse(ds.Tables[0].Rows[0]["FieldType"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsNull"] != null && ds.Tables[0].Rows[0]["IsNull"].ToString() != "")
                {
                    model.IsNull = int.Parse(ds.Tables[0].Rows[0]["IsNull"].ToString());
                }
                if (ds.Tables[0].Rows[0]["IsKey"] != null && ds.Tables[0].Rows[0]["IsKey"].ToString() != "")
                {
                    model.IsKey = int.Parse(ds.Tables[0].Rows[0]["IsKey"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DefaultVal"] != null && ds.Tables[0].Rows[0]["DefaultVal"].ToString() != "")
                {
                    model.DefaultVal = ds.Tables[0].Rows[0]["DefaultVal"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Display"] != null && ds.Tables[0].Rows[0]["Display"].ToString() != "")
                {
                    model.Display = int.Parse(ds.Tables[0].Rows[0]["Display"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Expression"] != null && ds.Tables[0].Rows[0]["Expression"].ToString() != "")
                {
                    model.Expression = ds.Tables[0].Rows[0]["Expression"].ToString();
                }
                if (ds.Tables[0].Rows[0]["InputType"] != null && ds.Tables[0].Rows[0]["InputType"].ToString() != "")
                {
                    model.InputType = ds.Tables[0].Rows[0]["InputType"].ToString();
                }
                if (ds.Tables[0].Rows[0]["InputLen"] != null && ds.Tables[0].Rows[0]["InputLen"].ToString() != "")
                {
                    model.InputLen = int.Parse(ds.Tables[0].Rows[0]["InputLen"].ToString());
                }
                if (ds.Tables[0].Rows[0]["OrderBy"] != null && ds.Tables[0].Rows[0]["OrderBy"].ToString() != "")
                {
                    model.OrderBy = int.Parse(ds.Tables[0].Rows[0]["OrderBy"].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);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ROYcms.Sys.Model.ROYcms_Field model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.Rid != null)
            {
                strSql1.Append("Rid,");
                strSql2.Append("" + model.Rid + ",");
            }
            if (model.Name != null)
            {
                strSql1.Append("Name,");
                strSql2.Append("'" + model.Name + "',");
            }
            if (model.Lable != null)
            {
                strSql1.Append("Lable,");
                strSql2.Append("'" + model.Lable + "',");
            }
            if (model.Len != null)
            {
                strSql1.Append("Len,");
                strSql2.Append("" + model.Len + ",");
            }
            if (model.FieldType != null)
            {
                strSql1.Append("FieldType,");
                strSql2.Append("" + model.FieldType + ",");
            }
            if (model.IsNull != null)
            {
                strSql1.Append("IsNull,");
                strSql2.Append("" + model.IsNull + ",");
            }
            if (model.IsKey != null)
            {
                strSql1.Append("IsKey,");
                strSql2.Append("" + model.IsKey + ",");
            }
            if (model.DefaultVal != null)
            {
                strSql1.Append("DefaultVal,");
                strSql2.Append("'" + model.DefaultVal + "',");
            }
            if (model.Display != null)
            {
                strSql1.Append("Display,");
                strSql2.Append("" + model.Display + ",");
            }
            if (model.Expression != null)
            {
                strSql1.Append("Expression,");
                strSql2.Append("'" + model.Expression + "',");
            }
            if (model.InputType != null)
            {
                strSql1.Append("InputType,");
                strSql2.Append("'" + model.InputType + "',");
            }
            if (model.InputLen != null)
            {
                strSql1.Append("InputLen,");
                strSql2.Append("" + model.InputLen + ",");
            }
            if (model.OrderBy != null)
            {
                strSql1.Append("OrderBy,");
                strSql2.Append("" + model.OrderBy + ",");
            }
            if (model.TIME != null)
            {
                strSql1.Append("TIME,");
                strSql2.Append("'" + model.TIME + "',");
            }
            strSql.Append("insert into " + PubConstant.date_prefix + "Field(");
            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));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ROYcms.Sys.Model.ROYcms_Field model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + PubConstant.date_prefix + "Field set ");
            if (model.Rid != null)
            {
                strSql.Append("Rid=" + model.Rid + ",");
            }
            else
            {
                strSql.Append("Rid= null ,");
            }
            if (model.Name != null)
            {
                strSql.Append("Name='" + model.Name + "',");
            }
            else
            {
                strSql.Append("Name= null ,");
            }
            if (model.Lable != null)
            {
                strSql.Append("Lable='" + model.Lable + "',");
            }
            else
            {
                strSql.Append("Lable= null ,");
            }
            if (model.Len != null)
            {
                strSql.Append("Len=" + model.Len + ",");
            }
            else
            {
                strSql.Append("Len= null ,");
            }
            if (model.FieldType != null)
            {
                strSql.Append("FieldType=" + model.FieldType + ",");
            }
            else
            {
                strSql.Append("FieldType= null ,");
            }
            if (model.IsNull != null)
            {
                strSql.Append("IsNull=" + model.IsNull + ",");
            }
            else
            {
                strSql.Append("IsNull= null ,");
            }
            if (model.IsKey != null)
            {
                strSql.Append("IsKey=" + model.IsKey + ",");
            }
            else
            {
                strSql.Append("IsKey= null ,");
            }
            if (model.DefaultVal != null)
            {
                strSql.Append("DefaultVal='" + model.DefaultVal + "',");
            }
            else
            {
                strSql.Append("DefaultVal= null ,");
            }
            if (model.Display != null)
            {
                strSql.Append("Display=" + model.Display + ",");
            }
            else
            {
                strSql.Append("Display= null ,");
            }
            if (model.Expression != null)
            {
                strSql.Append("Expression='" + model.Expression + "',");
            }
            else
            {
                strSql.Append("Expression= null ,");
            }
            if (model.InputType != null)
            {
                strSql.Append("InputType='" + model.InputType + "',");
            }
            else
            {
                strSql.Append("InputType= null ,");
            }
            if (model.InputLen != null)
            {
                strSql.Append("InputLen=" + model.InputLen + ",");
            }
            else
            {
                strSql.Append("InputLen= null ,");
            }
            if (model.OrderBy != null)
            {
                strSql.Append("OrderBy=" + model.OrderBy + ",");
            }
            else
            {
                strSql.Append("OrderBy= 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 Id=" + model.Id + "");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }