点击回首页
我的浏览记录 | | 帮助?
当前位置:
首页>> 学教实践>> HFC个人财务管理系统源码>> 源文件浏览
[免费版 Free] WinForm,下载次数:1537 次 | 关键字: 财务管理 报表 WebForm XML 序列化 反序列化

源码截图

源码目录树

当前路径:AddBillUse.cs     using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace FinancialManager
{
    public partial class AddBillUse : Form
    {
        public string UserName { get; set; }
        public AddBillUse(string name)
        {
            InitializeComponent();
            UserName = name;
        }
        public const string dir = "User\\";
        private const string path = "\\use.xml";
        private void btnReg_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtAccount.Text))
            {
                MessageBox.Show("输入账户用处不能为空!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            try
            {
                UserList list = new UserList();
                string url = dir + UserName + path;
                if (File.Exists(url))
                {
                    Serializer.Deserialize(url, ref list);
                }
                List<UserInfo> userlist = new List<UserInfo>();
                string id = CRC32.GetCRC32(txtAccount.Text).ToString();
                if (list.List != null)
                {
                    userlist = list.List;
                    bool flag = false;
                    for (int i = 0; i < userlist.Count; i++)
                    {
                        if (userlist[i].ID == id)
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (flag)
                    {
                        MessageBox.Show("账户用处已经存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.DialogResult = DialogResult.OK;
                        return;
                    }
                }
                UserInfo user = new UserInfo();
                user.ID = id;
                user.Account = txtAccount.Text;
                user.UserTime = DateTime.Now.ToString("yyyy-MM-dd");
                userlist.Add(user);
                list.List = userlist;
                Serializer.Serialiaze(url, list);
                Element em = new Element();
                string urls = "Templet\\Templet.xml";
                if (File.Exists(urls))
                {
                    Serializer.Deserialize(urls, ref em);
                }
                em = ElementSer.GetElement(em, txtAccount.Text, id, "账单用处");
                Serializer.Serialiaze(urls, em);
                if (MessageBox.Show("添加账户用处成功", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information) == DialogResult.OK)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                return;
            }
            catch
            {
                MessageBox.Show("添加账户用处失败", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }

        private void button_Cancel_Click(object sender, EventArgs e)
        {
            txtAccount.Text = "";
        }
    }
}
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2015. 京ICP备09089570号 | 京公网安备11010702000869号
分享该页面
关闭侧边栏