示例#1
0
        /// <summary>
        /// 根据stationType获取station数据
        /// </summary>
        /// <param name="stationType"></param>
        /// <returns></returns>
        public IList<StationDef> getStationByStationType(string stationType)
        {
            IList<StationDef> lstStation = new List<StationDef>();
            IList<IStation> iStation = new List<IStation>();
            try
            {
                IStationRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IStationRepository>();
                iStation = itemRepository.GetStationList(StationType.FATest);
                if (iStation != null && iStation.Count > 0)
                {
                    foreach (IStation ist in iStation)
                    {
                        StationDef sd = new StationDef();
                        sd.station = ist.StationId;
                        sd.stationType = ist.StationType.ToString();
                        sd.descr = ist.Descr;
                        sd.name = ist.Name;
                        sd.operationObject = ist.OperationObject.ToString();
                        sd.editor = ist.Editor;
                        sd.cdt = ist.Cdt.ToShortDateString();
                        sd.udt = ist.Udt.ToShortDateString();
                        lstStation.Add(sd);
                    }
                    return lstStation;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception)
            {
                throw;
            }

            return lstStation;
        }
示例#2
0
        //Boolean IsExistStation(string station)
        //IF EXISTS(
        //SELECT [Station]     
        //  FROM [Station]
        //where Station ='station)'
        //)
        //set @return='True'
        //ELSE
        //set @return='False' 

        public string AddStation(StationDef item)
        {
            String result = "";
            try
            {
                IStationRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IStationRepository>();

                Boolean isExist = itemRepository.IsExistStation(item.station);
                if (isExist == true)
                {
                    //已经存在具有相同Station的记录
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT043", erpara);
                    throw ex;

                }
                bool existFlag = itemRepository.CheckStationExistByName(item.name);
                if (existFlag)
                {
                    List<string> param = new List<string>();
                    throw new FisException("DMT139", param);
                }
                Station itemNew = new Station();

                itemNew.StationId = item.station;
                itemNew.StationType = (StationType)Enum.Parse(typeof(StationType), item.stationType);
                itemNew.OperationObject = Int32.Parse(item.operationObject);
                itemNew.Descr = item.descr;
                itemNew.Name = item.name;

                itemNew.Editor = item.editor;
                itemNew.Udt = DateTime.Now;
                itemNew.Cdt = DateTime.Now;

                itemRepository.AddStation(itemNew);
                result = itemNew.StationId;
            }
            catch (Exception)
            {
                throw;
            }

            return result;
        }
示例#3
0
        public string UpdateStation(StationDef item, string oldStationId)
        {
            String result = "";
            try
            {
                IStationRepository itemRepository = RepositoryFactory.GetInstance().GetRepository<IStationRepository>();
                Station itemNew = new Station();

                itemNew.StationId = item.station;
                itemNew.StationType = (StationType)Enum.Parse(typeof(StationType), item.stationType);
                itemNew.OperationObject = Int32.Parse(item.operationObject);
                itemNew.Descr = item.descr;
                itemNew.Name = item.name;
                itemNew.Editor = item.editor;
                itemNew.Udt = DateTime.Now;
                //ITC-1361-0095 ITC210012 2012-02-21
                IList<Station> stationObj = itemRepository.GetStationItemByName(item.name);

                if (stationObj.Count>0)
                {
                    if (stationObj[0].StationId != oldStationId)
                    {
                        List<string> param = new List<string>();
                        throw new FisException("DMT139", param);
                    }
                    //itemRepository.AddStation(itemNew);
                    //result = itemNew.StationId;
                }
                        //存在 进行更新操作...
                      itemRepository.UpdateStation(itemNew, oldStationId);
                      result = itemNew.StationId;
               
            }
            catch (Exception)
            {
                throw;
            }

            return result;
        }
示例#4
0
    protected void btnSave_ServerClick(Object sender, EventArgs e)
    {
        StationDef item = new StationDef();

        item.station = this.dStation.Text.Trim();
        item.stationType = this.cmbMaintainStationType.InnerDropDownList.SelectedValue.Trim();
        item.operationObject = this.cmbMaintainStationObject.InnerDropDownList.SelectedValue.Trim();
        item.descr = this.dDescription.Text.Trim();
        item.name = this.dName.Text.Trim();

        item.editor = this.HiddenUserName.Value;

        string oldItemId = this.dOldId.Value.Trim();
        try
        {
            if (oldItemId == item.station)
            {
                iStation.UpdateStation(item, oldItemId);
            }
            else
            {
                iStation.AddStation(item);
            }
        }
        catch (FisException ex)
        {
            showErrorMessage(ex.mErrmsg);
            return;
        }
        catch (Exception ex)
        {
            //show error
            showErrorMessage(ex.Message);
            return;
        }
        ShowList();

        String itemId = replaceSpecialChart(item.station);
        this.updatePanel.Update();
        ScriptManager.RegisterStartupScript(this.updatePanelAll, typeof(System.Object), "saveUpdate", "AddUpdateComplete('" + itemId + "');DealHideWait();", true);

    }