コード例 #1
0
        /// <summary>
        /// 添加指定数量的器件信息
        /// </summary>
        /// <param name="rowsAmount"></param>
        public void AddNewRecordExecute(int rowsAmount)
        {
            int tempCode = _maxCode;

            if (tempCode >= MaxDeviceAmount) //如果已经达到上限,则不添加任何行
            {
                rowsAmount = 0;
            }

            if ((tempCode + rowsAmount) > MaxDeviceAmount) //如果需要添加的行数将达上限,则增加剩余的行数
            {
                rowsAmount = tempCode + rowsAmount - MaxDeviceAmount;
            }
            int deviceID = BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8021;

            for (int i = 0; i < rowsAmount; i++)
            {
                tempCode++;
                deviceID++;
                EditableDeviceInfo8021 deviceInfo = new EditableDeviceInfo8021();
                deviceInfo.Loop = TheLoop;
                deviceInfo.Code = TheLoop.Code + tempCode.ToString().PadLeft(3, '0');//暂时将器件长度固定为3
                deviceInfo.ID   = deviceID;
                DeviceInfoObservableCollection.Add(deviceInfo);
            }
            BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8021 = deviceID;
            _maxCode = tempCode;
        }
コード例 #2
0
 public void BeginEdit()
 {
     if (inEdit)
     {
         return;
     }
     inEdit     = true;
     backupCopy = this.MemberwiseClone() as EditableDeviceInfo8021;
 }
コード例 #3
0
 public void EndEdit()
 {
     if (!inEdit)
     {
         return;
     }
     inEdit     = false;
     backupCopy = null;
     if (ItemEndEdit != null)
     {
         ItemEndEdit(this);
     }
 }
コード例 #4
0
        /// <summary>
        /// 添加指定数量的器件信息
        /// </summary>
        /// <param name="rowsAmount"></param>
        public void AddNewRecordExecute(int rowsAmount)
        {
            //int tempCode = _maxCode;
            //if (tempCode >= MaxDeviceAmount) //如果已经达到上限,则不添加任何行
            //{
            //    rowsAmount = 0;
            //}

            //if ((tempCode + rowsAmount) > MaxDeviceAmount) //如果需要添加的行数将达上限,则增加剩余的行数
            //{
            //    rowsAmount = tempCode + rowsAmount - MaxDeviceAmount;
            //}
            //int deviceID = BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8021;
            //for (int i = 0; i < rowsAmount; i++)
            //{
            //    tempCode++;
            //    deviceID++;
            //    EditableDeviceInfo8021 deviceInfo = new EditableDeviceInfo8021();
            //    deviceInfo.Loop = TheLoop;
            //    deviceInfo.Code = TheLoop.Code + tempCode.ToString().PadLeft(3, '0');//暂时将器件长度固定为3
            //    deviceInfo.ID = deviceID;
            //    DeviceInfoObservableCollection.Add(deviceInfo);
            //}
            //BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8021 = deviceID;
            //_maxCode = tempCode;
            _deviceService8021.TheLoop = this.TheLoop;
            List <DeviceInfo8021> lstDeviceInfo8021 = _deviceService8021.Create(rowsAmount);

            foreach (var device in lstDeviceInfo8021)
            {
                EditableDeviceInfo8021 editDevice8021 = new EditableDeviceInfo8021();
                editDevice8021.Loop     = device.Loop;
                editDevice8021.LoopID   = device.LoopID;
                editDevice8021.Code     = device.Code;
                editDevice8021.ID       = device.ID;
                editDevice8021.TypeCode = device.TypeCode;
                DeviceInfoObservableCollection.Add(editDevice8021);
            }
        }