基于C#+Oracle的考勤管理系统的设计与开发
tbXM.Focus(); return; }
string sql = \; if (type == \)
sql = \into YGB values('\ + tbBH.Text + \'\ + tbXM.Text + \'\ + cbXB.Text + \ + tbBM.Text + \; else if (type == \)
sql = \ + tbXM.Text + \ + cbXB.Text + \ + tbBM.Text + \ + tbBH.Text + \; else
return;
if (Program.ConnNonRead(sql) > 0) {
if (type == \) {
table.Rows.Add(tbBH.Text, tbXM.Text, cbXB.Text, tbBM.Text); dgvYG.DataSource = table;
dgvYG.Rows[dgvYG.Rows.Count - 1].Selected = true;
MessageBox.Show(\添加成功。\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); } else {
for (int i = 0; i < table.Rows.Count; ++i)
if (table.Rows[i][0].ToString() ==
dgvYG.SelectedRows[0].Cells[0].Value.ToString()) {
table.Rows[i][1] = tbXM.Text; table.Rows[i][2] = cbXB.Text; table.Rows[i][3] = tbBM.Text; dgvYG.DataSource = table; break; }
MessageBox.Show(\修改成功。\, \提示\, MessageBoxButtons.OK,
第 16 页 共 44 页
基于C#+Oracle的考勤管理系统的设计与开发
MessageBoxIcon.Information); }
type = \; isbj = false;
} else {
if (type == \)
MessageBox.Show(\添加失败,请重新添加。\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); else
MessageBox.Show(\修改失败,请重新修改。\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
///
private void btnQX_Click(object sender, EventArgs e) {
try {
tbBH.Text = dgvYG.SelectedRows[0].Cells[0].Value.ToString(); tbXM.Text = dgvYG.SelectedRows[0].Cells[1].Value.ToString(); cbXB.Text = dgvYG.SelectedRows[0].Cells[2].Value.ToString(); tbBM.Text = dgvYG.SelectedRows[0].Cells[3].Value.ToString();
}
catch { }
type = \; isbj = false;
}
///
第 17 页 共 44 页
ChangeButton(\);
ChangeButton(\);
基于C#+Oracle的考勤管理系统的设计与开发
/// 删除数据事件 ///
private void btnSC_Click(object sender, EventArgs e) {
if (MessageBox.Show(\确定要删除?\, \提示\, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk).ToString() == \) {
string sql = \ + tbBH.Text + \;
if (Program.ConnNonRead(sql) > 0) {
for (int i = 0; i < table.Rows.Count; ++i)
if (table.Rows[i][0].ToString() ==
dgvYG.SelectedRows[0].Cells[0].Value.ToString()) {
table.Rows.RemoveAt(i); dgvYG.DataSource = table; break; }
if (dgvYG.Rows.Count > 0) {
if (dgvYG.SelectedRows.Count <= 0)
dgvYG.Rows[dgvYG.Rows.Count - 1].Selected = true;
tbBH.Text = dgvYG.SelectedRows[0].Cells[0].Value.ToString(); tbXM.Text = dgvYG.SelectedRows[0].Cells[1].Value.ToString(); cbXB.Text = dgvYG.SelectedRows[0].Cells[2].Value.ToString(); tbBM.Text = dgvYG.SelectedRows[0].Cells[3].Value.ToString(); }
ChangeButton(\);
MessageBox.Show(\删除成功。\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information); } else
MessageBox.Show(\删除失败,请重新修改。\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Information);
第 18 页 共 44 页
基于C#+Oracle的考勤管理系统的设计与开发
} }
///
private void btnTC_Click(object sender, EventArgs e) {
Close(); }
///
private void frm_ygxx_FormClosing(object sender, FormClosingEventArgs e) {
if (isbj) {
MessageBox.Show(\请先关闭编辑。\, \提示\, MessageBoxButtons.OK, MessageBoxIcon.Asterisk); e.Cancel = true; } }
///
/// 退出后处理主界面变量事件 ///
private void frm_ygxx_FormClosed(object sender, FormClosedEventArgs e) {
Program.kqglxt.ygxx = null; }
3. 考勤类型管理模块
功能:操作当前考勤类型表,并可以进行考勤类型增、改、删的操作。 // 自定义变量
private string type = \;
// 按钮禁用判断标记
private DataTable table = null; // 封装数据 private bool isbj = false; // 状态标记
第 19 页 共 44 页
基于C#+Oracle的考勤管理系统的设计与开发
///
private void frm_kqlx_Load(object sender, EventArgs e) {
table = Program.ConnRead(\);
dgvKQ.DataSource = table; ChangeButton(\); }
///
/// 数据表行选择更改事件 ///
private void dgvKQ_SelectionChanged(object sender, EventArgs e) {
try {
tbBH.Text = dgvKQ.SelectedRows[0].Cells[0].Value.ToString(); tbLX.Text = dgvKQ.SelectedRows[0].Cells[1].Value.ToString(); } catch { } }
///
/// 编号文本框输入格式检查事件 ///
private void tbBH_TextChanged(object sender, EventArgs e) {
if (tbBH.Text.Length == 0) return;
if (!char.IsNumber(tbBH.Text, tbBH.Text.Length - 1)) {
tbBH.Text = tbBH.Text.Substring(0, tbBH.Text.Length - 1);
if (tbBH.Text.Length > 0)
tbBH.Select(tbBH.Text.Length, 0);
} }
第 20 页 共 44 页