Exemplo n.º 1
0
        public string IsValidEditSchedule(SchedulesEntity entity, string startTime, string endTime)
        {
            if (string.IsNullOrEmpty(startTime) || string.IsNullOrEmpty(endTime))
            {
                return("params error.");
            }

            int start = ScheduleTimeHelpers.TimeHandle(startTime);
            int end   = ScheduleTimeHelpers.TimeHandle(endTime);

            if (start > end)
            {
                return("Please entry again , Starting time should not exceed finishing time.");
            }

            if (DateTime.Parse(string.Format("{0} {1}", entity.PlanDate.ToString("MM/dd/yyyy"), startTime)) < DateTime.Now)
            {
                return("Plan time not less than the current time.");
            }

            if (!(entity.StartTime == startTime && entity.EndTime == endTime))
            {
                List <SchedulesEntity>    schedulesList    = new App.SchedulesApplication().GetSchedules(entity.PlanDate, UserID);
                List <ScheduleTimeEntity> scheduleTimeList = new ScheduleTimeHelpers(schedulesList).Times;
                for (int i = start; i < end; i++)
                {
                    ScheduleTimeEntity t = scheduleTimeList.Find(r => r.Cell == i && r.IsPlan);
                    if (t != null)
                    {
                        return("-1");
                    }
                }
            }
            return("1");
        }
Exemplo n.º 2
0
        private void Save(bool isNew)
        {
            SchedulesEntity entity = new SchedulesEntity();

            entity.Title       = txtTitle.Text;
            entity.Description = txtDescription.Text;
            entity.CreateBy    = UserInfo.UserID;
            entity.CreateOn    = DateTime.Now;
            entity.StartTime   = string.Format("{0}:{1}", ddlStartHours.SelectedValue, ddlStartMinute.SelectedValue);
            entity.EndTime     = string.Format("{0}:{1}", ddlEndHours.SelectedValue, ddlEndMinute.SelectedValue);
            entity.UpdateBy    = UserInfo.UserID;
            entity.UpdateOn    = DateTime.Now;
            entity.PlanDate    = Date;

            int start = ScheduleTimeHelpers.TimeHandle(entity.StartTime);
            int end   = ScheduleTimeHelpers.TimeHandle(entity.EndTime);

            if (string.IsNullOrEmpty(entity.Title))
            {
                ShowFailMessageToClient("Please enter the title.");
                return;
            }
            if (start > end)
            {
                ShowFailMessageToClient("Please entry again , Starting time should not exceed finishing time.");
                return;
            }

            if (DateTime.Parse(string.Format("{0} {1}", entity.PlanDate.ToString("MM/dd/yyyy"), entity.StartTime)) < DateTime.Now)
            {
                ShowFailMessageToClient("Plan time not less than the current time.");
                return;
            }

            for (int i = start; i < end; i++)
            {
                ScheduleTimeEntity t = ScheduleTimeList.Find(r => r.Cell == i && r.IsPlan);
                if (t != null)
                {
                    ShowFailMessageToClient("The hours of the two schedules conflict.");
                    return;
                }
            }

            if (chkMeeting.Checked)
            {
                entity.MeetingID     = string.Format("{0}:{1}", UserInfo.UserID, DateTime.Now.ToString("MM_dd_yy_HH:mm_ss"));
                entity.MeetingStatus = 1;
                List <UsersEntity> usersList = new List <UsersEntity>();
                for (int i = 0; i < this.rtpUser.Items.Count; i++)
                {
                    CheckBox check = (CheckBox)this.rtpUser.Items[i].FindControl("cbUser");
                    if (check.Checked)
                    {
                        Literal lit = this.rtpUser.Items[i].FindControl("ltlid") as Literal;
                        usersList.Add(new App.UserApplication().GetUser(int.Parse(lit.Text)));
                    }
                }
                if (usersList.Find(r => r.UserID == UserInfo.UserID) == null) //如果不包括创建者,就添加他
                {
                    usersList.Add(UserInfo);
                }
                if (new App.SchedulesApplication().Add(entity, usersList, UserInfo) > 0)
                {
                    if (isNew)
                    {
                        Redirect("Add.aspx?Date=" + Date.ToString("MM/dd/yyyy"), true);
                    }
                    else
                    {
                        Redirect(EmptyPopPageUrl, false, true);
                    }
                }
                else
                {
                    ShowFailMessageToClient();
                }
            }
            else
            {
                entity.MeetingID = string.Empty;
                entity.UserID    = UserInfo.UserID;

                if (new App.SchedulesApplication().Add(entity) > 0)
                {
                    if (isNew)
                    {
                        Redirect("Add.aspx?Date=" + Date.ToString("MM/dd/yyyy"), true);
                    }
                    else
                    {
                        Redirect(EmptyPopPageUrl, false, true);
                    }
                }
                else
                {
                    ShowFailMessageToClient();
                }
            }
        }
Exemplo n.º 3
0
        private void Save(bool isNew)
        {
            SchedulesEntity entity = new App.SchedulesApplication().GetInfo(int.Parse(hdID.Value));

            entity.Title       = txtTitle.Text;
            entity.Description = txtDescription.Text;
            entity.StartTime   = string.Format("{0}:{1}", ddlStartHours.SelectedValue, ddlStartMinute.SelectedValue);
            entity.EndTime     = string.Format("{0}:{1}", ddlEndHours.SelectedValue, ddlEndMinute.SelectedValue);
            entity.UpdateBy    = UserInfo.UserID;
            entity.UpdateOn    = DateTime.Now;

            int start = ScheduleTimeHelpers.TimeHandle(entity.StartTime);
            int end   = ScheduleTimeHelpers.TimeHandle(entity.EndTime);

            if (start > end)
            {
                ShowMessageToClient("Please entry again , Starting time should not exceed finishing time.", 0, false, false);
                return;
            }
            if (DateTime.Parse(string.Format("{0} {1}", entity.PlanDate.ToString("MM/dd/yyyy"), entity.StartTime)) < DateTime.Now)
            {
                ShowMessageToClient("Plan time not less than the current time.", 0, false, false);
                return;
            }

            for (int i = start; i < end; i++)
            {
                ScheduleTimeEntity t = ScheduleTimeList.Find(r => r.Cell == i && r.IsPlan && r.ScheduleID != entity.ID);
                if (t != null)
                {
                    ShowMessageToClient("The hours of the two schedules conflict.", 0, false, false);
                    return;
                }
            }

            if (chkMeeting.Checked)
            {
                List <UsersEntity> usersList = new List <UsersEntity>();
                foreach (ListItem li in lstMeetingUsers.Items)
                {
                    usersList.Add(new App.UserApplication().GetUser(int.Parse(li.Value)));
                }
                if (usersList.Find(r => r.UserID == UserInfo.UserID) == null) //如果不包括创建者,就添加他
                {
                    usersList.Add(UserInfo);
                }

                List <UsersEntity> moveSales = new App.SchedulesApplication().GetMeetingUsers(entity.MeetingID);
                List <UsersEntity> newList   = new List <UsersEntity>();
                UsersEntity        tmpUser;

                foreach (UsersEntity tmp in usersList)
                {
                    tmpUser = moveSales.Find(r => r.UserID == tmp.UserID);
                    if (tmpUser != null)
                    {
                        moveSales.Remove(tmpUser);
                    }
                    else
                    {
                        newList.Add(tmp);
                    }
                }

                if (new App.SchedulesApplication().Update(entity, moveSales, newList))
                {
                    if (isNew)
                    {
                        Server.Transfer("AddSchedules.aspx?Date=" + entity.PlanDate.ToString("MM/dd/yyyy"));
                    }
                    else
                    {
                        ShowSuccessMessageToClient(true, true);
                    }
                }
                else
                {
                    ShowFailMessageToClient();
                }
            }
            else
            {
                if (new App.SchedulesApplication().Update(entity))
                {
                    if (isNew)
                    {
                        Server.Transfer("AddSchedules.aspx?Date=" + entity.PlanDate.ToString("MM/dd/yyyy"));
                    }
                    else
                    {
                        ShowSuccessMessageToClient(true, true);
                    }
                }
                else
                {
                    ShowFailMessageToClient();
                }
            }
        }
Exemplo n.º 4
0
        private void Save(bool isNew)
        {
            SchedulesEntity entity = new SchedulesEntity();

            entity.Title       = txtTitle.Text;
            entity.Description = txtDescription.Text;
            entity.CreateBy    = UserInfo.UserID;
            entity.CreateOn    = DateTime.Now;
            entity.StartTime   = string.Format("{0}:{1}", ddlStartHours.SelectedValue, ddlStartMinute.SelectedValue);
            entity.EndTime     = string.Format("{0}:{1}", ddlEndHours.SelectedValue, ddlEndMinute.SelectedValue);
            entity.UpdateBy    = UserInfo.UserID;
            entity.UpdateOn    = DateTime.Now;
            entity.PlanDate    = Date;

            int start = ScheduleTimeHelpers.TimeHandle(entity.StartTime);
            int end   = ScheduleTimeHelpers.TimeHandle(entity.EndTime);

            if (start > end)
            {
                ShowMessageToClient("Please entry again , Starting time should not exceed finishing time.", 0, false, false);
                return;
            }

            if (DateTime.Parse(string.Format("{0} {1}", entity.PlanDate.ToString("MM/dd/yyyy"), entity.StartTime)) < DateTime.Now)
            {
                ShowMessageToClient("Plan time not less than the current time.", 0, false, false);
                return;
            }

            for (int i = start; i < end; i++)
            {
                ScheduleTimeEntity t = ScheduleTimeList.Find(r => r.Cell == i && r.IsPlan);
                if (t != null)
                {
                    ShowMessageToClient("The hours of the two schedules conflict.", 0, false, false);
                    return;
                }
            }

            if (chkMeeting.Checked)
            {
                entity.MeetingID     = string.Format("{0}:{1}", UserInfo.UserID, DateTime.Now.ToString("MM_dd_yy_HH:mm_ss"));
                entity.MeetingStatus = 1;
                List <UsersEntity> usersList = new List <UsersEntity>();
                foreach (ListItem li in lstMeetingUsers.Items)
                {
                    usersList.Add(new App.UserApplication().GetUser(int.Parse(li.Value)));
                }
                if (usersList.Find(r => r.UserID == UserInfo.UserID) == null) //如果不包括创建者,就添加他
                {
                    usersList.Add(UserInfo);
                }
                if (new App.SchedulesApplication().Add(entity, usersList, UserInfo) > 0)
                {
                    if (isNew)
                    {
                        Redirect("AddSchedules.aspx?Date=" + Date.ToString("MM/dd/yyyy"));
                    }
                    else
                    {
                        ShowSuccessMessageToClient(true, true);
                    }
                }
                else
                {
                    ShowFailMessageToClient();
                }
            }
            else
            {
                entity.MeetingID = string.Empty;
                entity.UserID    = UserInfo.UserID;

                if (new App.SchedulesApplication().Add(entity) > 0)
                {
                    //List<SchedulesEntity> list = new App.SchedulesApplication().GetSchedules(entity.PlanDate, UserInfo.UserID);
                    //jscheduleResult = SerializeScheduleList(list);

                    if (isNew)
                    {
                        Redirect("AddSchedules.aspx?Date=" + Date.ToString("MM/dd/yyyy"));
                    }
                    else
                    {
                        ShowSuccessMessageToClient(true, true);
                    }
                }
                else
                {
                    ShowFailMessageToClient();
                }
            }
        }