private void btnNew_Click(object sender, EventArgs e) { FormFunction form = new FormFunction(); form.IsEdit = false; if (form.ShowDialog() == DialogResult.OK) { DataRow row = _dt.NewRow(); row["MID"] = form.MID; row["MNAME"] = form.MID; row["COMMENTARY"] = form.COMMENTARY; row["DETAIL"] = form.DETAIL; row["METHODTYPE"] = "USER"; row["VALUETYPE"] = "数据集"; _dt.Rows.Add(row); try { _dao.UpdateMethod(_dt.GetChanges()); _dt.AcceptChanges(); } catch (Exception ex) { _dt.RejectChanges(); MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } GetData(); } }
private void btnEdit_Click(object sender, EventArgs e) { if (functionList.SelectedItems.Count > 0) { DataRow row = (DataRow)functionList.SelectedItems[0].Tag; if (row == null) { return; } if (row["METHODTYPE"].ToString() == "SYSTEM") { MessageBox.Show("系统函数不能编辑!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } FormFunction form = new FormFunction(); form.MID = row["MID"].ToString(); form.MNAME = row["MNAME"].ToString(); form.COMMENTARY = row["COMMENTARY"].ToString(); form.DETAIL = row["DETAIL"].ToString(); form.IsEdit = true; if (form.ShowDialog() == DialogResult.OK) { row["MID"] = form.MID; row["MNAME"] = form.MID; row["COMMENTARY"] = form.COMMENTARY; row["DETAIL"] = form.DETAIL; try { _dao.UpdateMethod(_dt.GetChanges()); _dt.AcceptChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } GetData(); } } }