员工考勤管理系统c语言,员工考勤信息管理小程序,考勤信息管理小程序
員工考勤信息管理小程序,考勤信息管理小程序
雖然這是個(gè)小程序,但是呢還是用到了許多的知識(shí)點(diǎn)的.主要是""使用集合組織相關(guān)數(shù)據(jù)."",這個(gè)知識(shí)點(diǎn)非常重要.
在以后搞大型的項(xiàng)目,絕對(duì)離不開(kāi)"集合組織數(shù)據(jù)".例如:ArrayList動(dòng)態(tài)存儲(chǔ)數(shù)據(jù),HashTable的數(shù)據(jù)結(jié)構(gòu)(哈希表).
泛型集合:List和Dictionary
泛型類(lèi).
下面呢就是一個(gè)"員工信息管理"小程序.用來(lái)強(qiáng)化知識(shí)點(diǎn).
首先,創(chuàng)幾個(gè)類(lèi):
SE類(lèi)
public classSE
{public string ID { get; set; }public int Age { get; set; }public Sex Gender { get; set; }public string Name { get; set; }
}
Gen類(lèi)(枚舉)
public classGen
{//public static 實(shí)現(xiàn)考勤信息管理.Gender 男 { get; set; }
}public enumSex
{
男, 女
}
Record類(lèi)
{public classRecord
{//簽到時(shí)間
public DateTime SingInTime { get; set; }//簽退時(shí)間
public DateTime SingOutTime { get; set; }//工號(hào)
public string ID { get; set; }//員工姓名
public string Name { get; set; }
管理信息:
添加信息:
代碼段:
public int MaintanceType { get; set; }//保存父窗體的引用
public FrmMain FrmParent { get; set; }//初始化//保存按鈕的響應(yīng)
private void btnOk_Click(objectsender, EventArgs e)
{try{
SE pr= newSE();
pr.ID= this.txtID1.Text.Trim();//工號(hào)
pr.Age = Int32.Parse(this.txtAge1.Text.Trim());//年齡
if (this.cmbgender1.SelectedIndex.ToString() == "男")//性別
{
pr.Gender=Sex.男;//這個(gè)也可以:pr.Gender=(Sex)(Enum.Parse(typeof(Sex),"男"));
}else{
pr.Gender=Sex.女;
}
pr.Name= this.txtName1.Text.Trim();//名字//添加操作//工號(hào)唯一性驗(yàn)證
if (this.MaintanceType == 1)
{foreach (SE item inFrmParent.programmerList)
{if (item.ID ==pr.ID)
{
MessageBox.Show("此工號(hào)已存在");return;
}
}
FrmParent.programmerList.Add(pr);
}this.Close();
}catch(Exception)
{
MessageBox.Show("出錯(cuò)啦");
}finally{this.FrmParent.BindGrid(FrmParent.programmerList);
}
看看主界面:
主界面的主要代碼
查詢(xún)信息:
//查詢(xún)信息
private void btnLook_Click(objectsender, EventArgs e)
{//根據(jù)員工號(hào)進(jìn)行模糊查詢(xún)
List teapList = new List();//用臨時(shí)列表保存查詢(xún)到的信息
foreach (SE item in this.programmerList)
{if (item.ID.IndexOf(this.txtID.Text.Trim()) != -1)//indexof()實(shí)現(xiàn)模糊查詢(xún)
{
teapList.Add(item);
}
}this.dgvlist.DataSource = new BindingList(teapList);
}
刪除信息:
private void toolStripButton3_Click(objectsender, EventArgs e)
{if (this.dgvlist.SelectedRows.Count == 0)
{
MessageBox.Show("你還未選中要?jiǎng)h除的信息,請(qǐng)選擇!");return;
}
DialogResult result= MessageBox.Show("確認(rèn)要?jiǎng)h除嗎?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);if (DialogResult.OK !=result)
{return;
}string sid = dgvlist.CurrentRow.Cells["ID"].Value.ToString();foreach (SE item inprogrammerList)
{if (item.ID ==sid)
{
programmerList.Remove(item);break;
}
}//刷新
BindGrid(programmerList);
MessageBox.Show("刪除成功!");
}
簽到:
代碼段:
//簽到菜單項(xiàng),
private void 簽到ToolStripMenuItem_Click(objectsender, EventArgs e)
{//驗(yàn)證//確保有選中的行
if (this.dgvlist.SelectedRows.Count != 1)
{
MessageBox.Show("請(qǐng)選擇要簽到的人");return;
}//確保沒(méi)有簽到過(guò)
string id = dgvlist.CurrentRow.Cells["ID"].Value.ToString();foreach (string item inrecordList.Keys)
{if (id ==item)
{
MessageBox.Show("您以前到過(guò)");return;
}
}//執(zhí)行簽到
Record record = newRecord();
record.ID=id;
record.Name= dgvlist.CurrentRow.Cells["Name"].Value.ToString();
record.SingInTime= DateTime.Now;//獲取當(dāng)前系統(tǒng)時(shí)間
this.recordList.Add(record.ID, record);//添加到記錄中
MessageBox.Show("簽到成功!!");
}
簽退:
//簽退操作
private void 簽退ToolStripMenuItem_Click(objectsender, EventArgs e)
{//確保有選中行
if (this.dgvlist.SelectedRows.Count != 1)
{
MessageBox.Show("請(qǐng)選擇!");return;
}string id = dgvlist.CurrentRow.Cells["ID"].Value.ToString();bool isOut = false;//標(biāo)識(shí)是否已簽過(guò)到
foreach (string item inrecordList.Keys)
{if (item ==id)
{//執(zhí)行簽到,設(shè)置簽退時(shí)間
this.recordList[item].SingOutTime =DateTime.Now;
MessageBox.Show("簽退成功!");
isOut= true;break;
}
}if (!isOut)
{
MessageBox.Show("很抱歉,尚未簽到!");
}
}
打卡記錄:
//打卡記錄
public Dictionary recordList { get; set; }//數(shù)據(jù)綁定
private voidBindRecords()
{
lblcount.Text= "共有"+recordList.Count+"條打卡記錄";//將Dictionary綁定到DataGridView控件
BindingSource bs= newBindingSource();#region 綁定數(shù)據(jù)源 BindingSource
/** 封裝窗體的數(shù)據(jù)源。
public BindingSource();
//
// 摘要:
// 初始化 System.Windows.Forms.BindingSource 類(lèi)的新實(shí)例,并將 System.Windows.Forms.BindingSource
// 添加到指定的容器。
//
// 參數(shù):
// container:
// 要將當(dāng)前 System.Windows.Forms.BindingSource 添加到的 System.ComponentModel.IContainer。
*
public BindingSource(IContainer container);
//
// 摘要:
// 用指定的數(shù)據(jù)源和數(shù)據(jù)成員初始化 System.Windows.Forms.BindingSource 類(lèi)的新實(shí)例。
//
// 參數(shù):
// dataSource:
// System.Windows.Forms.BindingSource 的數(shù)據(jù)源。
//
// dataMember:
// 要綁定到的數(shù)據(jù)源中的特定列或列表名稱(chēng)。
public BindingSource(object dataSource, string dataMember);
// 摘要:
// 獲取一個(gè)值,該值指示是否可以編輯基礎(chǔ)列表中的項(xiàng)。
//
// 返回結(jié)果:
// true 指示列表項(xiàng)可以編輯;否則為 false。*/
#endregionbs.DataSource=recordList.Values;
dgvlist.DataSource=bs;
}private void FrmRecord_Load(objectsender, EventArgs e)
{
BindRecords();
}
這樣最后呢,就可以完完整整的掌握了這些知識(shí)點(diǎn)------------------------------------
http://www.dengb.com/C_jc/1101897.htmlwww.dengb.comtruehttp://www.dengb.com/C_jc/1101897.htmlTechArticle員工考勤信息管理小程序,考勤信息管理小程序 雖然這是個(gè)小程序,但是呢還是用到了許多的知識(shí)點(diǎn)的.主要是""使用集合組織相關(guān)數(shù)據(jù)."",這...
總結(jié)
以上是生活随笔為你收集整理的员工考勤管理系统c语言,员工考勤信息管理小程序,考勤信息管理小程序的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: word计算机基础知识试题及答案,计算机
- 下一篇: 程序设计语言与语言程序处理程序基础(软件