⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emppic.aspx.cs

📁 专业的办公oa代码下载 c#语言编写 三层结构
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Drawing.Imaging;

using qminoa.Common;
using qminoa.Common.Data;
using qminoa.DA;

namespace qminoa.Webs.MR
{
	public class EmpPic : qminoa.Webs.PageBase
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Button cmdUpFile;
		protected System.Web.UI.WebControls.ImageButton cmdOK;
		protected System.Web.UI.WebControls.ImageButton imgDel;
		protected System.Web.UI.WebControls.ImageButton cmdCancel;
		protected System.Web.UI.WebControls.Label lblFileID;
		protected System.Web.UI.WebControls.Label lblErr;
		protected System.Web.UI.WebControls.Label lblEmpID;
		protected System.Web.UI.HtmlControls.HtmlInputFile File1;
		protected System.Web.UI.HtmlControls.HtmlImage lnkPic;

		private void Page_Load(object sender, System.EventArgs e)
		{
			this.PageBegin("人员管理",true);
			if(!Page.IsPostBack)
			{
				lblEmpID.Text = Request.QueryString["PARAM_EMPID"].ToString();
				lnkPic.Src = "emppicdown.aspx?EmpID="+lblEmpID.Text;
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.cmdUpFile.Click += new System.EventHandler(this.cmdUpFile_Click);
			this.cmdOK.Click += new System.Web.UI.ImageClickEventHandler(this.cmdOK_Click);
			this.imgDel.Click += new System.Web.UI.ImageClickEventHandler(this.imgDel_Click);
			this.cmdCancel.Click += new System.Web.UI.ImageClickEventHandler(this.cmdCancel_Click);
			this.Load += new System.EventHandler(this.Page_Load);
			//给“删除”按钮添加确认对话框
			this.imgDel.Attributes.Add("onclick","return confirm (\"确定要删除该人员的照片吗?\");");
		}
		#endregion

		private void cmdUpFile_Click(object sender, System.EventArgs e)
		{
			lblErr.Visible = false;
			Bitmap empPic;
			try
			{
				empPic = new Bitmap(File1.PostedFile.InputStream);
			}
			catch
			{
				lblErr.Text = "错误文件格式,请重试!!";
				lblErr.Visible = true;
				return;
			}
			lnkPic.Src = File1.PostedFile.FileName;
			cmdOK.Visible = true;
		}

		private void cmdOK_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if(this.EmpRightCode  >= 3)
			{
				Bitmap empPic;
				try
				{
					empPic = new Bitmap(lnkPic.Src);
				}
				catch
				{
					lblErr.Text = "错误文件格式,请重试!!";
					lblErr.Visible = true;
					return;
				}
				Bitmap picSmall = new Bitmap(empPic,110,130);
				MemoryStream stream = new MemoryStream();
				picSmall.Save(stream,ImageFormat.Jpeg);
				byte[]  byteArray = stream.ToArray();
				int empID = Convert.ToInt16(lblEmpID.Text,10);
				MrBaseInf PhotoAccess = new MrBaseInf();
				PhotoAccess.UpdateEmpPic(empID,byteArray);
				Response.Redirect("empbase.aspx?empid="+lblEmpID.Text,false);
			}
			else
				JScript.Alert("您没有权限进行此操作!");
		}

		private void cmdCancel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			Response.Redirect("empbase.aspx?empid="+lblEmpID.Text,false);
		}

		private void imgDel_Click(object sender, System.Web.UI.ImageClickEventArgs e)
		{
			if(this.EmpRightCode  >= 3)
			{
				int empID = Convert.ToInt16(lblEmpID.Text,10);
				MrBaseInf PhotoAccess = new MrBaseInf();
				PhotoAccess.UpdateEmpPic(empID,null);
			}
			else
				JScript.Alert("您没有权限进行此操作!");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -