Basf_EProject/EProject/FineUIPro.Web/Email_Send/Email_Send_Edit.aspx.cs

175 lines
5.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using FineUIPro.Web.common;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.Email_Send
{
public partial class Email_Send_Edit : PageBase
{
#region
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//按钮权限
GetButtonPower();
//加载菜单树
this.InitMenuTree();
}
}
#endregion
#region
/// <summary>
/// 加载菜单树:动态加载
/// </summary>
private void InitMenuTree()
{
this.tvMenu.Nodes.Clear();
TreeNode rootNode = new TreeNode();//定义根节点
rootNode.Text = "ALL People";
rootNode.NodeID = "0";
rootNode.Expanded = true;
rootNode.EnableCheckEvent = true;
rootNode.EnableCheckBox = true;
this.tvMenu.Nodes.Add(rootNode);
this.GetNodes(rootNode.Nodes, rootNode.NodeID);
}
#endregion
#region ()
/// <summary>
/// 遍历节点方法
/// </summary>
/// <param name="nodes">节点集合</param>
/// <param name="parentId">父节点</param>
private void GetNodes(TreeNodeCollection nodes, string parentId)
{
List<Model.Sys_User> sysUserMenu = null;
sysUserMenu = (from x in BLL.Funs.DB.Sys_User where x.Account != "gly" orderby x.UserName select x).ToList();
foreach (var q in sysUserMenu)
{
TreeNode newNode = new TreeNode();
newNode.Text = (q.UserName + "" + q.Email + ")").ToString();
newNode.NodeID = q.UserId;
newNode.CommandName = q.Email;
//newNode.NavigateUrl = q.Email;
newNode.EnableCheckEvent = true;
newNode.EnableCheckBox = true;
newNode.Selectable = true;
nodes.Add(newNode);
}
}
#endregion
#region
/// <summary>
/// 全选、全不选
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvMenu_NodeCheck(object sender, FineUIPro.TreeCheckEventArgs e)
{
if (e.Checked)
{
this.tvMenu.CheckAllNodes(e.Node.Nodes);
SetCheckParentNode(e.Node);
}
else
{
this.tvMenu.UncheckAllNodes(e.Node.Nodes);
}
}
/// <summary>
/// 选中父节点
/// </summary>
/// <param name="node"></param>
private void SetCheckParentNode(TreeNode node)
{
if (node.ParentNode != null && node.ParentNode.NodeID != "0")
{
node.ParentNode.Checked = true;
if (node.ParentNode.ParentNode.NodeID != "0")
{
SetCheckParentNode(node.ParentNode);
}
}
}
#endregion
#region
/// <summary>
/// 菜单按钮权限
/// </summary>
private void GetButtonPower()
{
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.UserId, BLL.Const.RolePowerMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnSave))
{
this.btnSave.Hidden = false;
}
}
}
#endregion
protected void btnSave_Click(object sender, EventArgs e)
{
//string mailFrom = MailHelper.MailServerFrom;
Email_Pop pop = new Email_Pop();
pop = MailHelper.getEmailPop("7EC5E991-B7A0-495A-90ED-2BE15370C959");
string mailFrom = pop.EmailYx;
string[] mailTo = null;
string mailSubject = string.Empty;
string mailBody = string.Empty;
string mailAttch = string.Empty;
string mailCode = string.Empty;
string mailPriority = string.Empty;
string[] mailCC = null;
string resultMessage = "";
List<string> namelist = new List<string>();
foreach (TreeNode tn in this.tvMenu.GetCheckedNodes())
{
if (tn.NodeID != "0")
{
namelist.Add(tn.CommandName);
}
}
mailTo = namelist.ToList().ToArray();
mailSubject = this.txtSendTitle.Text.Trim();
try
{
string templetpath = txtSendContent.Text.Trim();
mailBody = templetpath;
bool f = MailHelper.SendNetMail(pop, mailFrom, mailTo, mailSubject, mailBody, mailAttch, mailCode, mailPriority, mailCC, out resultMessage);
if (f == true)
{
ShowNotify("Send Successfully!", MessageBoxIcon.Success);
}
else
{
ShowNotify(resultMessage, MessageBoxIcon.Error);
}
}
catch (Exception ex)
{
ShowNotify(ex.Message, MessageBoxIcon.Success);
}
}
}
}