/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_ServicePanel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + TableName + " set "); List <string> cols = new List <string>(); if (("," + model.UpdateCols + ",").IndexOf(",Account,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Account") + "= @Account"); } if (("," + model.UpdateCols + ",").IndexOf(",Face,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Face") + "= @Face"); } if (("," + model.UpdateCols + ",").IndexOf(",Language,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Language") + "= @Language"); } if (("," + model.UpdateCols + ",").IndexOf(",Language_ids,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_ids") + "= @Language_ids"); } if (("," + model.UpdateCols + ",").IndexOf(",Name,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "= @Name"); } if (("," + model.UpdateCols + ",").IndexOf(",ServicePanel_Group_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("ServicePanel_Group_id") + "= @ServicePanel_Group_id"); } if (("," + model.UpdateCols + ",").IndexOf(",ServicePanel_Type_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("ServicePanel_Type_id") + "= @ServicePanel_Type_id"); } if (("," + model.UpdateCols + ",").IndexOf(",Sort,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "= @Sort"); } if (("," + model.UpdateCols + ",").IndexOf(",Supplier_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + "= @Supplier_id"); } strSql.Append(string.Join(",", cols)); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", model.id), new SqlParameter("@Account", model.Account), new SqlParameter("@Face", model.Face), new SqlParameter("@Language", model.Language), new SqlParameter("@Language_ids", model.Language_ids), new SqlParameter("@Name", model.Name), new SqlParameter("@ServicePanel_Group_id", model.ServicePanel_Group_id), new SqlParameter("@ServicePanel_Type_id", model.ServicePanel_Type_id), new SqlParameter("@Sort", model.Sort), new SqlParameter("@Supplier_id", model.Supplier_id) }; LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_ServicePanel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + TableName + " ("); strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Account") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Face") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Language") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Language_ids") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Name") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("ServicePanel_Group_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("ServicePanel_Type_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Sort") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + ")"); strSql.Append(" values ("); strSql.Append("@Account,@Face,@Language,@Language_ids,@Name,@ServicePanel_Group_id,@ServicePanel_Type_id,@Sort,@Supplier_id);select @@identity;"); SqlParameter[] parameters = { new SqlParameter("@Account", model.Account), new SqlParameter("@Face", model.Face), new SqlParameter("@Language", model.Language), new SqlParameter("@Language_ids", model.Language_ids), new SqlParameter("@Name", model.Name), new SqlParameter("@ServicePanel_Group_id", model.ServicePanel_Group_id), new SqlParameter("@ServicePanel_Type_id", model.ServicePanel_Type_id), new SqlParameter("@Sort", model.Sort), new SqlParameter("@Supplier_id", model.Supplier_id) }; object obj = LB.DataAccess.DB.Instance.TextExecute(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_ServicePanel GetModel(string strWhere, int seconds = 0) { if (strWhere.IndexOf("lbsql{") > 0) { SQLPara para = new SQLPara(strWhere, "", ""); return(GetModel(para, seconds)); } string strTableName = TableName; string strFieldShow = "*"; string cachekey = ""; string cachestr = ""; if (BaseUtils.BaseUtilsInstance.MemcacheInstance != null && seconds > 0) { cachestr = "select * " + TableName + " where " + strWhere + "|" + seconds; cachekey = LB.Tools.Utils.MD5(cachestr); var obj = LB.DataAccess.DB.Instance.GetMemchche(cachekey); if (obj != null) { return(obj as Lebi_ServicePanel); } } Lebi_ServicePanel model = null; using (IDataReader dataReader = LB.DataAccess.DB.Instance.TextExecuteReaderOne(strTableName, strFieldShow, strWhere, null)) { if (dataReader == null) { return(null); } while (dataReader.Read()) { model = ReaderBind(dataReader); if (cachekey != "") { LB.DataAccess.DB.Instance.SetMemchche(cachekey, model, "Lebi_ServicePanel", model.id, cachestr, seconds); } return(model); } } return(null); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_ServicePanel ReaderBind(IDataReader dataReader) { Lebi_ServicePanel model = new Lebi_ServicePanel(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = Convert.ToInt32(ojb); } model.Account = dataReader["Account"].ToString(); ojb = dataReader["Face"]; if (ojb != null && ojb != DBNull.Value) { model.Face = Convert.ToInt32(ojb); } model.Language = dataReader["Language"].ToString(); model.Language_ids = dataReader["Language_ids"].ToString(); model.Name = dataReader["Name"].ToString(); ojb = dataReader["ServicePanel_Group_id"]; if (ojb != null && ojb != DBNull.Value) { model.ServicePanel_Group_id = Convert.ToInt32(ojb); } ojb = dataReader["ServicePanel_Type_id"]; if (ojb != null && ojb != DBNull.Value) { model.ServicePanel_Type_id = Convert.ToInt32(ojb); } ojb = dataReader["Sort"]; if (ojb != null && ojb != DBNull.Value) { model.Sort = Convert.ToInt32(ojb); } ojb = dataReader["Supplier_id"]; if (ojb != null && ojb != DBNull.Value) { model.Supplier_id = Convert.ToInt32(ojb); } return(model); }
/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_ServicePanel SafeBindForm(Lebi_ServicePanel model) { if (HttpContext.Current.Request["Account"] != null) { model.Account = LB.Tools.RequestTool.RequestSafeString("Account"); } if (HttpContext.Current.Request["Face"] != null) { model.Face = LB.Tools.RequestTool.RequestInt("Face", 0); } if (HttpContext.Current.Request["Language"] != null) { model.Language = LB.Tools.RequestTool.RequestSafeString("Language"); } if (HttpContext.Current.Request["Language_ids"] != null) { model.Language_ids = LB.Tools.RequestTool.RequestSafeString("Language_ids"); } if (HttpContext.Current.Request["Name"] != null) { model.Name = LB.Tools.RequestTool.RequestSafeString("Name"); } if (HttpContext.Current.Request["ServicePanel_Group_id"] != null) { model.ServicePanel_Group_id = LB.Tools.RequestTool.RequestInt("ServicePanel_Group_id", 0); } if (HttpContext.Current.Request["ServicePanel_Type_id"] != null) { model.ServicePanel_Type_id = LB.Tools.RequestTool.RequestInt("ServicePanel_Type_id", 0); } if (HttpContext.Current.Request["Sort"] != null) { model.Sort = LB.Tools.RequestTool.RequestInt("Sort", 0); } if (HttpContext.Current.Request["Supplier_id"] != null) { model.Supplier_id = LB.Tools.RequestTool.RequestInt("Supplier_id", 0); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_ServicePanel model) { D_Lebi_ServicePanel.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_ServicePanel model) { return(D_Lebi_ServicePanel.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_ServicePanel SafeBindForm(Lebi_ServicePanel model) { return(D_Lebi_ServicePanel.Instance.SafeBindForm(model)); }