📄 personscheduleplan.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Office.DAL;
using Office.Model;
using Office.BLL;
public partial class ScheduleManage_PersonSchedule_PersonSchedulePlan : System.Web.UI.Page
{
//加载显示日志信息
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.DIV1.Visible = false;
this.divTree.Visible = false;
if (Request.QueryString["sid"] != null && Request.QueryString["sid"] != "")
{
this.GetSchdule();
}
else
{
this.bt_deletes.Enabled = false;
}
}
String date = Request.QueryString["date"];
if (date != null)
{
int y = Convert.ToInt32(date.Substring(0, 4));
int m = Convert.ToInt32(date.Substring(date.IndexOf('y') + 1, date.IndexOf('m') - date.IndexOf('y') - 1));
int d = Convert.ToInt32(date.Substring(date.IndexOf('m') + 1));
DateTime dt = new DateTime(y, m, d);
this.txt_createtime.Text = dt.ToString();
this.txt_createtime.Enabled = false;
}
this.MyBind();
//获得部门数据帮定
if (Request.QueryString["set"] != null && Request.QueryString["set"].Equals("1"))
{
this.setAllStyle();
}
}
//查询所有日志信息
public IList<MeetingInfo> GetAllMeetingInfos()
{
return MeetingInfoManager.GetAllMeetingInfos();
}
//数据绑定
public void MyBind()
{
this.ddl_meetingtype.DataSource = this.GetAllMeetingInfos();
this.ddl_meetingtype.DataTextField = "MeetingName";
this.ddl_meetingtype.DataValueField = "MeetingId";
this.DataBind();
}
//插入个人日志信息
public void InsertSchedule()
{
String titel = this.txt_themes.Text;
String address = this.txt_address.Text;
int meetingid = Int32.Parse(this.ddl_meetingtype.SelectedValue);
String begintime = this.txt_begintime.Text;
String endtime = this.txt_endtime.Text;
String content = this.txt_content.Text;
String human = this.ListBox1.Text;
String createtime = this.txt_createtime.Text;
String createhuman = ((UserInfo)Session["User"]).UserId;
int ifselect = (this.CheckBox1.Checked == true ? 1 : 0);
Schedule sc = new Schedule();
sc.Title = titel;
sc.Address = address;
sc.Meeting = MeetingInfoManager.GetMeetingInfoByMeetingId(meetingid);
sc.BeginTime = DateTime.Parse(begintime);
sc.EndTime = DateTime.Parse(endtime);
sc.SchContent = content;
sc.CreateTime = DateTime.Parse(createtime);
sc.CreateUser = UserInfoManager.GetUserInfoByUserId(createhuman);
sc.IfPrivate = ifselect;
ScheduleManager.AddSchedule(sc);
}
//插入个人日志中的预约人
public void InsertHuman()
{
foreach (ListItem li in this.ListBox1.Items)
{
PreContract pc = new PreContract();
pc.UserId = li.Text;
foreach (Schedule tmp in ScheduleManager.GetAllSchedules())
{
pc.Schedule = tmp;
}
PreContractManager.AddPreContract(pc);
}
Response.Redirect("PersonSchedule.aspx");
}
//获取个人日志中的预约人
public void GetHuman()
{
foreach (PreContract tmp in PreContractManager.GetAllPreContracts())
{
if (tmp.Schedule.ScheduleId == Convert.ToInt32(Request.QueryString["sid"]))
{
this.ListBox1.Items.Add(new ListItem(tmp.UserId));
}
}
}
//修改个人日志中的预约人
public void UpdateHuman()
{
List<PreContract> list = new List<PreContract>();
int count = 0;
foreach (ListItem li in this.ListBox1.Items)
{
PreContract pre = new PreContract();
pre.PreContractId = PreContractManager.GetPreContractIdByScheduleId(Convert.ToInt32(Request.QueryString["sid"]))[count].PreContractId;
pre.UserId = li.Text;
pre.Schedule = ScheduleManager.GetScheduleByScheduleId(Convert.ToInt32(Request.QueryString["sid"]));
list.Add(pre);
count++;
}
foreach(PreContract tmp in list)
{
PreContractManager.ModifyPreContract(tmp);
}
}
//获得数据
public void GetSchdule()
{
Schedule sc = ScheduleManager.GetScheduleByScheduleId(Convert.ToInt32(Request.QueryString["sid"]));
this.txt_themes.Text = sc.Title;
this.txt_address.Text = sc.Address;
this.ddl_meetingtype.SelectedIndex = sc.Meeting.MeetingId;
this.txt_begintime.Text = sc.BeginTime.ToString();
this.txt_endtime.Text = sc.EndTime.ToString();
this.txt_content.Text = sc.SchContent;
this.GetHuman();
this.CheckBox1.Checked = sc.IfPrivate == 1 ? true : false;
this.txt_createtime.Text = sc.CreateTime.ToString();
this.txt_createtime.Enabled = false;
}
//更新数据
public void UpdateSchdule()
{
Schedule sc = new Schedule();
sc.ScheduleId = Convert.ToInt32(Request.QueryString["sid"]);
sc.Title = this.txt_themes.Text;
sc.Address = this.txt_address.Text;
sc.Meeting = new MeetingInfo(this.ddl_meetingtype.SelectedIndex+1, this.ddl_meetingtype.SelectedItem.Text);
sc.BeginTime = DateTime.Parse(this.txt_begintime.Text);
sc.EndTime = DateTime.Parse(this.txt_endtime.Text);
sc.SchContent = this.txt_content.Text;
sc.CreateUser = (UserInfo)Session["User"];
sc.IfPrivate = this.CheckBox1.Checked == true?1:0;
sc.CreateTime = DateTime.Parse(this.txt_createtime.Text);
this.txt_createtime.Enabled = false;
ScheduleManager.ModifySchedule(sc);
Response.Redirect("PersonSchedule.aspx");
}
//删除数据
public void DeleteSchdule()
{
ScheduleManager.DeleteScheduleById(Convert.ToInt32(Request.QueryString["sid"]));
Response.Redirect("PersonSchedule.aspx");
}
protected void bt_saveexit_Click(object sender, EventArgs e)
{
if (Request.QueryString["sid"] != null && Request.QueryString["sid"] != "")
{
//this.UpdateHuman();
this.UpdateSchdule();
}
else
{
this.InsertSchedule();
this.InsertHuman();
}
}
//删除
protected void bt_deletes_Click(object sender, EventArgs e)
{
this.DeleteSchdule();
}
//退出
protected void bt_exit_Click(object sender, EventArgs e)
{
Response.Redirect("PersonSchedule.aspx");
}
//自定义显示的预约人
protected void ib_otherpeoper_Click(object sender, ImageClickEventArgs e)
{
DIV1.Visible = true;
this.TreeView1.Nodes.Clear();
InitMenu();
this.TreeView1.ExpandDepth = 5;
this.divTree.Visible = true;
}
//自定义控件
private void InitMenu()
{
IList<BranchInfo> brach = BranchInfoManager.GetAllBranchInfos();
foreach (BranchInfo tmp in brach)
{
TreeNode root = new TreeNode(tmp.BranchName);
root.ImageUrl = "~/Images/menuclose.gif";
IList<DepartInfo> depart = DepartInfoManager.GetDepartInfoByBranchId(tmp.BranchId);
foreach (DepartInfo de in depart)
{
TreeNode node = new TreeNode(de.DepartName);
node.ImageUrl = "~/Images/OpenTree.gif";
IList<UserInfo> user = UserInfoManager.GetUserInfosByDepartId(de.DepartId);
foreach (UserInfo u in user)
{
TreeNode node1 = new TreeNode(u.UserId);
node1.ImageUrl = "~/Images/person.gif";
node.ChildNodes.Add(node1);
}
root.ChildNodes.Add(node);
}
this.TreeView1.Nodes.Add(root);
}
}
//控件效果
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
String selectname = this.TreeView1.SelectedNode.Text;
if (UserInfoManager.GetUserInfoByUserId(selectname) != null)
{
this.ListBox1.Items.Add(new ListItem(selectname));
this.DIV1.Visible = false;
this.divTree.Visible = false;
}
else
{
Response.Write("<script>alert('你还没有选择预约的人!');</script>");
}
}
//控件效果
protected void bt_delete_Click(object sender, EventArgs e)
{
ListItem item = ListBox1.SelectedItem;
if (item != null)
{
ListBox1.Items.Remove(item);
}
else
{
Response.Write("<script>alert('你还没有选择你要是删除的预约人!');<script>");
}
}
//部门日程中的获得预约人
public void GetListHuman()
{
foreach (PreContract tmp in PreContractManager.GetAllPreContracts())
{
if (tmp.Schedule.ScheduleId == Convert.ToInt32(Request.QueryString["Sid"]))
{
this.ListBox1.Items.Add(new ListItem(tmp.UserId));
}
}
}
//部门日程的功能
private void setAllStyle()
{
Schedule tmp = ScheduleManager.GetScheduleByScheduleId(Convert.ToInt32(Request.QueryString["Sid"]));
this.txt_themes.Text = tmp.Title;
this.txt_address.Text = tmp.Address;
this.ddl_meetingtype.SelectedIndex = tmp.Meeting.MeetingId;
this.txt_begintime.Text = tmp.BeginTime.ToString();
this.txt_endtime.Text = tmp.EndTime.ToString();
this.txt_content.Text = tmp.SchContent;
this.GetListHuman();
this.CheckBox1.Checked = tmp.IfPrivate == 1 ? true : false;
this.txt_createtime.Text = tmp.CreateTime.ToString();
this.txt_address.ReadOnly = true;
this.txt_begintime.Enabled = false;
this.txt_content.ReadOnly = true;
this.txt_createtime.Enabled = false;
this.txt_endtime.Enabled = false;
this.txt_themes.ReadOnly = true;
this.ddl_meetingtype.Enabled = false;
this.ListBox1.Enabled = false;
this.CheckBox1.Enabled = false;
this.bt_delete.Enabled = false;
this.bt_deletes.Enabled = false;
this.bt_saveexit.Enabled = false;
this.bt_exit.PostBackUrl = "../DepartSchedule/DepartSchedule.aspx";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -