/// <summary> /// 添加一个记录 /// </summary> private void AppendPerson() { //检查空值 if (!IsHaveEmpty()) { return; } dba = new Dbaccess(); if (Utility.Optype == OpreatType.add) //添加 { //检查重复 person = AssignPersonData(OpreatType.add); string sql = "select * from staffs where (wWorkerNum = '" + person.WorkerNum + "') or ((wIdtype = '" + person.Idtype + "') and (wIdNumber = '" + person.IdNumber + "'))"; DataTable thedt = dba.ReadDatas(sql, false); if (thedt.Rows.Count >= 1) { MessageBox.Show("This employee data already exists in the database."); return; } //执行 SQL 命令 if (dba.SavePersonData(person)) { System.Windows.Forms.MessageBox.Show("Operation Successfuly."); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Operation Fail.\nErrorCode: >> " + dba.ErrorCode); } } if (Utility.Optype == OpreatType.edit) //编辑 { person = AssignPersonData(OpreatType.edit); if (dba.UpdatePersonData(person)) { System.Windows.Forms.MessageBox.Show("Update Data Successfuly."); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Operation Fail.\nErrorCode: >> " + dba.ErrorCode); } } }
private void btnExecute_Click(object sender, EventArgs e) { if (!IsEmptyValue()) { return; } dba = new Dbaccess(); if (Utility.Optype == OpreatType.add) //添加 { //检查重复 proj = GetProjectData(OpreatType.add); string sql = "select * from staffs where (wWorkerNum = '" + proj.ProjectID + "')" /* + or ((wIdtype = '" + person.Idtype + * "') and (wIdNumber = '" + person.IdNumber + "'))" */; DataTable thedt = dba.ReadDatas(sql, false); if (thedt.Rows.Count >= 1) { MessageBox.Show("This employee data already exists in the database."); return; } //执行 SQL 命令 if (dba.SavProjectData(proj)) { System.Windows.Forms.MessageBox.Show("Operation Successfuly."); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Operation Fail.\nErrorCode: >> " + dba.ErrorCode); } } if (Utility.Optype == OpreatType.edit) //编辑 { proj = GetProjectData(OpreatType.edit); if (dba.UpdateProjectData(proj)) { System.Windows.Forms.MessageBox.Show("Update Data Successfuly."); this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Operation Fail.\nErrorCode: >> " + dba.ErrorCode); } } }
/// <summary> /// 员工选项改变 [lvWorker] /// </summary> private void StaffItemChange(object sender, EventArgs e) { if (lvWorker.SelectedItems.Count == 0) { return; } //Person per = (Person)lvWorker.SelectedItems[0].Tag; DataTable retdt = dba.ReadDatas("Select * from staffs where wActive = true and wWorkerNum = '" + currentLView.SelectedItems[0].SubItems[1].Text + "'", false); Person per = new Person(retdt.Rows[0]); //txStaffDetail.Text = ""; //{ // txStaffDetail.Text += "Worker Number >>> \t" + per.WorkerNum + "\r\n"; // txStaffDetail.Text += "Company >>> \t" + per.CompanyID + "\r\n"; // txStaffDetail.Text += "Project >>> \t" + per.ProjectID + "\r\n"; // txStaffDetail.Text += "Worker Name >>> \t" + per.WorkerName + "\r\n"; //} }