Exemple #1
0
        private void button_save_Click(object sender, EventArgs e)
        {
            if (textBox_name.Text == "" || numericUpDown_volume.Value == 0 || numericUpDown_rate.Value == 0)
            {
                MessageBox.Show("请输入完整项目信息!", "保存项目", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox_name.Focus();
                return;
            }

            Project proj = new Project();
            proj.name = textBox_name.Text;
            proj.contact = textBox_contact.Text;
            proj.telephone = textBox_phone.Text;
            proj.comment = textBox_comment.Text;
            proj.volume = (int)numericUpDown_volume.Value;
            proj.rate = (double)numericUpDown_rate.Value;
            proj.cycle = (Cycle)Enum.ToObject(typeof(Cycle), byte.Parse(comboBox_cycle.SelectedIndex.ToString()));
            proj.start = dateTimePicker_start.Value;
            proj.end = dateTimePicker_end.Value;
            foreach (Project project in Form_Main.ar_Projects)
            {
                if (project.name == textBox_name.Text)
                {
                    if (DialogResult.Yes == MessageBox.Show("请确认更新项目信息: \"" + project.name + "\"", "更新项目", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        Form_Main.ar_Projects.Insert(Form_Main.ar_Projects.IndexOf(project), proj);
                        Form_Main.ar_Projects.Remove(project);
                        try
                        {
                            Xml.UpdateProject(Form_Main.file_Projects, Form_Main.ar_Projects);
                            MessageBox.Show("项目信息更新成功!", "更新项目", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("项目信息更新失败!\n\n(" + ex.Message + ")", "更新项目", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    return;
                }
            }
            if (DialogResult.Yes == MessageBox.Show("请确认添加项目: \"" + proj.name + "\"", "新建项目", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                Form_Main.ar_Projects.Add(proj);
                try
                {
                    Xml.UpdateProject(Form_Main.file_Projects, Form_Main.ar_Projects);
                    MessageBox.Show("项目信息添加成功!", "新建项目", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Form_Project_Load(this, null);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("项目信息添加失败!\n\n(" + ex.Message + ")", "新建项目", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #2
0
        private void button_save_Click(object sender, EventArgs e)
        {
            GroupBox gb = ((sender as Button).Parent as TabPage).Controls["groupBox_cash"] as GroupBox;
            string name = (gb.Controls["textBox_name"] as TextBox).Text;
            double volume = (double)(gb.Controls["numericUpDown_volume"] as NumericUpDown).Value;
            double rate = (double)(gb.Controls["numericUpDown_rate"] as NumericUpDown).Value;
            int cycle = (gb.Controls["comboBox_cycle"] as ComboBox).SelectedIndex;
            int day = (gb.Controls["comboBox_day"] as ComboBox).SelectedIndex;

            if (name == "" || volume == 0 || rate == 0 || cycle == -1 || day == -1)
            {
                MessageBox.Show("请输入完整项目信息!", "新建项目", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (Project p in ar_Projects)
            {
                if (p.name == name)
                {
                    MessageBox.Show("已存在同名项目!请重新输入项目名称!", "新建项目失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            Project project = new Project();
            project.name = name;
            project.contact = (gb.Controls["textBox_contact"] as TextBox).Text;
            project.telephone = (gb.Controls["textBox_phone"] as TextBox).Text;
            project.comment = (gb.Controls["textBox_comment"] as TextBox).Text;
            project.volume = volume;
            project.rate = rate;
            project.cycle = (Cycle)Enum.ToObject(typeof(Cycle), byte.Parse(cycle.ToString()));

            DateTime curMonth = DateTime.Parse(((((sender as Button).Parent as TabPage).Parent as TabControl).Parent as GroupBox).Text);
            project.start = new DateTime(curMonth.Year, curMonth.Month, day + 1);
            project.end = new DateTime(2100, 1, 1);

            if (DialogResult.Yes == MessageBox.Show("请确认添加项目: \"" + project.name + "\"", "新建项目", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                ar_Projects.Add(project);
                try
                {
                    Xml.UpdateProject(file_Projects, ar_Projects);
                    MessageBox.Show("项目信息添加成功!", "新建项目", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Reload();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("项目信息添加失败!\n\n(" + ex.Message + ")", "新建项目", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #3
0
        private void button_updateinvest_Click(object sender, EventArgs e)
        {
            GroupBox gb = (sender as Button).Parent as GroupBox;
            string name = (gb.Controls["textBox_nameinvest"] as TextBox).Text;
            double volume = (double)(gb.Controls["numericUpDown_volumeinvest"] as NumericUpDown).Value;
            double rate = (double)(gb.Controls["numericUpDown_rateinvest"] as NumericUpDown).Value;
            int cycle = (gb.Controls["comboBox_cycleinvest"] as ComboBox).SelectedIndex;
            int day = (gb.Controls["comboBox_dayinvest"] as ComboBox).SelectedIndex;

            if (name == "" || volume == 0 || rate == 0 || cycle == -1 || day == -1)
            {
                MessageBox.Show("请输入完整项目信息!", "更新项目", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (Project p in ar_Projects)
            {
                if (p.name == name)
                {
                    if (DialogResult.Yes == MessageBox.Show("请确认更新项目: \"" + p.name + "\"\n\n注:更新的项目信息会影响此前的资金量计算,请谨慎操作\n\n建议: 若调整投资额、收益率、付息周期、付息日,请中止当前项目并新建项目", "更新项目", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        Project project = new Project();
                        project.name = name;
                        project.contact = (gb.Controls["textBox_contactinvest"] as TextBox).Text;
                        project.telephone = (gb.Controls["textBox_telephoneinvest"] as TextBox).Text;
                        project.comment = (gb.Controls["textBox_commentinvest"] as TextBox).Text;
                        project.volume = volume;
                        project.rate = rate;
                        project.cycle = (Cycle)Enum.ToObject(typeof(Cycle), byte.Parse(cycle.ToString()));
                        project.start = new DateTime(p.start.Year, p.start.Month, day + 1); ;
                        project.end = p.end;

                        ar_Projects.Remove(p);
                        ar_Projects.Add(project);

                        try
                        {
                            Xml.UpdateProject(file_Projects, ar_Projects);
                            MessageBox.Show("项目信息更新成功!", "更新项目", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            Reload();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("项目信息更新失败!\n\n(" + ex.Message + ")", "更新项目", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    return;
                }
            }

            MessageBox.Show("未找到项目\"" + name + "\"!", "更新项目", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Exemple #4
0
        public static ArrayList LoadProject(string file)
        {
            ArrayList projects = new ArrayList();

            XmlDocument xml = new XmlDocument();
            xml.Load(file);
            XmlNode root = xml.SelectSingleNode("Projects");

            foreach (XmlNode project in root.ChildNodes)
            {
                Project proj = new Project();
                proj.name = project.Attributes["name"].Value;
                proj.contact = project.Attributes["contact"].Value;
                proj.telephone = project.Attributes["telephone"].Value;
                proj.volume = double.Parse(project.Attributes["volume"].Value);
                proj.rate = double.Parse(project.Attributes["rate"].Value);
                proj.cycle = (Cycle)(Enum.ToObject(typeof(Cycle), byte.Parse(project.Attributes["cycle"].Value)));
                proj.start = DateTime.Parse(project.Attributes["start"].Value);
                proj.end = DateTime.Parse(project.Attributes["end"].Value);
                proj.comment = project.Attributes["comment"].Value;
                projects.Add(proj);
            }

            return projects;
        }