📄 管理员信息.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
namespace 图书馆管理系统
{
public partial class 管理员信息 : Form
{
public BindingManagerBase Navigator;
public 管理员信息()
{
InitializeComponent();
}
public void TextReadOnly(bool A)
{
textBox1.ReadOnly = A;
textBox2.ReadOnly = A;
textBox3.ReadOnly = A;
textBox4.ReadOnly = A;
textBox5.ReadOnly = A;
textBox6.ReadOnly = A;
textBox7.ReadOnly = A;
}
public void showButton(bool A)
{
button1.Visible = !A;
button2.Visible = !A;
button3.Visible = !A;
}
private void 管理员信息_Load(object sender, EventArgs e)
{
sqlDataAdapter1.Fill(dataSet11, "管理员信息");
Navigator = this.BindingContext[dataSet11, "管理员信息"];
TextReadOnly(true);
}
//-------------------上一条------------------
private void button4_Click(object sender, EventArgs e)
{
if (Navigator.Position == 0)
Navigator.Position = 0;
else
Navigator.Position--;
}
//--------------------------------------下一条-----------------
private void button5_Click(object sender, EventArgs e)
{
if (Navigator.Position == Navigator.Count-1)
Navigator.Position = Navigator.Count-1;
else
Navigator.Position++;
}
//-------------------------------------------浏览图片-------------------------------------------
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.ShowDialog();
if (open.FileName != "")
{
Stream myStream = open.OpenFile();
int length =(int) myStream.Length;
byte[] bytes=new byte [length];
myStream.Read(bytes, 0, length);
myStream.Close();
dataSet11.Tables["管理员信息"].Rows[Navigator.Position][7] = bytes;
}
}
//----------------------保存图象---------------------------------------------
private void button2_Click(object sender, EventArgs e)
{
SqlCommandBuilder mycb = new SqlCommandBuilder(sqlDataAdapter1);
int num=sqlDataAdapter1.Update(dataSet11, "管理员信息");
if (num != 0)
MessageBox.Show("保存操作成功!");
}
//-------------------------------------删除图象---------------------
private void button3_Click(object sender, EventArgs e)
{
byte[] bytes = System.Text.Encoding.Unicode.GetBytes("");
dataSet11.Tables["管理员信息"].Rows[Navigator.Position][7] = bytes;
MessageBox.Show("删除操作成功!");
}
private void button6_Click(object sender, EventArgs e)
{
this.Close();
}
private void button7_Click(object sender, EventArgs e)
{
dataSet11.Clear();
sqlDataAdapter1.Fill(dataSet11, "管理员信息");
TextReadOnly(true);
}
private void button9_Click(object sender, EventArgs e)//----新增
{
try
{
Navigator.AddNew();
TextReadOnly(false);
}
catch (SqlException ab)
{
MessageBox.Show(ab.Message, "Error");
}
finally {
if (sqlConnection1.State == ConnectionState.Open)
{
sqlConnection1.Close();
}
}
}
private void button8_Click(object sender, EventArgs e)//-----删除
{
DialogResult result = MessageBox.Show("确定要删除这条记录吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (result == DialogResult.OK)
{
Navigator.RemoveAt(Navigator.Position);
sqlDataAdapter1.Update(dataSet11, "图书征订");
}
else
{
MessageBox.Show("不能进行数据删除!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void button10_Click(object sender, EventArgs e)
{
Navigator.CancelCurrentEdit();
TextReadOnly(true);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -