示例#1
0
        public bool AddSchedule(EditSchedule schedule)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("INSERT INTO Schedule (name,description,date) " +
                                                    "VALUES (@name, @description, @date )", conn);
                    cmd.Parameters.AddWithValue("@name", schedule.Name);
                    cmd.Parameters.AddWithValue("@description", schedule.Description);
                    cmd.Parameters.AddWithValue("@date", schedule.Date);

                    cmd.ExecuteNonQuery();

                    return(true);
                }
            }
            catch (SqlException ex)
            {
                return(false);

                throw;
            }
        }
示例#2
0
        public List <EditSchedule> GetSchedules()
        {
            List <EditSchedule> list   = new List <EditSchedule>();
            EditSchedule        result = new EditSchedule();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("Select * From Schedule ", conn);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        result = MapRowToSchedule(reader);
                        list.Add(result);
                    }

                    return(list);
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
        }
示例#3
0
        public EditSchedule GetScheduleById(int id)
        {
            EditSchedule result = new EditSchedule();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("Select * From Schedule WHERE id = @id", conn);
                    cmd.Parameters.AddWithValue("@id", id);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        result = MapRowToSchedule(reader);
                    }

                    return(result);
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
        }
示例#4
0
        public bool EditSchedule(EditSchedule schedule)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("UPDATE Schedule " +
                                                    "SET name = @name, description = @description, date = @date " +
                                                    "WHERE id = @id", conn);
                    cmd.Parameters.AddWithValue("@name", schedule.Name);
                    cmd.Parameters.AddWithValue("@description", schedule.Description);
                    cmd.Parameters.AddWithValue("@date", schedule.Date);
                    cmd.Parameters.AddWithValue("@id", schedule.Id);

                    cmd.ExecuteNonQuery();

                    return(true);
                }
            }
            catch (SqlException ex)
            {
                return(false);

                throw;
            }
        }
示例#5
0
        //Update schedule
        public ActionResult Edit(int id)
        {
            var svc      = CreateScheduleService();
            var modelOrg = svc.GetScheduleById(id);
            var model    = new EditSchedule();

            model.ScheduleId = id;
            var times   = GetAllTimes();
            var courses = GetAllCourses();
            var cList   = GetCourses(courses);
            var tutors  = GetTutorByLocation(modelOrg.LocationSchedule);
            var tList   = GetLocationsTutors(tutors);

            model.AvailableDays    = TimesSelectListItems(times);
            model.AvailableTutors  = LocationTutorListItems(tList);
            model.AvailableCourses = CourseListItems(cList);

            var service = CreateScheduleService();
            var detail  = service.GetScheduleById(id);

            model.ScheduleId       = id;
            model.ScheduleTutorID  = detail.ScheduleTutor;
            model.ScheduleCourseID = detail.ScheduleCourse;
            model.ScheduleDate     = detail.TimeSchedule;
            return(View(model));
        }
        public IActionResult EditSchedule(int id)
        {
            EditSchedule model = new EditSchedule();

            model = gymDAL.GetScheduleById(id);
            return(View(model));
        }
        private async Task EditItemAsync(string item)
        {
            StaticMethods.Toast($"Edit popup for {item}.");

            var pop = new EditSchedule();

            pop.BindingContext = new EditScheduleViewModel(this.Schedules.First(x => x.Code == item));

            await Rg.Plugins.Popup.Services.PopupNavigation.Instance.PushAsync(pop);
        }
示例#8
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            EditSchedule     view = new EditSchedule(currentDay, _loginName);
            DialogHostFormPC pc   = new DialogHostFormPC("编辑事项", view.Width, view.Height);

            pc.Child = view;
            pc.ShowDialog();

            TitleFormat();
        }
        public IActionResult EditSchedule(EditSchedule model)
        {
            if (ModelState.IsValid)
            {
                gymDAL.EditSchedule(model);
                return(RedirectToAction(nameof(ViewSchedules)));
            }

            return(View(model));
        }
示例#10
0
        public void EditItem(MedicalSystem.Anes.Domain.MED_DAILY_SCHEDULE item)
        {
            EditSchedule view = new EditSchedule(currentDay, _loginName);

            view.Edit(item);
            DialogHostFormPC pc = new DialogHostFormPC("编辑事项", view.Width, view.Height);

            pc.Child = view;
            pc.ShowDialog();

            TitleFormat();
        }
示例#11
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int index = dataGridView1.SelectedRows[0].Index;

            DateTime        date         = DateTime.Parse(dataGridView1.Rows[index].Cells[0].Value.ToString());
            string          from         = dataGridView1.Rows[index].Cells[2].Value.ToString();
            string          to           = dataGridView1.Rows[index].Cells[3].Value.ToString();
            string          flightNumber = dataGridView1.Rows[index].Cells[4].Value.ToString();
            FlightViewModel temp         = new FlightViewModel();

            temp = (list.Where(x => x.DateFlight == date && x.From.Equals(from) && x.To.Equals(to) && x.FlightNumber.Equals(flightNumber)).FirstOrDefault());
            using (EditSchedule edit = new EditSchedule(temp))
            {
                if (edit.ShowDialog() == DialogResult.OK)
                {
                    list = GetReloadList();
                    SetDataToView(list);
                }
            }
        }
示例#12
0
        //Update schedule
        public bool UpdateSchedule(EditSchedule model)
        {
            int    position       = model.ScheduleTutorID.IndexOf("-");
            int    tutorNum       = Int32.Parse(model.ScheduleTutorID.Substring(0, position));
            int    coursePosition = model.ScheduleCourseID.IndexOf("-");
            int    courseNum      = Int32.Parse(model.ScheduleCourseID.Substring(0, coursePosition));
            int    DaySelPos      = model.ScheduleDay.IndexOf(":");
            string DaySel         = model.ScheduleDay.Substring(DaySelPos - 1);
            int    hour           = 3;

            if (DaySel == "3:00")
            {
                hour = 15;
            }
            ;
            if (DaySel == "5:00")
            {
                hour = 17;
            }
            ;
            if (DaySel == "1:00")
            {
                hour = 13;
            }
            ;
            DateTime sch = new DateTime(model.ScheduleDate.Year, model.ScheduleDate.Month, model.ScheduleDate.Day, hour, 0, 0);

            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Schedules
                    .Single(e => e.Id == model.ScheduleId);
                entity.TutorId  = tutorNum;
                entity.CourseId = courseNum;
                entity.Time     = sch;
                return(ctx.SaveChanges() > 0);
            }
        }
示例#13
0
        public ActionResult Edit(int id, EditSchedule model)
        {
            View();
            var times   = GetAllTimes();
            var courses = GetAllCourses();
            var cList   = GetCourses(courses);
            var tutors  = GetTutorByLocation(model.ScheduleLocation);
            var tList   = GetLocationsTutors(tutors);

            model.ScheduleId       = id;
            model.AvailableDays    = TimesSelectListItems(times);
            model.AvailableTutors  = LocationTutorListItems(tList);
            model.AvailableCourses = CourseListItems(cList);

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.ScheduleId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateScheduleService();

            if (service.UpdateSchedule(model))
            {
                TempData["SaveResult"] = "The schedule was updated.";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "The schedule could not be updated.");
            return(View(model));
        }
示例#14
0
        public void SetDay(DateTime now, bool today, List <MED_DAILY_SCHEDULE> list)
        {
            currentDay = now;
            toDay      = today;
            data       = list;

            this.labTitle.Visible = false;
            if (today)
            {
                this.labDay.Image = Resources.day1;
                this.labDay.Text  = "";
                if (list != null && list.Count > 0)
                {
                    this.labTitle.Text    = string.Format("代办事项{0}项", list.Count);
                    this.labTitle.Visible = true;
                }
            }
            else if (list != null && list.Count > 0)
            {
                this.labDay.Image     = Resources.day2;
                this.labDay.Text      = now.Day.ToString();
                this.labDay.ForeColor = Color.White;

                this.labTitle.Text    = string.Format("代办事项{0}项", list.Count);
                this.labTitle.Visible = true;
            }
            else
            {
                this.labDay.Image     = null;
                this.labDay.Text      = now.Day.ToString();
                this.labDay.ForeColor = Color.Black;
            }

            PanelBorder p   = null;
            Label       lab = null;

            for (int i = 0; i < this.panelNoFlash2.Controls.Count || list != null && i < list.Count; i++)
            {
                if (i < panelTmpList.Count)
                {
                    p   = panelTmpList[i] as PanelBorder;
                    lab = p.Controls[0] as Label;
                }
                else
                {
                    p = new PanelBorder()
                    {
                        Height = 26
                    };
                    p.Padding     = new Padding(6);
                    p.DashStyle   = DashStyle.Custom;
                    p.DashPattern = new float[] { 1f, 3f };
                    panelTmpList.Add(p);
                    this.panelNoFlash2.Controls.Add(p);
                    p.Dock = DockStyle.Top;

                    lab = new Label();
                    p.Controls.Add(lab);
                    lab.Dock       = DockStyle.Fill;
                    lab.ImageAlign = ContentAlignment.MiddleLeft;
                    lab.TextAlign  = ContentAlignment.MiddleLeft;

                    p.Tag            = i;
                    lab.Tag          = i;
                    lab.DoubleClick += (sender, e) =>
                    {
                        EditSchedule view = new EditSchedule(currentDay, ExtendApplicationContext.Current.LoginUser.LOGIN_NAME);
                        view.Edit(list[(int)(sender as Control).Tag]);
                        DialogHostFormPC pc = new DialogHostFormPC("编辑事项", view.Width, view.Height);
                        pc.Child = view;
                        pc.ShowDialog();
                        SetDay(now, today, list);
                    };
                }
                p.BringToFront();

                if (list != null && i < list.Count)
                {
                    var tmp = list[i];
                    if (tmp.STATE == 0)
                    {
                        p.BorderColor = UN_FINISHED_COLOR;
                        p.BackColor   = UN_FINISHED_COLOR;
                        lab.Image     = Resources.unfinished;
                    }
                    else
                    {
                        p.BorderColor = FINISHED_COLOR;
                        p.BorderColor = FINISHED_COLOR;
                        p.BackColor   = FINISHED_COLOR;
                        lab.Image     = Resources.finished;
                    }
                    lab.Text = string.Format("    {0} {1}", tmp.CREATE_DATE.Value.ToString("HH:mm"), tmp.CONTENT);
                }
                else
                {
                    p.Visible = false;
                }
            }
        }
示例#15
0
 private void btnEditSchedule_Click(object sender, RoutedEventArgs e)
 {
     Schedule schedule = ScheduleLoader.LoadSchedule("schedule.dat");
     EditSchedule form = new EditSchedule(new ScheduleForEdit(schedule));
     form.Show();
 }