/// <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.MaxDeviceIDInController8000; for (int i = 0; i < rowsAmount; i++) { tempCode++; deviceID++; EditableDeviceInfo8000 deviceInfo = new EditableDeviceInfo8000(); deviceInfo.Loop = TheLoop; deviceInfo.Code = TheLoop.Code + tempCode.ToString().PadLeft(3, '0');//暂时将器件长度固定为3 deviceInfo.ID = deviceID; DeviceInfoObservableCollection.Add(deviceInfo); } BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8000 = deviceID; _maxCode = tempCode; }
public void BeginEdit() { if (inEdit) { return; } inEdit = true; backupCopy = this.MemberwiseClone() as EditableDeviceInfo8000; }
public void EndEdit() { if (!inEdit) { return; } inEdit = false; backupCopy = null; if (ItemEndEdit != null) { ItemEndEdit(this); } }
/// <summary> /// 添加指定数量的器件信息 /// </summary> /// <param name="rowsAmount"></param> public void AddNewRecordExecute(int rowsAmount) { _deviceService8000.TheLoop = this.TheLoop; List <DeviceInfo8000> lstDeviceInfo8000 = _deviceService8000.Create(rowsAmount); //int tempCode = _maxCode; //if (tempCode >= MaxDeviceAmount) //如果已经达到上限,则不添加任何行 //{ // rowsAmount = 0; //} //if ((tempCode + rowsAmount) > MaxDeviceAmount) //如果需要添加的行数将达上限,则增加剩余的行数 //{ // rowsAmount = tempCode + rowsAmount - MaxDeviceAmount; //} //int deviceID = BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8000; //for (int i = 0; i < rowsAmount; i++) //{ // tempCode++; // deviceID++; // EditableDeviceInfo8000 deviceInfo = new EditableDeviceInfo8000(); // deviceInfo.Loop = TheLoop; // deviceInfo.Code = TheLoop.Code + tempCode.ToString().PadLeft(3, '0');//暂时将器件长度固定为3 // deviceInfo.ID = deviceID; // DeviceInfoObservableCollection.Add(deviceInfo); //} //BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8000 = deviceID; //_maxCode = tempCode; foreach (var device in lstDeviceInfo8000) { EditableDeviceInfo8000 editDevice8000 = new EditableDeviceInfo8000(); editDevice8000.Loop = device.Loop; editDevice8000.LoopID = device.LoopID; editDevice8000.Code = device.Code; editDevice8000.ID = device.ID; editDevice8000.TypeCode = device.TypeCode; DeviceInfoObservableCollection.Add(editDevice8000); } }