TXLSMS.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:6k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections.Generic;
  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. public partial class TXLSMS : System.Web.UI.Page
  12. {
  13.     /// <summary>
  14.     /// 模板 
  15.     /// </summary>
  16.    public Model.Users MU = new Model.Users();
  17.     /// <summary>
  18.     /// 业务
  19.     /// </summary>
  20.    public BLL.Users BU = new BLL.Users();
  21.    /// <summary>
  22.    /// 模板 
  23.    /// </summary>
  24.    Model.Department MD = new Model.Department();
  25.    /// <summary>
  26.    /// 业务
  27.    /// </summary>
  28.    BLL.Department BD = new BLL.Department();
  29.     /// <summary>
  30.     /// 查询条件
  31.     /// </summary>
  32.     public string TiaoJian = "";
  33.     protected void Page_Load(object sender, EventArgs e)
  34.     {
  35.         LoginLogic.MatchLoad("../", "TXLSMS");
  36.         if (!IsPostBack)
  37.         {
  38.             TreeLoadSet();
  39.             TiaoJian = "";
  40.             MyDataBind(1);
  41.         }
  42.     }
  43.     /// <summary>
  44.     /// 获取信息
  45.     /// </summary>
  46.     /// <param name="pidx">页号</param>
  47.     public void MyDataBind(int pidx)
  48.     {
  49.         AspNetPager1.RecordCount = BU.GetCount(TiaoJian);
  50.         GridView1.DataSource = BU.GetPageList(20, pidx, "ID", false, TiaoJian);
  51.         GridView1.DataBind();
  52.     }
  53.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  54.     {
  55.         MyDataBind(e.NewPageIndex);
  56.     }
  57.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  58.     {
  59.         for (int i = 0; i < GridView1.Rows.Count; i++)
  60.         {
  61.             //首先判断是否是数据行
  62.             if (e.Row.RowType == DataControlRowType.DataRow)
  63.             {
  64.                 //当鼠标停留时更改背景色
  65.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  66.                 //当鼠标移开时还原背景色
  67.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  68.             }
  69.         }
  70.     }
  71.     /// <summary>
  72.     /// 角色
  73.     /// </summary>
  74.     /// <returns></returns>
  75.     public string JueSe()
  76.     {
  77.         int Id = int.Parse(Eval("PrivId").ToString());
  78.      return   OACommon.GetRole(Id);
  79.   
  80.     }
  81.     /// <summary>
  82.     /// 操作
  83.     /// </summary>
  84.     /// <returns></returns>
  85.     public string CaoZuo()
  86.     {
  87.         string Id = Eval("Id").ToString();
  88.         //编辑 清空密码 删除
  89.         string Rtstr = "<a href='UserInfo.aspx?id=" + Id + "'>编辑</a>&nbsp;&nbsp;";
  90.         Rtstr += "<a href='UserInfo.aspx?id=" + Id + "'>清空密码</a>&nbsp;&nbsp;";
  91.         Rtstr += "<a href='UserInfo.aspx?id=" + Id + "'>删除</a>&nbsp;&nbsp;";
  92.         return Rtstr;
  93.     }
  94.     
  95.     protected void TreeLoadSet()
  96.     {
  97.         TreeView1.Nodes.Clear();
  98.         object objcount = OACommon.HLP.ExecuteScalar(CommandType.Text, "select  max(parentdept) from department", null);
  99.         if (objcount != null)
  100.         {
  101.             int AllCount = int.Parse(objcount.ToString());//最深的ID
  102.             List<Model.Department> DPMT = BD.GetList();
  103.             foreach (Model.Department MD in DPMT)
  104.             {
  105.                 if (MD.ParentDept == 0)
  106.                 {
  107.                     TreeNode tn = new TreeNode();
  108.                     tn.Text = MD.DeptName;
  109.                     tn.Value = MD.ID.ToString();
  110.                     tn.ImageUrl = "~/images/node_dept.gif";
  111.                     TreeView1.Nodes.Add(tn);
  112.                 }
  113.             }
  114.             foreach (TreeNode tn in TreeView1.Nodes)
  115.             {
  116.                 CallMeTree(tn);
  117.             }
  118.         }
  119.     }
  120.     /// <summary>
  121.     /// 递归调用
  122.     /// </summary>
  123.     /// <param name="MaxDep"></param>
  124.     /// <param name="DepId"></param>
  125.     public void CallMeTree(TreeNode TNId)
  126.     {
  127.         List<Model.Department> DPMT = BD.GetList();
  128.         foreach (Model.Department MD in DPMT)
  129.         {
  130.             if (MD.ParentDept.ToString() == TNId.Value)
  131.             {
  132.                 TreeNode tn = new TreeNode();
  133.                 tn.Text = MD.DeptName;
  134.                 tn.Value = MD.ID.ToString();
  135.                 tn.ImageUrl = "~/images/node_dept.gif";
  136.                 //  Console.WriteLine(TreeView1.ExpandDepth.ToString());          
  137.                 TNId.ChildNodes.Add(tn);
  138.                 int Count = BD.GetCount("ParentDept=" + tn.Value);
  139.                 if (Count > 0)
  140.                 {
  141.                     CallMeTree(tn);
  142.                 }
  143.             }
  144.         }
  145.     }
  146.     protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
  147.     {
  148.         TiaoJian = "DeptId="+TreeView1.SelectedValue;
  149.         MyDataBind(1);
  150.     }
  151.     protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  152.     {
  153.         for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  154.         {
  155.             CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  156.             if (CheckBox1.Checked)
  157.             {
  158.                 cbox.Checked = true;
  159.             }
  160.             else
  161.             {
  162.                 cbox.Checked = false;
  163.             }
  164.         }
  165.     }
  166.     protected void DelButton1_Click(object sender, EventArgs e)
  167.     {
  168.         try
  169.         {
  170.             for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
  171.             {
  172.                 CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBoxItem");
  173.                 if (cbox.Checked)
  174.                 {
  175.                     SMSSend.Send(SessionInclude.SessionId, GridView1.Rows[i].Cells[2].Text.ToString(), Info_TextBox.Text, "SMS/SMSManager.aspx", SMSType.普通发送);
  176.                     if (CheckBox2.Checked)
  177.                     {
  178.                         SMSSend.Send(SessionInclude.SessionId, GridView1.Rows[i].Cells[2].Text.ToString(), Info_TextBox.Text, "SMS/SMSManager.aspx", SMSType.短信发送);
  179.                     }
  180.            
  181.                 }
  182.            
  183.                 }
  184.                 MessageBox.Show("发送完成!");
  185.             }
  186.             catch (Exception exp)
  187.             { MessageBox.Show(exp.Message); }
  188.             MyDataBind(AspNetPager1.CurrentPageIndex);
  189.     }
  190. }