private void Frm_Load(object sender, EventArgs e) //加载ComboBox的一些选项 { LinkSQL linksql = new LinkSQL(); //创建数据库连接对象 System.Data.SqlClient.SqlDataReader RD; //创建一个对像接收查询的返回数据 linksql.OpenSQL(); //打开数据库 linksql.SQLSelect(@"select ID from department"); //查询部门编号 RD = linksql.Comm.ExecuteReader(); while (RD.Read()) { department_ID.Items.Add(Convert.ToString(RD[0])); //将查询的结果添加到department_ID上 } sex.Items.Add("男"); sex.Items.Add("女"); linksql.CloseSQL(); //关闭数据库 linksql.OpenSQL(); //打开数据库 linksql.SQLSelect(@"select name from post"); //查询职位 RD = linksql.Comm.ExecuteReader(); while (RD.Read()) { post.Items.Add(Convert.ToString(RD[0])); //将查询的结果添加到post上 } linksql.CloseSQL(); //关闭数据库 }
private void BulletinContentChange_Click(object sender, EventArgs e) //当光标离开公告栏的textBox时发生 { LinkSQL linksql = new LinkSQL(); DialogResult dr = MessageBox.Show("确认修改?", "修改公告", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (dr == DialogResult.OK) { try { linksql.OpenSQL(); //打开数据库 int i = 0; if (label4.Text == "采购部") { i = linksql.SQLInsert(@"insert notice values('PU0001',GETDATE(),'" + BulletinBoardCententText.Text + "')"); } if (label4.Text == "仓储部") { i = linksql.SQLInsert(@"insert notice values('ST0001',GETDATE(),'" + BulletinBoardCententText.Text + "')"); } if (i > 0) { MessageBox.Show("修改成功!", "修改结果"); if (label4.Text == "采购部") { linksql.SQLSelect(@"select content from notice where department_id = 'PU0001' order by date desc"); BulletinBoardCentent.Text = linksql.Comm.ExecuteScalar().ToString(); } if (label4.Text == "仓储部") { linksql.SQLSelect(@"select content from notice where department_id = 'ST0001' order by date desc"); BulletinBoardCentent.Text = linksql.Comm.ExecuteScalar().ToString(); } } else { MessageBox.Show("修改失败!请重新修改!", "修改结果", MessageBoxButtons.OK, MessageBoxIcon.Stop); } linksql.CloseSQL(); } catch { string str = BulletinBoardCententText.Text; dr = MessageBox.Show("本次修改将不进行保存,是否依然修改?", "修改结果", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); if (dr == DialogResult.OK) { BulletinBoardCentent.Text = str; } } BulletinBoardCentent.Visible = true; BulletinBoardCententText.Visible = false; updateNotice.Text = "修改公告"; } else { MessageBox.Show("修改失败!您取消了修改!", "修改提示"); BulletinBoardCentent.Visible = true; BulletinBoardCententText.Visible = false; updateNotice.Text = "修改公告"; } }
private void comboBox_Check(object sender, EventArgs e) //检查输入的数据有效性,光标离开时自动触发 { LinkSQL linksql = new LinkSQL(); ComboBox comboxBox1 = (ComboBox)sender; int i; switch (comboxBox1.Name) { case "department_ID": linksql.OpenSQL(); linksql.SQLSelect(@"select count(*) from department where ID = '" + department_ID.Text + "'"); i = int.Parse(linksql.Comm.ExecuteScalar().ToString()); if (i != 1) { MessageBox.Show("输入的部门不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); department_ID.SelectAll(); } linksql.CloseSQL(); break; case "employee_ID": linksql.OpenSQL(); linksql.SQLSelect(@"select count(*) from employee where ID = '" + employee_ID.Text + "'"); i = int.Parse(linksql.Comm.ExecuteScalar().ToString()); if (i != 0) { MessageBox.Show("该员工已存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); employee_ID.SelectAll(); } linksql.CloseSQL(); break; case "sex": if (sex.Text != "男" && sex.Text != "女") { MessageBox.Show("请选择男或女!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); sex.SelectAll(); } break; case "post": linksql.OpenSQL(); linksql.SQLSelect(@"select count(*) from employee where post = '" + employee_ID.Text + "'"); i = int.Parse(linksql.Comm.ExecuteScalar().ToString()); if (i != 0) { MessageBox.Show("该职位不存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); post.SelectAll(); } linksql.CloseSQL(); break; } }
private void Initial_BaseData() { LinkSQL linksql = new LinkSQL(); //创建数据库连接 switch (label4.Text) { case "仓储部": linksql.OpenSQL(); linksql.SQLSelect(@"select content from notice where department_id = 'ST0001' order by date desc"); BulletinBoardCentent.Text = linksql.Comm.ExecuteScalar().ToString(); linksql.SQLSelect(@"select COUNT(*) from employee where department_ID = 'ST0001'"); label6.Text = linksql.Comm.ExecuteScalar().ToString(); linksql.SQLSelect(@"select COUNT(*) from sign,employee where SHC = 1 and employee_ID = employee.ID and employee.department_ID = 'ST0001'"); label8.Text = linksql.Comm.ExecuteScalar().ToString(); linksql.SQLSelect(@"select COUNT(*)from sign,employee where sign_in = 1 and employee_ID = employee.ID and employee.department_ID = 'ST0001'"); label10.Text = linksql.Comm.ExecuteScalar().ToString(); linksql.CloseSQL(); break; case "采购部": linksql.OpenSQL(); linksql.SQLSelect(@"select content from notice where department_id = 'PU0001' order by date desc"); BulletinBoardCentent.Text = linksql.Comm.ExecuteScalar().ToString(); //公告 linksql.SQLSelect(@"select COUNT(*) from employee where department_ID = 'PU0001'"); label6.Text = linksql.Comm.ExecuteScalar().ToString(); // linksql.SQLSelect(@"select COUNT(*) from sign,employee where SHC = 1 and employee_ID = employee.ID and employee.department_ID = 'PU0001'"); label8.Text = linksql.Comm.ExecuteScalar().ToString(); linksql.SQLSelect(@"select COUNT(*)from sign,employee where sign_in = 1 and employee_ID = employee.ID and employee.department_ID = 'PU0001'"); label10.Text = linksql.Comm.ExecuteScalar().ToString(); linksql.CloseSQL(); break; } }
/// <summary> /// 删除按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DeleteData(object sender, EventArgs e) { DialogResult Re = MessageBox.Show("确认删除?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (Re == DialogResult.OK) { int No = int.Parse(((Button)sender).Name); //获取要删除的数据所在行 int y = 0; //找出要删除的行 LinkSQL linkSql = new LinkSQL(); try { linkSql.OpenSQL(); } catch { MessageBox.Show("无法连接数据库!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } linkSql.SQLSelect(@"select No from demand"); System.Data.SqlClient.SqlDataReader DR = linkSql.Comm.ExecuteReader(); while (DR.Read()) { y++; if (y == No) { No = int.Parse(DR[0].ToString()); } } linkSql.CloseSQL(); try { linkSql.OpenSQL(); } catch { MessageBox.Show("无法连接数据库!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } linkSql.SQLInsert(@"delete demand where No = " + No.ToString()); linkSql.SQLSelect(@"dbcc checkident('demand',reseed,0)"); linkSql.Comm.ExecuteNonQuery(); linkSql.CloseSQL(); RefreshData(); } else { return; } }
private void LoadData(string sqlSelectStr, ComboBox C) //加载检索数据 { System.Data.SqlClient.SqlDataReader dataRead; C.Items.Clear(); //清空原数据 linkSql.OpenSQL(); //打开数据库 linkSql.SQLSelect(sqlSelectStr); //执行查询 dataRead = linkSql.Comm.ExecuteReader(); // while (dataRead.Read()) { int i = 0; string s = ""; s = (string)dataRead[i]; //记录下数据库中返回的内容 C.Items.Add(s); //将数据添到控件的选项中 i++; } linkSql.CloseSQL(); //关闭数据库 }
private System.Data.SqlClient.SqlDataReader AlterSelect()//根据部门选择查询 { LinkSQL linksql = new LinkSQL(); //System.Data.SqlClient.SqlDataReader dr; switch (label4.Text) //根据部门选择查询 { case "采购部": linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'PU0001'"); break; case "仓储部": linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'ST0001'"); break; } linksql.OpenSQL(); return(linksql.Comm.ExecuteReader()); }
/// <summary> /// 初始化表格或刷新表格数据 /// </summary> private void InitializeData() { foreach (Control a in panel1.Controls) { if (a.GetType().Name == "Button") { a.Visible = false; } } LinkSQL linkSql = new LinkSQL(); System.Data.SqlClient.SqlDataReader DR; //TODO:载入表格数据 linkSql.OpenSQL(); linkSql.SQLSelect("select *from demand"); DR = linkSql.Comm.ExecuteReader(); int i = 0; while (DR.Read()) { panel1.Controls.Add(delButton[i]); panel1.Controls.Add(alterButton[i]); for (int j = 0; j < table.GetLength(1); j++) { table[i, j].Visible = true; table[i, j].Text = DR[j].ToString(); if (DR[j].ToString() == "PU0001") { table[i, j].Text = "采购部"; } if (DR[j].ToString() == "ST0001") { table[i, j].Text = "仓储部"; } if (j == table.GetLength(1) - 1) { detail[i] = table[i, j].Text; //把完整的介绍提取出来 table[i, j].Size = new Size(350, 33); if (table[i, j].Text.Length > 18) //将详细介绍收缩 { table[i, j].Text = table[i, j].Text.Substring(0, 18); //截断字符串 table[i, j].Text += "..."; } } if (j == 0) { table[i, j].Text = (i + 1).ToString(); } } i++; } linkSql.CloseSQL(); }
/// <summary> /// 修改按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AlterButton_Click(object sender, EventArgs e) { //throw new NotImplementedException(); CententForm.Employee.WinForm.AddDemand addDemand = new CententForm.Employee.WinForm.AddDemand(); int buttonName = int.Parse(((Button)sender).Name);//获取要修改的数据所在行 int No = 0; int y = 0; LinkSQL linkSql = new LinkSQL(); try { linkSql.OpenSQL(); } catch { MessageBox.Show("无法连接数据库!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } linkSql.SQLSelect(@"select No from demand"); System.Data.SqlClient.SqlDataReader DR = linkSql.Comm.ExecuteReader(); while (DR.Read()) { if (buttonName == y) { No = int.Parse(DR[0].ToString()); } y++; } addDemand.UpDataNo = No; addDemand.Department_ID.Text = table[buttonName, 1].Text; if (table[buttonName, 1].Text == "采购部") { addDemand.Department_ID.Text = "PU0001"; } if (table[buttonName, 1].Text == "仓储部") { addDemand.Department_ID.Text = "ST0001"; } addDemand.Post.Text = table[buttonName, 2].Text; addDemand.Rec_Number.Text = table[buttonName, 3].Text; addDemand.Explain.Text = detail[buttonName]; DialogResult dr = addDemand.ShowDialog(); if (dr == DialogResult.Cancel) { RefreshData(); } else { return; } }
private void ID_Check(object sender, EventArgs e) //身份证号码检索 { LinkSQL linksql = new LinkSQL(); int i; linksql.OpenSQL(); linksql.SQLSelect(@"select count(*) from employee where ID_card = '" + IDCard.Text + "'"); i = int.Parse(linksql.Comm.ExecuteScalar().ToString()); if (i != 0) { MessageBox.Show("该员工已存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information); IDCard.SelectAll(); } linksql.CloseSQL(); }
private void DepartmentTextChange_Click(object sender, EventArgs e) { post.Items.Clear(); LinkSQL linksql = new LinkSQL(); //创建数据库连接对象 System.Data.SqlClient.SqlDataReader RD; //创建一个对像接收查询的返回数据 linksql.OpenSQL(); //打开数据库 linksql.SQLSelect(@"select name from post where department_ID='" + department_ID.Text + "'"); //查询职位 RD = linksql.Comm.ExecuteReader(); while (RD.Read()) { post.Items.Add(Convert.ToString(RD[0])); //将查询的结果添加到post上 } linksql.CloseSQL(); //关闭数据库 }
/// <summary> /// 添加需求事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { int number = 22; //记录当前的需求信息的数量 try { LinkSQL linkSql = new LinkSQL(); linkSql.OpenSQL(); linkSql.SQLSelect(@"select count(*) from demand"); number = int.Parse(linkSql.Comm.ExecuteScalar().ToString()); linkSql.CloseSQL(); } catch { MessageBox.Show("无法连接到服务器!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (number >= 20) { MessageBox.Show("最大只可发布20条招聘信息,请先删除部分的招聘信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (number == 22) { MessageBox.Show("无法连接到服务器!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } CententForm.Employee.WinForm.AddDemand addDemand = new CententForm.Employee.WinForm.AddDemand(); DialogResult dr = addDemand.ShowDialog(); if (dr == DialogResult.Cancel) { RefreshData(); } else { return; } }
/// <summary> /// 管理员登陆验证 /// </summary> /// <param name="id">用户名</param> /// <param name="root">密码</param> /// <returns></returns> private int CheckAdminLand(string id, string root) { LinkSQL landLinkSQL = new LinkSQL(); try { landLinkSQL.OpenSQL(); } catch { MessageBox.Show("连接服务器失败"); //打开数据库失败 Application.Exit(); } string T_SQL; int value = 0; T_SQL = "select count(*) from theUser where ID = '" + id + "' and Password = '******'" + " and theidentity = '管理员'"; landLinkSQL.SQLSelect(T_SQL); value = (int)landLinkSQL.Comm.ExecuteScalar(); if (value == 0) { landLinkSQL.CloseSQL(); MessageBox.Show("您输入的用户名或密码错误,请重新输入"); return(0); } else if (value == 1) { landLinkSQL.CloseSQL(); return(1); } else { landLinkSQL.CloseSQL(); MessageBox.Show("异常错误"); return(0); } }
/// <summary> /// 普通用户登陆 /// </summary> /// <param name="id">用户名</param> /// <param name="root">密码</param> /// <returns></returns> private int CheckUserLand(string id, string root) //普通用户登陆验证 { LinkSQL LandLinkSql = new LinkSQL(); try { LandLinkSql.OpenSQL(); } catch { MessageBox.Show("打开连接服务器失败!"); //打开数据库失败 Application.Exit(); } string Sql; Sql = "select count(*) from theUser where ID = '" + id + "' and Password = '******'" + " and theidentity = '普通用户'"; int Value; LandLinkSql.SQLSelect(Sql); Value = (int)LandLinkSql.Comm.ExecuteScalar(); if (Value == 0) { MessageBox.Show("您输入的用户名或密码错误,请重新输入"); return(0); } else if (Value == 1) { LandLinkSql.CloseSQL(); return(1); } else { MessageBox.Show("异常错误"); return(0); } }
private void AddData() { int i = 0, k = 0; //i记录影响行数,K记录重复行数 string insertStr = @"insert demand values('" + department_ID.Text + "','" + post.Text + "'," + rec_Number.Text + ",'" + explain.Text + "')"; LinkSQL linksql = new LinkSQL(); try { linksql.OpenSQL(); linksql.SQLSelect("select count(*) from demand where post = '" + post.Text + "'"); k = int.Parse(linksql.Comm.ExecuteScalar().ToString()); linksql.SQLSelect("select NO from demand where post = '" + post.Text + "'"); linksql.CloseSQL();//关闭连接 if (k == 0) { linksql.OpenSQL(); //打开连接 i = linksql.SQLInsert(insertStr); linksql.CloseSQL(); //关闭连接 } else { linksql.OpenSQL();//打开连接 My.MyMessageBox messageBox = new My.MyMessageBox(); messageBox.Show("该信息已存在,是否修改招聘信息?", "提示", My.MyMessageBox.MyMessageBoxButton.OKCancel, My.MyMessageBox.MyMessageBoxIcon.Question); DialogResult DR = messageBox.DialogResult; if (DR == DialogResult.Cancel) { this.Close(); } else { //upDateNO = int.Parse(linksql.Comm.ExecuteScalar().ToString()); string upDateStr = @"update demand set department_id = '" + department_ID.Text + "',post = '" + post.Text + "',rec_Number = " + rec_Number.Text + ",exlain = '" + explain.Text + "' where NO = " + upDateNO.ToString(); i = linksql.SQLInsert(upDateStr); } linksql.CloseSQL();//关闭连接 } } catch //插入或更新出错尝试重新插入更新(20次) { linksql.CloseSQL(); linksql.OpenSQL();//打开连接 //upDateNO = int.Parse(linksql.Comm.ExecuteScalar().ToString()); string upDateStr = @"update demand set department_id = '" + department_ID.Text + "',post = '" + post.Text + "',rec_Number = " + rec_Number.Text + ",exlain = '" + explain.Text + "' where NO = " + upDateNO.ToString(); for (int x = 0; x < 20; x++) { try { if (k == 0) { i = linksql.SQLInsert(insertStr); break; } else { i = linksql.SQLInsert(upDateStr); } } catch { continue; } } linksql.CloseSQL(); if (i == 1) { MessageBox.Show("添加成功!", "提示"); this.Close(); } else { MessageBox.Show("插入失败,请重试!如多次提示,请尝试删除一个招聘信息后再次修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } return; } linksql.CloseSQL(); if (i == 1)//判断添加数据结果 { MessageBox.Show("添加成功!", "提示"); this.Close(); } else { MessageBox.Show("插入失败,请重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
/// <summary> /// 确认提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { /// <summary>受影响的行数 </summary> int infRow = 0; //受影响的行数 int repeat = 0; //重复的数据数 LinkSQL linkSql = new LinkSQL(); try { try { //-------------------- linkSql.OpenSQL(); linkSql.SQLSelect(@"select count(*) from applicants where ID_card = '" + id.Text + "' "); repeat = int.Parse(linkSql.Comm.ExecuteScalar().ToString()); linkSql.Conn.Dispose(); linkSql.Comm.Dispose(); linkSql.CloseSQL(); //----------------------查询库中是否已存在数据 } catch { MessageBox.Show("无法连接服务器,请重试"); return; } if (repeat == 0) { linkSql.OpenSQL(); string insertStr = "insert into applicants values('" + name.Text + "','" + sex.Text + "'," + age.Text + ",'" + id.Text + "','" + post.Text + "','" + joinTime.Text + "')"; infRow = linkSql.SQLInsert(insertStr); linkSql.Comm.Dispose(); linkSql.Conn.Dispose(); linkSql.CloseSQL(); } else { MessageBox.Show("已存在此人,请勿插入重复数据!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } catch { MessageBox.Show("插入失败,请重试!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { linkSql.Conn.Dispose(); linkSql.Comm.Dispose(); } if (infRow == 1) { MessageBox.Show("添加成功!", "提示"); foreach (Control a in this.Controls) { if (a.GetType().Name == "TextBox") { a.Text = ""; } } } else { MessageBox.Show("添加失败", "提示"); return; } }
private void LookUp1_Click(object sender, EventArgs e) //部门人数查看,修改按钮事件 { int z = 0; count = 0; //z格式控制,count数据的行数 Initial_Data(); //初始化表格 tableHead[0].Text = ""; tableHead[1].Text = "员工编号"; tableHead[2].Text = "姓名"; tableHead[3].Text = "姓别"; tableHead[4].Text = "职位"; foreach (Label a in tableHead) { a.Visible = true; } LinkSQL linksql = new LinkSQL(); //创建数据库连接对像linksql System.Data.SqlClient.SqlDataReader RD; linksql.OpenSQL(); //打开数据库 switch (label4.Text) //根据部门选择查询 { case "采购部": linksql.SQLSelect(@"select ID,Name,sex,post from employee where department_Id = 'PU0001'"); break; case "仓储部": linksql.SQLSelect(@"select ID,Name,sex,post from employee where department_Id = 'ST0001'"); break; } RD = linksql.Comm.ExecuteReader(); //接收查询结果 while (RD.Read()) //输入查询结果 TODO:暂时只能输出十六条数据 { count++; if (count <= 8) //小于8行,用表1记录 { for (int i = 0; i < RD.FieldCount; i++) { tableLabel1[z].Text = ((z / 5) + 1).ToString(); tableLabel1[z].Visible = true; tableLabel1[i + z + 1].Text = Convert.ToString(RD[i]); tableLabel1[i + z + 1].Visible = true; } } if (count % 8 == 0) { z = 0; } if (count > 8 && count <= 16) //8-16行用表2记录 { z = 0; for (int i = 0; i < RD.FieldCount; i++) { tableLabel2[z].Text = (((z / 5) + 1) + 8).ToString(); tableLabel2[z].Visible = false; tableLabel2[i + z + 1].Text = Convert.ToString(RD[i]); tableLabel2[i + z + 1].Visible = false; } } z += 5; } pageNow.Text = "1"; //当前页码 pageAll.Text = ((count / 9) + 1).ToString(); //总页面数量 linksql.CloseSQL(); //闭关数据库 //if (((Button)sender).Name == "lookUp1") //{ if (int.Parse(pageAll.Text) > 1) { pageUp.Visible = true; pageDown.Visible = true; MessageBox.Show("共" + pageAll.Text + "页"); } //} if (((Button)sender).Name == "alter1") { add.Visible = true; callOff.Visible = true; } }
private void LookUp2_Click(object sender, EventArgs e) //应到、签到人数查看按钮事件 { Initial_Data(); foreach (Label a in tableHead) { a.Visible = true; } int z = 0; count = 0; //z格式控制,count数据的行数 //--------------------------------------以上为初始化---------------------------// LinkSQL linksql = new LinkSQL(); //创建数据库连接对像linksql System.Data.SqlClient.SqlDataReader RD; linksql.OpenSQL(); switch (((Button)sender).Name) //判断引发事件的按钮 { case "callOff": case "lookUp2": //应到人员 switch (label4.Text) //根据部门选择查询 { case "采购部": linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'PU0001' and (shc=1 or shc=2)"); break; case "仓储部": linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'ST0001' and (shc=1 or shc=2)"); break; } break; case "lookUp3": //实到人员 switch (label4.Text) //根据部门选择查询 { case "采购部": linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'PU0001' and (sign_in=1 or sign_in=2)"); break; case "仓储部": linksql.SQLSelect(@"select a.employee_ID,a.employee_Name,a.shc,a.sign_in,b.post from sign as a,employee as b where a.employee_ID=b.ID and b.department_ID = 'ST0001' and (sign_in=1 or sign_in=2)"); break; } break; } RD = linksql.Comm.ExecuteReader(); while (RD.Read()) { count++; if (count <= 8) { for (int i = 0; i < RD.FieldCount; i++) { tableLabel1[i + z].Visible = true; switch (i) { case 0: case 1: //tableLabel1[i + z].Visible = true; tableLabel1[i + z].Text = Convert.ToString(RD[i]); break; case 2: case 3: switch (Convert.ToInt16(RD[i])) //判断上班的值:0为不用上班,1为正常上班,2为特殊情况 签到:0为未签到,1为已签到,2为请假 { //tableLabel1[i + z].Visible = true; case 0: tableLabel1[i + z].Text = "×"; break; case 1: tableLabel1[i + z].Text = "√"; break; case 2: tableLabel1[i + z].Text = "○"; break; } break; case 4: tableLabel1[i + z].Text = Convert.ToString(RD[i]); break; } } } if (count % 8 == 0) //新的一页重置格式控制 { z = -5; } if (count > 8 && count <= 16) { for (int i = 0; i < RD.FieldCount; i++) { tableLabel2[i + z].Visible = false; //tableLabel2[i + z].Text = Convert.ToString(RD[i]); switch (i) { case 0: case 1: //tableLabel1[i + z].Visible = true; tableLabel2[i + z].Text = Convert.ToString(RD[i]); break; case 2: case 3: switch (Convert.ToInt16(RD[i])) //判断上班的值:0为不用上班,1为正常上班,2为特殊情况 签到:0为未签到,1为已签到,2为请假 { //tableLabel1[i + z].Visible = true; case 0: tableLabel2[i + z].Text = "×"; break; case 1: tableLabel2[i + z].Text = "√"; break; case 2: tableLabel2[i + z].Text = "○"; break; } break; case 4: tableLabel2[i + z].Text = Convert.ToString(RD[i]); break; } } } z += 5; } linksql.CloseSQL(); //闭关数据库 pageNow.Text = "1"; //当前页码 pageAll.Text = ((count / 9) + 1).ToString(); //总页面数量 if (int.Parse(pageAll.Text) > 1) { pageUp.Visible = true; pageDown.Visible = true; MessageBox.Show("共" + pageAll.Text + "页"); } if (((Button)sender).Name == "alter2") { putIn.Visible = true; callOff.Visible = true; } }