/// <summary> /// 安全方式绑定对象表单 /// </summary> public Lebi_Product_Stock_Log SafeBindForm(Lebi_Product_Stock_Log model) { if (HttpContext.Current.Request["Count"] != null) { model.Count = LB.Tools.RequestTool.RequestDecimal("Count", 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["Product_id"] != null) { model.Product_id = LB.Tools.RequestTool.RequestInt("Product_id", 0); } if (HttpContext.Current.Request["Remark"] != null) { model.Remark = LB.Tools.RequestTool.RequestSafeString("Remark"); } if (HttpContext.Current.Request["Time_Add"] != null) { model.Time_Add = LB.Tools.RequestTool.RequestTime("Time_Add", System.DateTime.Now); } if (HttpContext.Current.Request["Type_id_Stock"] != null) { model.Type_id_Stock = LB.Tools.RequestTool.RequestInt("Type_id_Stock", 0); } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Lebi_Product_Stock_Log model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + TableName + " ("); strSql.Append(LB.DataAccess.DB.BaseUtilsInstance.ColName("Count") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_Code") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Order_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Product_id") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "," + LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_Stock") + ")"); strSql.Append(" values ("); strSql.Append("@Count,@Order_Code,@Order_id,@Product_id,@Remark,@Time_Add,@Type_id_Stock);select @@identity;"); SqlParameter[] parameters = { new SqlParameter("@Count", model.Count), new SqlParameter("@Order_Code", model.Order_Code), new SqlParameter("@Order_id", model.Order_id), new SqlParameter("@Product_id", model.Product_id), new SqlParameter("@Remark", model.Remark), new SqlParameter("@Time_Add", model.Time_Add), new SqlParameter("@Type_id_Stock", model.Type_id_Stock) }; object obj = LB.DataAccess.DB.Instance.TextExecute(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Lebi_Product_Stock_Log model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + TableName + " set "); List <string> cols = new List <string>(); if (("," + model.UpdateCols + ",").IndexOf(",Count,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Count") + "= @Count"); } 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(",Product_id,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Product_id") + "= @Product_id"); } if (("," + model.UpdateCols + ",").IndexOf(",Remark,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Remark") + "= @Remark"); } if (("," + model.UpdateCols + ",").IndexOf(",Time_Add,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Time_Add") + "= @Time_Add"); } if (("," + model.UpdateCols + ",").IndexOf(",Type_id_Stock,") > -1 || model.UpdateCols == "") { cols.Add(LB.DataAccess.DB.BaseUtilsInstance.ColName("Type_id_Stock") + "= @Type_id_Stock"); } strSql.Append(string.Join(",", cols)); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", model.id), new SqlParameter("@Count", model.Count), new SqlParameter("@Order_Code", model.Order_Code), new SqlParameter("@Order_id", model.Order_id), new SqlParameter("@Product_id", model.Product_id), new SqlParameter("@Remark", model.Remark), new SqlParameter("@Time_Add", model.Time_Add), new SqlParameter("@Type_id_Stock", model.Type_id_Stock) }; LB.DataAccess.DB.Instance.TextExecuteNonQuery(strSql.ToString().Replace(", where id=@id", " where id=@id"), parameters); }
/// <summary> /// 得到一个对象实体 by where条件 /// </summary> public Lebi_Product_Stock_Log 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_Product_Stock_Log); } } Lebi_Product_Stock_Log 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_Product_Stock_Log", model.id, cachestr, seconds); } return(model); } } return(null); }
/// <summary> /// 对象实体绑定数据 /// </summary> public Lebi_Product_Stock_Log ReaderBind(IDataReader dataReader) { Lebi_Product_Stock_Log model = new Lebi_Product_Stock_Log(); object ojb; ojb = dataReader["id"]; if (ojb != null && ojb != DBNull.Value) { model.id = Convert.ToInt32(ojb); } ojb = dataReader["Count"]; if (ojb != null && ojb != DBNull.Value) { model.Count = (decimal)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["Product_id"]; if (ojb != null && ojb != DBNull.Value) { model.Product_id = Convert.ToInt32(ojb); } model.Remark = dataReader["Remark"].ToString(); ojb = dataReader["Time_Add"]; if (ojb != null && ojb != DBNull.Value) { model.Time_Add = (DateTime)ojb; } ojb = dataReader["Type_id_Stock"]; if (ojb != null && ojb != DBNull.Value) { model.Type_id_Stock = Convert.ToInt32(ojb); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public static void Update(Lebi_Product_Stock_Log model) { D_Lebi_Product_Stock_Log.Instance.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(Lebi_Product_Stock_Log model) { return(D_Lebi_Product_Stock_Log.Instance.Add(model)); }
/// <summary> /// 安全方式绑定表单数据 /// </summary> public static Lebi_Product_Stock_Log SafeBindForm(Lebi_Product_Stock_Log model) { return(D_Lebi_Product_Stock_Log.Instance.SafeBindForm(model)); }