/// <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.MaxDeviceIDInController8001; for (int i = 0; i < rowsAmount; i++) { tempCode++; deviceID++; EditableDeviceInfo8001 deviceInfo = new EditableDeviceInfo8001(); deviceInfo.Loop = TheLoop; deviceInfo.Code = TheLoop.Code + tempCode.ToString().PadLeft(3, '0');//暂时将器件长度固定为3 deviceInfo.ID = deviceID; DeviceInfoObservableCollection.Add(deviceInfo); } BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8001 = deviceID; _maxCode = tempCode; }
public void BeginEdit() { if (inEdit) { return; } inEdit = true; backupCopy = this.MemberwiseClone() as EditableDeviceInfo8001; }
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) { _deviceService8001.TheLoop = TheLoop; List <DeviceInfo8001> lstDeviceInfo8001 = _deviceService8001.Create(rowsAmount); //int tempCode = _maxCode; //if (tempCode >= MaxDeviceAmount) //如果已经达到上限,则不添加任何行 //{ // rowsAmount = 0; //} //if ((tempCode + rowsAmount) > MaxDeviceAmount) //如果需要添加的行数将达上限,则增加剩余的行数 //{ // rowsAmount = tempCode + rowsAmount - MaxDeviceAmount; //} //int deviceID = BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8001; //for (int i = 0; i < rowsAmount; i++) //{ // tempCode++; // deviceID++; // EditableDeviceInfo8001 deviceInfo = new EditableDeviceInfo8001(); // deviceInfo.Loop = TheLoop; // deviceInfo.Code = TheLoop.Code + tempCode.ToString().PadLeft(3, '0');//暂时将器件长度固定为3 // deviceInfo.ID = deviceID; // DeviceInfoObservableCollection.Add(deviceInfo); //} //BusinessLib.ProjectManager.GetInstance.MaxDeviceIDInController8001 = deviceID; //_maxCode = tempCode; foreach (var device in lstDeviceInfo8001) { EditableDeviceInfo8001 editDevice8001 = new EditableDeviceInfo8001(); editDevice8001.Loop = device.Loop; editDevice8001.LoopID = device.LoopID; editDevice8001.Code = device.Code; editDevice8001.ID = device.ID; editDevice8001.TypeCode = device.TypeCode; DeviceInfoObservableCollection.Add(editDevice8001); } }