密码管理专家代码

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;

namespace PasswordManage
{
    public partial class frmStart : Form
    {
        public frmStart()
        {
            InitializeComponent();
            this.timer1.Enabled = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (this.Opacity > 0.01)
            {
                this.Opacity = this.Opacity - 0.02;
            }
            else
            {
                this.timer1.Enabled = false;
                this.Hide();//隐藏当前窗体
                //打开一个新窗体
                PersonalEditions pe = new PersonalEditions();
                pe.Show();
            }
        }
    }
}

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;

namespace PasswordManage
{
    public partial class PersonalEditions : Form
    {
        public PersonalEditions()
        {
            InitializeComponent();
        }

        private void PersonalEditions_Load(object sender, EventArgs e)
        {
            this.skinEngine1.SkinFile = "Wave.ssk";
            dsUsers.ReadXml("Users.xml");
            dgdUserKey.DataSource = dsUsers.Tables["UserKey"];
            //设置表头
            dgdUserKey.Columns[0].HeaderText = "序号";
            dgdUserKey.Columns[1].HeaderText = "标题";
            dgdUserKey.Columns[2].HeaderText = "网址";
            dgdUserKey.Columns[3].HeaderText = "姓名";
            dgdUserKey.Columns[4].HeaderText = "密码";
            dgdUserKey.Columns[5].HeaderText = "更新时间";
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void 绿色风格ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.skinEngine1.SkinFile = "WaveColor1.ssk";
        }

        private void 蓝色风格ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.skinEngine1.SkinFile = "Wave.ssk";
        }

        private void PersonalEditions_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void 导出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            if (diaSavaFile.ShowDialog() ==DialogResult.OK)
            {
                dsUsers.WriteXml(@diaSavaFile.FileName+".xml");
                this.Visible = true;
                MessageBox.Show("文件导出成功!", "提醒");
            }
            else
            {
                this.Visible = true;
            }
        }

        private void 导入ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Hide();
            if (diaFile.ShowDialog() == DialogResult.OK)
            {
                if (diaFile.OpenFile()!= null)
                {
                    //将文件导入到新的数据集
                    dsNew.ReadXml(@diaFile.FileName);
                    //遍历新数据集中的行
                    foreach (DataRow dr in dsNew.Tables["UserKey"].Rows)
                    {
                        //新建一行数据
                        DataRow newRow = dsUsers.Tables["UserKey"].NewRow();
                        newRow["Number"] = dr["Number"];
                        newRow["Title"] = dr["Title"];
                        newRow["NetAdd"] = dr["NetAdd"];
                        newRow["Name"] = dr["Name"];
                        newRow["Key"] = dr["Key"];
                        newRow["UpdateTiem"] = dr["UpdateTiem"];
                        //将新建的这行数据添加到旧的数据集中去
                        dsUsers.Tables[0].Rows.Add(newRow);
                    }
                    int n = dsUsers.Tables[0].Rows.Count;
                    for (int i = 0; i < n; i++)
                    {
                        dsUsers.Tables["UserKey"].Rows[i]["Number"] =i + 1;
                    }
                    //将数据写入Users.xml
                    dsUsers.WriteXml(@"Users.xml");
                    MessageBox.Show("文件导入成功!");
                    this.Visible = true;
                }
            }
        }

        private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddKey ak = new AddKey(dsUsers);
            ak.ShowDialog();
        }
    }
}

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;

namespace PasswordManage
{
    public partial class AddKey : Form
    {
        private DataSet dsUsers;
        //通过构造函数传值
        public AddKey(DataSet ds)
        {
            InitializeComponent();
            dsUsers=ds;
            int n=dsUsers.Tables["UserKey"].Rows.Count;
            this.lblNumber.Text=Convert.ToString(n+1);
            this.txtNet.Text="http://";
        }

        private void btnReturn_Click(object sender, EventArgs e)
        {
          this.Close();
        }
           //添加记录
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if(this.txtTitle.Text.Trim()=="")
            {
                MessageBox.Show("标题不能为空!","提醒");
                return;
            }
            DataRow newRow=dsUsers.Tables["UserKey"].NewRow();
            newRow["Number"] = this.lblNumber.Text;
            newRow["Title"] = this.txtTitle.Text;
            newRow["NetAdd"] = this.txtNet.Text;
            newRow["Name"] = this.txtUserName.Text;
            newRow["Key"] = this.txtPassword.Text;
            newRow["UpdateTiem"] = DateTime.Now.ToString();
            dsUsers.Tables["UserKey"].Rows.Add(newRow);
            dsUsers.WriteXml(@"Users.xml");
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

邹琼俊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值