/// <summary> /// 得到一个对象实体 by SQLpara /// </summary> public Lebi_User_Question GetModel(SQLPara para) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_User_Question] "); if (para.Where != "") { strSql.Append(" where " + para.Where + ""); } Lebi_User_Question model = new Lebi_User_Question(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), para.Para); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_User_Question GetModel(string strWhere) { if (strWhere.IndexOf("lbsql{") > 0) { SQLPara para = new SQLPara(strWhere, "", ""); return(GetModel(para)); } StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_User_Question] "); strSql.Append(" where " + strWhere + ""); Lebi_User_Question model = new Lebi_User_Question(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 by id /// </summary> public Lebi_User_Question GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_User_Question] "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Lebi_User_Question model = new Lebi_User_Question(); DataSet ds = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["Sort"].ToString() != "") { model.Sort = int.Parse(ds.Tables[0].Rows[0]["Sort"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_User_Question model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_User_Question]("); strSql.Append("Name,Sort)"); strSql.Append(" values ("); strSql.Append("@Name,@Sort)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", model.Name), new SqlParameter("@Sort", model.Sort) }; object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
public string QuestionName(int id) { Lebi_User_Question model = B_Lebi_User_Question.GetModel(id); if (model != null) { return(Lang(model.Name)); } return(""); }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_User_Question SafeBindForm(Lebi_User_Question model) { if (HttpContext.Current.Request["Name"] != null) { model.Name = Shop.Tools.RequestTool.RequestSafeString("Name"); } if (HttpContext.Current.Request["Sort"] != null) { model.Sort = Shop.Tools.RequestTool.RequestInt("Sort", 0); } return(model); }
protected void Page_Load(object sender, EventArgs e) { int id = RequestTool.RequestInt("id", 0); if (!EX_Admin.Power("question_list", "安全问题")) { PageNoPower(); } model = B_Lebi_User_Question.GetModel(id); if (model == null) { model = new Lebi_User_Question(); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_User_Question model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_User_Question] set "); strSql.Append("[Name]=@Name,"); strSql.Append("[Sort]=@Sort"); strSql.Append(" where id=" + model.id); OleDbParameter[] parameters = { new OleDbParameter("@Name", model.Name), new OleDbParameter("@Sort", model.Sort) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_User_Question model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_User_Question]("); strSql.Append("[Name],[Sort])"); strSql.Append(" values ("); strSql.Append("@Name,@Sort)"); OleDbParameter[] parameters = { new OleDbParameter("@Name", model.Name), new OleDbParameter("@Sort", model.Sort) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); return(1); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_User_Question ReaderBind(IDataReader dataReader) { Lebi_User_Question model = new Lebi_User_Question(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = (int)ojb; } model.Name = dataReader["Name"].ToString(); ojb = dataReader["Sort"]; if (ojb != null && ojb != DBNull.Value) { model.Sort = (int)ojb; } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_User_Question model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_User_Question] set "); strSql.Append("Name= @Name,"); strSql.Append("Sort= @Sort"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.NVarChar, 2000), new SqlParameter("@Sort", SqlDbType.Int, 4) }; parameters[0].Value = model.id; parameters[1].Value = model.Name; parameters[2].Value = model.Sort; SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_User_Question model) { D_Lebi_User_Question.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_User_Question model) { return(D_Lebi_User_Question.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_User_Question SafeBindForm(Lebi_User_Question model) { return(D_Lebi_User_Question.Instance.SafeBindForm(model)); }