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