Пример #1
0
 public static void EventAddToDataBase(EasyCalProj.EasyCalDB.Tasks1 newEvent)
 {
     using (var EasyCal = new EasyCalEntities1())
     {
         EasyCal.Tasks1.Add(newEvent);
         EasyCal.SaveChanges();
     }
 }
Пример #2
0
 public static void ExamAddToDataBase(EasyCalProj.EasyCalDB.Exams1 newExam)
 {
     using (EasyCalEntities1 EasyCal = new EasyCalEntities1())
     {
         EasyCal.Exams1.Add(newExam);
         EasyCal.SaveChanges();
     }
 }
Пример #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            var eventList    = GetTaskList();
            var ItemToUpdate = eventList.Where(p => p.TaskName == label2.Text).Single();

            using (var EasyCal = new EasyCalEntities1())
            {
                EasyCal.Tasks1.Attach(ItemToUpdate);
                EasyCal.Tasks1.Remove(ItemToUpdate);
                EasyCal.SaveChanges();
            }
            ItemToUpdate.Status = comboBox1.Text;
            EventAddToDataBase(ItemToUpdate);
            MessageBox.Show("סטטוס עודכן בהצלחה");
        }
Пример #4
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedCells != null && dataGridView1.SelectedCells.Count == 1)
            {
                int item;
                int.TryParse(dataGridView1.CurrentRow.Cells["SerialNum"].Value.ToString(), out item);

                var eventList = GetTaskList();

                var itemToRemove = eventList.FirstOrDefault(p => p.SerialNum == item);

                using (var EasyCal = new EasyCalEntities1())
                {
                    EasyCal.Tasks1.Attach(itemToRemove);
                    EasyCal.Tasks1.Remove(itemToRemove);
                    EasyCal.SaveChanges();
                }
                dataGridView1.DataSource = GetTaskList();
            }
        }
Пример #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("האם אתה בטוח שברצונך למחוק מטלה זו?", "מחיקת מטלה", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                var eventList    = GetTaskList();
                var ItemToRemove = eventList.Where(p => p.TaskName == label2.Text).Single();
                using (var EasyCal = new EasyCalEntities1())
                {
                    EasyCal.Tasks1.Attach(ItemToRemove);
                    EasyCal.Tasks1.Remove(ItemToRemove);
                    EasyCal.SaveChanges();
                }
                this.Hide();
            }
            else
            {
                return;
            }
        }
Пример #6
0
        private void Form2_Load(object sender, EventArgs e)
        {
            //label16.Parent = day15;
            //day15.Parent = Form2.DefaultBackColor;
            this.Text    = "EasyCal Welcome " + Form1.AccountName;
            label34.Text = Form1.AccountName;
            var eventList    = GetEventList();
            var taskList     = GetTaskList();
            var activityList = GetActivityList();
            var timeTable    = GetTimeTableList();

            allDays = new List <ListBox> {
                day1, day2, day3, day4, day5, day6, day7, day8, day9, day10, day11, day12, day13, day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25, day26, day27, day28, day29, day30, day31
            };
            Dictionary <String, String> allEvents = new Dictionary <String, String>();
            var eventsToRemove = eventList.Where(p => p.Date < new DateTime(Convert.ToInt32(year), Convert.ToInt32(month), DateTime.Now.Day)).ToList();

            using (var EasyCal = new EasyCalEntities1())
            {
                for (int i = 0; i < eventsToRemove.Count; i++)
                {
                    EasyCal.Events1.Attach(eventsToRemove.ElementAt(i));
                    EasyCal.Events1.Remove(eventsToRemove.ElementAt(i));
                    EasyCal.SaveChanges();
                }
            }
            RightAmountOfDays(day29, day30, day31, label30, label31, label32);
            eventList    = eventList.Where(p => p.Date <= new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)) && p.Date >= DateTime.Now.Date).ToList();
            taskList     = taskList.Where(p => p.Date <= new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)) && p.Date >= DateTime.Now.Date).ToList();
            activityList = activityList.Where(p => p.Date <= new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)) && p.Date >= DateTime.Now.Date).ToList();
            for (int i = 0; i < eventList.Count(); i++)
            {
                var    nextEvent = eventList.ElementAt(i);
                String newDate   = nextEvent.Date.ToString();
                String newDay    = getDayFromDate(newDate);
                allEvents.Add(nextEvent.EventName, newDay);
            }
            for (int i = 0; i < taskList.Count(); i++)
            {
                var    nextTask = taskList.ElementAt(i);
                String newDate  = nextTask.Date.ToString();
                String newDay   = getDayFromDate(newDate);
                if (allEvents.ContainsKey(nextTask.TaskName) == false)
                {
                    allEvents.Add(nextTask.TaskName, newDay);
                }
            }
            for (int i = 0; i < activityList.Count(); i++)
            {
                var    nextEvent = activityList.ElementAt(i);
                String newDate   = nextEvent.Date.ToString();
                String newDay    = getDayFromDate(newDate);
                allEvents.Add(nextEvent.ActivityName, newDay);
            }
            for (int i = 0; i < timeTable.Count(); i++)
            {
                for (int j = 0; j <= 4; j++)
                {
                    if (j * 7 <= 31)
                    {
                        lessons.Add(new Tuple <String, int>(timeTable.ElementAt(i).CourseName, Convert.ToInt32(timeTable.ElementAt(i).Day) + (j * 7)));
                    }
                }
            }
            fillListBoxes(allDays, allEvents);
            fillListBoxes(allDays, lessons);
            numToMonth(label1);
            label1.Text = label1.Text + " " + year;
        }