/// <summary> /// 得到一个对象实体 /// </summary> public System.Model.t_custom_feedback GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id, customId, memo, pudate "); strSql.Append(" from t_custom_feedback "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; System.Model.t_custom_feedback model = new System.Model.t_custom_feedback(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } model.customId = ds.Tables[0].Rows[0]["customId"].ToString(); model.memo = ds.Tables[0].Rows[0]["memo"].ToString(); model.pudate = ds.Tables[0].Rows[0]["pudate"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(System.Model.t_custom_feedback model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into t_custom_feedback("); strSql.Append("customId,memo,pudate"); strSql.Append(") values ("); strSql.Append("@customId,@memo,@pudate"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@customId", SqlDbType.NVarChar, 50), new SqlParameter("@memo", SqlDbType.NVarChar, -1), new SqlParameter("@pudate", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.customId; parameters[1].Value = model.memo; parameters[2].Value = model.pudate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(System.Model.t_custom_feedback model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update t_custom_feedback set "); strSql.Append(" customId = @customId , "); strSql.Append(" memo = @memo , "); strSql.Append(" pudate = @pudate "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@customId", SqlDbType.NVarChar, 50), new SqlParameter("@memo", SqlDbType.NVarChar, -1), new SqlParameter("@pudate", SqlDbType.NVarChar, 50) }; parameters[0].Value = model.id; parameters[1].Value = model.customId; parameters[2].Value = model.memo; parameters[3].Value = model.pudate; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 获得数据列表 /// </summary> public List <System.Model.t_custom_feedback> DataTableToList(DataTable dt) { List <System.Model.t_custom_feedback> modelList = new List <System.Model.t_custom_feedback>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { System.Model.t_custom_feedback model; for (int n = 0; n < rowsCount; n++) { model = new System.Model.t_custom_feedback(); if (dt.Rows[n]["id"].ToString() != "") { model.id = int.Parse(dt.Rows[n]["id"].ToString()); } model.customId = dt.Rows[n]["customId"].ToString(); model.memo = dt.Rows[n]["memo"].ToString(); model.pudate = dt.Rows[n]["pudate"].ToString(); modelList.Add(model); } } return(modelList); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string res = ""; JsonData jsonResult = new JsonData(); try { string memberid = _bll.getUserToke(Utility.Helper.gerString(Request["memberid"])); string text = Request["text"] != null?Utility.Helper.Checkstr(Request["text"]) : ""; #region 意见反馈 if (!string.IsNullOrEmpty(memberid) && !string.IsNullOrEmpty(text)) { System.Model.t_custom_feedback tcf = new System.Model.t_custom_feedback(); tcf.customId = memberid; tcf.memo = text; tcf.pudate = System.DateTime.Now.ToString(); _bll.tcfbll.Add(tcf); jsonResult["res"] = (int)MyEnum.ResultEnum.成功; jsonResult["msg"] = "已收到您的反馈,我们会尽快处理"; jsonResult["code"] = ""; } else { jsonResult["res"] = (int)MyEnum.ResultEnum.失败; jsonResult["msg"] = "反馈失败了"; jsonResult["code"] = "参数缺失"; } #endregion } catch (Exception ex) { jsonResult["result"] = (int)MyEnum.ResultEnum.系统错误; jsonResult["msg"] = "服务器繁忙,请稍后再试"; jsonResult["code"] = ex.Message; } res = JsonMapper.ToJson(jsonResult); res = MyString.UnicodeToString(res); Response.Write(res); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(System.Model.t_custom_feedback model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(System.Model.t_custom_feedback model) { return(dal.Add(model)); }