private void btnEdit_Click(object sender, EventArgs e) { try { int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); int sortOrder = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colSortOrder)); WorkingStepModel model = new WorkingStepModel(); var dr = grvData.GetRow(grvData.FocusedRowHandle); model = (WorkingStepModel)dr; frmWorkingStepDetail frm = new frmWorkingStepDetail(); frm.WorkingStep = model; if (frm.ShowDialog() == DialogResult.OK) { var lst = arrStep.ToArray().ToList(); lst = lst.Where(o => ((WorkingStepModel)o).ID != id && ((WorkingStepModel)o).SortOrder != sortOrder).ToList(); arrStep = new ArrayList(); for (int i = 0; i < lst.Count; i++) { arrStep.Add(lst[i]); } arrStep.Add(frm.WorkingStep); grdData.DataSource = null; grdData.DataSource = arrStep; } } catch (Exception ex) { } }
private void btnNew_Click(object sender, EventArgs e) { frmWorkingStepDetail frm = new frmWorkingStepDetail(); if (frm.ShowDialog() == DialogResult.OK) { //arrStep.Insert(0, frm.WorkingStep); arrStep.Add(frm.WorkingStep); grdData.DataSource = null; grdData.DataSource = arrStep; } }