Ejemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ROYcms.Sys.Model.ROYcms_ASKResult GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,ASKID,UserID,AdminID,Title,Contents,IP,CreateTime from ROYcms_ASKResult ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            ROYcms.Sys.Model.ROYcms_ASKResult model = new ROYcms.Sys.Model.ROYcms_ASKResult();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            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]["ASKID"] != null && ds.Tables[0].Rows[0]["ASKID"].ToString() != "")
                {
                    model.ASKID = int.Parse(ds.Tables[0].Rows[0]["ASKID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["UserID"] != null && ds.Tables[0].Rows[0]["UserID"].ToString() != "")
                {
                    model.UserID = int.Parse(ds.Tables[0].Rows[0]["UserID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AdminID"] != null && ds.Tables[0].Rows[0]["AdminID"].ToString() != "")
                {
                    model.AdminID = int.Parse(ds.Tables[0].Rows[0]["AdminID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Title"] != null && ds.Tables[0].Rows[0]["Title"].ToString() != "")
                {
                    model.Title = ds.Tables[0].Rows[0]["Title"].ToString();
                }
                if (ds.Tables[0].Rows[0]["Contents"] != null && ds.Tables[0].Rows[0]["Contents"].ToString() != "")
                {
                    model.Contents = ds.Tables[0].Rows[0]["Contents"].ToString();
                }
                if (ds.Tables[0].Rows[0]["IP"] != null && ds.Tables[0].Rows[0]["IP"].ToString() != "")
                {
                    model.IP = ds.Tables[0].Rows[0]["IP"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CreateTime"] != null && ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        protected void Button_save_Click(object sender, EventArgs e)
        {
            string strErr = "";


            if (this.txtTitle.Text.Trim().Length == 0)
            {
                strErr += "标题不能为空!\\n";
            }
            if (this.txtContents.Text.Trim().Length == 0)
            {
                strErr += "内容不能为空!\\n";
            }


            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            int      ASKID      = Convert.ToInt32(Request["Id"]);
            int      UserID     = 0;
            int      AdminID    = Convert.ToInt32(ROYcms.Common.Session.Get("administrator_id"));
            string   Title      = this.txtTitle.Text;
            string   Contents   = this.txtContents.Text;
            string   IP         = ROYcms.Common.SystemCms.GetClientIPv4(); //IP地址
            DateTime CreateTime = DateTime.Now;

            ROYcms.Sys.Model.ROYcms_ASKResult model = new ROYcms.Sys.Model.ROYcms_ASKResult();

            model.ASKID      = ASKID;
            model.UserID     = UserID;
            model.AdminID    = AdminID;
            model.Title      = Title;
            model.Contents   = Contents;
            model.IP         = IP;
            model.CreateTime = CreateTime;

            ROYcms.Sys.BLL.ROYcms_ASKResult bll = new ROYcms.Sys.BLL.ROYcms_ASKResult();
            bll.Add(model);

            Bind();

            ROYcms.Common.MessageBox.Show(this, "保存成功!");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ROYcms.Sys.Model.ROYcms_ASKResult model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ROYcms_ASKResult set ");
            strSql.Append("ASKID=@ASKID,");
            strSql.Append("UserID=@UserID,");
            strSql.Append("AdminID=@AdminID,");
            strSql.Append("Title=@Title,");
            strSql.Append("Contents=@Contents,");
            strSql.Append("IP=@IP,");
            strSql.Append("CreateTime=@CreateTime");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ASKID",      SqlDbType.Int,          4),
                new SqlParameter("@UserID",     SqlDbType.Int,          4),
                new SqlParameter("@AdminID",    SqlDbType.Int,          4),
                new SqlParameter("@Title",      SqlDbType.VarChar,    200),
                new SqlParameter("@Contents",   SqlDbType.VarChar,   8000),
                new SqlParameter("@IP",         SqlDbType.VarChar,     20),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@Id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ASKID;
            parameters[1].Value = model.UserID;
            parameters[2].Value = model.AdminID;
            parameters[3].Value = model.Title;
            parameters[4].Value = model.Contents;
            parameters[5].Value = model.IP;
            parameters[6].Value = model.CreateTime;
            parameters[7].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ROYcms.Sys.Model.ROYcms_ASKResult model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ROYcms_ASKResult(");
            strSql.Append("ASKID,UserID,AdminID,Title,Contents,IP,CreateTime)");
            strSql.Append(" values (");
            strSql.Append("@ASKID,@UserID,@AdminID,@Title,@Contents,@IP,@CreateTime)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ASKID",      SqlDbType.Int,        4),
                new SqlParameter("@UserID",     SqlDbType.Int,        4),
                new SqlParameter("@AdminID",    SqlDbType.Int,        4),
                new SqlParameter("@Title",      SqlDbType.VarChar,  200),
                new SqlParameter("@Contents",   SqlDbType.VarChar, 8000),
                new SqlParameter("@IP",         SqlDbType.VarChar,   20),
                new SqlParameter("@CreateTime", SqlDbType.DateTime)
            };

            parameters[0].Value = model.ASKID;
            parameters[1].Value = model.UserID;
            parameters[2].Value = model.AdminID;
            parameters[3].Value = model.Title;
            parameters[4].Value = model.Contents;
            parameters[5].Value = model.IP;
            parameters[6].Value = model.CreateTime;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

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