温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:某公司人事工资管理系统源码
当前文件路径:StaffSalaryManage/CheckManage/MonthCheckForm.aspx.cs

1//文件名:MonthCheckForm.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 CheckManage_MonthCheckForm : System.Web.UI.Page 15
{ 16
private static string MySQL = ""; 17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
string MyForbidString = Session["MyForbid"].ToString(); 20
if (MyForbidString.IndexOf("B1") > 1) 21
{ 22
Server.Transfer("~/SystemManage/AllErrorHelp.aspx"); 23
} 24
} 25
protected void Button1_Click(object sender, EventArgs e) 26
{//查询考勤记录信息 27
28
String MySQLConnectionString = ConfigurationManager.ConnectionStrings["MyPersonnelDBConnectionString"].ConnectionString; 29
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString); 30
MyConnection.Open(); 31
string MySQL = "SELECT * FROM [考勤记录] WHERE (([考勤年份] ='"+this.DropDownList2.SelectedValue.ToString()+"') AND ([考勤月份] = '"+this.DropDownList3.SelectedValue.ToString() +"') AND (员工编号 IN (SELECT 员工编号 FROM 在职员工视图 WHERE (所属部门 LIKE '"+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
int My考勤年份 = Convert.ToInt16(this.DropDownList2.SelectedValue.ToString()); 44
int My考勤月份 = Convert.ToInt16(this.DropDownList3.SelectedValue.ToString()); 45
MySQL = "INSERT INTO 考勤记录([员工编号], [员工姓名], [考勤年份], [考勤月份]) VALUES (@员工编号, @员工姓名, @考勤年份, @考勤月份)"; 46
MyConnection = new SqlConnection(MySQLConnectionString); 47
MyConnection.Open(); 48
SqlCommand MyCommand = MyConnection.CreateCommand(); 49
MyCommand.CommandText = MySQL; 50
MyCommand.Parameters.Add(new SqlParameter("@员工编号", SqlDbType.VarChar)); 51
MyCommand.Parameters.Add(new SqlParameter("@员工姓名", SqlDbType.VarChar)); 52
MyCommand.Parameters.Add(new SqlParameter("@考勤年份", SqlDbType.Int)); 53
MyCommand.Parameters.Add(new SqlParameter("@考勤月份", SqlDbType.Int)); 54
MyCommand.Parameters["@员工编号"].Value = My员工编号; 55
MyCommand.Parameters["@员工姓名"].Value = My员工姓名; 56
MyCommand.Parameters["@考勤年份"].Value = My考勤年份; 57
MyCommand.Parameters["@考勤月份"].Value = My考勤月份; 58
MyCommand.ExecuteNonQuery(); 59
} 60
this.GridView1.DataBind(); 61
} 62
if (MyConnection.State == ConnectionState.Open) 63
{ 64
MyConnection.Close(); 65
} 66
} 67
protected void Button2_Click(object sender, EventArgs e) 68
{//打印月度部门考勤信息 69
Server.Transfer("~/CheckManage/MonthCheckPrint.aspx"); 70
} 71
public string MyPrintSQL 72
{//设置要传递到打印页的数据 73
get 74
{ 75
return "SELECT * FROM [考勤记录] WHERE (([考勤年份] ='" + this.DropDownList2.SelectedValue.ToString() + "') AND ([考勤月份] = '" + this.DropDownList3.SelectedValue.ToString() + "') AND (员工编号 IN (SELECT 员工编号 FROM 在职员工视图 WHERE (所属部门 LIKE '" + this.DropDownList1.SelectedValue.ToString() + "'))))"; 76
} 77
} 78
public String MyPrintDate 79
{//设置要传递到打印页的数据 80
get 81
{ 82
return "考勤日期:" + this.DropDownList2.SelectedValue.ToString() + "年" + this.DropDownList3.SelectedValue.ToString() + "月" ; 83
} 84
} 85
public String MyPrintTitle 86
{//设置要传递到打印页的数据 87
get 88
{ 89
return Session["MyCompanyName"].ToString() + this.DropDownList1.SelectedValue.ToString() + "月度考勤表"; 90
} 91
} 92
} 93





}
}