public bool EmployeeParseLine(string strValue, string strSplit, out CMSMStruct.EmployeeStruct empinfo, out Exception err) { int i = 0; empinfo = new CMSMData.CMSMStruct.EmployeeStruct(); err = null; try { string[] strFields = strValue.Split(strSplit.ToCharArray()); empinfo.strCardID = strFields[i++]; empinfo.strEmpName = strFields[i++]; empinfo.strSex = strFields[i++]; empinfo.strEmpNbr = strFields[i++]; empinfo.strInDate = strFields[i++]; empinfo.strDegree = strFields[i++]; empinfo.strLinkPhone = strFields[i++]; empinfo.strAddress = strFields[i++]; empinfo.strPwd = strFields[i++]; empinfo.strOfficer = strFields[i++]; empinfo.strDeptID = strFields[i++]; empinfo.strFlag = strFields[i++]; empinfo.strComments = strFields[i++]; empinfo.strOperDate = strFields[i++]; } catch (Exception e) { err = e; return(false); } return(true); }
private void sbtnOk_Click(object sender, System.EventArgs e) { CMSMStruct.EmployeeStruct emp1 = new CMSMData.CMSMStruct.EmployeeStruct(); if (txtCardID.Text.Trim() == "" || txtCardID.Text.Trim().Length != 4) { MessageBox.Show("员工卡号不可为空且为4位,请重新填写员工卡号!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtCardID.Focus(); return; } else if (!cs.ChkEmpCardIDDup(txtCardID.Text.Trim(), out err)) { emp1.strCardID = txtCardID.Text.Trim(); } else { MessageBox.Show("该卡已经有其他员工使用,请重新输入!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtCardID.Focus(); return; } if (txtEmpName.Text.Trim() == "" || txtEmpName.Text.Trim().Length > 30) { MessageBox.Show("员工姓名不可为空且小于15个字,请重新填写员工姓名!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtEmpName.Focus(); return; } else { emp1.strEmpName = txtEmpName.Text.Trim(); } if (txtEmpNbr.Text.Trim() != "" && txtEmpNbr.Text.Trim().Length != 15 && txtEmpNbr.Text.Trim().Length != 18) { MessageBox.Show("身份证号应为15或18位,请重新填写身份证号!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtEmpNbr.Focus(); return; } else { emp1.strEmpNbr = txtEmpNbr.Text.Trim(); } if (txtLinkPhone.Text.Trim() == "" || txtLinkPhone.Text.Trim().Length > 25) { MessageBox.Show("联系电话不可为空且小于25位,请重新填写联系电话!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); txtLinkPhone.Focus(); return; } else { emp1.strLinkPhone = txtLinkPhone.Text.Trim(); } emp1.strSex = cmbSex.Text.Trim(); emp1.strInDate = this.dateTimePicker1.Value.ToShortDateString(); emp1.strDegree = this.GetColEn(cmbDegree.Text.Trim(), "DE"); emp1.strOfficer = this.GetColEn(cmbOfficer.Text.Trim(), "OF"); emp1.strAddress = txtLinkAddress.Text.Trim(); emp1.strDeptID = SysInitial.CurOps.strDeptID; emp1.strFlag = "0"; emp1.strPwd = ""; emp1.strComments = txtComments.Text.Trim(); emp1.strOperDate = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(); err = null; string strresult = cs.InsertEmployee(emp1, out err); if (err != null || (!strresult.Equals(CardCommon.CardDef.ConstMsg.RFOK))) { if (strresult != "") { strresult = this.GetColCh(strresult, "ERR"); } MessageBox.Show("添加新员工失败,请重试!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); if (err != null || strresult != null) { clog.WriteLine(err + "\n" + strresult); } } else { MessageBox.Show("添加新员工成功!", "系统提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); this.ClearText(); } }