1.項目操作流程
2.2.描述項目操作流程動圖功能和步驟胚泌;
第一步:調(diào)試該程序然后彈出登錄界面;
第二步:輸入管理員賬號和密碼點擊登錄扣草;
第三步:登錄成功后出現(xiàn)管理員登陸界面间影;
第四步:點擊“查詢職員考勤”出現(xiàn)查詢條件界面;
3.職員登陸晴氨、查詢職員考勤界面
點擊查詢后會出現(xiàn)已注冊員工的信息和打卡信息
4.相關(guān)代碼
private void bt_Query_Click(object sender, EventArgs e)
{
String connStr = ConfigurationManager.ConnectionStrings["Attendance"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(connStr);
try
{
// 連接數(shù)據(jù)庫
sqlConn.Open();
// DataGridView數(shù)據(jù)綁定
//String sqlStr=" select t1.id, t1.name, t1.bm, t1.zw, t2.date, t2.time from 員工表 t1 inner join record t2 on t1.id = t2.employee_id where date>= @start and date<= @end";
String sqlStr = "select * from record where 1=1 ";
sqlStr += " and date>=@begin and date<=@end";
SqlCommand cmd = new SqlCommand(sqlStr, sqlConn);
cmd.Parameters.Add(new SqlParameter("@begin",this.begin.Value.ToShortDateString() ));
cmd.Parameters.Add(new SqlParameter("@end", this.end.Value.ToShortDateString()));
// 添加查詢條件
// 將該查詢過程綁定到DataAdapter
SqlDataAdapter adp = new SqlDataAdapter();
adp.SelectCommand = cmd;
// 將DataSet和DataAdapter綁定
DataSet ds = new DataSet();
// 自定義一個表(MyGoods)來標(biāo)識數(shù)據(jù)庫的GOODS表
adp.Fill(ds, "Myrecord");
// 指定DataGridView的數(shù)據(jù)源為DataSet的MyGoods表
this.dgv_record.DataSource = ds.Tables["Myrecord"];
}
catch (Exception exp)
{
MessageBox.Show("訪問數(shù)據(jù)庫錯誤:" + exp.Message);
}
finally
{
sqlConn.Close();
}
}