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

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using COM.OA.BLL;
  11. using System.Collections.Generic;
  12. using COM.OA.Entity;
  13. using System.Data.SqlClient;
  14. public partial class _Default : System.Web.UI.Page 
  15. {
  16.     protected void Page_Load(object sender, EventArgs e)
  17.     {
  18.         
  19.        
  20.     }
  21.     //清空
  22.     protected void Button6_Click(object sender, EventArgs e)
  23.     {
  24.         this.btn_xiaoxi.Text = "";
  25.         this.txt_jieshouren.Text = "";     
  26.     }
  27.     protected void Button5_Click(object sender, EventArgs e)
  28.     {
  29.         //接收标题
  30.         string biaoti = this.Request.Form["txt_biaoti"];
  31.         //取部门
  32.         string bumen = this.ddl_bumen.Text;
  33.         //取对象
  34.         string duixiang = this.ddl_duixiang.Text;
  35.         //取消息内容
  36.         string xiaoxi = this.btn_xiaoxi.Text;
  37.         //取接收人,
  38.         string jieshouren1 = this.txt_jieshouren.Text;
  39.         string jieshouren=this.ddl_duixiang.Text;
  40.         if (duixiang == null || duixiang == "")
  41.         {
  42.             this.Response.Write(string.Format(GetRedirect.WINALERT, "对象不能为空"));
  43.             this.ddl_duixiang.Focus();
  44.             return;
  45.         }
  46.         else if (jieshouren1 == null || jieshouren1 == "")
  47.         {
  48.             this.Response.Write(string.Format(GetRedirect.WINALERT, "接收人不能为空"));
  49.             this.txt_jieshouren.Focus();
  50.             return;
  51.         }
  52.         
  53.         else if (xiaoxi == null || xiaoxi == "")
  54.         {
  55.             this.Response.Write(string.Format(GetRedirect.WINALERT, "消息不能为空"));
  56.             this.btn_xiaoxi.Focus=true;
  57.             return;
  58.         }
  59.       
  60.         //取对象
  61.         //string duixiang = this.ddl_duixiang.Text;       
  62.         else
  63.         {
  64.             //设置where语句,将接收人格式化成SQL语句查接收人ID
  65.             String where = "em_name='{0}'";
  66.             where = string.Format(where, jieshouren);
  67.             IList<employee> list = employeeBLL.Select(where);
  68.             employee emp = list[0];
  69.             int jieshoureni = emp.em_id;
  70.             String where1 = "u_em_id='{0}'";
  71.             where1 = string.Format(where1, jieshoureni);
  72.             IList<users> list1 = usersBLL.Select(where1);
  73.             users uu=list1[0];
  74.             int jieshourenid = uu.u_id;
  75.             
  76.             //取当前时间
  77.             DateTime time = DateTime.Now;
  78.             //取发送人
  79.             //取登陆人信息 
  80.             COM.OA.Entity.users loginuser = Session["loginuser"] as COM.OA.Entity.users;
  81.             //如果取不到跳转到登陆页
  82.             if (loginuser == null)
  83.             {
  84.                 this.Response.Write(string.Format(GetRedirect.ALLREDIRECT, "../login.aspx"));
  85.             }
  86.             else
  87.             {
  88.                 int sendid = loginuser.u_id;
  89.                 //往消息实体类里存值
  90.                 message mage = new message();
  91.                 mage.m_title = biaoti;
  92.                 mage.m_content = xiaoxi;
  93.                 mage.m_releasetime = time;
  94.                 mage.m_sendu_id = sendid;
  95.                 mage.m_u_id = jieshourenid;
  96.                 mage.m_g_id = 1;
  97.                 //回执 是:1  否:0
  98.                 mage.m_isreturn = 0;
  99.                 //往数据库里插入数据
  100.                 messageBLL.Insert(mage);
  101.                 this.Response.Write(string.Format(GetRedirect.WINALERT, "插入成功"));
  102.             }
  103.         }
  104.     }
  105.     protected void ddl_bumen_SelectedIndexChanged(object sender, EventArgs e)
  106.     {
  107.         //2级连动,取部门
  108.         String bumen=this.ddl_bumen.Text;
  109.         // String where = "em_dept_id='{0}'";
  110.         //  where = string.Format(where,bumen);
  111.         //   IList<employee> list = employeeBLL.Select(where);
  112.         //根据部门查询子数据
  113.         SqlParameter parambumen = new SqlParameter("@deptid", bumen);
  114.          IList<liandongren> lists = BLLGeneric.Select<liandongren>(CommandType.StoredProcedure, "liandong", parambumen);
  115.         //配置数据源
  116.          this.ddl_duixiang.DataSource = lists;
  117.         //绑定TEXT,VALUE属性
  118.          this.ddl_duixiang.DataTextField = "Em_name";
  119.          this.ddl_duixiang.DataValueField = "Em_name";
  120.         //this.ddl_duixiang.DataValueField = "Em_id";
  121.         //绑定
  122.          this.ddl_duixiang.DataBind();
  123.     }
  124.     
  125.     protected void Button4_Click(object sender, EventArgs e)
  126.     {
  127.         this.txt_jieshouren.Text = "";
  128.     }
  129.     //添加接收人
  130.     protected void Button1_Click(object sender, EventArgs e)
  131.     {
  132.         string duixiang=this.ddl_duixiang.Text;
  133.         this.txt_jieshouren.Text = duixiang;
  134.     }
  135.     //部门群发
  136.     protected void Button3_Click(object sender, EventArgs e)
  137.     {
  138.        this.Response.Write(string.Format(GetRedirect.REDIRECT,"bumenqunfa.aspx"));
  139.         ////取部门
  140.         //string bumen=this.ddl_bumen.Text;
  141.         //SqlParameter parambumen = new SqlParameter("@deptid", bumen);
  142.         //IList<liandongren> lists = BLLGeneric.Select<liandongren>(CommandType.StoredProcedure, "liandong", parambumen);
  143.        
  144.         ////取消息内容
  145.         //string xiaoxi = this.btn_xiaoxi.Text;       
  146.         ////接收标题
  147.         //string biaoti = this.Request.Form["txt_biaoti"];
  148.         ////取当前时间
  149.         //DateTime time = DateTime.Now;
  150.         ////取发送人
  151.         //int sendid = 1;
  152.         ////往消息实体类里存值
  153.         //message mage = new message();
  154.         //mage.m_title = biaoti;
  155.         //mage.m_content = xiaoxi;
  156.         //mage.m_releasetime = time;
  157.         //mage.m_sendu_id = sendid;
  158.         
  159.         //mage.m_g_id = 1;
  160.         ////回执 是:1  否:0
  161.         //mage.m_isreturn = 0;
  162.         
  163.         ////循环取接收人
  164.         //if (lists.Count > 0)
  165.         //{
  166.         //    foreach (liandongren jdr in lists)
  167.         //    {
  168.         //        int jieshourenid = jdr.Em_id;
  169.         //        mage.m_u_id = jieshourenid;
  170.         //        //往数据库里插入数据
  171.         //        messageBLL.Insert(mage);
  172.         //    }
  173.         //}
  174.         //this.Response.Write(string.Format(GetRedirect.WINALERT,"插入成功"));
  175.         
  176.     }
  177.     protected void Button2_Click(object sender, EventArgs e)
  178.     {
  179.         this.Response.Write(string.Format(GetRedirect.REDIRECT, "bumenqunfa.aspx"));
  180.     }
  181. }