public bool Appeal(long userid, int type, string content, string picpath, out string message) { lgk.Model.tb_user userInfo = userBLL.GetModel(userid); lgk.Model.tb_leaveMsg leaveMsg = new lgk.Model.tb_leaveMsg() { MsgTitle = "", MsgContent = content.Trim(), LeaveTime = DateTime.Now, IsRead = 0, IsReply = 0, FromUserType = 1, UserID = userid, UserCode = userInfo.UserCode, FromIDIsDel = 0, ToIDIsDel = 0, ToUserID = 1, ToUserType = 2, ToUserCode = "admin", MsgType = type, Pic = picpath }; if (leaveMsgBLL.Add(leaveMsg) > 0) { message = "发送成功"; return(true); } else { message = "发送失败"; return(false); } }
protected void btnSubmit_Click(object sender, EventArgs e) { lgk.Model.tb_admin fromAdmin = adminBLL.GetModel(getLoginID()); lgk.Model.tb_user user = null;//收件人 if (textUserCode.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('留言对象不能为空!');", true); return; } //验证是否存在会员 user = userBLL.GetModel(GetUserID(textUserCode.Value.Trim())); if (user == null) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('不存在的账号!');", true); return; } if (user.IsOpend == 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('会员未开通!');", true); return; } if (textTitle.Value == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('标题不能为空!');", true); return; } if (txtPubContext.Text == "") { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('内容不能为空!');", true); return; } lgk.Model.tb_leaveMsg leaveMsg = new lgk.Model.tb_leaveMsg() { MsgTitle = textTitle.Value, MsgContent = txtPubContext.Text, LeaveTime = DateTime.Now, IsRead = 0, IsReply = 0, FromUserType = 2, UserID = 1, UserCode = "admin", FromIDIsDel = 0, ToIDIsDel = 0, }; leaveMsg.ToUserType = 1; leaveMsg.ToUserID = user.UserID; leaveMsg.ToUserCode = user.UserCode; if (leaveMsgBLL.Add(leaveMsg) > 0) { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('发送成功!');window.location.href='LeaveOut.aspx';", true); } else { ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('发送失败!');", true); } }
/// <summary> /// 增加一条数据 /// </summary> public long Add(lgk.Model.tb_leaveMsg model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into tb_leaveMsg("); strSql.Append("MsgTitle,MsgContent,LeaveTime,IsRead,IsReply,FromUserType,UserID,UserCode,FromIDIsDel,ToUserType,ToUserID,ToUserCode,ToIDIsDel,MsgType,Pic)"); strSql.Append(" values ("); strSql.Append("@MsgTitle,@MsgContent,@LeaveTime,@IsRead,@IsReply,@FromUserType,@UserID,@UserCode,@FromIDIsDel,@ToUserType,@ToUserID,@ToUserCode,@ToIDIsDel,@MsgType,@Pic)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@MsgTitle", SqlDbType.VarChar, 100), new SqlParameter("@MsgContent", SqlDbType.Text), new SqlParameter("@LeaveTime", SqlDbType.DateTime), new SqlParameter("@IsRead", SqlDbType.Int, 4), new SqlParameter("@IsReply", SqlDbType.Int, 4), new SqlParameter("@FromUserType", SqlDbType.Int, 4), new SqlParameter("@UserID", SqlDbType.BigInt, 8), new SqlParameter("@UserCode", SqlDbType.VarChar, 20), new SqlParameter("@FromIDIsDel", SqlDbType.Int, 4), new SqlParameter("@ToUserType", SqlDbType.Int, 4), new SqlParameter("@ToUserID", SqlDbType.BigInt, 8), new SqlParameter("@ToUserCode", SqlDbType.VarChar, 20), new SqlParameter("@ToIDIsDel", SqlDbType.Int, 4), new SqlParameter("@MsgType", SqlDbType.Int, 4), new SqlParameter("@Pic", SqlDbType.VarChar, 200) }; parameters[0].Value = model.MsgTitle; parameters[1].Value = model.MsgContent; parameters[2].Value = model.LeaveTime; parameters[3].Value = model.IsRead; parameters[4].Value = model.IsReply; parameters[5].Value = model.FromUserType; parameters[6].Value = model.UserID; parameters[7].Value = model.UserCode; parameters[8].Value = model.FromIDIsDel; parameters[9].Value = model.ToUserType; parameters[10].Value = model.ToUserID; parameters[11].Value = model.ToUserCode; parameters[12].Value = model.ToIDIsDel; parameters[13].Value = model.MsgType; parameters[14].Value = model.Pic; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt64(obj)); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (txtTitle.Value == "") { MessageBox.ShowBox(this.Page, GetLanguage("TitleIsNull"), Library.Enums.ModalTypes.warning);//标题不能为空 return; } if (txtPubContext.Text == "") { MessageBox.ShowBox(this.Page, GetLanguage("ContentIsNull"), Library.Enums.ModalTypes.warning);//内容不能为空 return; } lgk.Model.tb_leaveMsg leaveMsg = new lgk.Model.tb_leaveMsg() { MsgTitle = SafeHelper.GetSafeSqlandHtml(txtTitle.Value), MsgContent = SafeHelper.GetSafeSqlandHtml(this.txtPubContext.Text.Trim()), LeaveTime = DateTime.Now, IsRead = 0, IsReply = 0, FromUserType = 1, UserID = LoginUser.UserID, UserCode = LoginUser.UserCode, FromIDIsDel = 0, ToIDIsDel = 0, ToUserID = 1, ToUserType = 2, ToUserCode = "admin" }; if (leaveMsgBLL.Add(leaveMsg) > 0) { MessageBox.ShowBox(this.Page, GetLanguage("SentSuccessfully"), Library.Enums.ModalTypes.success, "LeaveOut.aspx");//发送成功 } else { MessageBox.ShowBox(this.Page, GetLanguage("SendFailed"), Library.Enums.ModalTypes.error);//发送失败 } }
/// <summary> /// 填充留言表 /// </summary> /// <param name="id">显示的留言id</param> protected void BindData(string id) { long value = 0; if (long.TryParse(id, out value)) { lgk.Model.tb_leaveMsg leaveMsg = leaveMsgBLL.GetModel(value); lblSendTitle.Text = leaveMsg.MsgTitle; lblSendContent.Text = leaveMsg.MsgContent; lblSendDate.Text = leaveMsg.LeaveTime.ToString("yyyy-MM-dd HH:mm:ss"); if (leaveMsg.FromUserType == 1) { lgk.Model.tb_user user = userBLL.GetModel(Convert.ToInt64(leaveMsg.UserID)); lblSendMember.Text = user.UserCode; } else { lgk.Model.tb_admin admin = adminBLL.GetModel(Convert.ToInt32(leaveMsg.UserID)); lblSendMember.Text = admin.UserName; } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(lgk.Model.tb_leaveMsg model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update tb_leaveMsg set "); strSql.Append("MsgTitle=@MsgTitle,"); strSql.Append("MsgContent=@MsgContent,"); strSql.Append("LeaveTime=@LeaveTime,"); strSql.Append("IsRead=@IsRead,"); strSql.Append("IsReply=@IsReply,"); strSql.Append("FromUserType=@FromUserType,"); strSql.Append("UserID=@UserID,"); strSql.Append("UserCode=@UserCode,"); strSql.Append("FromIDIsDel=@FromIDIsDel,"); strSql.Append("ToUserType=@ToUserType,"); strSql.Append("ToUserID=@ToUserID,"); strSql.Append("ToUserCode=@ToUserCode,"); strSql.Append("ToIDIsDel=@ToIDIsDel,"); strSql.Append("MsgType=@MsgType"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@MsgTitle", SqlDbType.VarChar, 100), new SqlParameter("@MsgContent", SqlDbType.Text), new SqlParameter("@LeaveTime", SqlDbType.DateTime), new SqlParameter("@IsRead", SqlDbType.Int, 4), new SqlParameter("@IsReply", SqlDbType.Int, 4), new SqlParameter("@FromUserType", SqlDbType.Int, 4), new SqlParameter("@UserID", SqlDbType.BigInt, 8), new SqlParameter("@UserCode", SqlDbType.VarChar, 20), new SqlParameter("@FromIDIsDel", SqlDbType.Int, 4), new SqlParameter("@ToUserType", SqlDbType.Int, 4), new SqlParameter("@ToUserID", SqlDbType.BigInt, 8), new SqlParameter("@ToUserCode", SqlDbType.VarChar, 20), new SqlParameter("@ToIDIsDel", SqlDbType.Int, 4), new SqlParameter("@MsgType", SqlDbType.Int, 4), new SqlParameter("@ID", SqlDbType.BigInt, 8) }; parameters[0].Value = model.MsgTitle; parameters[1].Value = model.MsgContent; parameters[2].Value = model.LeaveTime; parameters[3].Value = model.IsRead; parameters[4].Value = model.IsReply; parameters[5].Value = model.FromUserType; parameters[6].Value = model.UserID; parameters[7].Value = model.UserCode; parameters[8].Value = model.FromIDIsDel; parameters[9].Value = model.ToUserType; parameters[10].Value = model.ToUserID; parameters[11].Value = model.ToUserCode; parameters[12].Value = model.ToIDIsDel; parameters[13].Value = model.MsgType; parameters[14].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public lgk.Model.tb_leaveMsg GetModel(long ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,MsgTitle,MsgContent,LeaveTime,IsRead,IsReply,FromUserType,UserID,UserCode,FromIDIsDel,ToUserType,ToUserID,ToUserCode,ToIDIsDel,MsgType,Pic from tb_leaveMsg "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.BigInt) }; parameters[0].Value = ID; lgk.Model.tb_leaveMsg model = new lgk.Model.tb_leaveMsg(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["MsgTitle"] != null && ds.Tables[0].Rows[0]["MsgTitle"].ToString() != "") { model.MsgTitle = ds.Tables[0].Rows[0]["MsgTitle"].ToString(); } if (ds.Tables[0].Rows[0]["MsgContent"] != null && ds.Tables[0].Rows[0]["MsgContent"].ToString() != "") { model.MsgContent = ds.Tables[0].Rows[0]["MsgContent"].ToString(); } if (ds.Tables[0].Rows[0]["LeaveTime"] != null && ds.Tables[0].Rows[0]["LeaveTime"].ToString() != "") { model.LeaveTime = DateTime.Parse(ds.Tables[0].Rows[0]["LeaveTime"].ToString()); } if (ds.Tables[0].Rows[0]["IsRead"] != null && ds.Tables[0].Rows[0]["IsRead"].ToString() != "") { model.IsRead = int.Parse(ds.Tables[0].Rows[0]["IsRead"].ToString()); } if (ds.Tables[0].Rows[0]["IsReply"] != null && ds.Tables[0].Rows[0]["IsReply"].ToString() != "") { model.IsReply = int.Parse(ds.Tables[0].Rows[0]["IsReply"].ToString()); } if (ds.Tables[0].Rows[0]["FromUserType"] != null && ds.Tables[0].Rows[0]["FromUserType"].ToString() != "") { model.FromUserType = int.Parse(ds.Tables[0].Rows[0]["FromUserType"].ToString()); } if (ds.Tables[0].Rows[0]["UserID"] != null && ds.Tables[0].Rows[0]["UserID"].ToString() != "") { model.UserID = long.Parse(ds.Tables[0].Rows[0]["UserID"].ToString()); } if (ds.Tables[0].Rows[0]["UserCode"] != null && ds.Tables[0].Rows[0]["UserCode"].ToString() != "") { model.UserCode = ds.Tables[0].Rows[0]["UserCode"].ToString(); } if (ds.Tables[0].Rows[0]["FromIDIsDel"] != null && ds.Tables[0].Rows[0]["FromIDIsDel"].ToString() != "") { model.FromIDIsDel = int.Parse(ds.Tables[0].Rows[0]["FromIDIsDel"].ToString()); } if (ds.Tables[0].Rows[0]["ToUserType"] != null && ds.Tables[0].Rows[0]["ToUserType"].ToString() != "") { model.ToUserType = int.Parse(ds.Tables[0].Rows[0]["ToUserType"].ToString()); } if (ds.Tables[0].Rows[0]["ToUserID"] != null && ds.Tables[0].Rows[0]["ToUserID"].ToString() != "") { model.ToUserID = long.Parse(ds.Tables[0].Rows[0]["ToUserID"].ToString()); } if (ds.Tables[0].Rows[0]["ToUserCode"] != null && ds.Tables[0].Rows[0]["ToUserCode"].ToString() != "") { model.ToUserCode = ds.Tables[0].Rows[0]["ToUserCode"].ToString(); } if (ds.Tables[0].Rows[0]["ToIDIsDel"] != null && ds.Tables[0].Rows[0]["ToIDIsDel"].ToString() != "") { model.ToIDIsDel = int.Parse(ds.Tables[0].Rows[0]["ToIDIsDel"].ToString()); } if (ds.Tables[0].Rows[0]["MsgType"] != null && ds.Tables[0].Rows[0]["MsgType"].ToString() != "") { model.MsgType = int.Parse(ds.Tables[0].Rows[0]["MsgType"].ToString()); } if (ds.Tables[0].Rows[0]["Pic"] != null && ds.Tables[0].Rows[0]["Pic"].ToString() != "") { model.Pic = ds.Tables[0].Rows[0]["Pic"].ToString(); } return(model); } else { return(null); } }