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

📄 updatesalary.aspx.cs

📁 人事管理系统是非常通用的信息管理系统
💻 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 MisPersonnel.Components;
using System.Data.SqlClient;

namespace MisPersonnel.DesktopModules.Salary
{
	/// <summary>
	/// UpdateSalary 的摘要说明。
	/// </summary>
	public class UpdateSalary : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.TextBox Desn;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfDe;
		protected System.Web.UI.WebControls.Label lblAdditionalNo;
		protected System.Web.UI.WebControls.TextBox NewSalary;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfNew;
		protected System.Web.UI.WebControls.RegularExpressionValidator reNew;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Web.UI.WebControls.TextBox OldSalary;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfOld;
		protected System.Web.UI.WebControls.RegularExpressionValidator reOld;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.TextBox PubDate;
		protected System.Web.UI.WebControls.RequiredFieldValidator rfPub;
		protected System.Web.UI.WebControls.RegularExpressionValidator rePub;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.TextBox Reason;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.TextBox Remark;
		protected System.Web.UI.WebControls.Button UpdateBtn;
		protected System.Web.UI.WebControls.Button ReturnBtn;
	
		private int nSalaryID = 0;

		private void Page_Load(object sender, System.EventArgs e)
		{
			///判断用户是否登陆
			if(Session["UserID"] == null)
			{
				Response.Redirect("~/Default.aspx");
			}
			///判断用户是否是超级管理员
			if(Components.User.IsAuthorityAdmin(Session["UserID"].ToString()) >= Components.User.USERTYPENORMAL)
			{
				Response.Write("<script>alert(\"你没有权限,请与管理员联系!\")</script>");
				Response.Write("<script>history.back();</script>");
			}	
		
			if(Request.Params["SalaryID"] != null)
			{
				nSalaryID = Int32.Parse(Request.Params["SalaryID"].ToString());
			}
			if(!Page.IsPostBack)
			{
				///绑定控件的数据				
				if(nSalaryID > -1)
				{
					///显示信息
					BindSalaryData(nSalaryID);
				}
			}

			///控制按钮的可用性
			UpdateBtn.Enabled = nSalaryID <= -1 ? false : true;
		}

		private void BindSalaryData(int nSalaryID)
		{
			///定义获取数据的类
			MisPersonnel.Components.Salary salary = new MisPersonnel.Components.Salary();
			SqlDataReader recs = salary.GetSingleSalary(nSalaryID);

			///从获取的数据中读取数据
			if(recs.Read())
			{
				Desn.Text      = recs["Desn"].ToString();
				NewSalary.Text = recs["Salary"].ToString();
				OldSalary.Text = recs["OldSalary"].ToString();
				Reason.Text    = recs["Reason"].ToString();
				PubDate.Text   = Convert.ToDateTime(recs["PubDate"].ToString()).ToShortDateString();
				Remark.Text    = recs["Remark"].ToString();
			}
			///关闭数据读取器和数据库的连接
			recs.Close();
		}

		private void ReturnBtn_Click(object sender, System.EventArgs e)
		{
			///跳转到管理页面
			Response.Redirect("~/DesktopModules/Salary/SalaryManage.aspx");
		}

		private void UpdateBtn_Click(object sender, System.EventArgs e)
		{
			if(Page.IsValid == true)
			{
				///定义类
				MisPersonnel.Components.Salary salary = new MisPersonnel.Components.Salary();
				try
				{
					///修改操作
					salary.UpdateSalary(nSalaryID,Desn.Text.Trim(),
						Decimal.Parse(NewSalary.Text.Trim()),
						Decimal.Parse(OldSalary.Text.Trim()),
						Convert.ToDateTime(PubDate.Text.Trim()),
						Reason.Text,
						Remark.Text);
					
					///显示操作结果信息
					Response.Write ("<script>window.alert('" + MisSystem.OPERATIONUPDATESUCCESSMESSAGE + "')</script>");
				}
				catch(Exception ex)
				{			
					///显示添加操作中的失败、错误信息
					Response.Redirect("~/DesktopModules/ErrorPage.aspx?ErrorUrl="
						+ MisSystem.RedirectErrorUrl(Request.RawUrl)
						+ "&ErrorMessage=" + ex.Message.Replace("\n"," "));
				}
			}
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.UpdateBtn.Click += new System.EventHandler(this.UpdateBtn_Click);
			this.ReturnBtn.Click += new System.EventHandler(this.ReturnBtn_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

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