public IList<IMES.DataModel.AssetRangeDef> GetAllAssetRanges() { IList<AssetRangeDef> assetRangeItems = new List<AssetRangeDef>(); try { IList<AssetRangeInfo> assetRangeVos = itemRepository.GetAllAssetRanges(); if(assetRangeVos!=null) { foreach (AssetRangeInfo vo in assetRangeVos) { AssetRangeDef def = new AssetRangeDef(); def.id = vo.id; def.code = vo.code; def.begin = vo.begin; def.end = vo.end; def.remark = vo.remark; def.editor = vo.editor; def.cdt = vo.cdt.ToString("yyyy-MM-dd hh:mm:ss"); def.udt = vo.udt.ToString("yyyy-MM-dd hh:mm:ss"); assetRangeItems.Add(def); } } } catch(Exception ee) { logger.Error(ee.Message); throw; } return assetRangeItems; }
protected void btnSave_ServerClick(object sender, EventArgs e) { AssetRangeDef def = new AssetRangeDef(); def.id = Convert.ToInt32(this.dOldId.Value.Trim()); def.code = this.ttCode.Text.Trim();//this.ttCode.Text.Trim().ToUpper(); def.begin = this.ttBegin.Text.Trim(); //this.ttBegin.Text.Trim().ToUpper(); def.end = this.ttEnd.Text.Trim();//this.ttEnd.Text.Trim().ToUpper(); def.remark = this.ttRemark.Text.Trim(); def.editor = this.HiddenUserName.Value.Trim(); string id = this.dOldId.Value.Trim(); try { //调用更新方法1... 相同key时需要抛出异常... iassetRange.CheckAssetRange(def.code, def.begin, def.end); iassetRange.CheckAddRangeItem(def, ""); IList<SysSettingInfo> syslist = iSysSetting.GetSysSettingListByCondition(new SysSettingInfo { name = "CheckIPCAstRange" }); if (syslist.Count != 0) { if (syslist[0].value == "Y") { iassetRange_SH.CheckAddRangeItem(def, "_SH"); } } iassetRange.UpdateAssetRangeItem(def); //int length = iassetRange.GetBeginLength(def.code); //if (length == -1) //{ // iassetRange.UpdateAssetRangeItem(def); //} //else //{ // if (length == def.begin.Length && length == def.end.Length) // { // iassetRange.UpdateAssetRangeItem(def); // } // else // { // throw new Exception("Input [Begin] and [End] Length need" + length + "!"); // } //} //iassetRange.UpdateAssetRangeItem(def); } catch (FisException fex) { showErrorMessage(fex.mErrmsg); return; } catch (System.Exception ex) { showErrorMessage(ex.Message); return; } //根据ac acdaptor list的数据加载表格中的数据 //... initCodeTopSelect(def.code); showListByAssetRangeList(); updatePanel2.Update(); ScriptManager.RegisterStartupScript(this.updatePanel, typeof(System.Object), "saveUpdate", "resetTableHeight();AddUpdateComplete('" + id + "');HideWait();", true); }
protected void btnAdd_ServerClick(object sender, EventArgs e) { int CheckRange = -1; AssetRangeDef def = new AssetRangeDef(); def.code = this.ttCode.Text.Trim(); def.begin = this.ttBegin.Text.Trim(); def.end = this.ttEnd.Text.Trim(); def.remark = this.ttRemark.Text.Trim(); def.editor = this.HiddenUserName.Value.Trim(); //CheckRange = string.Compare(def.begin, def.end); System.DateTime cdt = DateTime.Now; string timeStr = cdt.ToString(); def.cdt = timeStr; string id = ""; try { iassetRange.CheckAssetRange(def.code, def.begin, def.end); iassetRange.CheckAddRangeItem(def, ""); IList<SysSettingInfo> syslist = iSysSetting.GetSysSettingListByCondition(new SysSettingInfo { name = "CheckIPCAstRange" }); if (syslist.Count != 0) { if (syslist[0].value == "Y") { iassetRange_SH.CheckAddRangeItem(def, "_SH"); } } id = iassetRange.AddAssetRangeItem(def); //if (CheckRange == 1) //{ // throw new Exception("輸入的 [Begin]:" + def.begin + " 不可大於 [End]:" + def.end + " ..."); //} //int length = iassetRange.GetBeginLength(def.code); //if (length == -1) //{ // id = iassetRange.AddAssetRangeItem(def); //} //else //{ // if (length == def.begin.Length && length == def.end.Length) // { // id = iassetRange.AddAssetRangeItem(def); // } // else // { // throw new Exception("Input [Begin] and [End] Length need" + length + "!"); // } //} //调用添加的方法 相同的key时需要抛出异常... //id = iassetRange.AddAssetRangeItem(def); } catch (FisException fex) { showErrorMessage(fex.mErrmsg); return; } catch (System.Exception ex) { showErrorMessage(ex.Message); return; } //按照ac adaptor list加载表格中的数据 //... initCodeTopSelect(def.code); showListByAssetRangeList(); this.updatePanel2.Update(); // string assemblyId = replaceSpecialChart(adaptor.assemb); ScriptManager.RegisterStartupScript(this.updatePanel, typeof(System.Object), "saveUpdate", "resetTableHeight();AddUpdateComplete('" + id + "');HideWait();", true); }
protected void btnCloseRange_ServerClick(object sender, EventArgs e) { AssetRangeDef def = new AssetRangeDef(); string id = this.dOldId.Value.Trim(); try { def.id = Convert.ToInt32(this.dOldId.Value.Trim()); def.code = this.ttCode.Text.Trim();//this.ttCode.Text.Trim().ToUpper(); def.begin = this.ttBegin.Text.Trim(); //this.ttBegin.Text.Trim().ToUpper(); def.end = this.ttEnd.Text.Trim();//this.ttEnd.Text.Trim().ToUpper(); def.remark = this.ttRemark.Text.Trim(); def.status = this.hidStatus.Value; def.editor = this.HiddenUserName.Value.Trim(); iassetRange.CloseActiveRange(def); } catch (FisException fex) { showErrorMessage(fex.mErrmsg); return; } catch (System.Exception ex) { showErrorMessage(ex.Message); return; } initCodeTopSelect(def.code); showListByAssetRangeList(); updatePanel2.Update(); ScriptManager.RegisterStartupScript(this.updatePanel, typeof(System.Object), "CloseRange", "resetTableHeight();AddUpdateComplete('" + id + "');HideWait();", true); }
public void CloseActiveRange(AssetRangeDef item) { if (item.status != "A") { throw new Exception("Status is not Active Status!!"); } INumControlRepository numCtrlRepository = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>(); NumControl currentMaxNum = numCtrlRepository.GetMaxValue("AST", item.code); if (currentMaxNum == null) { throw new Exception("No max Asset Number!!"); } CheckAssetRange(item.code, item.begin, item.end); if (checkNewRange(currentMaxNum.Value, item.begin, item.end)) { throw new Exception(string.Format("max number:{0} is not between begin number:{2} and end number:{3)", currentMaxNum.Value, item.begin, item.end)); } // update Asset Rnage number AssetRangeInfo updatePo = new AssetRangeInfo(); updatePo.udt = DateTime.Now; updatePo.id = item.id; updatePo.editor = item.editor; updatePo.code = item.code; //item.code.ToUpper(); updatePo.begin = item.begin; //item.begin.ToUpper(); updatePo.end = currentMaxNum.Value; updatePo.status = "C"; updatePo.remark = item.remark; itemRepository.UpdateAssetRangeItem(updatePo); }
public void CheckUpdateRangeItem(AssetRangeDef item, string side) { Exception e = null; try { IList<AssetRangeCodeInfo> lst = itemRepository.GetDuplicateAssetRange(item.code, item.begin, item.end); if (lst.Count > 1 && item.begin.Length == lst[0].Begin.Length) { string msg = ""; foreach (AssetRangeCodeInfo errorrange in lst) { msg += errorrange.Begin.ToString() + "~" + errorrange.End.ToString() + Environment.NewLine; } e = new Exception("重複範圍:" + msg); throw e; } else if (lst.Count == 1) { if (lst[0].ID != item.id && item.begin.Length == lst[0].Begin.Length) { string msg = lst[0].Begin.ToString() + "~" + lst[0].End.ToString(); e = new Exception("重複範圍:" + msg); throw e; } } } catch (Exception ee) { logger.Error(ee.Message); throw; } }
public void CheckAddRangeItem(AssetRangeDef item, string side) { Exception e = null; try { IList<AssetRangeCodeInfo> lst = itemRepository.GetDuplicateAssetRange(item.code, item.begin, item.end); string msg = ""; foreach (AssetRangeCodeInfo check in lst) { if (item.begin.Length == check.Begin.Length) { msg += check.Begin.ToString() + "~" + check.End.ToString() + Environment.NewLine; } } if (msg != "") { e = new Exception("重複範圍" + side + ":" + msg); throw e; } } catch (Exception ee) { logger.Error(ee.Message); throw; } }