/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Express_LogList ReaderBind(IDataReader dataReader) { Lebi_Express_LogList model = new Lebi_Express_LogList(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = Convert.ToInt32(ojb); } ojb = dataReader["Express_Log_Id"]; if (ojb != null && ojb != DBNull.Value) { model.Express_Log_Id = Convert.ToInt32(ojb); } model.Order_Code = dataReader["Order_Code"].ToString(); ojb = dataReader["Order_Id"]; if (ojb != null && ojb != DBNull.Value) { model.Order_Id = Convert.ToInt32(ojb); } ojb = dataReader["Status"]; if (ojb != null && ojb != DBNull.Value) { model.Status = Convert.ToInt32(ojb); } ojb = dataReader["Supplier_id"]; if (ojb != null && ojb != DBNull.Value) { model.Supplier_id = Convert.ToInt32(ojb); } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Express_LogList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + TableName + " ("); strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Express_Log_Id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_Id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Status") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Supplier_id") + ")"); strSql.Append(" values ("); strSql.Append("@Express_Log_Id,@Order_Code,@Order_Id,@Status,@Supplier_id);select @@identity;"); SqlParameter[] parameters = { new SqlParameter("@Express_Log_Id", model.Express_Log_Id), new SqlParameter("@Order_Code", model.Order_Code), new SqlParameter("@Order_Id", model.Order_Id), new SqlParameter("@Status", model.Status), 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_Express_LogList 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_Express_LogList); } } Lebi_Express_LogList 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_Express_LogList", model.id, cachestr, seconds); } return(model); } } return(null); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Express_LogList model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + TableName + " set "); List <string> cols = new List <string>(); if (("," + model.UpdateCols + ",").IndexOf(",Express_Log_Id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Express_Log_Id") + "= @Express_Log_Id"); } if (("," + model.UpdateCols + ",").IndexOf(",Order_Code,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_Code") + "= @Order_Code"); } if (("," + model.UpdateCols + ",").IndexOf(",Order_Id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_Id") + "= @Order_Id"); } if (("," + model.UpdateCols + ",").IndexOf(",Status,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Status") + "= @Status"); } 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("@Express_Log_Id", model.Express_Log_Id), new SqlParameter("@Order_Code", model.Order_Code), new SqlParameter("@Order_Id", model.Order_Id), new SqlParameter("@Status", model.Status), 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 Lebi_Express_LogList SafeBindForm(Lebi_Express_LogList model) { if (HttpContext.Current.Request["Express_Log_Id"] != null) { model.Express_Log_Id = LB.Tools.RequestTool.RequestInt("Express_Log_Id", 0); } if (HttpContext.Current.Request["Order_Code"] != null) { model.Order_Code = LB.Tools.RequestTool.RequestSafeString("Order_Code"); } if (HttpContext.Current.Request["Order_Id"] != null) { model.Order_Id = LB.Tools.RequestTool.RequestInt("Order_Id", 0); } if (HttpContext.Current.Request["Status"] != null) { model.Status = LB.Tools.RequestTool.RequestInt("Status", 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_Express_LogList model) { D_Lebi_Express_LogList.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Express_LogList model) { return(D_Lebi_Express_LogList.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Express_LogList SafeBindForm(Lebi_Express_LogList model) { return(D_Lebi_Express_LogList.Instance.SafeBindForm(model)); }