/// <summary> /// update time cycle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_update_Click(object sender, EventArgs e) { var row = dataGridView1.CurrentRow; if (row == null) { MessageBox.Show("请选择一行数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int id = (int)row.Cells["ID"].Value; TimeCycleModule preModule = null; foreach (var item in cycleModules) { if (item.ID == id) { preModule = item; break; } } if (preModule == null) { return; } using (TimeCycleChange dialog = new TimeCycleChange(preModule)) { dialog.ChangeTitle = "修改评价指标"; if (dialog.ShowDialog() == DialogResult.OK) { TimeCycleModule module = dialog.GetModule; SqliteHelper.Update(TableName.TimeCycle, preModule.ID, module, out string msg); if (string.IsNullOrEmpty(msg)) { DataRefresh(); } else { MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
/// <summary> /// add time cycle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_add_Click(object sender, EventArgs e) { using (TimeCycleChange dialog = new TimeCycleChange()) { dialog.ChangeTitle = "新增评价阶段"; if (dialog.ShowDialog() == DialogResult.OK) { TimeCycleModule module = dialog.GetModule; module.UserName = currentUser.UserName; SqliteHelper.Insert(TableName.TimeCycle, module, out string msg); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <TimeCycleModule> timeModule = (List <TimeCycleModule>)SqliteHelper.Select(TableName.TimeCycle, TimeCycleState.Local, module.Name, currentUser.UserName); if (timeModule.Count > 0) { InitEvalutationData(timeModule[0].ID); } DataRefresh(); } } }