public void ApplyDtoToGUI(CalenderItemDto dto, bool editable = false)
        {
            ReadOnly = !editable;
            Details.Text = dto.Details;
            name.Text = dto.Name;
            date.SelectedDate = dto.ItemDate;

            dto = new CalenderItemDto(dto);

            if (data.categoryStore.CalendarItems.ContainsKey(dto.categoryId))
            {
                comboCategory.SelectedValue = data.categoryStore.CalendarItems[dto.categoryId];
            }

            string filepaths = "";

            foreach (string file in dto.filePaths)
            {
                filepaths += file + "\n";
            }

            filepaths = filepaths.Trim('\n');

            filesTextBox.Text = filepaths;
        }
 public void AddItemToCalendar(CalenderItemDto item)
 {
     if (MonthlyCalenderBoxes.ContainsKey(item.ItemDate.Date)) MonthlyCalenderBoxes[item.ItemDate.Date].AddItem(item);
     if (WeeklyCalenderBoxes.ContainsKey(item.ItemDate.Date)) WeeklyCalenderBoxes[item.ItemDate.Date].AddItem(item);
     if (BiWeeklyCalenderBoxes.ContainsKey(item.ItemDate.Date)) BiWeeklyCalenderBoxes[item.ItemDate.Date].AddItem(item);
     if (CalenderBoxDay.ItemDate == item.ItemDate.Date) CalenderBoxDay.AddItem(item);
 }
Exemplo n.º 3
0
        public static bool AddCalenderItem(CalenderItemDto dto, SQLiteConnection conn = null)
        {
            bool closeCon = false;
            if (conn == null)
            {
                conn = DatabaseHelper.GetDatabaseConnection();
                closeCon = true;
            }

            using (SQLiteCommand command = new SQLiteCommand(conn))
            {
                command.CommandText = ADD_ITEM_SQL;
                command.Prepare();
                command.Parameters.AddWithValue("@Name", dto.Name);
                command.Parameters.AddWithValue("@Type", dto.Type.ToString());
                command.Parameters.AddWithValue("@Date", dto.ItemDate.Date.ToString());
                command.Parameters.AddWithValue("@Time", dto.ItemDate.TimeOfDay.ToString());
                command.Parameters.AddWithValue("@Complete", dto.done);
                command.Parameters.AddWithValue("@Details", dto.Details);
                command.Parameters.AddWithValue("@CategoryId", dto.categoryId);
                command.Parameters.AddWithValue("@FilePaths", dto.AddFilesToArchive());

                dto.id = command.ExecuteNonQuery();
            }

            if (closeCon) conn.Close();
            return false;
        }
Exemplo n.º 4
0
 public CalenderItemDto(CalenderItemDto dto)
 {
     Name = dto.Name;
     id = dto.id;
     Details = dto.Details;
     ItemDate = dto.ItemDate;
     WorkAssigned = dto.WorkAssigned;
     categoryId = dto.categoryId;
     done = dto.done;
     Type = dto.Type;
     filePaths = dto.filePaths;
 }
        public CalenderItemControl(CalenderItemDto item)
        {
            InitializeComponent();

            this.item = item;
            lblTaskName.Content = item.Name;
            lblType.Content = TypeToChar(item.Type);
            Background = new SolidColorBrush(ApplicationData.Get().categoryStore.CalendarItems[item.categoryId].Color);
            doneChk.Checked -= doneChk_Checked;
            doneChk.IsChecked = item.done;
            doneChk.Checked += doneChk_Checked;
        }
 public void AddItem(CalenderItemDto item)
 {
     if (item.id == -1)
     {
         item.id = currentId--;
         CalenderItemDao.AddCalenderItem(item);
     }
     else if (item.id <= currentId) currentId = item.id - 1;
     CalendarItems[item.id] = item;
     addItemByDate(item);
     if (ItemAddedEvt != null) ItemAddedEvt(item);
 }
Exemplo n.º 7
0
        public static bool DeleteCalenderItem(CalenderItemDto dto, SQLiteConnection conn = null)
        {
            bool closeCon = false;
            if (conn == null)
            {
                conn = DatabaseHelper.GetDatabaseConnection();
                closeCon = true;
            }

            if (closeCon) conn.Close();
            return false;
        }
        public CalenderItemDetailDialog()
        {
            InitializeComponent();

            data = ApplicationData.Get();
            dto = null;

            date.SelectedDate = DateTime.Now;
            comboType.ItemsSource = Enum.GetValues(typeof(CalendarItemType));
            comboType.SelectedValue = CalendarItemType.Task;
            comboCategory.ItemsSource = data.categoryStore.CalendarItems.Values;
            comboCategory.SelectedItem = data.categoryStore.CalendarItems[1];
            name.Focus();
        }
        public CalenderItemDto GUIToObject()
        {
            if (dto == null) dto = new CalenderItemDto();
            dto.Details = Details.Text;
            dto.ItemDate = date.SelectedDate.Value;
            dto.Name = name.Text;
            dto.Type = (comboType.SelectedItem as CalendarItemType?).Value;

            CatagoryDto Categorydto = comboCategory.SelectedItem as CatagoryDto;

            if (Categorydto != null)
            {
                dto.categoryId = Categorydto.id;
            }

            string[] files = filesTextBox.Text.Split('\n');

            foreach (string file in files)
            {
                dto.filePaths.Add(file);
            }

            return dto;
        }
Exemplo n.º 10
0
        public void AddItem(CalenderItemDto item)
        {
            calenderItems[item.id] = new CalenderItemControl(item);

            addCalenderItemsToBox();
        }
Exemplo n.º 11
0
        private void UserControl_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("myFormat") || sender == e.Source)
            {
                if (e.Data.GetData("myFormat") is CalenderItemDto)
                {
                    CalenderItemDto dto = e.Data.GetData("myFormat") as CalenderItemDto;

                    if (dto.ItemDate.Date != this.ItemDate)
                    {
                        dto = new CalenderItemDto(dto);
                        dto.ItemDate = this.ItemDate;

                        ApplicationData.Get().calendarItemStore.UpdateItem(dto);
                    }
                }
            }
        }
 private void Store_ItemAddedEvt(CalenderItemDto item)
 {
     AddItemToCalendar(item);
 }
        private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            CalenderItemDetailDialog dialog = new CalenderItemDetailDialog();
            dialog.ApplyDtoToGUI(item, true);
            dialog.ShowDialog();

            if (dialog.DialogResult.Value)
            {
                CalenderItemDto dto = dialog.GUIToObject();
                if (!item.Equals(dto))
                {
                    dto.id = item.id;
                    item = dto;
                    ApplicationData.Get().calendarItemStore.UpdateItem(dto);
                }
            }
        }
Exemplo n.º 14
0
        public void UpdateItem(CalenderItemDto item)
        {
            if (item.id < 0) return;

            CalenderItemDto oldDto = CalendarItems[item.id];
            CalendarItemsByDate[oldDto.ItemDate.Date].Remove(oldDto);
            addItemByDate(item);
            modifiedItems[item.id] = item;
            CalendarItems[item.id] = item;

            Dictionary<DateTime, List<CalenderItemDto>> updatedItems = new Dictionary<DateTime, List<CalenderItemDto>>();
            updatedItems[item.ItemDate.Date] = new List<CalenderItemDto>();
            updatedItems[item.ItemDate.Date].Add(item);

            Dictionary<DateTime, List<CalenderItemDto>> oldItems = new Dictionary<DateTime, List<CalenderItemDto>>();
            oldItems[oldDto.ItemDate.Date] = new List<CalenderItemDto>();
            oldItems[oldDto.ItemDate.Date].Add(oldDto);

            if (ItemsUpdatedEvt != null) ItemsUpdatedEvt(updatedItems, oldItems);
        }
Exemplo n.º 15
0
 private void addItemByDate(CalenderItemDto dto)
 {
     if (!CalendarItemsByDate.ContainsKey(dto.ItemDate.Date)) CalendarItemsByDate[dto.ItemDate.Date] = new List<CalenderItemDto>();
     CalendarItemsByDate[dto.ItemDate.Date].Add(dto);
 }
Exemplo n.º 16
0
        static CalenderItemDto DtoFromReader(SQLiteDataReader read)
        {
            CalenderItemDto dto = new CalenderItemDto();

            dto.Details = read["Details"] as string;
            dto.Name = read["Name"] as string;
            DateTime date = DateTime.Parse(read["Date"] as string);
            DateTime time = DateTime.Parse(read["Time"] as string);
            dto.ItemDate = date.Add(time.TimeOfDay);
            dto.Type = (CalendarItemType)Enum.Parse(typeof(CalendarItemType), read["Type"] as string);
            dto.id = Convert.ToInt32(read["id"]);
            dto.done = (read["Complete"] as bool?).Value;
            dto.categoryId = Convert.ToInt32(read["CategoryId"]);

            object ob = read["FilePaths"];
            string pathstring =  ob as string;
            string[] files = pathstring.Split(';');
            foreach (string file in files)
            {
                dto.filePaths.Add(file);
            }

            return dto;
        }