/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.call_pm</param> /// <returns>ID</returns> public int Add(Model.call_pm model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [" + databaseprefix + "call_pm]("); strSql.Append("user_id,call_id,time"); strSql.Append(") values("); strSql.Append("@user_id,@call_id,@time)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@call_id", SqlDbType.Int, 4), new SqlParameter("@time", SqlDbType.DateTime) }; parameters[0].Value = model.user_id; parameters[1].Value = model.call_id; parameters[2].Value = model.time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (null != obj) { return(Convert.ToInt32(obj)); } else { return(0); } }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.call_pm</param> /// <returns>True or False</returns> public bool Update(Model.call_pm model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [" + databaseprefix + "call_pm] set "); strSql.Append("user_id=@user_id,"); strSql.Append("call_id=@call_id,"); strSql.Append("time=@time"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@call_id", SqlDbType.Int, 4), new SqlParameter("@time", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.user_id; parameters[1].Value = model.call_id; parameters[2].Value = model.time; parameters[3].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } return(false); }
private void call_pm(HttpContext context) { int uid = DTRequest.GetInt("uid", 0); int cid = DTRequest.GetInt("cid", 0); if (new BLL.call_pm().GetCount("user_id=" + uid + " and call_id=" + cid) == 0) { if (new BLL.user().GetModel(uid).point < 30) { context.Response.Write("{\"status\":0,\"msg\":\"积分不足30!\"}"); return; } Model.call_pm call = new Model.call_pm(); call.user_id = uid; call.call_id = cid; call.time = DateTime.Now; new BLL.call_pm().Add(call); Model.point model = new Model.point(); model.user_id = uid; model.value = -30; model.remark = "联系产品经理"; model.add_time = DateTime.Now; new BLL.point().Add(model); new BLL.user().UpdateField(uid, "point=point+" + model.value); context.Response.Write("{\"status\":1,\"msg\":\"成功联系产品经理!\"}"); } else { context.Response.Write("{\"status\":1,\"msg\":\"非首次联系产品经理,不重复扣除积分!\"}"); } }
/// <summary> /// 组合成对象实体 /// </summary> /// <param name="row">一行数据</param> /// <returns>Model.call_pm</returns> private Model.call_pm DataRowToModel(DataRow row) { Model.call_pm model = new Model.call_pm(); if (row != null) { if (null != row["id"] && "" != row["id"].ToString()) { model.id = int.Parse(row["id"].ToString()); } if (null != row["user_id"] && "" != row["user_id"].ToString()) { model.user_id = int.Parse(row["user_id"].ToString()); } if (null != row["call_id"] && "" != row["call_id"].ToString()) { model.call_id = int.Parse(row["call_id"].ToString()); } if (null != row["time"] && "" != row["time"].ToString()) { model.time = DateTime.Parse(row["time"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.call_pm</param> /// <returns>True Or False</returns> public bool Update(Model.call_pm model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.call_pm</param> /// <returns>ID</returns> public int Add(Model.call_pm model) { return(dal.Add(model)); }