public frmAddDomen(frmMain par, ESys.DomensRow row, int index) { InitializeComponent(); parent = par; editrow = index; if (index >= 0) { Load_value(par, row); } }
public void Load_value(frmMain par, ESys.DomensRow row) { btnSave.Text = "Применить"; txtName.Text = row.Имя_домена; DataRow[] rows = (from dom in par.es.Domens join vals in par.es.DomenVal on dom.Имя_домена equals vals.Имя_домена where dom.Имя_домена == txtName.Text select vals).ToArray(); foreach (DataRow r in rows) { dataVDom.Rows.Add(r[1]); } editname = txtName.Text; }
private void edit_domen() { if (dataDomen.SelectedRows.Count == 0) { MessageBox.Show("Выберите домен для изменения"); } else { ESys.DomensRow dr = es.Domens.Where(e => e.Имя_домена == dataDomen.SelectedRows[0].Cells[0].Value.ToString()).First(); frmAddDomen frm = new frmAddDomen(this, dr, dataDomen.SelectedRows[0].Index); if (!check_dom_in_rule(dataDomen.SelectedRows[0].Cells[0].Value.ToString())) { MessageBox.Show("Значения домена уже используются в правилах\nИзменение значений домена запрещено", "Внимание"); frm.dataVDom.AllowUserToAddRows = false; } frm.ShowDialog(this); } }
private void dataDomen_DragDrop(object sender, DragEventArgs e) { // The mouse locations are relative to the screen, so they must be // converted to client coordinates. Point clientPoint = dataDomen.PointToClient(new Point(e.X, e.Y)); // Get the row index of the item the mouse is below. rowIndexOfItemUnderMouseToDrop = dataDomen.HitTest(clientPoint.X, clientPoint.Y).RowIndex; // If the drag operation was a move then remove and insert the row. if (e.Effect == DragDropEffects.Move) { DataGridViewRow row = e.Data.GetData( typeof(DataGridViewRow)) as DataGridViewRow; ESys.DomensRow rowToMove = es.Domens.NewDomensRow(); rowToMove.ItemArray = es.Domens[row.Index].ItemArray; if (row.Index < 0) { return; } if (rowIndexFromMouseDown < rowIndexOfItemUnderMouseToDrop) { es.Domens.Rows.RemoveAt(rowIndexFromMouseDown); es.Domens.Rows.InsertAt(rowToMove, rowIndexOfItemUnderMouseToDrop - 1); dataDomen.Update(); } else if (rowIndexFromMouseDown > rowIndexOfItemUnderMouseToDrop) { es.Domens.Rows.RemoveAt(rowIndexFromMouseDown); es.Domens.Rows.InsertAt(rowToMove, rowIndexOfItemUnderMouseToDrop); dataDomen.Update(); } } }