/// <summary> /// 添加日程信息 /// </summary> /// <param name="user"></param> private void AddSchedule(User user) { Schedule schedule = GiveSchedule(user); int i = ScheduleManager.AddSchedule(schedule); if (i != 0) { if (this.lbUserName.Items.Count > 0) { foreach (ListItem li in lbUserName.Items) { PreContract preContract = new PreContract(); preContract.Schedule.ScheduleId = i; preContract.UserId = li.Value; int count = PreContractManager.AddPreContract(preContract); if (count == 0) { ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('添加失败!')", true); break; } } Response.Redirect("PersonSchedule.aspx"); } else { Response.Redirect("PersonSchedule.aspx"); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('添加失败!')", true); } }
/// <summary> /// 显示日程信息 /// </summary> /// <param name="schedule"></param> private void ShowSchedule(Schedule schedule) { this.txtTitle.Text = schedule.Title; this.txtAddress.Text = schedule.SchContent; this.txtBeginTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", schedule.BeginTime); this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss}", schedule.EndTime); this.txtContent.Text = schedule.SchContent; this.lblUserName.Text = schedule.CreateUser.UserName; IList <PreContract> preContracts = PreContractManager.GetPreContractByScheduleId(schedule.ScheduleId); if (preContracts.Count != 0) { foreach (PreContract pre in preContracts) { User us = UserManager.GetUserById(pre.UserId); Depart depart = DepartInfoManager.GetDepartGetById(us.DepartId); ListItem item = new ListItem(depart.DepartName + "-" + us.UserName, us.UserId); this.lbUserName.Items.Add(item); } } if (schedule.IfPrivate == 1) { this.cboPrivate.Checked = true; } else { this.cboPrivate.Checked = false; } this.ddlType.SelectedValue = schedule.Meeting.MeetingId.ToString(); }
/// <summary> /// 修改日程信息 /// </summary> /// <param name="user"></param> /// <param name="schedules"></param> private void ModifySchedule(User user, IList <Schedule> schedules) { int scheduleId = 0; foreach (Schedule sch in schedules) { scheduleId = sch.ScheduleId; } Schedule schedule = new Schedule(); schedule.Title = this.txtTitle.Text.Trim(); schedule.Address = this.txtAddress.Text.Trim(); schedule.BeginTime = Convert.ToDateTime(this.txtBeginTime.Text.Trim()); schedule.EndTime = Convert.ToDateTime(this.txtEndTime.Text.Trim()); schedule.CreateTime = Convert.ToDateTime(this.lblTime.Text.Trim()); schedule.CreateUser.UserId = user.UserId; schedule.SchContent = this.txtContent.Text.Trim(); schedule.Meeting.MeetingId = Convert.ToInt32(this.ddlType.SelectedValue); schedule.ScheduleId = scheduleId; if (this.cboPrivate.Checked == true) { schedule.IfPrivate = 1; } else { schedule.IfPrivate = 0; } int i = ScheduleManager.ModifyScheduleById(schedule); if (i != 0) { if (lbUserName.Items.Count > 0) { PreContract p = new PreContract(); p.Schedule = ScheduleManager.GetScheduleById(scheduleId); int count = PreContractManager.DeletePreContractById(p.Schedule.ScheduleId); if (count > 0) { foreach (ListItem li in lbUserName.Items) { PreContract pre = new PreContract(); pre.Schedule.ScheduleId = scheduleId; pre.UserId = li.Value; int num = PreContractManager.AddPreContract(pre); if (num == 0) { ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('修改失败!')", true); break; } } Response.Redirect("PersonSchedule.aspx"); } else { Response.Redirect("PersonSchedule.aspx"); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('修改失败!')", true); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('修改失败!')", true); } }