/// <summary> /// 得到一个对象实体 by SQLpara /// </summary> public Lebi_Units GetModel(SQLPara para) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Units] "); if (para.Where != "") { strSql.Append(" where " + para.Where + ""); } Lebi_Units model = new Lebi_Units(); 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(); return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_Units 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_Units] "); strSql.Append(" where " + strWhere + ""); Lebi_Units model = new Lebi_Units(); 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(); return(model); } else { return(null); } }
/// <summary> /// 得到一个对象实体 by id /// </summary> public Lebi_Units GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from [Lebi_Units] "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Lebi_Units model = new Lebi_Units(); 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(); return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Units model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Units]("); strSql.Append("Name)"); strSql.Append(" values ("); strSql.Append("@Name)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", model.Name) }; object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_Units SafeBindForm(Lebi_Units model) { if (HttpContext.Current.Request["Name"] != null) { model.Name = Shop.Tools.RequestTool.RequestSafeString("Name"); } return(model); }
public string GetUnitName(int id) { Lebi_Units model = B_Lebi_Units.GetModel(id); if (model == null) { return(""); } return(Lang(model.Name)); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Units ReaderBind(IDataReader dataReader) { Lebi_Units model = new Lebi_Units(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = (int)ojb; } model.Name = dataReader["Name"].ToString(); return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Units model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Units] set "); strSql.Append("[Name]=@Name"); strSql.Append(" where id=" + model.id); OleDbParameter[] parameters = { new OleDbParameter("@Name", model.Name) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Units model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Lebi_Units]("); strSql.Append("[Name])"); strSql.Append(" values ("); strSql.Append("@Name)"); OleDbParameter[] parameters = { new OleDbParameter("@Name", model.Name) }; AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters); return(1); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Units model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Lebi_Units] set "); strSql.Append("Name= @Name"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 500) }; parameters[0].Value = model.id; parameters[1].Value = model.Name; SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters); }
protected void Page_Load(object sender, EventArgs e) { int id = RequestTool.RequestInt("id", 0); if (id == 0) { if (!EX_Admin.Power("pro_units_add", "添加商品单位")) { WindowNoPower(); } } else { if (!EX_Admin.Power("pro_units_edit", "编辑商品单位")) { WindowNoPower(); } } model = B_Lebi_Units.GetModel(id); if (model == null) { model = new Lebi_Units(); } }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Units model) { D_Lebi_Units.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Units model) { return(D_Lebi_Units.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Units SafeBindForm(Lebi_Units model) { return(D_Lebi_Units.Instance.SafeBindForm(model)); }