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;
using System.IO.Compression;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;namespace Server
{
[Serializable]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//创建DBHelper对象
DBHelper dbh = new DBHelper(); //点击登陆
private void button1_Click(object sender, EventArgs e)
{
string sql = string.Format("select count(*) from [T_DepartManager] where [ID] = '{0}' and [password] = '{1}'", txtName.Text, txtPwd.Text);
int res = (int)dbh.DataScalar(sql);
if (res > 0)
{
//Form1.DeSerialize();
Form1.toBin();
MessageBox.Show("登陆成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("登陆失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtPwd.Clear();
}
}
//点击取消
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void linkLabel1_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.baidu.com");
}
public static void toBin()
{
Form1 name = new Form1();
using (FileStream fs = new FileStream("c:\\name.txt", FileMode.Create))
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs,name.txtName.Text); }
}
public static void DeSerialize()
{ using (FileStream fileStream = new FileStream("c:\\name.dat", FileMode.Open, FileAccess.Read, FileShare.Read))
{
BinaryFormatter b = new BinaryFormatter();
Form1 name = new Form1();
name = b.Deserialize(fileStream)as Form1;
Console.WriteLine(name.txtName.Text);
fileStream.Close();
}
}
}
}
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;
using System.IO.Compression;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;namespace Server
{
[Serializable]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//创建DBHelper对象
DBHelper dbh = new DBHelper(); //点击登陆
private void button1_Click(object sender, EventArgs e)
{
string sql = string.Format("select count(*) from [T_DepartManager] where [ID] = '{0}' and [password] = '{1}'", txtName.Text, txtPwd.Text);
int res = (int)dbh.DataScalar(sql);
if (res > 0)
{
//Form1.DeSerialize();
Form1.toBin();
MessageBox.Show("登陆成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show("登陆失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.txtPwd.Clear();
}
}
//点击取消
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void linkLabel1_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("http://www.baidu.com");
}
public static void toBin()
{
Form1 name = new Form1();
using (FileStream fs = new FileStream("c:\\name.txt", FileMode.Create))
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs,name.txtName.Text); }
}
public static void DeSerialize()
{ using (FileStream fileStream = new FileStream("c:\\name.dat", FileMode.Open, FileAccess.Read, FileShare.Read))
{
BinaryFormatter b = new BinaryFormatter();
Form1 name = new Form1();
name = b.Deserialize(fileStream)as Form1;
Console.WriteLine(name.txtName.Text);
fileStream.Close();
}
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货