private void cb_wrench_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cb_wrench.SelectedIndex == 1) { if (!string.IsNullOrEmpty(this.wrenchbarcode.Text.Trim())) { GetWrenchInfo gwi = new GetWrenchInfo(); wrenchinfo wi = gwi.GetWrenchinfo(this.wrenchbarcode.Text.Trim()); if (wi == null) { MessageAlert.Alert("没有任何详细信息!"); } else { WrenchShow us = new WrenchShow(wi); us.ShowDialog(); } } } if (cb_wrench.SelectedIndex == 2) { if (string.IsNullOrEmpty(this.wrenchbarcode.Text.Trim())) { return; } WrenchBorrowHistory wbh = new WrenchBorrowHistory(); wrench w = Wrench.selectByBarcode(this.wrenchbarcode.Text.Trim()); if (w == null) { return; } List <BorrowHistory> bhl = wbh.GetByUser(Borrow.SelectByWrench(w.guid)); UserBorrow ub = new UserBorrow(bhl); ub.ShowDialog(); } this.cb_wrench.SelectedIndex = 0; }
bool DelWrench(wrench w) { if (w == null) { return(false); } try { StringBuilder borrowlist = new StringBuilder(""); StringBuilder checklist = new StringBuilder(""); StringBuilder ws = new StringBuilder(""); if (SystData.userInfo != null && SystData.userInfo.user != null) { ws.Append("操作人:" + SystData.userInfo.user.username + "\n"); } ws.Append("wrench:" + " 工具编号 " + w.wrenchCode + " 工具条码号 " + w.wrenchBarCode + " 最小值 " + w.rangeMin + " 最大值 " + w.rangeMax + " 生产厂家 " + w.factory + " 入库日期 " + w.createDate + " IP " + w.IP + " port " + w.port + " 种类 " + w.species + " 状态 " + w.status + " 最近维护时间 " + w.lastrepair + " 周期 " + w.cycletime + " 允许校验 " + w.isallowcheck + " 目标值 " + w.targetvalue + " 单位 " + w.unit + " comment " + w.comment + " 标识 " + w.guid + "\n" ); List <borrow> borrowmodel = Borrow.SelectByWrench(w.guid); List <torquechecktarget> torquechecktargetlist = CheckTarget.SelectByWrench(w.guid); if (borrowmodel != null && borrowmodel.Count > 0) { foreach (borrow b in borrowmodel) { borrowlist.Append("Borrow:" + " 工具编号 " + b.WrenchID + " 借用人 " + b.borrowUser + " 借出操作人 " + b.borrowOperator + " 归还人 " + b.returnUser + " 归还操作人 " + b.returnOperator + " 借用日期 " + b.borrowDate + " 归还 " + b.is_return + " 归还日期 " + b.returnDate + " comment " + b.comment + " 标识 " + b.guid + "\n" ); Borrow.Del(b); } } if (torquechecktargetlist != null && torquechecktargetlist.Count > 0) { foreach (torquechecktarget t in torquechecktargetlist) { checklist.Append("Torquechecktarget:" + " wrenchID " + t.wrenchID + " 校验时间 " + t.checkDate + " 质检id " + t.qaID + " 操作人 " + t.operatorID + " 目标校验值 " + t.torqueTargetValue + " 最大允许误差 " + t.errorRangeMax + " 最小允许误差 " + t.errorRangeMin + " 是否合格 " + t.is_good + " comment " + t.comment + " 唯一标识 " + t.guid + "\n" ); List <torquecheckrecord> checkrecord = CheckTargetRecord.SelectByCheckTargetID(t.guid); if (checkrecord != null && checkrecord.Count > 0) { foreach (torquecheckrecord tq in checkrecord) { checklist.Append("torquecheckrecord:" + " 目标id " + tq.TorqueCheckTargetID + " 教育你值 " + tq.analyserValue + " 校验时间 " + tq.checkTime + " 是否合格 " + tq.passedFlag + " 是否有效 " + tq.isEffective + " comment " + tq.comment + " 标识 " + tq.guid + "\n" ); CheckTargetRecord.Del(tq); } } CheckTarget.Del(t); } } Wrench.Del(w); // LogUtil.WriteLog(typeof(string), borrowlist.ToString()); LogUtil.WriteLog(typeof(string), ws.ToString() + borrowlist.ToString() + checklist.ToString()); MessageAlert.Alert("删除成功"); return(true); } catch { LogUtil.WriteLog(typeof(string), "删除失败!"); MessageAlert.Alert("删除失败"); return(false); } }