/// <summary> /// 删除【CkTimeInfo】表中重复数据 /// </summary> /// <returns></returns> private bool DelCkSN() { CkTimeInfo ck = new CkTimeInfo(); ck.SN = txtCheckIn.Text.Trim(); string sqlCk = string.Format("delete from cktimeinfo where SN='{0}'", ck.SN); return(SqlHelper.modify(sqlCk)); }
/// <summary> /// 修改【CkTimeInfo】表中SNcheckOut /// </summary> /// <returns></returns> private bool UpdateSNcheckOut() { CkTimeInfo ck = new CkTimeInfo(); ck.SNCheckOut = DateTime.Now.ToString(); ck.SN = txtCheckOut.Text.Trim(); string sql = string.Format("update cktimeinfo SET SNCheckOut='{0}',employee_id='{1}' where SN='{2}'", ck.SNCheckOut, employee_id, ck.SN); txtCheckIn.Text = string.Empty; txtCheckOut.Text = string.Empty; return(SqlHelper.modify(sql)); }
//----------------------------------------------------------录入黑色异常时间界面------------------------------------------------------------------------------------- /// <summary> /// 添加【CkTimeInfo】表中SN,SNCheckIn,employee_id数据 /// </summary> /// <returns></returns> private bool InserSNcheckIn() { CkTimeInfo ck = new CkTimeInfo(); ck.SN = txtCheckIn.Text.Trim(); ck.SNCheckIn = DateTime.Now.ToString(); string sql = string.Format("insert into cktimeinfo(employee_id,SN,SNCheckIn)values ('{0}','{1}','{2}')" , employee_id, ck.SN, ck.SNCheckIn); return(SqlHelper.modify(sql)); }
/// <summary> /// SNCheckIn回车事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtCheckIn_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (txtCheckIn.Text.Trim() != "") { //string txtText = txtCheckIn.Text; //string regular1 = @"^[A-Za-z0-9]{10}$"; //string regular2 = @"^[A-Za-z0-9]{23}$"; //bool a = Regex.IsMatch(txtText, regular2); //bool b=Regex.IsMatch(txtText,regular1); //if (b==false && a==false) //{ // MessageBox.Show("格式错误!请输入10位或者23位的字母数字组合!"); // txtCheckIn.Text = string.Empty; // return; //} black_unusual black = new black_unusual(); black.SN = txtCheckIn.Text.Trim(); string sqlBlack = "select*from black_unusual where SN='" + black.SN + "'"; DataTable dtBlack = SqlHelper.GetList(sqlBlack); CkTimeInfo ck = new CkTimeInfo(); ck.SN = txtCheckIn.Text.Trim(); string sqlCk = "select*from cktimeinfo where SN='" + ck.SN + "'"; DataTable dtCk = SqlHelper.GetList(sqlCk); if (dtBlack.Rows.Count <= 0 && dtCk.Rows.Count <= 0) { InserSNcheckIn(); if (rdoPersonal.Checked == true) { rdoPersonal_Click(null, null); } else if (rdoPublic.Checked == true) { rdoPublic_Click(null, null); } txtCheckIn.Text = string.Empty; txtCheckOut.Text = string.Empty; return; } else { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("该SN已录入,是否删除?", "删除原纪录!!!", messButton); if (dr == DialogResult.OK) { DelCkSN(); DelBlackSN(); if (rdoPersonal.Checked == true) { rdoPersonal_Click(null, null); } else if (rdoPublic.Checked == true) { rdoPublic_Click(null, null); } } else { return; } } } else { MessageBox.Show("SNCheckIn输入值不能为空!"); return; } } }