gw_urge.aspx.cs
上传用户:lishan0805
上传日期:2019-12-08
资源大小:12048k
文件大小:4k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. using COM.OA.Entity;
  13. using System.Collections.Generic;
  14. using COM.OA.BLL;
  15. public partial class gw_gw_urge : System.Web.UI.Page
  16. {
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.     }
  20.     //联动
  21.     protected void ddldepartment_SelectedIndexChanged(object sender, EventArgs e)
  22.     {
  23.         //取部门的值
  24.         string ddldepartment = this.ddldepartment.Text;
  25.         SqlParameter parambumen = new SqlParameter("@deptid", ddldepartment);
  26.         IList<liandongren> lists = BLLGeneric.Select<liandongren>(CommandType.StoredProcedure, "liandong", parambumen);
  27.         this.ddlname.DataSource = lists;
  28.         this.ddlname.DataTextField = "Em_name";
  29.         this.ddlname.DataValueField = "Em_name";
  30.         this.ddlname.DataBind();
  31.     }
  32.     //发送按钮
  33.     protected void btnSend_Click(object sender, EventArgs e)
  34.     {
  35.         //接收人
  36.         string takeuser = this.Request.Form["sendto"];
  37.         //判断接收人是否为空
  38.         if (takeuser == null || takeuser == "")
  39.         {
  40.             this.Response.Write(string.Format(GetRedirect.WINALERT, "接收人不能为空"));
  41.             return;
  42.         }
  43.         //标题
  44.         string title = this.Request.Form["mtitle"];
  45.         //判断标题是否为空
  46.         if (title == null || title == "")
  47.         {
  48.             this.Response.Write(string.Format(GetRedirect.WINALERT, "请输入标题!!"));
  49.             return;
  50.         }
  51.         //内容
  52.         string content = this.FreeTextBox1.Text;
  53.         //判断内容是否为空
  54.         if (content == null || content == "")
  55.         {
  56.             this.Response.Write(string.Format(GetRedirect.WINALERT, "请输入催办内容!!"));
  57.             return;
  58.         }
  59.        
  60.         //接收人id
  61.         int takeuserid = 0;
  62.         string sql = "em_name='{0}'";
  63.         sql = string.Format(sql, takeuser);
  64.         IList<employee> elist = employeeBLL.Select(sql);
  65.         if (elist.Count == 1)
  66.         {
  67.             foreach (employee em in elist)
  68.             {
  69.                 takeuserid = em.em_id;
  70.             }
  71.             string uid = "u_em_id={0}";
  72.             uid = string.Format(uid, takeuserid);
  73.             IList<users> u = usersBLL.Select(uid);
  74.             if (u.Count == 1)
  75.             {
  76.                 foreach (users user in u)
  77.                 {
  78.                     takeuserid = user.u_id;
  79.                 }
  80.             }
  81.         }
  82.         //发送人
  83.         string username = this.Request.Form["username"];
  84.         //发送人id
  85.         int userid = 0;
  86.         string sql3 = "u_username='{0}'";
  87.         sql3 = string.Format(sql3, username);
  88.         IList<users> userlist = usersBLL.Select(sql3);
  89.         if (userlist.Count == 1)
  90.         {
  91.             foreach (users u in userlist)
  92.             {
  93.                 userid = u.u_id;
  94.             }
  95.         }
  96.         //发布时间
  97.         DateTime time = DateTime.Parse(this.Request.Form["txtsendtime"]);
  98.         //是否回执
  99.         int isreturn = 0;
  100.         //群id
  101.         int gid = 1;
  102.         message mess = new message();
  103.         mess.m_title = title;//标题
  104.         mess.m_content = content;//内容
  105.         mess.m_u_id = takeuserid;//接收人id
  106.         mess.m_sendu_id = userid;//发送人id 
  107.         mess.m_g_id = gid;//群组id
  108.         mess.m_releasetime = time;//发送时间
  109.         mess.m_isreturn = isreturn;//是否回执
  110.         int flag = messageBLL.Insert(mess);
  111.         if (flag == 0)
  112.         {
  113.             this.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('短消息发送失败!!');</script>");
  114.         }
  115.         this.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('短消息发送成功!!');</script>");
  116.     }
  117. }