/// <summary> /// 取得ICASA的所有记录数据 /// </summary> /// <param name="?"></param> /// <returns>IList<ChepPalletDef></returns> public IList<ICASAInfo> GetICASAList() { IList<ICASADef> lstICASADef = new List<ICASADef>(); IList<ICASAInfo> listInfo = new List<ICASAInfo>(); try { ILCMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<ILCMRepository>(); lstICASADef = itemRepository.GetICASAList(); foreach (ICASADef iCASADef in lstICASADef) { ICASAInfo iCASAInfo = new ICASAInfo(); iCASAInfo.vc = iCASADef.vc; iCASAInfo.av = iCASADef.av; iCASAInfo.anatel1 = iCASADef.anatel1; iCASAInfo.anatel2 = iCASADef.anatel2; iCASAInfo.icasa = iCASADef.icasa; iCASAInfo.edit = iCASADef.edit; if (iCASADef.cdt == DateTime.MinValue) { iCASAInfo.cdt = ""; } else { iCASAInfo.cdt = ((System.DateTime)iCASADef.cdt).ToString("yyyy-MM-dd HH:mm:ss"); } if (iCASADef.udt == DateTime.MinValue) { iCASAInfo.udt = ""; } else { iCASAInfo.udt = ((System.DateTime)iCASADef.udt).ToString("yyyy-MM-dd HH:mm:ss"); } iCASAInfo.id = iCASADef.id; listInfo.Add(iCASAInfo); } return listInfo; } catch (Exception) { throw; } }
/// <summary> /// 保存一条ICASA的记录数据(Add) /// </summary> /// <param name="Object">ICASADef item</param> public string AddICASAInfo(ICASAInfo item) { FisException ex; List<string> paraError = new List<string>(); try { ILCMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<ILCMRepository>(); UnitOfWork uow = new UnitOfWork(); ICASADef iCASADefs = itemRepository.GetICASAInfoByVC(item.vc); if (iCASADefs != null) { //要添加的数据已经存在 ex = new FisException("DMT095", paraError); throw ex; } ICASADef iCASADef = new ICASADef(); iCASADef.vc = item.vc; iCASADef.av = item.av; iCASADef.anatel1 = item.anatel1; iCASADef.anatel2 = item.anatel2; iCASADef.icasa = item.icasa; iCASADef.edit = item.edit; iCASADef.cdt = DateTime.Now; iCASADef.udt = DateTime.Now; itemRepository.AddICASAInfoDefered(uow, iCASADef); uow.Commit(); iCASADef = itemRepository.GetICASAInfoByVC(item.vc); return iCASADef.id.ToString(); } catch (Exception) { throw; } }
/// <summary> /// 保存一条ICASA的记录数据(Add) /// </summary> /// <param name="Object">ICASADef item</param> public void UpdateICASAInfo(ICASAInfo item, string itemId) { FisException ex; List<string> paraError = new List<string>(); try { ILCMRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<ILCMRepository>(); UnitOfWork uow = new UnitOfWork(); //当前信息是否存在 if (itemRepository.GetICASAInfoById(int.Parse(itemId)) == null) { //要更新的原始数据已被删除 ex = new FisException("DMT082", paraError); throw ex; } ICASADef iCASADefs = itemRepository.GetICASAInfoByVC(item.vc); if (iCASADefs != null) { //判断非当前记录和要更新的数据是否有重复 if (iCASADefs.id != int.Parse(itemId)) { //要更新的数据已经存在于其他记录 ex = new FisException("DMT095", paraError); throw ex; } } ICASADef iCASADef = new ICASADef(); iCASADef.vc = item.vc; iCASADef.av = item.av; iCASADef.anatel1 = item.anatel1; iCASADef.anatel2 = item.anatel2; iCASADef.icasa = item.icasa; iCASADef.edit = item.edit; itemRepository.UpdateICASAInfoDefered(uow, iCASADef, int.Parse(itemId)); uow.Commit(); } catch (Exception) { throw; } }
protected void btnSave_ServerClick(Object sender, EventArgs e) { string itemId = this.itemId.Value.Trim(); ICASAInfo item = new ICASAInfo(); item.vc = this.vc.Text.Trim().ToUpper(); //ITC-1361-0103 ITC210012 2012-3-6 item.av = this.av.Text.Trim(); item.anatel1 = this.antel1.Text.Trim(); item.anatel2 = this.antel2.Text.Trim(); item.icasa = this.icasa.Text.Trim(); item.edit = this.HiddenUserName.Value; try { iICASA.UpdateICASAInfo(item, itemId); } catch (FisException ex) { ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "DealHideWait", "DealHideWait();", true); showErrorMessage(ex.mErrmsg); return; } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "DealHideWait", "DealHideWait();", true); //show error showErrorMessage(ex.Message); return; } //读取并显示列表信息 ShowICASAInfo(); itemId = replaceSpecialChart(itemId); this.updatePanel2.Update(); ScriptManager.RegisterStartupScript(this.updatePanel2, typeof(System.Object), "saveUpdate", "resetTableHeight();AddUpdateComplete('" + itemId + "');DealHideWait();", true); }