Beispiel #1
0
 /// <summary>
 /// 更新ListChild 的 Mark
 /// </summary>
 /// <param name="markType"></param>
 private void UpdateListChildMark(MarkType markType)
 {
     listChildrenDisplayPart.SelectedListChild.Mark = markType;
     ListChild.UpdateListChild(listChildrenDisplayPart.SelectedListChild);
     ReadListChildren();
     popupMark.IsOpen = false;
 }
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                listChild.Title     = tbListChildTitle.Text;
                listChild.Detail    = tbListChildDetail.Text;
                listChild.StartTime = (DateTime)dtpStartTime.Value;
                listChild.EndTime   = (DateTime)dtpEndTime.Value;
                listChild.Mark      = ((MarkItem)cmbMark.SelectedItem).Mark;
                switch (dialogType)
                {
                case DialogType.Add:
                    listChild.FamilyId = selectedListFamilyId;
                    ListChild.AddListChild(listChild);
                    break;

                case DialogType.Edit:
                    ListChild.UpdateListChild(listChild);
                    break;
                }
            }
            catch (Exception ex)
            {
                App.writeLog.Error("保存失败", ex);
                MessageBox.Show("项目保存失败!\n错误日志请查看Error.log文件!", "噢噢,出错了", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            this.DialogResult = true;
        }
Beispiel #3
0
        /// <summary>
        /// 移动ListChild
        /// </summary>
        /// <param name="moveDirection"></param>
        private void MoveListChild(MoveDirection moveDirection)
        {
            int flag = Convert.ToInt16(moveDirection);

            if ((listChildrenDisplayPart.SelectionIndex - flag > -1) && (listChildrenDisplayPart.SelectionIndex - flag < listChildrenDataTable.Rows.Count))
            {
                if (selectedListFamily.SortType != SortType.Manual)
                {
                    UpdateListChildrenDisplayWeight();
                    ReadListChildren();
                    selectedListFamily.SortType = SortType.Manual;
                    ListFamily.UpdateListFamily(selectedListFamily);
                }

                listChildrenDisplayPart.SelectedListChild.DisplayWeight -= flag;
                ListChild listChild = ListChild.GetListChildById(Convert.ToInt32(listChildrenDataTable.Rows[listChildrenDisplayPart.SelectionIndex - flag][ListChild.FIELD_NAME_ID]));
                listChild.DisplayWeight += flag;

                ListChild.UpdateListChild(listChildrenDisplayPart.SelectedListChild);
                ListChild.UpdateListChild(listChild);

                listChildrenDisplayPart.SelectionIndex -= flag;

                ReadListChildren();
            }
        }
Beispiel #4
0
        /// <summary>
        /// 插入帮助列表
        /// </summary>
        private void InsertHelpLists()
        {
            ListFamily whatsNewListFamily = new ListFamily
            {
                Title         = "最新更新 ",
                Detail        = ProjectVersion.GetLocalVersion().AssemblyVersion,
                DisplayWeight = listFamiliesDataTable.Rows.Count
            };

            ListFamily.AddListFamily(whatsNewListFamily);

            ListChild.AddListChild(new ListChild
            {
                Title         = "修复bug",
                Detail        = "",
                DisplayWeight = 0,
                Mark          = MarkType.Finished,
                StartTime     = new DateTime(2013, 1, 6, 11, 52, 00),
                EndTime       = DateTime.MaxValue,
                FamilyId      = ListFamily.GetListFamilyByWeight(whatsNewListFamily.DisplayWeight).Id
            });

            ListChild.AddListChild(new ListChild
            {
                Title         = "细节调整",
                Detail        = "将设置按钮名称改为属性",
                DisplayWeight = 1,
                Mark          = MarkType.Finished,
                StartTime     = new DateTime(2013, 1, 8, 9, 26, 00),
                EndTime       = DateTime.MaxValue,
                FamilyId      = ListFamily.GetListFamilyByWeight(whatsNewListFamily.DisplayWeight).Id
            });
            ListChild.AddListChild(new ListChild
            {
                Title         = "细节调整",
                Detail        = "在下方按钮中添加了上移和下移,方便移动",
                DisplayWeight = 1,
                Mark          = MarkType.Finished,
                StartTime     = new DateTime(2013, 1, 8, 9, 30, 00),
                EndTime       = DateTime.MaxValue,
                FamilyId      = ListFamily.GetListFamilyByWeight(whatsNewListFamily.DisplayWeight).Id
            });

            ListChild.AddListChild(new ListChild
            {
                Title         = "功能增加",
                Detail        = "现在可以调整窗口大小了",
                DisplayWeight = 2,
                Mark          = MarkType.Finished,
                StartTime     = new DateTime(2013, 1, 8, 14, 50, 00),
                EndTime       = DateTime.MaxValue,
                FamilyId      = ListFamily.GetListFamilyByWeight(whatsNewListFamily.DisplayWeight).Id
            });

            ReadListFamiles();
            lstListFamilies.SelectedIndex = whatsNewListFamily.DisplayWeight;

            GenerateLocalXml();
        }
Beispiel #5
0
 /// <summary>
 /// 删除 ListChild
 /// </summary>
 private void DeleteListChild()
 {
     if (MessageBox.Show(string.Format("确定要删除这个项目吗?\n项目标题:{0}", listChildrenDisplayPart.SelectedListChild.Title), "三思而后行", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation) == MessageBoxResult.OK)
     {
         ListChild.DeleteListChild(listChildrenDisplayPart.SelectedListChild);
         ReadListChildren();
     }
 }
Beispiel #6
0
        /// <summary>
        /// 通过DataRow获取ListChild
        /// </summary>
        /// <param name="dataRow"></param>
        /// <returns></returns>
        public static ListChild GetListChildByDataRow(DataRow dataRow)
        {
            ListChild listChild = new ListChild();

            listChild.Id            = Convert.ToInt16(dataRow[FIELD_NAME_ID].ToString());
            listChild.Title         = Convert.ToString(dataRow[FIELD_NAME_TITLE]);
            listChild.Detail        = Convert.ToString(dataRow[FIELD_NAME_DETAIL]);
            listChild.StartTime     = Convert.ToDateTime(dataRow[FIELD_NAME_START_TIME].ToString());
            listChild.EndTime       = Convert.ToDateTime(dataRow[FIELD_NAME_END_TIME].ToString());
            listChild.Mark          = (MarkType)Enum.Parse(typeof(MarkType), dataRow[FIELD_NAME_MARK].ToString(), true);
            listChild.DisplayWeight = Convert.ToInt16(dataRow[FIELD_NAME_DISPLAY_WEIGHT].ToString());
            listChild.FamilyId      = Convert.ToInt16(dataRow[FIELD_NAME_FAMILY_ID].ToString());
            return(listChild);
        }
 public ListChildInfoDialog(ListChild listChild)
     : this()
 {
     dialogType                  = DialogType.Edit;
     this.listChild              = listChild;
     this.tbListChildTitle.Text  = listChild.Title;
     this.tbListChildDetail.Text = listChild.Detail;
     this.cmbMark.SelectedIndex  = (int)listChild.Mark;
     this.dtpStartTime.Value     = listChild.StartTime;
     this.dtpEndTime.Value       = listChild.EndTime;
     if (listChild.EndTime.ToString(Global.TIME_FORMAT_STRING).Equals(DateTime.MaxValue.ToString(Global.TIME_FORMAT_STRING)))
     {
         chkNeverEnd.IsChecked = true;
     }
 }
 public ListChildInfoDialog(ListChild listChild)
     : this()
 {
     dialogType = DialogType.Edit;
     this.listChild = listChild;
     this.tbListChildTitle.Text = listChild.Title;
     this.tbListChildDetail.Text = listChild.Detail;
     this.cmbMark.SelectedIndex = (int)listChild.Mark;
     this.dtpStartTime.Value = listChild.StartTime;
     this.dtpEndTime.Value = listChild.EndTime;
     if (listChild.EndTime.ToString(Global.TIME_FORMAT_STRING).Equals(DateTime.MaxValue.ToString(Global.TIME_FORMAT_STRING)))
     {
         chkNeverEnd.IsChecked = true;
     }
 }
Beispiel #9
0
 /// <summary>
 /// 更新ListChildren的DisplayWeight
 /// </summary>
 private void UpdateListChildrenDisplayWeight()
 {
     try
     {
         ListChild.BeginTransaction();
         for (int i = 0; i < listChildrenDataTable.Rows.Count; i++)
         {
             ListChild listChild = ListChild.GetListChildById(Convert.ToInt32(listChildrenDataTable.Rows[i][ListChild.FIELD_NAME_ID]));
             listChild.DisplayWeight = i;
             ListChild.UpdateListChild(listChild);
         }
         ListChild.CommitTransaction();
     }
     catch (Exception ex)
     {
         App.writeLog.Warn("更新ListChildren的DisplayWeight失败,可能是由于删除列表导致", ex);
     }
 }
Beispiel #10
0
        /// <summary>
        /// 添加 ListChild
        /// </summary>
        /// <param name="listChild"></param>
        public static void AddListChild(ListChild listChild)
        {
            try
            {
                sqlite.CreateTableIfNotExists(
                    TABLE_NAME,                         //表名
                    FIELD_NAME_ID,                      //主键名
                    true,                               //自增
                    FIELD_NAME_TITLE,
                    FIELD_NAME_DETAIL,
                    FIELD_NAME_START_TIME,
                    FIELD_NAME_END_TIME,
                    FIELD_NAME_MARK,
                    FIELD_NAME_DISPLAY_WEIGHT,
                    FIELD_NAME_FAMILY_ID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            List <string> columnList = new List <string>
            {
                FIELD_NAME_TITLE,
                FIELD_NAME_DETAIL,
                FIELD_NAME_START_TIME,
                FIELD_NAME_END_TIME,
                FIELD_NAME_MARK,
                FIELD_NAME_DISPLAY_WEIGHT,
                FIELD_NAME_FAMILY_ID
            };
            List <string> valueList = new List <string>
            {
                listChild.Title,
                listChild.Detail,
                listChild.StartTime.ToString(Global.TIME_FORMAT_STRING),
                listChild.EndTime.ToString(Global.TIME_FORMAT_STRING),
                listChild.Mark.ToString("d"),
                listChild.DisplayWeight.ToString(),
                listChild.FamilyId.ToString()
            };

            sqlite.Insert(TABLE_NAME, columnList, valueList);
        }
Beispiel #11
0
        public static void UpdateOverdueChildren()
        {
            DataTable dt = sqlite.GetDataTable(string.Format(("SELECT * FROM {0} WHERE {1} < '{2}'"), ListChild.TABLE_NAME, ListChild.FIELD_NAME_END_TIME, DateTime.Now.ToString(Global.TIME_FORMAT_STRING)));

            if (dt.Rows.Count > 0)
            {
                sqlite.BeginTransaction();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ListChild listChild = ListChild.GetListChildById(Convert.ToInt32(dt.Rows[i][ListChild.FIELD_NAME_ID]));
                    if ((listChild.Mark != MarkType.Overdue) && (listChild.Mark != MarkType.Abandoned))
                    {
                        listChild.Mark = MarkType.Overdue;
                        UpdateListChild(listChild);
                    }
                }
                sqlite.CommitTransaction();
            }
        }
        public static bool? ShowDialog(Window window, DialogType dialogType, int selectedListFamilyId, ListChild selectedListChild)
        {
            ListChildInfoDialog listChildInfoDialog = null;
            switch (dialogType)
            {
                case DialogType.Add:
                    listChildInfoDialog = new ListChildInfoDialog(selectedListFamilyId);
                    break;
                case DialogType.Edit:
                    listChildInfoDialog = new ListChildInfoDialog(selectedListChild);
                    break;
            }

            if (listChildInfoDialog != null)
            {
                listChildInfoDialog.Owner = window;
                return listChildInfoDialog.ShowDialog().Value;
            }
            return null;
        }
Beispiel #13
0
        /// <summary>
        /// 更新ListChild
        /// </summary>
        /// <param name="listChild"></param>
        public static void UpdateListChild(ListChild listChild)
        {
            List <string> columnsList = new List <string>
            {
                FIELD_NAME_TITLE,
                FIELD_NAME_DETAIL,
                FIELD_NAME_START_TIME,
                FIELD_NAME_END_TIME,
                FIELD_NAME_MARK,
                FIELD_NAME_DISPLAY_WEIGHT,
            };

            List <string> valuesList = new List <string>
            {
                listChild.Title,
                listChild.Detail,
                listChild.StartTime.ToString(Global.TIME_FORMAT_STRING),
                listChild.EndTime.ToString(Global.TIME_FORMAT_STRING),
                listChild.Mark.ToString("d"),
                listChild.DisplayWeight.ToString()
            };

            sqlite.Update(TABLE_NAME, columnsList, valuesList, string.Format("{0} = '{1}'", FIELD_NAME_ID, +listChild.Id));
        }
Beispiel #14
0
        /// <summary>
        /// 更新ListChild
        /// </summary>
        /// <param name="listChild"></param>
        public static void UpdateListChild(ListChild listChild)
        {
            List<string> columnsList = new List<string>
                {
                    FIELD_NAME_TITLE,
                    FIELD_NAME_DETAIL,
                    FIELD_NAME_START_TIME,
                    FIELD_NAME_END_TIME,
                    FIELD_NAME_MARK,
                    FIELD_NAME_DISPLAY_WEIGHT,
                };

            List<string> valuesList = new List<string>
                {
                    listChild.Title,
                    listChild.Detail,
                    listChild.StartTime.ToString(Global.TIME_FORMAT_STRING),
                    listChild.EndTime.ToString(Global.TIME_FORMAT_STRING),
                    listChild.Mark.ToString("d"),
                    listChild.DisplayWeight.ToString()
                };

            sqlite.Update(TABLE_NAME, columnsList, valuesList, string.Format("{0} = '{1}'", FIELD_NAME_ID, +listChild.Id));
        }
Beispiel #15
0
        /// <summary>
        /// 添加 ListChild
        /// </summary>
        /// <param name="listChild"></param>
        public static void AddListChild(ListChild listChild)
        {
            try
            {
                sqlite.CreateTableIfNotExists(
                    TABLE_NAME,                         //表名
                    FIELD_NAME_ID,                      //主键名
                    true,                               //自增
                    FIELD_NAME_TITLE,
                    FIELD_NAME_DETAIL,
                    FIELD_NAME_START_TIME,
                    FIELD_NAME_END_TIME,
                    FIELD_NAME_MARK,
                    FIELD_NAME_DISPLAY_WEIGHT,
                    FIELD_NAME_FAMILY_ID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            List<string> columnList = new List<string>
            {
                FIELD_NAME_TITLE,
                FIELD_NAME_DETAIL,
                FIELD_NAME_START_TIME,
                FIELD_NAME_END_TIME,
                FIELD_NAME_MARK,
                FIELD_NAME_DISPLAY_WEIGHT,
                FIELD_NAME_FAMILY_ID
            };
            List<string> valueList = new List<string>
            {
                    listChild.Title,
                    listChild.Detail,
                    listChild.StartTime.ToString(Global.TIME_FORMAT_STRING),
                    listChild.EndTime.ToString(Global.TIME_FORMAT_STRING),
                    listChild.Mark.ToString("d"),
                    listChild.DisplayWeight.ToString(),
                    listChild.FamilyId.ToString()
            };

            sqlite.Insert(TABLE_NAME, columnList, valueList);
        }
Beispiel #16
0
 /// <summary>
 /// 删除ListChild
 /// </summary>
 /// <param name="listChild"></param>
 public static void DeleteListChild(ListChild listChild)
 {
     sqlite.ExecuteNonQuery(string.Format("DELETE FROM {0} WHERE {1} ='{2}'", TABLE_NAME, FIELD_NAME_ID, listChild.Id));
 }
Beispiel #17
0
 /// <summary>
 /// 通过DataRow获取ListChild
 /// </summary>
 /// <param name="dataRow"></param>
 /// <returns></returns>
 public static ListChild GetListChildByDataRow(DataRow dataRow)
 {
     ListChild listChild = new ListChild();
     listChild.Id = Convert.ToInt16(dataRow[FIELD_NAME_ID].ToString());
     listChild.Title = Convert.ToString(dataRow[FIELD_NAME_TITLE]);
     listChild.Detail = Convert.ToString(dataRow[FIELD_NAME_DETAIL]);
     listChild.StartTime = Convert.ToDateTime(dataRow[FIELD_NAME_START_TIME].ToString());
     listChild.EndTime = Convert.ToDateTime(dataRow[FIELD_NAME_END_TIME].ToString());
     listChild.Mark = (MarkType)Enum.Parse(typeof(MarkType), dataRow[FIELD_NAME_MARK].ToString(), true);
     listChild.DisplayWeight = Convert.ToInt16(dataRow[FIELD_NAME_DISPLAY_WEIGHT].ToString());
     listChild.FamilyId = Convert.ToInt16(dataRow[FIELD_NAME_FAMILY_ID].ToString());
     return listChild;
 }
Beispiel #18
0
 public SelectionChangedEventArgs(int selectionIndex, ListChild selectedListChild)
 {
     this.selectionIndex    = selectionIndex;
     this.selectedListChild = selectedListChild;
 }
Beispiel #19
0
 public SelectionChangedEventArgs(int selectionIndex, ListChild selectedListChild)
 {
     this.selectionIndex = selectionIndex;
     this.selectedListChild = selectedListChild;
 }
        public static bool?ShowDialog(Window window, DialogType dialogType, int selectedListFamilyId, ListChild selectedListChild)
        {
            ListChildInfoDialog listChildInfoDialog = null;

            switch (dialogType)
            {
            case DialogType.Add:
                listChildInfoDialog = new ListChildInfoDialog(selectedListFamilyId);
                break;

            case DialogType.Edit:
                listChildInfoDialog = new ListChildInfoDialog(selectedListChild);
                break;
            }

            if (listChildInfoDialog != null)
            {
                listChildInfoDialog.Owner = window;
                return(listChildInfoDialog.ShowDialog().Value);
            }
            return(null);
        }
Beispiel #21
0
        /// <summary>
        /// 读取 ListChildren
        /// </summary>
        private void ReadListChildren()
        {
            try
            {
                listChildrenDataTable = ListChild.GetListChildrenTable(selectedListFamily);
                if (listChildrenDataTable.Rows.Count == 0)
                {
                    btnEditListChild.IsEnabled   = false;
                    btnDeleteListChild.IsEnabled = false;
                    btnMarkListChild.IsEnabled   = false;
                }
                else
                {
                    btnEditListChild.IsEnabled   = true;
                    btnDeleteListChild.IsEnabled = true;
                    btnMarkListChild.IsEnabled   = true;
                    listChildrenDisplayPart.LoadListChildItems(listChildrenDataTable);

                    if (listChildrenDisplayPart.SelectionIndex == listChildrenDataTable.Rows.Count)
                    {
                        listChildrenDisplayPart.SelectionIndex -= 1;
                    }
                    else if (listChildrenDisplayPart.SelectionIndex < 0)
                    {
                        listChildrenDisplayPart.SelectionIndex = 0;
                    }
                }

                ListChildrenTitleUpTriangle.Visibility   = Visibility.Collapsed;
                ListChildrenTitleDownTriangle.Visibility = Visibility.Collapsed;
                ListChildrenTimeUpTriangle.Visibility    = Visibility.Collapsed;
                ListChildrenTimeDownTriangle.Visibility  = Visibility.Collapsed;
                ListChildrenMarkUpTriangle.Visibility    = Visibility.Collapsed;
                ListChildrenMarkDownTriangle.Visibility  = Visibility.Collapsed;

                switch (selectedListFamily.SortType)
                {
                case SortType.Title:
                    ListChildrenTitleUpTriangle.Visibility   = Visibility.Visible;
                    ListChildrenTitleDownTriangle.Visibility = Visibility.Visible;
                    if (selectedListFamily.SortSequence == SortSequence.Asc)
                    {
                    }
                    else
                    {
                    }
                    break;

                case SortType.StartTime:
                    ListChildrenTimeUpTriangle.Visibility   = Visibility.Visible;
                    ListChildrenTimeDownTriangle.Visibility = Visibility.Visible;
                    break;

                case SortType.Mark:
                    ListChildrenMarkUpTriangle.Visibility   = Visibility.Visible;
                    ListChildrenMarkDownTriangle.Visibility = Visibility.Visible;
                    break;
                }
            }
            catch (Exception ex)
            {
                App.writeLog.Warn("未能从数据库中读取ListChildren", ex);
            }
        }
Beispiel #22
0
 /// <summary>
 /// 删除ListChild
 /// </summary>
 /// <param name="listChild"></param>
 public static void DeleteListChild(ListChild listChild)
 {
     sqlite.ExecuteNonQuery(string.Format("DELETE FROM {0} WHERE {1} ='{2}'", TABLE_NAME, FIELD_NAME_ID, listChild.Id));
 }