/// <summary> /// 添加员工 /// </summary> private void AddEmp() { if (this.CheckAddInput()) { Employee emp = new Employee(); emp.Name = this.txtNewName.Text; emp.Sex = rabFemale.Checked ? "女" : "男"; emp.departId = int.Parse(this.cbxNewDepart.SelectedValue.ToString()); //如果添加成功 if (EmployeeMgr.Add(emp)) { //刷新树 for (int i = 0; i < Root.Nodes.Count; i++) { if (Root.Nodes[i].Text == this.cbxNewDepart.Text) { TreeNode newemp = new TreeNode(); newemp.Text = this.txtNewName.Text; Root.Nodes[i].Nodes.Add(newemp); } } this.txtNewName.Text = ""; } else { untCommon.InfoMsg("注册失败"); } } }
/// <summary> /// 转换list数据为树形组件绑定结构 /// </summary> /// <param name="list"></param> /// <returns></returns> private List <LayTreeItem> GetDepartmentTreeData() { List <LayTreeItem> res = new List <LayTreeItem>(); List <Department> depList = DepartmentMgr.GetList(); List <Employee> empList = EmployeeMgr.GetList(); // 第一次遍历,插入一级部门 foreach (var item in depList) { var node = new LayTreeItem(); node.title = item.DepartmentName; node.field = item.DepartmentID.ToString(); node.id = $"dep_{item.DepartmentID.ToString()}"; res.Add(node); } // 第二次遍历,在部门下插入员工 foreach (var item in res) { // 找到对应部门下所有员工 var emps = empList.Where(t => t.DepartmentID.ToString() == item.field); foreach (var empItem in emps) { var empNode = new LayTreeItem(); empNode.title = empItem.EmployeeName; empNode.field = empItem.EmployeeID.ToString(); empNode.id = $"emp_{empItem.EmployeeID.ToString()}"; item.children.Add(empNode); } } return(res); }
/// <summary> /// 删除员工 /// </summary> private void Del() { if (this.dbgEmp.SelectedRows.Count == 0) { untCommon.InfoMsg("请在员工表中选择所要删除的员工。"); return; } int empno = int.Parse(this.dbgEmp.SelectedRows[0].Cells[0].Value.ToString()); if (untCommon.QuestionMsg("您确定要删除该员工吗?")) { int result = EmployeeMgr.Del(empno); if (result > 0) { untCommon.InfoMsg("删除成功。"); this.InitTree(); } else { if (result == -1) { untCommon.ErrorMsg("删除失败,该员工是本单位固定资产的保管员,\r\n请取消该员工的保管员身份后再删除。"); return; } if (result == -2) { untCommon.ErrorMsg("删除失败,该员工还有领用的资产没有归还,\r\n请归还所借的资产后再删除。"); return; } untCommon.InfoMsg("删除失败"); } } }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { if (this.checkBox1.Checked) { Borrow br = new Borrow(); DataTable Empdt = EmployeeMgr.GetAllName(); br.RAgent = this.name2ID(Empdt, this._user, "name"); br.RDate = this.dtpBDate1.Value; br.rRemark = this.textRRemark.Text; string eqno = this.textEqNO.Text; if (_power == "0" || _power == "1") { bool flag = BoroowMgr.RUpdateWithoutVerify(_id, br); flag = EqMgr.ReturnEq(eqno); untCommon.InfoMsg("归还成功。"); } else { bool flag = BoroowMgr.RUpdate(_id, br); untCommon.InfoMsg("归还待审核。"); } } this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// 修改资料 /// </summary> private void UpdateInfo() { if (this.CheckUpdatInput()) { Employee emp = new Employee(); // emp.ID = this.txtId.Text; emp.EmpNo = int.Parse(this.txtEmpNo.Text); emp.Name = txtName.Text; emp.Sex = rabBoy.Checked ? "男" : "女"; emp.departId = int.Parse(this.cbxDepart.SelectedValue.ToString()); if (EmployeeMgr.Update(emp)) { this.InitDbgEmp(); this.InitTree(); //修改成功以后改变相关空间的状态 this.txtName.Text = ""; this.txtEmpNo.Text = ""; this.btnSave.Enabled = false; this.tctrEmp.SelectedIndex = 0; } else { untCommon.InfoMsg("修改失败"); } } }
public void DeleteEmployeeTest() { _unitOfWork.Setup(m => m.EmployeeRepository.DeleteEmployee(It.IsAny <Guid>())); EmployeeMgr employeeMgr = new EmployeeMgr(_unitOfWork.Object); employeeMgr.DeleteEmployee(Guid.Parse("{0F681332-D795-409A-85BB-B77678FB74EE}")); _unitOfWork.Verify(m => m.Commit()); }
/// <summary> /// 初始化员工表 /// </summary> private void InitDbgEmp() { dat = EmployeeMgr.GetAllInfo(); if (dat != null) { this.dbgEmp.DataSource = null; this.dbgEmp.DataSource = dat; } }
/// <summary> /// 保存添加的保管人员 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { if (txtKeeper.Text == "填写新保管员的工号") { untCommon.InfoMsg("填写新保管员的工号"); return; } if (txtKeeper.Text.Trim() == "") { untCommon.InfoMsg("填写新保管员的工号"); return; } int empid; try { empid = int.Parse(txtKeeper.Text); DataTable dt = EmployeeMgr.GetOneEmp(empid);//检查用户输入的工号是否正确 if (dt != null) { if (dt.Rows.Count != 0) { //如果输入的工号正确 string name = dt.Rows[0][1].ToString(); if (KeeperMgr.Add(empid, name)) { //添加成功以后根据需要设置相关按钮的状态 this.btnCancel.Enabled = false; this.btnSave.Enabled = false; this.btnDel.Enabled = true; txtKeeper.Text = ""; txtKeeper.Enabled = false; InitKeeper(); } else { untCommon.InfoMsg("添加失败"); } } else { untCommon.ErrorMsg("您所填的员工不是本单位员工,不能保管本单位的资产。\r\n请确认员工编号是否正确。"); } } } catch (FormatException) { untCommon.ErrorMsg("工号请输入数字"); } }
/// <summary> /// 通过控制台的输入,获得一个员工对象 /// </summary> /// <returns></returns> static Employee GetEmployeeByConsole(bool isAdd = true) { Employee emp = new Employee(); string msg = string.Empty; if (isAdd) { msg = "请输入新增员工的编号:"; } else { ShowEmpList(); msg = "请输入需要修改员工的编号"; } emp.EmployeeID = ConvertHelper.CheckConsoleInput <int>(msg); // 当为更新操作的时候,需要校验编号是否存在,如果存在显示该实体信息 if (!isAdd) { Employee oldEmp = EmployeeMgr.GetEmployeeById(emp.EmployeeID); if (oldEmp == null) { Console.WriteLine("该编号的员工不存在,请重新选择!"); return(null); } else { Console.WriteLine($"需要修改员工的基本信息:EmployeeID:{oldEmp.EmployeeID},EmployeeName:{oldEmp.EmployeeName}"); } } Console.WriteLine("请输入员工姓名:"); emp.EmployeeName = Console.ReadLine(); Console.WriteLine("请输入员工性别(1-男,2-女):"); if (Console.ReadLine() == "1") { emp.Sex = "男"; } else { emp.Sex = "女"; } emp.BirthDate = ConvertHelper.CheckConsoleInput <DateTime>("请输入员工生日(yyyy-mm-dd):"); emp.HireDate = ConvertHelper.CheckConsoleInput <DateTime>("请输入员工入职日期(yyyy-mm-dd):"); emp.Salary = ConvertHelper.CheckConsoleInput <decimal>("请输入员工薪水:"); emp.DepartmentID = ConvertHelper.CheckConsoleInput <int>("请输入员工部门编号:"); return(emp); }
public void AddEmployeeTest() { EmployeeModel mockData = new EmployeeModel { Email = "Email", EmployeeID = "EmployeeID", FirstName = "FirstName1", Id = Guid.NewGuid(), LastName = "LastName", Phone = "Phone" }; _unitOfWork.Setup(m => m.EmployeeRepository.AddEmployee(It.IsAny <EmployeeEntry>())); EmployeeMgr employeeMgr = new EmployeeMgr(_unitOfWork.Object); employeeMgr.AddEmployee(mockData); _unitOfWork.Verify(m => m.Commit()); }
private void cbxDepart_SelectionChangeCommitted(object sender, EventArgs e) { int id = int.Parse(this.cbxDepart.SelectedValue.ToString()); DataTable dat = EmployeeMgr.GetEmpByDepart(id); if (dat != null) { cbxEmp.DataSource = dat; cbxEmp.DisplayMember = dat.Columns[1].ToString(); cbxEmp.ValueMember = dat.Columns[0].ToString(); } }
/// <summary> /// 领用资产 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { Borrow br = new Borrow(); br.ID = this.textSerialNO.Text; br.EqNo = this.textEqNO.Text; br.EqName = this.textName.Text; DataTable Empdt = EmployeeMgr.GetAllName(); DataTable Depdt = DepartMgr.GetAllDepartment(); br.Department = this.name2ID(Depdt, this.textDepartment.Text, "departName"); br.KeepPlace = this.textKeepPlace.Text; br.Keeper = this.name2ID(Empdt, this.textKeeper.Text, "name"); br.BAgent = this.name2ID(Empdt, _user, "name"); br.Borrower = this.cbxborrower.SelectedValue.ToString(); br.BDate = this.dtpBDate.Value; br.RDate = this.dtpRDate.Value; br.bRemark = this.textBorrowRemark.Text; bool flag; if (updata_flag) { flag = BoroowMgr.BUpdate(ID, br); } else { if (IsEqAvailable(this.textEqNO.Text)) { if (_power == "0" || _power == "1") { flag = BoroowMgr.AddWithoutVerify(br); } else { flag = BoroowMgr.Add(br); } flag = EqMgr.BorrowEq(br.EqNo); if (flag) { untCommon.InfoMsg("出借成功。"); } else { untCommon.InfoMsg("出借失败。"); } } else { untCommon.InfoMsg("该资产状态已改变,无法修改该信息。"); } } this.DialogResult = DialogResult.OK; }
private void InitCombo() { DataTable dtEmp = EmployeeMgr.GetAllName(); this.cbxborrower.DataSource = dtEmp; this.cbxborrower.DisplayMember = "name"; this.cbxborrower.ValueMember = "empid"; if (!string.IsNullOrWhiteSpace(defaultBorrower)) { this.cbxborrower.SelectedValue = defaultBorrower; } }
public void UpdateEmployeeTest() { EmployeeModel mockData = new EmployeeModel { Email = "Email", EmployeeID = "EmployeeID", FirstName = "FirstName1", Id = Guid.Parse("{0F681332-D795-409A-85BB-B77678FB74EE}"), LastName = "LastName", Phone = "Phone" }; _unitOfWork.Setup(m => m.EmployeeRepository.UpdateEmployee(It.IsAny <EmployeeEntry>())); EmployeeMgr employeeMgr = new EmployeeMgr(_unitOfWork.Object); employeeMgr.UpdateEmployee(mockData); _unitOfWork.Verify(m => m.Commit()); }
private static void DeleteEmp() { ShowEmpList(); int id = ConvertHelper.CheckConsoleInput <int>("请输入要删除的员工编号:"); if (EmployeeMgr.Delete(id)) { Console.WriteLine("删除成功!"); } else { Console.WriteLine("无法删除,请查看日志。。。"); } }
private static void ShowEmpList() { DataTable dt = EmployeeMgr.GetEmployeeData(); Console.WriteLine("编号\t姓名\t性别\t出生日期\t入职日期\t薪水\t部门"); foreach (DataRow item in dt.Rows) { for (int i = 0; i < dt.Columns.Count; i++) { Console.Write(item[i] + "\t"); } Console.WriteLine(); } }
private static void AddEmp() { Console.WriteLine("添加员工,请依次输入员工相关信息!"); Employee emp = GetEmployeeByConsole(); if (EmployeeMgr.Add(emp)) { Console.WriteLine("添加成功!"); ShowEmpList(); } else { Console.WriteLine("未添加任何信息!"); } }
public void GetEmployeeTest() { EmployeeEntry mockData = new EmployeeEntry { Email = "Email", EmployeeID = "EmployeeID", FirstName = "FirstName1", Id = Guid.Parse("{0F681332-D795-409A-85BB-B77678FB74EE}"), LastName = "LastName", Phone = "Phone" }; _unitOfWork.Setup(m => m.EmployeeRepository.GetEmployee(Guid.Parse("{0F681332-D795-409A-85BB-B77678FB74EE}"))).Returns((mockData)); EmployeeMgr employeeMgr = new EmployeeMgr(_unitOfWork.Object); EmployeeModel result = employeeMgr.GetEmployee(Guid.Parse("{0F681332-D795-409A-85BB-B77678FB74EE}")); Assert.IsTrue(result.EmployeeID == mockData.EmployeeID && result.Email == mockData.Email && result.FirstName == mockData.FirstName && result.LastName == mockData.LastName && result.Phone == mockData.Phone); }
/// <summary> /// 初始化员工节点 /// </summary> /// <param name="departid">部门id</param> /// <param name="parent">父节点</param> private void InitEmp(int departid, TreeNode parent) { DataTable dt = EmployeeMgr.GetEmpByDepart(departid); if (dt != null) { for (int i = 0; i < dt.Rows.Count; i++) { TreeNode emp = new TreeNode(); emp.Text = dt.Rows[i][1].ToString();//5~1-a-s-p-x emp.Tag = dt.Rows[i][0].ToString(); emp.ImageIndex = 2; emp.SelectedImageIndex = 2; parent.Nodes.Add(emp); } } }
private static void UpdateEmp() { Employee emp = GetEmployeeByConsole(false); if (emp == null) { Console.WriteLine("无法完成更新操作!"); return; } if (EmployeeMgr.Update(emp)) { Console.WriteLine("更新成功!"); ShowEmpList(); } else { Console.WriteLine("无法更新,请检查!"); } }
public void GetAllEmployeeTest() { List <EmployeeEntry> mockData = new List <EmployeeEntry>() { new EmployeeEntry { Email = "Email", EmployeeID = "EmployeeID1", FirstName = "FirstName1", Id = Guid.Parse("{0F681332-D795-409A-85BB-B77678FB74EE}"), LastName = "LastName", Phone = "Phone" }, new EmployeeEntry { Email = "Email", EmployeeID = "EmployeeID2", FirstName = "FirstName2", Id = Guid.Parse("{0F681332-D795-409A-85BB-B77678FB74EE}"), LastName = "LastName", Phone = "Phone" }, new EmployeeEntry { Email = "Email", EmployeeID = "EmployeeID3", FirstName = "FirstName3", Id = Guid.Parse("{0F681332-D795-409A-85BB-B77678FB74EE}"), LastName = "LastName", Phone = "Phone" }, }; _unitOfWork.Setup(m => m.EmployeeRepository.GetAllEmployee()).Returns((mockData)); EmployeeMgr employeeMgr = new EmployeeMgr(_unitOfWork.Object); IEnumerable <EmployeeModel> result = employeeMgr.GetAllEmployee(); var resultList = result.ToList(); mockData.ForEach(m => Assert.IsTrue(resultList.Exists(r => r.EmployeeID == m.EmployeeID))); }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { if (this.checkBox1.Checked) { Fix fix = new Fix(); DataTable Empdt = EmployeeMgr.GetAllName(); fix.RAgent = this.name2ID(Empdt, this._user, "name"); fix.EqNo = this.textEqNO.Text; fix.RDate = this.dtpBDate1.Value; fix.rRemark = this.textRRemark.Text; if (_power == "0" || _power == "1") { bool flag = FixMgr.RUpdateWithoutVerify(_id, fix); flag = EqMgr.ReturnEq(fix.EqNo); } else { bool flag = FixMgr.RUpdate(_id, fix); } } this.DialogResult = DialogResult.OK; this.Close(); }
private void btnOK_Click(object sender, EventArgs e) { Fix fix = new Fix(); fix.ID = this.textSerialNO.Text; fix.EqNo = this.textEqNO.Text; fix.EqName = this.textName.Text; DataTable Empdt = EmployeeMgr.GetAllName(); DataTable Depdt = DepartMgr.GetAllDepartment(); fix.Department = this.name2ID(Depdt, this.textDepartment.Text, "departName"); fix.KeepPlace = this.textKeepPlace.Text; fix.Keeper = this.name2ID(Empdt, this.textKeeper.Text, "name"); fix.Maintainer = this.cbxMaintainer.Text; fix.MAgent = this.name2ID(Empdt, _user, "name"); fix.MDate = this.dtpMDate.Value; fix.RDate = this.dtpRDate.Value; fix.mRemark = this.textFixRemark.Text; bool flag; if (updata_flag) { flag = FixMgr.MUpdate(ID, fix); if (flag) { untCommon.InfoMsg("修改成功。"); } else { untCommon.InfoMsg("修改失败。"); } } else { if (IsEqAvailable(this.textEqNO.Text)) { if (_power == "0" || _power == "1") { flag = FixMgr.AddWithoutVerify(fix); } else { flag = FixMgr.Add(fix); } flag = EqMgr.FixEq(fix.EqNo); if (flag) { untCommon.InfoMsg("送修成功。"); } else { untCommon.InfoMsg("送修失败。"); } } else { untCommon.InfoMsg("该资产状态已改变,无法修改该信息。"); } } this.DialogResult = DialogResult.OK; }
//保存修改的信息 private void toolEqUpdate_Click(object sender, EventArgs e) { if (this.checkInput()) { Equipment eq = new Equipment(); eq.EqNo = this.txtEqNo.Text; eq.EqName = this.txtEqName.Text; eq.AssetNo = this.txtAssetNo.Text; eq.EduNo = this.txtEduNo.Text; eq.EqType = this.cbxEqType.Text; eq.Gb = this.txtGB.Text; eq.Usage = this.cbxUsage.Text; eq.Unit = this.cbxUnit.Text; eq.Direction = this.cbxDirection.Text; eq.BuyWay = this.cbxBuyWay.Text; eq.GetWay = this.cbxGetWay.Text; eq.Purchaser = this.cbxPurchaser.Text; eq.Agent = this.txtAgent.Text; eq.Brand = this.txtBrand.Text; eq.Model = this.txtModel.Text; eq.Country = this.txtCountry.Text; eq.Mfrs = this.txtMfrs.Text; eq.ProductNo = this.txtProductNo.Text; eq.Supplier = this.txtSupplier.Text; eq.PriceType = this.cbxPriceType.Text; eq.EqKeeper = this.cbxEqKeeper.Text; eq.Department = DepartMgr.GetIdFromName(this.txtDepartment.Text); eq.Campus = this.cbxCampus.Text; eq.KeepPlace = this.cbxKeepPlace.Text; eq.Cn = this.txtCN.Text; eq.InvNo = this.txtInvNo.Text; eq.Funds = this.cbxFunds.Text; eq.BelongTo = ""; eq.Photo = ""; eq.Remark = this.txtRemark.Text; eq.Photo = this.getPhotoPath(); if (this.dtpGetDate.Checked == true) { eq.GetDate = this.dtpGetDate.Value.ToShortDateString(); } else { eq.GetDate = ""; } if (dtpAddDate.Checked == true) { eq.AddDate = this.dtpAddDate.Value.ToShortDateString(); } else { eq.AddDate = ""; } if (this.dtpBirthday.Checked == true) { eq.Birthday = this.dtpBirthday.Value.ToShortDateString(); } else { eq.Birthday = ""; } if (this.dtpSvcDate.Checked == true) { eq.SvcDate = this.dtpSvcDate.Value.ToShortDateString(); } else { eq.SvcDate = ""; } /*****************************根据资产类别判断所要填的项********************************************/ //资产类别为“土地、房屋及构筑物”时 if (eq.EqType == "土地、房屋及构筑物") { eq.Pr = this.cbxPR.Text; eq.Address = this.txtAddress.Text; eq.CertNature = this.cbxCertNature.Text; eq.Structure = this.cbxStructure.Text; //有产权时以下四项才可以被填写 if (eq.Pr == "有产权") { if (this.txtCertNo.Text.Trim() == "") { untCommon.InfoMsg("请输入权属证号"); return; } else { eq.CertNo = this.txtCertNo.Text; } if (this.dtpIssueDate.Checked == false) { untCommon.InfoMsg("请选择发证日期"); return; } else { eq.IssueDate = this.dtpIssueDate.Value.ToShortDateString(); } if (this.txtCertProve.Text.Trim() == "") { untCommon.InfoMsg("请输入权属证明"); return; } else { eq.CertProve = this.txtCertProve.Text; } try { eq.CertLim = int.Parse(this.txtCertLim.Text); } catch (FormatException) { untCommon.ErrorMsg("权属年限请输入数字。"); return; } } else { eq.CertNo = ""; eq.IssueDate = ""; eq.CertProve = ""; eq.CertLim = 0; } try { eq.Area = double.Parse(this.txtArea.Text); } catch (FormatException) { untCommon.ErrorMsg("建筑/土地面积请输入数字。"); return; } try { eq.TenuArea = double.Parse(this.txtTenuArea.Text); } catch (FormatException) { untCommon.ErrorMsg("自用面积请输入数字。"); return; } try { eq.TenuPrice = double.Parse(this.txtTenuPrice.Text); } catch (FormatException) { untCommon.ErrorMsg("自用价值请输入数字。"); return; } } else { eq.Pr = ""; eq.CertNo = ""; eq.IssueDate = ""; eq.CertProve = ""; eq.Address = ""; eq.CertNature = ""; eq.Structure = ""; eq.Area = 0; eq.TenuArea = 0; eq.TenuPrice = 0; eq.CertLim = 0; } //资产类别为"通用设备(车辆)" if (eq.EqType == "通用设备(车辆)") { eq.CarUse = this.cbxCarUse.Text; eq.CarBP = this.cbxCarBP.Text; eq.LicNo = this.txtLicNo.Text; eq.Dspl = this.txtDSPL.Text; eq.EngNo = this.txtEngNo.Text; eq.Formation = this.cbxFormation.Text; } else { eq.CarUse = ""; eq.CarBP = ""; eq.LicNo = ""; eq.Dspl = ""; eq.EngNo = ""; eq.Formation = ""; } //资产类别为"无形资产" if (eq.EqType == "无形资产") { eq.RegAuz = this.txtRegAuz.Text; eq.PatNo = this.txtPatNo.Text; eq.ApvNo = this.txtApvNo.Text; eq.MgtAgency = this.txtMgtAgency.Text; if (this.dtpRegTime.Checked == true) { eq.RegTime = this.dtpRegTime.Value.ToShortDateString(); } else { eq.RegTime = ""; } } else { eq.RegAuz = ""; eq.RegTime = ""; eq.PatNo = ""; eq.ApvNo = ""; eq.MgtAgency = ""; } //资产类别为"文物和陈列品" if (eq.EqType == "文物和陈列品") { eq.RelicLv = this.cbxRelicLv.Text; } else { eq.RelicLv = ""; } /*************************************判断结束******************************************************/ try { count = int.Parse(this.txtCount.Text); } catch (FormatException) { untCommon.ErrorMsg("数量请输入数字。"); return; } try { eq.Price = double.Parse(this.txtPrice.Text); } catch (FormatException) { untCommon.ErrorMsg("价值请输入数字。"); return; } try { if (this.txtUSDPrice.Text.Trim() != "") { eq.UsdPrice = double.Parse(this.txtUSDPrice.Text); } else { eq.UsdPrice = 0; } } catch (FormatException) { untCommon.ErrorMsg("美金单价请输入数字。"); return; } //判断更新模式 switch (this.mode) { case 0: this.DialogResult = DialogResult.OK; break; //直接修改 case 1: { int error = 0; //0级和1级用户直接更新 if (_power == "0" || _power == "1") { foreach (string field in eqnoList) { eq.EqNo = field; eq.State = "入库"; if (EqMgr.Update(eq)) { // } else { error++; } } if (error == 0) { untCommon.InfoMsg("更新成功"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("操作失败,失败数目为:" + error.ToString()); this.DialogResult = DialogResult.OK; this.Close(); } } else { DataTable Empdt = EmployeeMgr.GetAllName(); foreach (string field in eqnoList) { eq.EqNo = "U" + this.Loginid + DateTime.Now.ToString("yyyyMMddHHmmss") + field; eq.State = "更新待审核"; if (EqMgr.Add(eq)) { // } else { error++; } } if (error == 0) { untCommon.InfoMsg("更新成功,请等待审核"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("操作失败,失败数目为:" + error.ToString()); this.DialogResult = DialogResult.OK; this.Close(); } } break; } //直接批量修改 case 2: { string question = "确定要更改这单数量为: "; question += EqMgr.AssetCount(this.asset).ToString() + " 的资产吗?"; if (untCommon.QuestionMsg(question)) { if (_power == "0" || _power == "1") { eq.State = "入库"; if (EqMgr.UpdateByAsset(eq, asset)) { untCommon.InfoMsg("更新成功"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("更新失败。"); this.DialogResult = DialogResult.OK; this.Close(); } } else { List <string> list = EqMgr.GetEqNoByAssetNo(this.asset); DataTable Empdt = EmployeeMgr.GetAllName(); int error = 0; if (list != null) { foreach (string field in list) { eq.EqNo = "U" + this.name2ID(Empdt, this._user, "name") + DateTime.Now.ToString("yyyyMMddHHmmss") + field; eq.State = "更新待审核"; if (EqMgr.Add(eq)) { } else { error++; } } } if (error == 0) { untCommon.InfoMsg("更新信息提交成功,请等待审核"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("更新信息发生错误\n" + "失败数为: " + error.ToString()); this.DialogResult = DialogResult.OK; this.Close(); } } } break; } //从新增审核处修改 case 3: { eq.State = "新增待审核"; if (EqMgr.UpdateByAsset(eq, asset)) { untCommon.InfoMsg("更新信息提交成功,请等待审核"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("更新失败。"); this.DialogResult = DialogResult.OK; this.Close(); } break; } //从更新审核处修改 case 4: { int error = 0; DataTable Empdt = EmployeeMgr.GetAllName(); foreach (string field in eqnoList) { eq.EqNo = field; eq.State = "更新待审核"; if (EqMgr.Update(eq)) { // } else { error++; } } if (error == 0) { untCommon.InfoMsg("更新成功,请等待审核"); this.DialogResult = DialogResult.OK; this.Close(); } else { untCommon.InfoMsg("操作失败,失败数目为:" + error.ToString()); this.DialogResult = DialogResult.OK; this.Close(); } break; } } } }
private void btnOk_Click(object sender, EventArgs e) { if (view_only) { untCommon.InfoMsg("当前无法修改。"); } else { Clear clear = new Clear(); clear.ID = this.textSerialNO.Text; clear.EqNo = this.textEqNO.Text; clear.EqName = this.textName.Text; DataTable Empdt = EmployeeMgr.GetAllName(); DataTable Depdt = DepartMgr.GetAllDepartment(); clear.Department = this.name2ID(Depdt, this.textDepartment.Text, "departName"); clear.KeepPlace = this.textKeepPlace.Text; clear.Keeper = this.name2ID(Empdt, this.textKeeper.Text, "name"); clear.CType = this.cbxClearType.Text; clear.CAgent = this.name2ID(Empdt, _user, "name"); clear.CDate = this.dtpDate.Value; clear.Remark = this.textRemark.Text; bool flag; if (updata_flag) { flag = ClearMgr.CUpdate(ID, clear); if (flag) { untCommon.InfoMsg("修改成功。"); } else { untCommon.InfoMsg("修改失败。"); } } else { if (IsEqAvailable(this.textEqNO.Text)) { if (_power == "0" || _power == "1") { flag = ClearMgr.AddWithoutVerify(clear); untCommon.InfoMsg("注销成功。"); } else { flag = ClearMgr.Add(clear); untCommon.InfoMsg("注销成功待审核。"); } flag = EqMgr.ClearEq(clear.EqNo); if (!flag) { untCommon.InfoMsg("注销失败。"); } } else { untCommon.InfoMsg("该资产状态已改变,无法修改该信息。"); } } this.DialogResult = DialogResult.OK; } }