addsalaryitem.aspx.cs
来自「MIS系统开发与应用配套的源代码」· CS 代码 · 共 147 行
CS
147 行
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>
/// AddSalaryItem 的摘要说明。
/// </summary>
public partial class AddSalaryItem : System.Web.UI.Page
{
private int nSalaryID = -1;
protected 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)
{
///绑定控件的数据
BindSalaryData();
BindTaxRatioData();
}
}
private void BindSalaryData()
{
///定义获取数据的类
MisPersonnel.Components.Salary salary = new MisPersonnel.Components.Salary();
SqlDataReader recs = salary.GetSalarys();
///设定控件的数据源
SalaryList.DataSource = recs;
///设定控件的Text属性和Value属性
SalaryList.DataTextField = "Desn";
SalaryList.DataValueField = "SalaryID";
///绑定控件的数据
SalaryList.DataBind();
///关闭数据读取器和数据库的连接
recs.Close();
}
private void BindTaxRatioData()
{
///定义获取数据的类
MisPersonnel.Components.TaxRatio ratio = new TaxRatio();
SqlDataReader recr = ratio.GetTaxRatios();
///设定控件的数据源
TaxRatioList.DataSource = recr;
///设定控件的Text属性和Value属性
TaxRatioList.DataTextField = "Desn";
TaxRatioList.DataValueField = "TaxRatioID";
///绑定控件的数据
TaxRatioList.DataBind();
///关闭数据读取器和数据库的连接
recr.Close();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
protected void ReturnBtn_Click(object sender, System.EventArgs e)
{
///跳转到管理页面
Response.Redirect("~/DesktopModules/Salary/SalaryItemManage.aspx?SalaryID=" + nSalaryID.ToString());
}
protected void AddBtn_Click(object sender, System.EventArgs e)
{
if(Page.IsValid == true)
{
///定义类
MisPersonnel.Components.SalaryItem salaryItem = new SalaryItem();
try
{
///添加操作
salaryItem.AddSalaryItem(Name.Text.Trim(),
Int32.Parse(TypeList.SelectedValue),
Convert.ToDecimal(BaseValue.Text.Trim()),
Int32.Parse(BelongList.SelectedValue),
Int32.Parse(OperationList.SelectedValue),
Int32.Parse(TaxRatioList.SelectedValue),
Int32.Parse(SalaryList.SelectedValue),
Remark.Text);
///显示操作结果信息
Response.Write ("<script>window.alert('" + MisSystem.OPERATIONADDSUCCESSMESSAGE + "')</script>");
}
catch(Exception ex)
{
///显示添加操作中的失败、错误信息
Response.Redirect("~/DesktopModules/ErrorPage.aspx?ErrorUrl="
+ MisSystem.RedirectErrorUrl(Request.RawUrl)
+ "&ErrorMessage=" + ex.Message.Replace("\n"," "));
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?