private void AddHolds(GridViewSelectedRowsCollection selectedRows) { string holdId = InputDialog.Show("Enter Hold Id:", "Add Machine Hold"); if (string.IsNullOrWhiteSpace(holdId)) { // User cancelled return; } var hostNames = selectedRows.Select(n => n.Cells[GridColumns.NAME_GRID_COLUMN].Value.ToString()); try { this.Cursor = Cursors.WaitCursor; VMInventoryManager.AddHold(hostNames, holdId); foreach (var row in selectedRows) { row.Cells[GridColumns.HOLDID_GRID_COLUMN].Value = holdId; } } finally { this.Cursor = Cursors.Default; } }
public static void copyGridBack01(GridViewSelectedRowsCollection CopyFrom, RadGridView ToCopy) { foreach (GridViewRowInfo itemRow in CopyFrom) { // ToCopy.CurrentRow = null; // ToCopy.AllowAddNewRow = true; ToCopy.Rows.AddNew(); foreach (GridViewDataColumn col in ToCopy.Columns) { try { // ToCopy.Rows[ToCopy.Rows.Count - 1] = itemRow; // GridViewCellInfo col in itemRow.Cells for (int i = 0; i < itemRow.Cells.Count; i++) { if (itemRow.Cells[i].ColumnInfo.FieldName == col.FieldName) { ToCopy.Rows[ToCopy.Rows.Count - 1].Cells[col.FieldName].Value = itemRow.Cells[col.FieldName].Value; break; } } } catch (Exception ex) { try { if (col.FieldName == "Person_Picture") { var ms = new System.IO.MemoryStream(); var Picture = ((Bitmap)itemRow.Cells[col.FieldName].Value); Picture.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); ToCopy.Rows[ToCopy.Rows.Count - 1].Cells[col.FieldName].Value = ms.ToArray(); } else { ItemsPublic.Exeptor(col.Name + "\r\n" + ex.Message); } } catch (Exception ex2) { ItemsPublic.Exeptor(col.Name + "\r\n" + ex.Message + "\r\n" + ex2.Message); } } ToCopy.Rows[ToCopy.Rows.Count - 1].Cells["GatePass_State"].Value = true; ToCopy.Rows[ToCopy.Rows.Count - 1].Cells["GatePass_IsExpired"].Value = false; ToCopy.Rows[ToCopy.Rows.Count - 1].Cells["Gatepass_ID"].Value = null; } } }
private void SetUsage(GridViewSelectedRowsCollection selectedRows, VMUsageState state) { try { this.Cursor = Cursors.WaitCursor; var hostNames = selectedRows.Select(n => n.Cells[GridColumns.NAME_GRID_COLUMN].Value.ToString()); VMInventoryManager.SetUsageState(hostNames, state); RefreshGrid(); } finally { this.Cursor = Cursors.Default; } }
private void RemoveHolds(GridViewSelectedRowsCollection selectedRows) { var hostNames = selectedRows.Select(n => n.Cells[GridColumns.NAME_GRID_COLUMN].Value.ToString()); try { this.Cursor = Cursors.WaitCursor; VMInventoryManager.RemoveHold(hostNames); foreach (var row in selectedRows) { row.Cells[GridColumns.HOLDID_GRID_COLUMN].Value = null; } } finally { this.Cursor = Cursors.Default; } }
public static void copyGridBack02(GridViewSelectedRowsCollection CopyFrom, RadGridView ToCopy) { Dictionary <int, int> Indexs = new Dictionary <int, int>(); // GridViewDataColumn col in ToCopy.Columns) for (int j = 0; j < ToCopy.Columns.Count(); j++) { for (int i = 0; i < CopyFrom[0].Cells.Count; i++) { if (CopyFrom[0].Cells[i].ColumnInfo.FieldName == ToCopy.Columns[j].FieldName) { Indexs.Add(i, j); break; } } } foreach (GridViewRowInfo itemRow in CopyFrom) { // ToCopy.CurrentRow = null; // ToCopy.AllowAddNewRow = true; ToCopy.Rows.AddNew(); foreach (var myIndex in Indexs) { try { ToCopy.Rows[ToCopy.Rows.Count - 1].Cells[myIndex.Value].Value = itemRow.Cells[myIndex.Key].Value; //} //else //{ // var ms = new System.IO.MemoryStream(); // var Picture = ((Bitmap)itemRow.Cells[myIndex.Key].Value); // Picture.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); // ToCopy.Rows[ToCopy.Rows.Count - 1].Cells[myIndex.Value].Value // = ms.ToArray(); //} } catch (Exception ex) { try { if (itemRow.Cells[myIndex.Key].ColumnInfo.FieldName == "Person_Picture") { var ms = new System.IO.MemoryStream(); var Picture = ((Bitmap)itemRow.Cells[myIndex.Key].Value); Picture.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); ToCopy.Rows[ToCopy.Rows.Count - 1].Cells[myIndex.Value].Value = ms.ToArray(); } else { ItemsPublic.Exeptor(itemRow.Cells[myIndex.Key].ColumnInfo.FieldName + "\r\n" + ex.Message); } } catch (Exception ex2) { ItemsPublic.Exeptor(itemRow.Cells[myIndex.Key].ColumnInfo.FieldName + "\r\n" + ex.Message + "\r\n" + ex2.Message); } } ToCopy.Rows[ToCopy.Rows.Count - 1].Cells["GatePass_State"].Value = true; ToCopy.Rows[ToCopy.Rows.Count - 1].Cells["GatePass_IsExpired"].Value = false; ToCopy.Rows[ToCopy.Rows.Count - 1].Cells["Gatepass_ID"].Value = null; // ToCopy.Rows[ToCopy.Rows.Count - 1].Cells["GatePass_State"].Value = true; // ToCopy.Rows[ToCopy.Rows.Count - 1].Cells["GatePass_IsExpired"].Value = false; // ToCopy.Rows[ToCopy.Rows.Count - 1].Cells["Gatepass_ID"].Value = null; } } }