Example #1
0
    /// <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);
        }
    }
Example #2
0
        /// <summary>
        /// 添加预约人
        /// </summary>
        /// <param name="preContract"></param>
        /// <returns></returns>
        public static int AddPreContract(PreContract preContract)
        {
            string sql = "insert into PreContract(ScheduleId,UserId) values(@ScheduleId,@UserId)";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@ScheduleId", preContract.Schedule.ScheduleId),
                new SqlParameter("@UserId", preContract.UserId)
            };
            return(DBHelper.ExecuteCommand(sql, para));
        }
Example #3
0
        /// <summary>
        /// 通过sql语句查询所有预约人的信息
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        private static IList <PreContract> GetAllPreContractsBySql(string sql)
        {
            IList <PreContract> ltPreContract = new List <PreContract>();

            try {
                DataTable dt = DBHelper.GetDataSet(sql);
                foreach (DataRow row in dt.Rows)
                {
                    PreContract preContract = new PreContract();
                    preContract.PreContractId = Convert.ToInt32(row["PreContractId"]);
                    preContract.UserId        = Convert.ToString(row["UserId"]);
                    preContract.Schedule      = ScheduleService.GetScheduleById(Convert.ToInt32(row["ScheduleId"]));
                    ltPreContract.Add(preContract);
                }
                return(ltPreContract);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
        }
Example #4
0
 /// <summary>
 /// 添加预约人
 /// </summary>
 /// <param name="preContract"></param>
 /// <returns></returns>
 public static int AddPreContract(PreContract preContract)
 {
     return(PreContractService.AddPreContract(preContract));
 }
Example #5
0
    /// <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);
        }
    }