CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/TestRun/Meeting/MeetingInitiateEdit.aspx.cs

233 lines
9.0 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 BLL;
using System;
namespace FineUIPro.Web.TestRun.Meeting
{
public partial class MeetingInitiateEdit : PageBase
{
#region
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string id = Request.Params["id"];
if (!string.IsNullOrEmpty(id))
{
Model.Driver_Meeting data = BLL.MeetingService.GetMeetingById(id);
if (data != null)
{
this.hdId.Text = id;
this.txtMeetingName.Text = data.MeetingName;
this.txtStartTime.Text = data.StartTime.HasValue ? string.Format("{0:yyyy-MM-dd hh:mm:ss}", data.StartTime) : "";
this.txtEndTime.Text = data.EndTime.HasValue ? string.Format("{0:yyyy-MM-dd hh:mm:ss}", data.EndTime) : "";
this.txtMeetingAddress.Text = data.MeetingAddress;
this.txtMeetingUrl.Text = data.MeetingUrl;
this.txtInitiationDate.Text = data.InitiationDate.HasValue ? string.Format("{0:yyyy-MM-dd}", data.InitiationDate) : "";
this.txtMeetingContent.Text = data.MeetingContent;
this.rblMeetingType.SelectedValue = data.MeetingType;
}
}
else
{
this.txtStartTime.Text = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd hh:mm:ss}", DateTime.Now);
this.txtInitiationDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
}
InitMenuTree();
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
SaveData(BLL.Const.BtnSave);
ShowNotify("保存成功!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
}
/// <summary>
/// 保存数据
/// </summary>
/// <param name="type"></param>
private void SaveData(string type)
{
string id = Request.Params["id"];
Model.Driver_Meeting newData = new Model.Driver_Meeting();
newData.MeetingName = this.txtMeetingName.Text.Trim();
newData.StartTime = Funs.GetNewDateTime(this.txtStartTime.Text.Trim());
newData.EndTime = Funs.GetNewDateTime(this.txtEndTime.Text.Trim());
newData.MeetingAddress = this.txtMeetingAddress.Text.Trim();
newData.MeetingUrl = this.txtMeetingUrl.Text.Trim();
newData.InitiationDate = Funs.GetNewDateTime(this.txtInitiationDate.Text.Trim());
newData.MeetingContent = this.txtMeetingContent.Text.Trim();
newData.MeetingType = this.rblMeetingType.SelectedValue;
newData.ProjectId = this.CurrUser.LoginProjectId;
if (!string.IsNullOrEmpty(id))
{
newData.MeetingId = id;
BLL.MeetingService.UpdateMeeting(newData);
}
else
{
if (!string.IsNullOrEmpty(this.hdId.Text))
{
newData.MeetingId = this.hdId.Text.Trim();
}
else
{
newData.MeetingId = SQLHelper.GetNewID(typeof(Model.Driver_Meeting));
this.hdId.Text = newData.MeetingId;
}
BLL.MeetingService.AddMeeting(newData);
}
#region
BLL.MeetingItemService.DeleteMeetingItemByMeetingId(this.hdId.Text);
TreeNode[] nodes = this.tvAttendMeetingsPerson.GetCheckedNodes();
if (nodes.Length > 0)
{
foreach (TreeNode tn in nodes)
{
if (tn.NodeID != "0")
{
Model.Driver_MeetingItem newItem = new Model.Driver_MeetingItem
{
MeetingItemId = SQLHelper.GetNewID(typeof(Model.Driver_MeetingItem)),
MeetingId = this.hdId.Text,
UserId = tn.NodeID,
};
BLL.MeetingItemService.AddMeetingItem(newItem);
}
}
}
#endregion
}
#endregion
#region
/// <summary>
/// 初始化树
/// </summary>
/// <param name="menuList">单位集合</param>
private void InitMenuTree()
{
this.tvAttendMeetingsPerson.Nodes.Clear();
var units = BLL.UnitService.GetUnitByProjectIdList(this.CurrUser.LoginProjectId);
foreach (var item in units)
{
TreeNode rootNode = new TreeNode
{
Text = item.UnitName,
NodeID = item.UnitId,
EnableCheckBox = true,
EnableCheckEvent = true,
Expanded = true
};
this.tvAttendMeetingsPerson.Nodes.Add(rootNode);
this.BoundTree(rootNode.Nodes, rootNode.NodeID);
}
}
/// <summary>
/// 遍历增加子节点
/// </summary>
/// <param name="nodes"></param>
/// <param name="menuId"></param>
private void BoundTree(TreeNodeCollection nodes, string superMenuId)
{
var menus = BLL.UserService.GetUserByUnitId(this.CurrUser.LoginProjectId, superMenuId);
foreach (var item in menus)
{
TreeNode chidNode = new TreeNode
{
Text = item.Text,
NodeID = item.Value,
EnableCheckBox = true,
EnableCheckEvent = true
};
var items = BLL.MeetingItemService.GetMeetingItemByMeetingId(this.hdId.Text.Trim());
if (items.Count > 0)
{
foreach (var i in items)
{
if (i.UserId == item.Value)
{
chidNode.Checked = true;
chidNode.Expanded = true;
chidNode.Selectable = true;
//var meeting = BLL.MeetingService.GetMeetingById(this.hdId.Text.Trim());
//if (meeting != null)
//{
// if (meeting.States == "2")
// {
// if (i.IsMeeting == true)
// {
// chidNode.Text = item.Text + "(可按时参加)";
// }
// else if (i.IsMeeting == false)
// {
// chidNode.Text = item.Text + "(因故不参加:" + i.Feedback + "";
// }
// else
// {
// chidNode.Text = item.Text + "(暂未反馈)";
// }
// }
//}
}
}
}
nodes.Add(chidNode);
}
}
#endregion
#region
/// <summary>
/// 全选、全不选
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvAttendMeetingsPerson_NodeCheck(object sender, FineUIPro.TreeCheckEventArgs e)
{
if (e.Checked)
{
this.tvAttendMeetingsPerson.CheckAllNodes(e.Node.Nodes);
SetCheckParentNode(e.Node);
}
else
{
this.tvAttendMeetingsPerson.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
}
}