public Model_SysFilter DataRowToModel(DataRow row) { Model_SysFilter filter = new Model_SysFilter(); if (row != null) { if (row["SysFilter_id"] != null) { filter.SysFilter_id = row["SysFilter_id"].ToString(); } if (row["KeyWord"] != null) { filter.KeyWord = row["KeyWord"].ToString(); } if ((row["Create_Time"] != null) && (row["Create_Time"].ToString() != "")) { filter.Create_Time = new DateTime?(DateTime.Parse(row["Create_Time"].ToString())); } if (row["Create_UserId"] != null) { filter.Create_UserId = row["Create_UserId"].ToString(); } } return(filter); }
public bool Add(Model_SysFilter model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into SysFilter("); builder.Append("SysFilter_id,KeyWord,Create_Time,Create_UserId)"); builder.Append(" values ("); builder.Append("@SysFilter_id,@KeyWord,@Create_Time,@Create_UserId)"); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@SysFilter_id", SqlDbType.Char, 0x24), new SqlParameter("@KeyWord", SqlDbType.VarChar, 500), new SqlParameter("@Create_Time", SqlDbType.DateTime), new SqlParameter("@Create_UserId", SqlDbType.Char, 30) }; cmdParms[0].Value = model.SysFilter_id; cmdParms[1].Value = model.KeyWord; cmdParms[2].Value = model.Create_Time; cmdParms[3].Value = model.Create_UserId; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
public bool Update(Model_SysFilter model) { StringBuilder builder = new StringBuilder(); builder.Append("update SysFilter set "); builder.Append("KeyWord=@KeyWord,"); builder.Append("Create_Time=@Create_Time,"); builder.Append("Create_UserId=@Create_UserId"); builder.Append(" where SysFilter_id=@SysFilter_id "); SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@KeyWord", SqlDbType.VarChar, 500), new SqlParameter("@Create_Time", SqlDbType.DateTime), new SqlParameter("@Create_UserId", SqlDbType.Char, 30), new SqlParameter("@SysFilter_id", SqlDbType.Char, 0x24) }; cmdParms[0].Value = model.KeyWord; cmdParms[1].Value = model.Create_Time; cmdParms[2].Value = model.Create_UserId; cmdParms[3].Value = model.SysFilter_id; return(DbHelperSQL.ExecuteSql(builder.ToString(), cmdParms) > 0); }
protected void btnSave_Click(object sender, EventArgs e) { try { BLL_SysFilter bll = new BLL_SysFilter(); DataTable dt = bll.GetList("").Tables[0]; if (dt.Rows.Count > 0) { Model_SysFilter model = new Model_SysFilter(); model = bll.GetModel(dt.Rows[0]["SysFilter_id"].ToString()); model.KeyWord = this.txtKeyWord.Text.Trim(); model.Create_Time = DateTime.Now; model.Create_UserId = loginUser.SysUser_ID; if (bll.Update(model)) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.msg('修改关键字成功', { time: 2000, icon: 1})</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.msg('修改关键字失败', { time: 2000, icon: 2})</script>"); return; } } else { Model_SysFilter model = new Model_SysFilter(); model.SysFilter_id = Guid.NewGuid().ToString(); model.Create_UserId = loginUser.SysUser_ID; model.Create_Time = DateTime.Now; model.KeyWord = this.txtKeyWord.Text.Trim(); if (bll.Add(model)) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.msg('添加关键字成功', { time: 2000, icon: 1})</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.msg('添加关键字失败', { time: 2000, icon: 2})</script>"); return; } } } catch (Exception ex) { ClientScript.RegisterStartupScript(this.GetType(), "save", "<script>layer.msg('添加关键字失败', { time: 2000, icon: 2})</script>"); return; } }
public List <Model_SysFilter> DataTableToList(DataTable dt) { List <Model_SysFilter> list = new List <Model_SysFilter>(); int count = dt.Rows.Count; if (count > 0) { for (int i = 0; i < count; i++) { Model_SysFilter item = this.dal.DataRowToModel(dt.Rows[i]); if (item != null) { list.Add(item); } } } return(list); }
public bool Update(Model_SysFilter model) { return(this.dal.Update(model)); }
public bool Add(Model_SysFilter model) { return(this.dal.Add(model)); }