コード例 #1
0
        internal Annual GetDeepCopy()
        {
            Annual a = new Annual();

            //a.accumulatedValue = this.accumulatedValue;
            a.currentValue = this.currentValue;
            a.targetValue  = this.targetValue;
            a.year         = this.year.GetDeepCopy();

            return(a);
        }
コード例 #2
0
        private void OptionClicked(object sender, RoutedEventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            if (mi != null)
            {
                if (mi.Header.Equals("_Details"))
                {
                    try
                    {
                        string details = Annual.GetAnnualDetails(this.annualTargetList);

                        统计信息 info = new 统计信息(loginedUser.UserFolder, details);

                        info.ShowDialog();
                    }
                    catch (InvalidOperationException ioe)
                    {
                        return;
                    }
                    catch (Exception ex)
                    {
                        return;
                    }
                }
                else if (mi.Header.Equals("_Developer Options"))
                {
                    SetParams set = new SetParams(this.staticAccountCollection[1],
                                                  this.staticAccountCollection[2],
                                                  this.staticAccountCollection[3],
                                                  this.staticAccountCollection[0]);

                    set.ShowDialog();
                }
                else if (mi.Header.Equals("_ScrollBack"))
                {
                    /*SetParams set = new SetParams(this.staticAccountCollection[1],
                     *  this.staticAccountCollection[2],
                     *  this.staticAccountCollection[3]);
                     *
                     * set.ShowDialog();*/
                    MessageBox.Show("未找到备份文件");
                }
                else if (mi.Header.Equals("_Import History Record"))
                {
                    ImportOpMsgs();
                }
            }
        }
コード例 #3
0
        private void annualsCmb_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cmb = sender as ComboBox;

            if (cmb != null)
            {
                if (cmb.SelectedIndex != -1)
                {
                    targetAnnual = this.annuals[cmb.SelectedIndex];

                    //更新年度计划显示
                    this.targetTb.Text  = targetAnnual.TargetValue.ToString("F2");
                    this.initValTb.Text = targetAnnual.CurrentValue.ToString("F2");
                }
            }
        }
コード例 #4
0
        private static string annualDescription(Annual a)
        {
            string s = null;

            if (a != null)
            {
                s += ("年度:" + a.Year.Name);
                s += ("\n起止时间:" + a.Year.TimeSpan);
                s += ("\n目标:" + a.TargetValue.ToString());
                s += ("\n实现:" + a.CurrentValue.ToString());
                s += ("\n完成度:" + a.GetCompleteDegree().ToString("F2"));
                s += "\n\n";
            }

            return(s);
        }
コード例 #5
0
        private void LoadAnnuals()
        {
            //加载年度计划列表失败,重新创建一个计划列表,并重新创建一个当前年度对应的计划对象
            if (!Annual.Load(this.annualSavePath, out this.annualTargetList))
            {
                //创建年度计划列表
                this.annualTargetList = new List <Annual>();
                //创建当前年度计划
                this.currentAnnualTarget = new Annual();

                this.currentAnnualTarget.TargetValue  = 70000;
                this.currentAnnualTarget.CurrentValue = this.staticAccountCollection[0].TotalValue;
                this.currentAnnualTarget.SetYear(DateTime.Now.Year);

                this.annualTargetList.Add(this.currentAnnualTarget);
            }

            //找到当前的年度计划

            /*******************************************************************
             * 如果日期在5.1日(不含)之前,为上一年度,之后为本年度
             ******************************************************************/
            int year = (DateTime.Now.Month < 5) ? (DateTime.Now.Year - 1) : (DateTime.Now.Year);

            this.currentAnnualTarget = FindAnnualTargetByYear(year);

            //判断是否未找到年度计划,或者已进入新年度,如果进入新的年度则新建一个AnnualTarget实例作为当前年度。
            if (this.currentAnnualTarget == null ||
                this.currentAnnualTarget.WithinCurrentYear(DateTime.Today) == 1)
            {
                //创建当前年度计划
                this.currentAnnualTarget = new Annual();

                this.currentAnnualTarget.TargetValue  = 70000;
                this.currentAnnualTarget.CurrentValue = 0;
                this.currentAnnualTarget.SetYear(DateTime.Now.Year);

                this.annualTargetList.Add(this.currentAnnualTarget);
            }

            //刷新界面显示
            //刷新年度计划信息
            this.currentAnnualTarget.UpdateForeground(this.CompletePercentBar);

            //设置与年度计划相关的绑定值
            SetAnnualBinding();
        }
コード例 #6
0
        /// <summary>
        /// 载入数据,设置对象失败返回false,对象将为null
        /// </summary>
        /// <returns></returns>
        public static bool Load(string path, out List <Annual> an)
        {
            try
            {
                an = null;

                //拆分为多个annual_target.toString()数据
                if (!File.Exists(path))
                {
                    return(false);
                }

                string[] temp = File_Operate.LoadFromTextFile(path);

                if (temp == null)
                {
                    return(false);
                }

                string[] infos = temp[0].Split("*".ToArray(), StringSplitOptions.RemoveEmptyEntries);

                if (infos.Length > 0)
                {
                    //创建对象
                    an = new List <Annual>();

                    for (int i = 0; i < infos.Length; i++)
                    {
                        Annual a = new Annual();

                        GetAnnualDetailsFromStrings(infos[i].Split('#'), a);

                        an.Add(a);
                    }

                    return(true);
                }
            }
            catch (Exception e)
            {
                an = null;

                return(false);
            }

            return(false);
        }
コード例 #7
0
        /// <summary>
        /// 选择日期,
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void datePicker1_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            DatePicker dg = sender as DatePicker;

            if (dg != null &&
                dg.SelectedDate != null)
            {
                //加载对应的年度计划
                DateTime select = dg.SelectedDate.Value;
                int      year   = select.Year;

                //看所选日期在哪一年度
                //4.30日之前按前一年算
                if (select.CompareTo(new DateTime(year, 4, 30)) <= 0)
                //if (select.Month < 5 &&
                //        select.Day < 30)
                {
                    year = select.Year - 1;
                }

                this.currentAnnualTarget = FindAnnualTargetByYear(year);

                //如果未找到该年度计划,新建一个
                if (this.currentAnnualTarget == null)
                {
                    this.currentAnnualTarget = new Annual();

                    this.currentAnnualTarget.TargetValue  = 85000.00;
                    this.currentAnnualTarget.CurrentValue = 0.00;
                    this.currentAnnualTarget.SetYear(year);

                    //添加到年度计划列表中
                    if (this.annualTargetList != null)
                    {
                        this.annualTargetList.Add(this.currentAnnualTarget);
                    }
                }

                //刷新界面显示
                //刷新年度计划信息
                this.currentAnnualTarget.UpdateForeground(this.CompletePercentBar);

                //重新设置与年度计划相关的绑定值
                SetAnnualBinding();
            }
        }
コード例 #8
0
        private void Save()
        {
            //获取要保存的参数
            string content = "";

            //保存静态账户数据
            if (this.staticAccountCollection.Count > 0)
            {
                foreach (AccountClass a in this.staticAccountCollection)
                {
                    content += a.ToString() + "#";
                }
            }
            //保存动态账户数据
            if (this.dynamicAccountCollection.Count > 0)
            {
                foreach (AccountClass a in this.dynamicAccountCollection)
                {
                    content += a.ToString() + "#";
                }
            }

            //保存参数
            if (!File_Encode_Operate.SaveToTextFileAndHideFile(this.dataSavePath, content))
            {
                //参数保存失败
                MessageBox.Show("参数保存失败!");
            }

            //保存年度计划
            if (this.annualTargetList.Count > 0)
            {
                if (!Annual.Save(this.annualSavePath, this.annualTargetList))
                {
                    //参数保存失败
                    MessageBox.Show("参数保存失败!");
                }
            }

            //保存logcat信息
            SaveLogcatMessage(this.infoSavePath, this.logcatRtb);

            //根据设定更新版本信息
            updateVersion();
        }
コード例 #9
0
        private static void GetAnnualDetailsFromStrings(string[] temp, Annual a)
        {
            DateTime date = new DateTime();

            a.year.Name = temp[0];

            DateTime.TryParse(temp[1], out date);
            a.year.BeginDate = date;

            DateTime.TryParse(temp[2], out date);
            a.year.EndDate = date;

            a.targetValue = double.Parse(temp[3]);

            a.currentValue = double.Parse(temp[4]);

            //a.accumulatedValue = double.Parse(temp[5]);
        }