infshow.cs
上传用户:zhongfine
上传日期:2022-08-01
资源大小:2860k
文件大小:4k
- 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.Data.SqlClient;
- using System.IO;
- namespace 人事管理系统
- {
- public partial class infshow : Form
- {
- SqlCommand cmd = new SqlCommand();
- Datacon mydatacon = new Datacon();
- SqlConnection sqlcn = new SqlConnection();
- OpenFileDialog mydlg = new OpenFileDialog();
- public infshow()
- {
- InitializeComponent();
- }
- private void label11_Click(object sender, EventArgs e)
- {
- }
- private void infshow_Load(object sender, EventArgs e)
- {
- }
- int i =1;
- private void button1_Click(object sender, EventArgs e)
- {
- if (label13.Text == label19.Text||label24.Text=="管理员")
- {
- sqlcn = mydatacon.getcon();
- sqlcn.Open();
- cmd.CommandText = "update PERSON set BIRTHDAY='" + dateTimePicker1.Text + "',ADDRESS='" + textBox1.Text + "',TEL='" + textBox2.Text + "',REMARK='" + textBox3.Text + "' where ID='" + label13.Text + "'";
- cmd.Connection = sqlcn;
- cmd.ExecuteNonQuery();
- Stream ms;
- byte[] picbyte;
- if (pictureBox1.Image != null)
- {
- //cmd.CommandText = "update PERSON set PHOTO=null where ID='"+label13.Text+"'";
- //cmd.ExecuteNonQuery();
- if (i != 1)
- {
- if ((ms = mydlg.OpenFile()) != null)
- {
- picbyte = new byte[ms.Length];
- ms.Position = 0;
- ms.Read(picbyte, 0, Convert.ToInt32(ms.Length));
-
- SqlCommand csd = new SqlCommand("update PERSON set PHOTO=@zhaopian where ID='" + label13.Text + "'", sqlcn);
- csd.Parameters.Add("@zhaopian", SqlDbType.Image);
- csd.Parameters["@zhaopian"].Value = picbyte;
- csd.ExecuteNonQuery();
- ms.Close();
- }
- }
- }
- MessageBox.Show("当前修改保存成功!");
- sqlcn.Close();
- }
- else
- {
- MessageBox.Show("您不是当前页面员工或管理员,无法修改信息!");
- return;
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- mydlg.Title = "选择照片";
- mydlg.Filter = "JPEG图像文件(*JPG)|*jpg|所有图像文件(*GIF,*BMP,*JPEG,etc)|*gif;*bmp;*jpeg;*jpeg;*tif;*tiff;*png|所有文件(*.*)|*.*";
- if (mydlg.ShowDialog() == DialogResult.OK)
- {
- Image image = Image.FromFile(mydlg.FileName);
- pictureBox1.Image = image;
- i = 0;
- return;
- }
- i = 1;
- }
- private void button4_Click(object sender, EventArgs e)
- {
- if (label13.Text == label19.Text || label24.Text == "管理员")
- {
- pictureBox1.Image = null;
- sqlcn = mydatacon.getcon();
- sqlcn.Open();
- cmd.Connection = sqlcn;
- cmd.CommandText = "update PERSON set PHOTO=null where ID='" + label13.Text + "'";
- cmd.ExecuteNonQuery();
- }
- else
- {
- MessageBox.Show("您不是当前页面员工或管理员,无法修改信息!");
- return;
- }
- }
- }
- }