温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:某公司人事工资管理系统源码
当前文件:
StaffSalaryManage/SalaryManage/ComputeForm.aspx.cs,打开代码结构图
StaffSalaryManage/SalaryManage/ComputeForm.aspx.cs,打开代码结构图1//文件名:ComputeForm.aspx.cs 2
using System; 3
using System.Data; 4
using System.Configuration; 5
using System.Collections; 6
using System.Web; 7
using System.Web.Security; 8
using System.Web.UI; 9
using System.Web.UI.WebControls; 10
using System.Web.UI.WebControls.WebParts; 11
using System.Web.UI.HtmlControls; 12
13
using System.Data.SqlClient; 14
public partial class SalaryManage_ComputeForm : System.Web.UI.Page 15
{ 16
protected void Page_Load(object sender, EventArgs e) 17
{ 18
string MyForbidString = Session["MyForbid"].ToString(); 19
if (MyForbidString.IndexOf("C1") > 1) 20
{ 21
Server.Transfer("~/SystemManage/AllErrorHelp.aspx"); 22
} 23
string MyInfo = "一旦发放当月该部门工资,就不能再进行修改!是否确定发放工资?"; 24
this.Button3.OnClientClick = "return confirm('" + MyInfo + "')"; 25
} 26
protected void Button1_Click(object sender, EventArgs e) 27
{//查询部门员工工资信息 28
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyPersonnelDBConnectionString"].ConnectionString; 29
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString); 30
MyConnection.Open(); 31
string MySQL = "SELECT * FROM [工资核算表] WHERE ([员工编号] IN (Select 员工编号 FROM 在职员工视图 WHERE 所属部门='" + this.DropDownList1.SelectedValue.ToString() + "'))"; 32
SqlCommand MyQueryCommand = new SqlCommand(MySQL, MyConnection); 33
if (MyQueryCommand.ExecuteScalar() == null) 34
{ 35
System.Data.DataTable MyQueryTable = new System.Data.DataTable(); 36
MySQL = "Select * From 在职员工视图 WHERE 所属部门='" + this.DropDownList1.SelectedValue.ToString() + "'"; 37
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MyConnection); 38
MyAdapter.Fill(MyQueryTable); 39
foreach (DataRow MyRow in MyQueryTable.Rows) 40
{ 41
string My员工编号 = MyRow[1].ToString(); 42
string My员工姓名 = MyRow[3].ToString(); 43
float My基本工资 = (float)Convert.ToDouble(MyRow[18].ToString()); 44
MySQL = "INSERT INTO 工资核算表([员工编号], [员工姓名], [基本工资]) VALUES (@员工编号, @员工姓名, @基本工资)"; 45
MyConnection = new SqlConnection(MySQLConnectionString); 46
MyConnection.Open(); 47
SqlCommand MyCommand = MyConnection.CreateCommand(); 48
MyCommand.CommandText = MySQL; 49
MyCommand.Parameters.Add(new SqlParameter("@员工编号", SqlDbType.VarChar)); 50
MyCommand.Parameters.Add(new SqlParameter("@员工姓名", SqlDbType.VarChar)); 51
MyCommand.Parameters.Add(new SqlParameter("@基本工资", SqlDbType.Float)); 52
MyCommand.Parameters["@员工编号"].Value = My员工编号; 53
MyCommand.Parameters["@员工姓名"].Value = My员工姓名; 54
MyCommand.Parameters["@基本工资"].Value = My基本工资; 55
MyCommand.ExecuteNonQuery(); 56
} 57
this.GridView1.DataBind(); 58
} 59
if (MyConnection.State == ConnectionState.Open) 60
{ 61
MyConnection.Close(); 62
} 63
} 64
protected void Button2_Click(object sender, EventArgs e) 65
{//打印月度部门员工工资核算信息 66
Server.Transfer("~/SalaryManage/ComputePrint.aspx"); 67
} 68
public string MyPrintSQL 69
{//设置要传递到打印页的数据 70
get 71
{ 72
return "SELECT * FROM [工资核算表] WHERE ([员工编号] IN (Select 员工编号 FROM 在职员工视图 WHERE 所属部门='" + this.DropDownList1.SelectedValue.ToString() + "'))"; 73
} 74
} 75
public String MyPrintDate 76
{//设置要传递到打印页的数据 77
get 78
{ 79
return "日期:" + this.DropDownList2.SelectedValue.ToString() + "年" + this.DropDownList3.SelectedValue.ToString() + "月" ; 80
} 81
} 82
public String MyPrintTitle 83
{//设置要传递到打印页的数据 84
get 85
{ 86
return Session["MyCompanyName"].ToString() + this.DropDownList1.SelectedValue.ToString() + "员工工资核算表"; 87
} 88
} 89
protected void Button3_Click(object sender, EventArgs e) 90
{//发工资 91
int My年份 = Convert.ToInt16(this.DropDownList2.SelectedValue.ToString()); 92
int My月份 = Convert.ToInt16(this.DropDownList3.SelectedValue.ToString()); 93
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyPersonnelDBConnectionString"].ConnectionString; 94
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString); 95
MyConnection.Open(); 96
string My发放年份 = this.DropDownList2.SelectedValue.ToString(); 97
string My发放月份 = this.DropDownList3.SelectedValue.ToString(); 98
string MySQL = "Select * From 工资发放表 Where (发放年份=" + My发放年份 + ") AND (发放月份=" + My发放月份 + ") AND ([员工编号] IN (Select 员工编号 FROM 在职员工视图 WHERE 所属部门='" + this.DropDownList1.SelectedValue.ToString() + "'))"; 99
SqlCommand MyQueryCommand = new SqlCommand(MySQL, MyConnection); 100
if (MyQueryCommand.ExecuteScalar() == null) 101
{ 102
MySQL = "SELECT * FROM [工资核算表] WHERE ([员工编号] IN (Select 员工编号 FROM 在职员工视图 WHERE 所属部门='" + this.DropDownList1.SelectedValue.ToString() + "'))"; 103
SqlDataAdapter MyAdapter = new SqlDataAdapter(MySQL, MySQLConnectionString); 104
DataTable MyTable = new DataTable(); 105
MyAdapter.Fill(MyTable); 106
foreach (DataRow MyRow in MyTable.Rows) 107
{ 108
string My员工编号 = MyRow[1].ToString(); 109
System.Data.DataTable MyQueryTable = new System.Data.DataTable(); 110
MySQL = "Select 银行账号,养老保险账号,医疗保险账号,住房基金账号,身份证号码 From 基本档案 WHERE 员工编号='" + My员工编号 + "'"; 111
SqlDataAdapter MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection); 112
MyDataAdapter.Fill(MyQueryTable); 113
string My银行账号 = MyQueryTable.Rows[0][0].ToString(); 114
string My养老保险账号 = MyQueryTable.Rows[0][1].ToString(); 115
string My医疗保险账号 = MyQueryTable.Rows[0][2].ToString(); 116
string My住房基金账号 = MyQueryTable.Rows[0][3].ToString(); 117
string My身份证号码 = MyQueryTable.Rows[0][4].ToString(); 118
MySQL = "INSERT INTO 工资发放表([员工编号], [员工姓名], [基本工资],[津贴] ,[奖金], [工龄工资], [岗位工资],[其他应增项] ,[所得税], [养老险],[医疗险] ,[住房基金], [其他应减项], [银行账号],[养老保险账号] ,[医疗保险账号], [住房基金账号], [身份证号码],[发放年份] ,[发放月份], [补充说明]) VALUES (@员工编号,@员工姓名,@基本工资,@津贴 ,@奖金,@工龄工资,@岗位工资,@其他应增项 ,@所得税,@养老险,@医疗险 ,@住房基金,@其他应减项,@银行账号,@养老保险账号 ,@医疗保险账号,@住房基金账号,@身份证号码,@发放年份 ,@发放月份,@补充说明)"; 119
SqlCommand MyCommand = new SqlCommand(MySQLConnectionString); 120
MyCommand = MyConnection.CreateCommand(); 121
MyCommand.CommandText = MySQL; 122
MyCommand.Parameters.Add(new SqlParameter("@员工编号", SqlDbType.VarChar)); 123
MyCommand.Parameters.Add(new SqlParameter("@员工姓名", SqlDbType.VarChar)); 124
MyCommand.Parameters.Add(new SqlParameter("@基本工资", SqlDbType.Float)); 125
MyCommand.Parameters.Add(new SqlParameter("@津贴", SqlDbType.Float)); 126
MyCommand.Parameters.Add(new SqlParameter("@奖金", SqlDbType.Float)); 127
MyCommand.Parameters.Add(new SqlParameter("@工龄工资", SqlDbType.Float)); 128
MyCommand.Parameters.Add(new SqlParameter("@岗位工资", SqlDbType.Float)); 129
MyCommand.Parameters.Add(new SqlParameter("@其他应增项", SqlDbType.Float)); 130
MyCommand.Parameters.Add(new SqlParameter("@所得税", SqlDbType.Float)); 131
MyCommand.Parameters.Add(new SqlParameter("@养老险", SqlDbType.Float)); 132
MyCommand.Parameters.Add(new SqlParameter("@医疗险", SqlDbType.Float)); 133
MyCommand.Parameters.Add(new SqlParameter("@住房基金", SqlDbType.Float)); 134
MyCommand.Parameters.Add(new SqlParameter("@其他应减项", SqlDbType.Float)); 135
MyCommand.Parameters.Add(new SqlParameter("@银行账号", SqlDbType.VarChar)); 136
MyCommand.Parameters.Add(new SqlParameter("@养老保险账号", SqlDbType.VarChar)); 137
MyCommand.Parameters.Add(new SqlParameter("@医疗保险账号", SqlDbType.VarChar)); 138
MyCommand.Parameters.Add(new SqlParameter("@住房基金账号", SqlDbType.VarChar)); 139
MyCommand.Parameters.Add(new SqlParameter("@身份证号码", SqlDbType.VarChar)); 140
MyCommand.Parameters.Add(new SqlParameter("@发放年份", SqlDbType.Int)); 141
MyCommand.Parameters.Add(new SqlParameter("@发放月份", SqlDbType.Int)); 142
MyCommand.Parameters.Add(new SqlParameter("@补充说明", SqlDbType.VarChar)); 143
144
MyCommand.Parameters["@员工编号"].Value = My员工编号; 145
MyCommand.Parameters["@员工姓名"].Value = MyRow[2].ToString(); 146
MyCommand.Parameters["@基本工资"].Value = MyRow[3]; 147
MyCommand.Parameters["@津贴"].Value = MyRow[4]; 148
MyCommand.Parameters["@奖金"].Value = MyRow[5]; 149
MyCommand.Parameters["@工龄工资"].Value = MyRow[6]; 150
MyCommand.Parameters["@岗位工资"].Value = MyRow[7]; 151
MyCommand.Parameters["@其他应增项"].Value = MyRow[8]; 152
MyCommand.Parameters["@所得税"].Value = MyRow[9]; 153
MyCommand.Parameters["@养老险"].Value = MyRow[10]; 154
MyCommand.Parameters["@医疗险"].Value = MyRow[11]; 155
MyCommand.Parameters["@住房基金"].Value = MyRow[12]; 156
MyCommand.Parameters["@其他应减项"].Value = MyRow[13]; 157
MyCommand.Parameters["@银行账号"].Value = My银行账号; 158
MyCommand.Parameters["@养老保险账号"].Value = My养老保险账号; 159
MyCommand.Parameters["@医疗保险账号"].Value = My医疗保险账号; 160
MyCommand.Parameters["@住房基金账号"].Value = My住房基金账号; 161
MyCommand.Parameters["@身份证号码"].Value = My身份证号码; 162
MyCommand.Parameters["@发放年份"].Value = My发放年份; 163
MyCommand.Parameters["@发放月份"].Value = My发放月份; 164
MyCommand.Parameters["@补充说明"].Value = MyRow[14]; 165
MyCommand.ExecuteNonQuery(); 166
} 167
this.Page.RegisterStartupScript("msgonlyAlert","<script language='javascript'>alert('发放部门工资操作成功')</script>"); 168
} 169
else 170
{ 171
this.Label1.Text="<script language='javascript'>alert('发放部门工资操作失败!不能重复发放工资!')</script>"; 172
} 173
if (MyConnection.State == ConnectionState.Open) 174
{ 175
MyConnection.Close(); 176
} 177
} 178
} 179





}
}