/// <summary> /// 取得KitLoc的所有记录数据 /// </summary> /// <param name="?"></param> /// <returns>IList<FAFloatLocationDef> chepList</returns> public IList<FAFloatLocationDef> GetKitLocList() { IList<FAFloatLocationDef> chepList = new List<FAFloatLocationDef>(); IList<FAFloatLocationInfo> listInfo = new List<FAFloatLocationInfo>(); try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); listInfo = itemRepository.GetFAFloatLocationList(); foreach (FAFloatLocationInfo kitLocInfo in listInfo) { FAFloatLocationDef item = new FAFloatLocationDef(); item.family = kitLocInfo.family; item.partType = kitLocInfo.partType; item.pdLine = kitLocInfo.pdLine; item.location = kitLocInfo.location; item.editor = kitLocInfo.editor; item.id = kitLocInfo.id; if (kitLocInfo.cdt == DateTime.MinValue) { item .cdt= ""; } else { item.cdt = ((System.DateTime)kitLocInfo.cdt).ToString("yyyy-MM-dd HH:mm:ss"); } if (kitLocInfo.udt == DateTime.MinValue) { item.udt = ""; } else { item.udt = ((System.DateTime)kitLocInfo.udt).ToString("yyyy-MM-dd HH:mm:ss"); } chepList.Add(item); } return chepList; } catch (Exception) { throw; } }
protected void btnDelete_ServerClick(Object sender, EventArgs e) { try { FAFloatLocationDef item = new FAFloatLocationDef(); item.id = int.Parse(this.itemId.Value.Trim()); iFAKitLoc.DeleteKitLoc(item); } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } ShowListByFamilyTop(); this.updatePanel2.Update(); ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "DeleteComplete();DealHideWait();", true); }
//btnAdd的后台处理 protected void btnAdd_ServerClick(Object sender, EventArgs e) { FAFloatLocationDef item = new FAFloatLocationDef(); String family = null; String pType = null; String pdLine = null; item.family = this.cmbMaintainFamily.InnerDropDownList.SelectedValue; item.partType = this.pType.Text.Trim().ToUpper(); item.location = this.location.Text.Trim(); item.pdLine = this.cmbMaintainPdLine.InnerDropDownList.SelectedValue; item.editor = this.HiddenUserName.Value; try { iFAKitLoc.AddKitLoc(item); } catch (FisException ex) { showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { //show error showErrorMessage(ex.Message); return; } ShowListByFamilyTop(); family = replaceSpecialChart(item.family); pType = replaceSpecialChart(item.partType); pdLine = replaceSpecialChart(item.pdLine); this.updatePanel2.Update(); ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "DealHideWait();AddUpdateComplete('" + family + "','" + pType + "','" + pdLine + "');", true); }
/// <summary> /// "删除一条记录 /// </summary> /// <param name="?">FAFloatLocationDef item</param> public void DeleteKitLoc(FAFloatLocationDef item) { try { FAFloatLocationInfo fAFloatLocation = new FAFloatLocationInfo(); IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); UnitOfWork uow = new UnitOfWork(); itemRepository.DeleteFAFloatLocationInfoDefered(uow, item.id); uow.Commit(); } catch (Exception) { throw; } }
/// <summary> /// 更新一条KitLoc的记录数据 /// </summary> /// <param name="Object">FAFloatLocationDef item,string family,string pType,string pdLine</param> public void UpdateKitLoc(FAFloatLocationDef item, string itemId) { FisException ex; List<string> paraError = new List<string>(); try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); UnitOfWork uow = new UnitOfWork(); //当前信息是否存在 FAFloatLocationInfo fAFloatLocations = itemRepository.GetFAFloatLocationInfo(int.Parse(itemId)); if (fAFloatLocations == null) { //要更新的原始数据已被删除 ex = new FisException("DMT082", paraError); throw ex; } FAFloatLocationInfo lstFAFloatLocationInfo = itemRepository.GetFAFloatLocation(item.family, item.partType, item.pdLine); //判断非当前记录和要更新的数据是否有重复 //if (lstFAFloatLocationInfo.id != int.Parse(itemId)) if (lstFAFloatLocationInfo != null && lstFAFloatLocationInfo.id != int.Parse(itemId)) { //要更新的数据已经存在于其他记录 ex = new FisException("DMT079", paraError); throw ex; } FAFloatLocationInfo fAFloatLocation = new FAFloatLocationInfo(); fAFloatLocation.family = item.family; fAFloatLocation.partType = item.partType; fAFloatLocation.pdLine = item.pdLine; fAFloatLocation.location = item.location; fAFloatLocation.editor = item.editor; fAFloatLocation.cdt = DateTime.Now; fAFloatLocation.udt = DateTime.Now; itemRepository.UpdateFAFloatLocationInfoDefered(uow, fAFloatLocation, int.Parse(itemId)); uow.Commit(); } catch (Exception) { throw; } }
/// <summary> /// 保存一条KitLoc的记录数据(Add) /// </summary> /// <param name="Object"> FAFloatLocationDef item</param> public void AddKitLoc(FAFloatLocationDef item) { FisException ex; List<string> paraError = new List<string>(); try { IProductRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository>(); UnitOfWork uow = new UnitOfWork(); FAFloatLocationInfo fAFloatLocationInfo = itemRepository.GetFAFloatLocation(item.family, item.partType, item.pdLine); if (fAFloatLocationInfo != null) { //要添加的数据已经存在 ex = new FisException("DMT079", paraError); throw ex; } FAFloatLocationInfo fAFloatLocation = new FAFloatLocationInfo(); fAFloatLocation.family = item.family; fAFloatLocation.partType = item.partType; fAFloatLocation.pdLine = item.pdLine; fAFloatLocation.location = item.location; fAFloatLocation.editor = item.editor; fAFloatLocation.cdt = DateTime.Now; fAFloatLocation.udt = DateTime.Now; itemRepository.AddFAFloatLocationInfoDefered(uow, fAFloatLocation); uow.Commit(); } catch (Exception) { throw; } }