基本信息
源码名称:学籍查看系统(全屏+软键盘)
源码大小:18.23M
文件格式:.rar
开发语言:C#
更新时间:2019-07-18
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
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.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
namespace PPSUCsria
{
public partial class Form1 : Form, IMessageFilter
{
public Form1()
{
InitializeComponent();
Application.AddMessageFilter(this); // 添加消息过滤
timer.Tick = delegate
{
if (unchecked(Environment.TickCount - lastTick) > 10 * 1000) // 测试用60秒
{
backclik();
}
};
timer.Start();
}
#region 计时器
Timer timer = new System.Windows.Forms.Timer() { Interval = 10 * 1000 };
int lastTick = Environment.TickCount;
public bool PreFilterMessage(ref Message m)
{
const int WM_KEYDOWN = 0x0100;
const int WM_LBUTTONDOWN = 0x0201;
const int WM_RBUTTONDOWN = 0x0204;
switch (m.Msg)
{
case WM_KEYDOWN:
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
lastTick = Environment.TickCount;
break;
}
return false;
}
#endregion
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
public string picpathread;
public string[,] picdatare = new string[,] { };
public DataTable picdatab = new DataTable();
int picboxX ;
int picboxY;
int picboxH;
int picboxW ;
int sign;
private void button4_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
listBox1.Visible = false;
label4.Visible = false;
#region 界面适配
//设置输入框自适应
double inputy =(double)( this.Height/2-panel1.Height/2);
panel1.Location = new System.Drawing.Point(panel1.Location.X, Convert.ToInt16(inputy));
//设置图片框尺寸
double pich = (double)(498 - 140) / 498 * this.Height-50;
double picw = (double)this.Width - 480 - 60;
pictureBox3.Size = new System.Drawing.Size(Convert.ToInt16(picw), Convert.ToInt16(pich));
//设置图片框坐标
double picy = (double)(this.Height/2-pictureBox3.Height/2);
//double picx = (double)(this.Width-pictureBox3.Width-60);
pictureBox3.Location = new System.Drawing.Point(480, Convert.ToInt16(picy));
//提示信息坐标
//double infoX = (double)800 / 963 * this.Width;
double infoY = (double)65 / 558 * this.Height;
label4.Location = new System.Drawing.Point(10, Convert.ToInt16(infoY));
//panel1尺寸
double panelH = (double)400 /558 * this.Height;
panel1.Size = new System.Drawing.Size(480, Convert.ToInt16(panelH));
//panel1坐标
double panelY = (double)78 / 558 * this.Height;
panel1.Location = new System.Drawing.Point(0, Convert.ToInt16(panelY));
//logo尺寸
double logoH = (double)120;
pictureBox1.Size = new System.Drawing.Size(Convert.ToInt16(logoH), Convert.ToInt16(logoH));
//logo坐标
double logoX = (double)panel1.Width / 2 - logoH / 2;
double logoY = (double)panel1.Location.X pictureBox1.Width / 4 * 2;
pictureBox1.Location = new System.Drawing.Point(Convert.ToInt16(logoX), Convert.ToInt16(logoY));
////大名称尺寸
//double dmcw = (double)330;
//double dmcH = (double)70;
//pictureBox2.Size = new System.Drawing.Size(330, 60);
//大名称坐标
double dmcX = (double)panel1.Width / 2 - pictureBox2.Width / 2;
double dmcY = (double)pictureBox1.Location.Y pictureBox1.Height pictureBox2.Height / 6 *3;
pictureBox2.Location = new System.Drawing.Point(Convert.ToInt16(dmcX), Convert.ToInt16(dmcY));
////小名称尺寸
//double xmcH = (double)30 / 400 * panel1.Height;
//double xmcw = (double)160 / 30 * xmcH;
//pictureBox4.Size = new System.Drawing.Size(Convert.ToInt16(xmcw), Convert.ToInt16(xmcH));
//小名称坐标
double xmcX = (double)panel1.Width / 2 - pictureBox4.Width / 2;
double xmcY = (double)pictureBox2.Location.Y pictureBox2.Height pictureBox4.Height /4 * 1;
pictureBox4.Location = new System.Drawing.Point(Convert.ToInt16(xmcX), Convert.ToInt16(xmcY));
//入学位置
double lX = (double)panel1.Width / 2 - (label2.Width*2 comboBox1.Width) / 2;
double lY = (double)pictureBox4.Location.Y pictureBox4.Height label2.Height * 5;
label2.Location = new System.Drawing.Point(Convert.ToInt16(lX), Convert.ToInt16(lY));
double cX = (double)label2.Location.X label2.Width 5;
double cY = (double)lY-5;
comboBox1.Location = new System.Drawing.Point(Convert.ToInt16(cX), Convert.ToInt16(cY));
//姓名位置
double tX = cX;
double tY = (double)label2.Location.Y label2.Height label2.Height ;
textBox1.Location = new System.Drawing.Point(Convert.ToInt16(tX), Convert.ToInt16(tY));
double nX = lX;
double nY = (double)tY 5;
label3.Location = new System.Drawing.Point(Convert.ToInt16(nX), Convert.ToInt16(nY));
//查询坐标
double cbX = (double)textBox1.Location.X textBox1.Width-button1.Width;
double cbY = (double)textBox1.Location.Y textBox1.Height button1.Height;
button2.Location = new System.Drawing.Point(Convert.ToInt16(cbX), Convert.ToInt16(cbY));
//返回坐标
double fbX = (double)cX;
double fbY = (double)textBox1.Location.Y textBox1.Height button1.Height;
button1.Location = new System.Drawing.Point(Convert.ToInt16(fbX), Convert.ToInt16(fbY));
//list坐标
double lsX = (double)button2.Location.X button2.Width-listBox1.Width;
double lsY = (double)button2.Location.Y-listBox1.Height-button2.Height/2;
listBox1.Location = new System.Drawing.Point(Convert.ToInt16(lsX), Convert.ToInt16(lsY));
sign = 0;
#endregion
#region 获取图片框的尺寸坐标
picboxX = pictureBox3.Location.X;
picboxY = pictureBox3.Location.Y;
picboxH = pictureBox3.Height;
picboxW = pictureBox3.Width;
#endregion
#region 检测配置文件
if (!Directory.Exists("C:\\PPSUCsria"))
{
Directory.CreateDirectory("C:\\PPSUCsria");
}
string a =Inifile.ReadIniData("PPSUCsria", "picpath", "", "C:\\PPSUCsria\\config.ini");
if (a == "no" || a=="")
{
MessageBox.Show("请点击<路径>,配置文件路径!!!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
}
else
{
#region 读取配置文件
picpathread = Inifile.ReadIniData("PPSUCsria", "picpath", "", "C:\\PPSUCsria\\config.ini");
if (!Directory.Exists(@picpathread))
{
if (MessageBox.Show("配置文件读取失败,请点击<确认>配置文件路径", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
{
wrini();
}
}
else if (havetif(@picpathread))
{
reini();
}
else
{
MessageBox.Show("路径中未找到“*.jpg”文件", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
}
#endregion
}
#endregion
}
private void upbtu_Click(object sender, EventArgs e)
{
#region 读取配置文件
picpathread = Inifile.ReadIniData("PPSUCsria", "picpath", "", "C:\\PPSUCsria\\config.ini");
#endregion
if (havetif(@picpathread))
{
#region 读取文件名
//读取路径下的信息
DirectoryInfo folder = new DirectoryInfo(@picpathread);//文件夹名为,放在软件根目录下
int piccou = folder.GetFiles("*.jpg").Count();
string[,] picda = new string[4, piccou];
//循环文件夹下指定文件的信息
for (int i = 0; i < piccou; i )
// folder.GetFiles("*.txt").Count() 这个的意思是获取文件类型为txt的数量
{
//这里就是 给数组中指定索引来赋值了
string picname = folder.GetFiles("*.jpg")[i].Name;
if (picname.Length > 8)
{
string name = (picname.Substring(0, picname.Length - 4)).Remove(0, 4).Trim();
picda[0, i] = (i 1).ToString();
picda[1, i] = picname.Substring(0, 4);
picda[2, i] = name;
picda[3, i] = picname;
}
label4.Visible = true;
int j = i 1;
label4.Text = "共计" piccou "条数据,已更新" j "条";
System.Windows.Forms.Application.DoEvents();
}
#endregion
#region 获取文件写入数据
using (FileStream fs = new FileStream("C:\\PPSUCsria\\picdata.dat", FileMode.Create))
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, picda);
MessageBox.Show("数据更新成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
label4.Visible = false;
}
#endregion
#region 读取数据文件
reini();
#endregion
}
else
{
MessageBox.Show("路径中未找到“*.jpg”文件", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk);
}
}
private void button1_Click(object sender, EventArgs e)
{
backclik();
}
public void backclik()
{
pictureBox3.Size = new System.Drawing.Size(picboxW, picboxH);
pictureBox3.Location = new System.Drawing.Point(picboxX, picboxY);
pictureBox3.BackColor = Color.Transparent;
pictureBox3.Image = PPSUCsria.Properties.Resources.indextp1;
pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
sign = 0;
listBox1.Items.Clear();
listBox1.Visible = false;
button2.Enabled = true;
textBox1.Text = "";
comboBox1.Text = "请选择";
}
private void button2_Click(object sender, EventArgs e)
{
keyboard.HideInputPanel();
//int index=-10;
if (textBox1.Text != "" && comboBox1.Text == "请选择" || comboBox1.Text != "请选择")
{
if (comboBox1.Text == "请选择")
{
#region 只查询姓名
string na = "'%" textBox1.Text.Trim() "%'";
int sl = (int)picdatab.Compute("count([name])", "name LIKE " na "");
if (sl == 1)
{
DataRow[] dr = picdatab.Select("name LIKE " na "");
string picpathre = picpathread "\\" dr[0][3].ToString();
pictureBox3.Load(picpathre);
pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
sign = 1;
}
else if(sl!=0)
{
DataRow[] dr = picdatab.Select("name LIKE " na "");
int i = (int)dr.Count();
for (int j = 0; j < i; j )
{
listBox1.Items.Add(dr[j][1].ToString() "年" dr[j][2].ToString() " 、" dr[j][0].ToString());
}
button2.Enabled = false;
listBox1.Visible = true;
}
else
{
MessageBox.Show("查无此人!!!","提示");
}
#endregion
}
else if(textBox1.Text!="")
{
#region 入学年份和姓名同时查询
string na = "'%" textBox1.Text.Trim() "%'";
int sl = (int)picdatab.Compute("count([name])", "name LIKE " na "and year=" comboBox1.Text);
if (sl == 1)
{
DataRow[] dr = picdatab.Select("name LIKE " na "and year=" comboBox1.Text);
string picpathre = picpathread "\\" dr[0][3].ToString();
pictureBox3.Load(picpathre);
pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
sign = 1;
}
else if(sl!=0)
{
DataRow[] dr = picdatab.Select("name LIKE " na "and year=" comboBox1.Text);
int i = (int)dr.Count();
for (int j = 0; j < i; j )
{
listBox1.Items.Add(dr[j][1].ToString() "年" dr[j][2].ToString() " 、" dr[j][0].ToString());
}
button2.Enabled = false;
listBox1.Visible = true;
}
else
{
MessageBox.Show("查无此人!!!", "提示");
}
#endregion
}
else
{
#region 入学年份查询
string na = "'%" textBox1.Text.Trim() "%'";
int sl = (int)picdatab.Compute("count([name])", "year=" comboBox1.Text);
if (sl != 0)
{
DataRow[] dr = picdatab.Select("year=" comboBox1.Text);
int i = (int)dr.Count();
for (int j = 0; j < i; j )
{
listBox1.Items.Add(dr[j][1].ToString() "年" dr[j][2].ToString() " 、" dr[j][0].ToString());
}
button2.Enabled = false;
listBox1.Visible = true;
}
else
{
MessageBox.Show("查无此人!!!", "提示");
}
#endregion
}
}
else
{
MessageBox.Show("请输入姓名或者选择入学年份!!!", "提示");
}
//label1.Text = index.ToString();
//pictureBox3.Load(picpathre);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedItems.Count != 0)
{
string liitpic = listBox1.SelectedItem.ToString();
string[] liitpicno = liitpic.Split('、');
DataRow[] dr = picdatab.Select("no= '" liitpicno[1] "'");
string picpathre = picpathread "\\" dr[0][3].ToString();
pictureBox3.Load(picpathre);
pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
sign = 1;
}
}
private void pictureBox3_Click(object sender, EventArgs e)
{
if (sign == 1)
{
if (pictureBox3.Height == picboxH)
{
pictureBox3.Size = new System.Drawing.Size(this.Width, this.Height);
pictureBox3.Location = new System.Drawing.Point(0, 0);
pictureBox3.BackColor = Color.Black;
}
else
{
pictureBox3.Size = new System.Drawing.Size(picboxW, picboxH);
pictureBox3.Location = new System.Drawing.Point(picboxX, picboxY);
pictureBox3.BackColor = Color.Transparent;
}
}
}
private void textBox1_Enter(object sender, EventArgs e)
{
keyboard.ShowInputPanel();
}
private void textBox1_Leave(object sender, EventArgs e)
{
keyboard.HideInputPanel();
}
private void button3_Click(object sender, EventArgs e)
{
wrini();
}
#region 写入配置文件
public void wrini()
{
string picpath;
FolderBrowserDialog dialog = new FolderBrowserDialog();
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
picpath = dialog.SelectedPath;
if (Inifile.WriteIniData("PPSUCsria", "picpath", picpath, "C:\\PPSUCsria\\config.ini"))
{
MessageBox.Show("配置资料路径成功,请点击<更新>,更新数据","提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
else
{
MessageBox.Show("配置资料路径失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
}
#endregion
#region 读取数据文件
public void reini()
{
if (File.Exists("C:\\PPSUCsria\\picdata.dat"))
{
using (FileStream fs = new FileStream("C:\\PPSUCsria\\picdata.dat", FileMode.Open))
{
BinaryFormatter formatter = new BinaryFormatter();
picdatare = (string[,])formatter.Deserialize(fs);
#region 获取入学年份
string[] intcount = new string[picdatare.Length / 4];
for (int k = 0; k < picdatare.Length / 4; k )
{
intcount[k] = picdatare[1, k];
}
List<string> listString = new List<string>();
Array.Sort(intcount);//排序数组
int MaxLine = intcount.Length;
#region 单独计算第一个
listString.Add("请选择");
listString.Add(intcount[0]);
#endregion
for (int i = 2; i < MaxLine; i )
{
if (intcount[i] != intcount[i - 1])
{
listString.Add(intcount[i]);
}
}
comboBox1.DataSource = listString;
//comboBox1.Text = "请选择";
#endregion
#region 把数组给到datatable
picdatab = Datapic.ToDataTable(picdatare);
picdatab.Columns["0"].ColumnName = "no";
picdatab.Columns["1"].ColumnName = "year";
picdatab.Columns["2"].ColumnName = "name";
picdatab.Columns["3"].ColumnName = "path";
#endregion
}
}
else
{
MessageBox.Show("数据不存在,请点击<更新>按钮更新数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
#endregion
#region 判断是否有tif
public bool havetif(string path)
{
string[] files = Directory.GetFileSystemEntries(path);
foreach (var file in files)
{
if (File.Exists(file))
{
FileInfo fi = new FileInfo(file);
if (fi.Extension.ToLower() == ".tif")
return true;
}
else
{
return havetif(file);
}
}
return false;
}
#endregion
}
}