예제 #1
0
        public string[] UpdateMachine_MachinesPage(string state, string SelectedMachineID, string MachineCode, string MachineName, string MachineTypeID, string ControlStationID, string MachineConnectionTel, string IsActive)
        {
            this.InitializeCulture();

            string[] retMessage = new string[4];

            try
            {
                decimal MachineID         = 0;
                decimal selectedMachineID = decimal.Parse(this.StringBuilder.CreateString(SelectedMachineID));
                MachineCode = this.StringBuilder.CreateString(MachineCode);
                MachineName = this.StringBuilder.CreateString(MachineName);
                decimal machineTypeID    = decimal.Parse(this.StringBuilder.CreateString(MachineTypeID));
                decimal controlStationID = decimal.Parse(this.StringBuilder.CreateString(ControlStationID));
                MachineConnectionTel = this.StringBuilder.CreateString(MachineConnectionTel);
                bool         isActive = bool.Parse(this.StringBuilder.CreateString(IsActive));
                UIActionType uam      = (UIActionType)Enum.Parse(typeof(UIActionType), this.StringBuilder.CreateString(state).ToUpper());

                GTS.Clock.Model.BaseInformation.Clock machine = new Model.BaseInformation.Clock();
                machine.ID = selectedMachineID;
                if (uam != UIActionType.DELETE)
                {
                    machine.CustomCode = MachineCode;
                    machine.Name       = MachineName;
                    ClockType machineType = new ClockType();
                    machineType.ID    = machineTypeID;
                    machine.Clocktype = machineType;
                    ControlStation controlStation = new ControlStation();
                    controlStation.ID = controlStationID;
                    machine.Station   = controlStation;
                    machine.Tel       = MachineConnectionTel;
                    machine.Active    = isActive;
                }

                switch (uam)
                {
                case UIActionType.ADD:
                    MachineID = this.MachineBusiness.InsertMachine(machine, uam);
                    break;

                case UIActionType.EDIT:
                    if (selectedMachineID == 0)
                    {
                        retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoMachineSelectedforEdit").ToString()), retMessage);
                        return(retMessage);
                    }
                    MachineID = this.MachineBusiness.UpdateMachine(machine, uam);
                    break;

                case UIActionType.DELETE:
                    if (selectedMachineID == 0)
                    {
                        retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, new Exception(GetLocalResourceObject("NoMachineSelectedforDelete").ToString()), retMessage);
                        return(retMessage);
                    }
                    MachineID = this.MachineBusiness.DeleteMachine(machine, uam);
                    break;
                }


                retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
                string SuccessMessageBody = string.Empty;
                switch (uam)
                {
                case UIActionType.ADD:
                    SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString();
                    break;

                case UIActionType.EDIT:
                    SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString();
                    break;

                case UIActionType.DELETE:
                    SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString();
                    break;

                default:
                    break;
                }
                retMessage[1] = SuccessMessageBody;
                retMessage[2] = "success";
                retMessage[3] = MachineID.ToString();
                return(retMessage);
            }
            catch (UIValidationExceptions ex)
            {
                retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
                return(retMessage);
            }
            catch (UIBaseException ex)
            {
                retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
                return(retMessage);
            }
            catch (Exception ex)
            {
                retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
                return(retMessage);
            }
        }
 public void Remove(ControlStation entity)
 {
     throw new NotImplementedException();
 }
예제 #3
0
        public string[] UpdateControlStation_ControlStationsPage(string state, string SelectedControlStationID, string ControlStationCode, string ControlStationName)
        {
            this.InitializeCulture();

            string[] retMessage = new string[4];

            try
            {
                AttackDefender.CSRFDefender(this.Page);
                decimal ControlStationID         = 0;
                decimal selectedControlStationID = decimal.Parse(this.StringBuilder.CreateString(SelectedControlStationID), CultureInfo.InvariantCulture);
                ControlStationCode = this.StringBuilder.CreateString(ControlStationCode);
                ControlStationName = this.StringBuilder.CreateString(ControlStationName);
                UIActionType uam = (UIActionType)Enum.Parse(typeof(UIActionType), this.StringBuilder.CreateString(state).ToUpper());

                ControlStation controlStation = new ControlStation();
                controlStation.ID = selectedControlStationID;
                if (uam != UIActionType.DELETE)
                {
                    controlStation.CustomCode = ControlStationCode;
                    controlStation.Name       = ControlStationName;
                }

                switch (uam)
                {
                case UIActionType.ADD:
                    ControlStationID = this.ControlStationBusiness.InsertControlStation(controlStation, uam);
                    break;

                case UIActionType.EDIT:
                    if (selectedControlStationID == 0)
                    {
                        retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoControlStationSelectedforEdit").ToString()), retMessage);
                        return(retMessage);
                    }
                    ControlStationID = this.ControlStationBusiness.UpdateControlStation(controlStation, uam);
                    break;

                case UIActionType.DELETE:
                    if (selectedControlStationID == 0)
                    {
                        retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, new Exception(GetLocalResourceObject("NoControlStationSelectedforDelete").ToString()), retMessage);
                        return(retMessage);
                    }
                    ControlStationID = this.ControlStationBusiness.DeleteControlStation(controlStation, uam);
                    break;
                }

                retMessage[0] = GetLocalResourceObject("RetSuccessType").ToString();
                string SuccessMessageBody = string.Empty;
                switch (uam)
                {
                case UIActionType.ADD:
                    SuccessMessageBody = GetLocalResourceObject("AddComplete").ToString();
                    break;

                case UIActionType.EDIT:
                    SuccessMessageBody = GetLocalResourceObject("EditComplete").ToString();
                    break;

                case UIActionType.DELETE:
                    SuccessMessageBody = GetLocalResourceObject("DeleteComplete").ToString();
                    break;

                default:
                    break;
                }
                retMessage[1] = SuccessMessageBody;
                retMessage[2] = "success";
                retMessage[3] = ControlStationID.ToString();
                return(retMessage);
            }
            catch (UIValidationExceptions ex)
            {
                retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIValidationExceptions, ex, retMessage);
                return(retMessage);
            }
            catch (UIBaseException ex)
            {
                retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.UIBaseException, ex, retMessage);
                return(retMessage);
            }
            catch (Exception ex)
            {
                retMessage = this.exceptionHandler.HandleException(this.Page, ExceptionTypes.Exception, ex, retMessage);
                return(retMessage);
            }
        }
예제 #4
0
 public void GetByIDTest()
 {
     station_testObject = busstaion.GetByID(ADOStaion1.ID);
     Assert.IsNotNull(station_testObject);
     Assert.IsTrue(station_testObject.ID == ADOStaion1.ID);
 }
예제 #5
0
 public void TestSetup()
 {
     station_testObject = new ControlStation();
     busstaion          = new BControlStation();
 }
 public ControlStationItemViewModel(ViewModelBase parent, ControlStation model)
     : base(parent, model)
 {
     _model = model;
 }