public void DeleteAssetRule(AstRuleInfo item) { try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); AstRuleInfo astRule = new AstRuleInfo(); //astRule.tp = "AT"; //astRule.code = item.code; //astRule.checkTp = "";//item.checkTp; //astRule.checkItem = item.checkItem; //astRule.custName = item.custName; //astRule.station = item.station; //astRule.editor = item.editor; astRule.id = item.id; itemRepository.DeleteAstRuleRule(astRule); } catch (Exception) { throw; } }
public string AddAssetRule(AstRuleInfo item) { String result = ""; try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); AstRuleInfo astRule = new AstRuleInfo(); astRule.tp = item.tp; astRule.code = item.code; astRule.checkTp = item.checkTp; astRule.checkItem = item.checkItem; astRule.custName = item.custName; astRule.station = item.station; DataTable exists = itemRepository.ExistAstRule(astRule); if (exists != null && exists.Rows.Count > 0) { //已经存在具有相同AstType、CheckItem、CheckType、Station和CustName的AssetRule记录 List<string> erpara = new List<string>(); FisException ex; ex = new FisException("DMT071", erpara); throw ex; } astRule.editor = item.editor; astRule.remark = item.remark; astRule.cdt = DateTime.Now; astRule.udt = DateTime.Now; itemRepository.AddAstRuleInfo(astRule); result = astRule.id.ToString(); } catch (Exception) { throw; } return result; }
private AstRuleInfo CheckAstRule(AstRuleInfo rule, IProduct product, IPart part) { IProductRepository prodRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>(); IDeliveryRepository dnRep = RepositoryFactory.GetInstance().GetRepository<IDeliveryRepository, Delivery>(); IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>(); AstRuleInfo ret = rule; if (ret.checkTp == "PrintLog") { if ( !string.IsNullOrEmpty(ret.checkItem)) { var printRep = RepositoryFactory.GetInstance().GetRepository<IPrintLogRepository, PrintLog>(); if (!printRep.CheckPrintLogListByRange(product.ProId,ret.checkItem, ret.code) && !printRep.CheckPrintLogListByRange(product.CUSTSN, ret.checkItem,ret.code)) { //throw error throw new FisException("CQCHK1062", new string[] { product.ProId, ret.code, ret.checkItem }); } } else { throw new FisException("CQCHK1064", new string[] { product.ProId, ret.code}); } return null; } else if (ret.checkTp == "Value") { Delivery dn; ret.remark = ""; switch (ret.checkItem) { case "PoNo": if (!string.IsNullOrEmpty(product.DeliveryNo)) { dn = dnRep.Find(product.DeliveryNo); if (dn != null && !string.IsNullOrEmpty(dn.PoNo)) { ret.remark = dn.PoNo; } } break; case "CustPo": if (!string.IsNullOrEmpty(product.DeliveryNo)) { ret.remark = dnRep.GetDeliveryInfoValue(product.DeliveryNo, "CustPo"); } break; case "UUID": ret.remark = prodRep.GetProductInfoValue(product.ProId, "UUID"); break; case "MAC": ret.remark = product.MAC; break; case "WM": ret.remark = prodRep.GetProductInfoValue(product.ProId, "WM"); if (!string.IsNullOrEmpty(ret.remark)) { ret.remark = ret.remark.Replace(":", ""); //去掉字符':' } break; case "SN": ret.remark = product.CUSTSN; break; case "CHAR": IList<ConstValueInfo> valueList = partRep.GetConstValueListByType("ASTCHAR").Where(x => x.value.Trim() != "" && x.name == ret.custName).ToList(); if (valueList != null && valueList.Count > 0) { ret.remark = valueList[0].value; } break; case "AST": //跟之前邏輯有些不同 var astSn=( from p in product.ProductParts where p.BomNodeType== ret.tp && p.PartType== ret.code select p.PartSn).FirstOrDefault(); ret.remark =astSn; break; case "PartNo": ret.remark = part.PN; break; default: break; } if (string.IsNullOrEmpty(ret.remark)) { //throw error throw new FisException("CQCHK1063", new string[] { product.ProId, ret.code, ret.checkItem }); } return ret; } else if (ret.checkTp == "ProductLog") { if (!string.IsNullOrEmpty(ret.checkItem)) { IList<ProductLog> productLogList = product.ProductLogs; if (!productLogList.Any(x=>x.Station== ret.checkItem && x.Line == ret.code)) { //throw error throw new FisException("CQCHK1066", new string[] { product.ProId, ret.code, ret.checkItem }); } } else { throw new FisException("CQCHK1067", new string[] { product.ProId, ret.code }); } return null; } else { throw new FisException("CQCHK1065", new string[] { product.ProId,ret.checkTp}); } }
public void AddAsSetRule(AstRuleInfo item) { try { IPartRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IPartRepository>(); IList<AstRuleInfo> exists = itemRepository.GetAstRuleByCondition(item); if (exists != null && exists.Count > 0) { //已经存在具有相同AstType、CheckItem、CheckType、Station和CustName的AssetRule记录 List<string> erpara = new List<string>(); FisException ex; ex = new FisException("DMT071", erpara); throw ex; } item.cdt = DateTime.Now; item.udt = DateTime.Now; itemRepository.AddAstRule(item); } catch (Exception) { throw; } }
protected void btnAdd_ServerClick(Object sender, EventArgs e) { AstRuleInfo item = new AstRuleInfo(); item.tp = this.cmbTp.SelectedValue; item.code = this.cmbMaintainAssetRuleAstType.InnerDropDownList.SelectedValue; item.checkItem = this.cmbMaintainAssetRuleCheckItem.SelectedValue;//this.cmbMaintainAssetRuleCheckItem.InnerDropDownList.SelectedValue; item.checkTp = this.cmbCheckType.SelectedValue; item.station = this.cmbMaintainAssetRuleCheckStation.InnerDropDownList.SelectedItem.Value; item.custName = this.cmbAVPart.SelectedValue; item.editor = Master.userInfo.UserId; //this.HiddenUserName.Value; item.remark = this.txtRemark.Text.Trim(); string itemId = ""; try { itemId=iAssetRule.AddAssetRule(item); } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } ShowList(); //itemId = replaceSpecialChart(itemId); this.updatePanel1.Update(); ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "AddUpdateComplete('" + itemId + "');DealHideWait();", true); }