Example #1
0
        public static ArrayList LoadPartner(string file)
        {
            ArrayList partners = new ArrayList();

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

            foreach (XmlNode partner in root.ChildNodes)
            {
                Partner par = new Partner();
                par.name = partner.Attributes["name"].Value;
                par.telephone = partner.Attributes["telephone"].Value;
                par.comment = partner.Attributes["comment"].Value;
                par.funds = new ArrayList();
                foreach (XmlNode fund in partner.ChildNodes)
                {
                    Fund f = new Fund();
                    f.volume = double.Parse(fund.Attributes["volume"].Value);
                    f.rate = double.Parse(fund.Attributes["rate"].Value);
                    f.cycle = (Cycle)Enum.ToObject(typeof(Cycle), byte.Parse(fund.Attributes["cycle"].Value));
                    f.start = DateTime.Parse(fund.Attributes["start"].Value);
                    f.end = DateTime.Parse(fund.Attributes["end"].Value);
                    f.comment = fund.Attributes["comment"].Value;
                    par.funds.Add(f);
                }
                partners.Add(par);
            }

            return partners;
        }
Example #2
0
        private void button_save_Click(object sender, EventArgs e)
        {
            if (textBox_name.Text == "")
            {
                MessageBox.Show("请输入股东姓名!", "更新股东", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox_name.Focus();
                return;
            }

            Partner partner = new Partner();

            partner.name      = textBox_name.Text;
            partner.telephone = textBox_phone.Text;
            partner.comment   = textBox_comment.Text;
            partner.funds     = new ArrayList();
            foreach (DataGridViewRow row in dataGridView_volume.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[1] != null && row.Cells[2].Value != null)
                {
                    Fund fund = new Fund();
                    fund.volume = double.Parse(row.Cells[0].Value.ToString());
                    fund.rate   = double.Parse(row.Cells[1].Value.ToString());
                    if (row.Cells[2].Value.ToString() == "0")
                    {
                        fund.cycle = Cycle.undefined;
                    }
                    else if (row.Cells[2].Value.ToString() == "1")
                    {
                        fund.cycle = Cycle.monthly;
                    }
                    else if (row.Cells[2].Value.ToString() == "2")
                    {
                        fund.cycle = Cycle.seasonly;
                    }
                    else if (row.Cells[2].Value.ToString() == "3")
                    {
                        fund.cycle = Cycle.halfyearly;
                    }
                    else if (row.Cells[2].Value.ToString() == "4")
                    {
                        fund.cycle = Cycle.yearly;
                    }
                    else
                    {
                        fund.cycle = Cycle.undefined;
                    }
                    fund.start   = (DateTime)row.Cells[3].Value;
                    fund.end     = (DateTime)row.Cells[4].Value;
                    fund.comment = row.Cells[5].Value == null ? "" : row.Cells[5].Value.ToString();
                    partner.funds.Add(fund);
                }
            }
            foreach (Partner par in Form_Main.ar_Partners)
            {
                if (par.name == partner.name)
                {
                    if (DialogResult.Yes == MessageBox.Show("请确认更新股东信息: \"" + par.name + "\"", "更新股东信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        Form_Main.ar_Partners.Insert(Form_Main.ar_Partners.IndexOf(par), partner);
                        Form_Main.ar_Partners.Remove(par);
                        try
                        {
                            Xml.UpdatePartner(Form_Main.file_Partners, Form_Main.ar_Partners);
                            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("请确认添加股东: \"" + partner.name + "\"", "新添加股东", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                Form_Main.ar_Partners.Add(partner);
                try
                {
                    Xml.UpdatePartner(Form_Main.file_Partners, Form_Main.ar_Partners);
                    MessageBox.Show("股东信息添加成功!", "新建股东", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Form_Partner_Load(this, null);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("股东信息添加失败!\n\n(" + ex.Message + ")", "新建股东", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #3
0
        private void button_save_Click(object sender, EventArgs e)
        {
            if (textBox_name.Text == "")
            {
                MessageBox.Show("请输入股东姓名!", "更新股东", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBox_name.Focus();
                return;
            }

            Partner partner = new Partner();
            partner.name = textBox_name.Text;
            partner.telephone = textBox_phone.Text;
            partner.comment = textBox_comment.Text;
            partner.funds = new ArrayList();
            foreach (DataGridViewRow row in dataGridView_volume.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[1] != null && row.Cells[2].Value != null)
                {
                    Fund fund = new Fund();
                    fund.volume = double.Parse(row.Cells[0].Value.ToString());
                    fund.rate = double.Parse(row.Cells[1].Value.ToString());
                    if (row.Cells[2].Value.ToString() == "0")
                    { fund.cycle = Cycle.undefined; }
                    else if(row.Cells[2].Value.ToString() == "1")
                    { fund.cycle = Cycle.monthly; }
                    else if(row.Cells[2].Value.ToString() == "2")
                    { fund.cycle = Cycle.seasonly; }
                    else if (row.Cells[2].Value.ToString() == "3")
                    { fund.cycle = Cycle.halfyearly; }
                    else if (row.Cells[2].Value.ToString() == "4")
                    { fund.cycle = Cycle.yearly; }
                    else
                    { fund.cycle = Cycle.undefined; }
                    fund.start = (DateTime)row.Cells[3].Value;
                    fund.end = (DateTime)row.Cells[4].Value;
                    fund.comment = row.Cells[5].Value == null ? "" : row.Cells[5].Value.ToString();
                    partner.funds.Add(fund);
                }
            }
            foreach(Partner par in Form_Main.ar_Partners)
            {
                if (par.name == partner.name)
                {
                    if (DialogResult.Yes == MessageBox.Show("请确认更新股东信息: \"" + par.name + "\"", "更新股东信息", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        Form_Main.ar_Partners.Insert(Form_Main.ar_Partners.IndexOf(par), partner);
                        Form_Main.ar_Partners.Remove(par);
                        try
                        {
                            Xml.UpdatePartner(Form_Main.file_Partners, Form_Main.ar_Partners);
                            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("请确认添加股东: \"" + partner.name + "\"", "新添加股东", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
            {
                Form_Main.ar_Partners.Add(partner);
                try
                {
                    Xml.UpdatePartner(Form_Main.file_Partners, Form_Main.ar_Partners);
                    MessageBox.Show("股东信息添加成功!", "新建股东", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Form_Partner_Load(this, null);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("股东信息添加失败!\n\n(" + ex.Message + ")", "新建股东", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }