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