/// <summary> /// 新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_add_Click(object sender, EventArgs e) { if (combo_one.Items.Count == 0) { MessageBox.Show("请先添加一级指标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (combo_two.Items.Count == 0) { MessageBox.Show("请先添加二级指标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (combo_three.Items.Count == 0) { MessageBox.Show("请先添加三级指标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } using (ChangeIndicatorFour dialog = new ChangeIndicatorFour()) { dialog.ChangeTitle = $"新增 四级指标 : {combo_one.SelectedItem} > {combo_two.SelectedItem} > {combo_three.SelectedItem}"; if (dialog.ShowDialog() == DialogResult.OK) { BasicFourModule fourModule = dialog.GetModule; fourModule.ParentId = dataHelper.GetCurrentId(modules, combo_three.SelectedItem.ToString()); SqliteHelper.Insert(TableName.BasicFour, fourModule, out string msg); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DataRefresh(); } } }
/// <summary> /// initialize evalutation data /// </summary> /// <param name="id">time cycle id</param> private void InitEvalutationData(int id) { List <BasicFourModule> fours = (List <BasicFourModule>)SqliteHelper.Select(TableName.BasicFour); if (fours.Count == 0) { return; } List <EvalutationDataModule> datas = new List <EvalutationDataModule>(); foreach (var four in fours) { EvalutationDataModule dataModule = new EvalutationDataModule(); dataModule.TimeCycle = id; dataModule.IndicatorFour = four.ID; dataModule.DataSource = null; dataModule.Description = string.Empty; dataModule.Grade = 0; datas.Add(dataModule); } if (datas.Count > 0) { SqliteHelper.Insert(TableName.EvalutationData, datas, out string msg); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
/// <summary> /// 新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_add_Click(object sender, EventArgs e) { if (combo_one.Items.Count == 0) { MessageBox.Show("请先添加一级指标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string message = dataHelper.CheckComboItem(modules, 2); if (!string.IsNullOrEmpty(message)) { MessageBox.Show("请先添加二级指标", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } using (ChangeIndicatorThree dialog = new ChangeIndicatorThree(modules)) { dialog.ChangeTitle = "新增 三级指标"; if (dialog.ShowDialog() == DialogResult.OK) { BasicDataModule module = dialog.GetModule; SqliteHelper.Insert(TableName.BasicData, module, out string msg); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DataRefresh(); } } }
private void btn_ok_Click(object sender, EventArgs e) { lbl_name_msg.Text = string.Empty; lbl_pw_msg.Text = string.Empty; lbl_pw_msg2.Text = string.Empty; string name = txt_name.Text.Trim(); if (string.IsNullOrEmpty(name)) { lbl_name_msg.Text = "请输入用户名"; return; } string password = txt_password.Text.Trim(); if (string.IsNullOrEmpty(password)) { lbl_pw_msg.Text = "请输入密码"; return; } string password2 = txt_password2.Text.Trim(); if (string.IsNullOrEmpty(password2)) { lbl_pw_msg2.Text = "请确认密码"; return; } else if (!string.Equals(password, password2)) { lbl_pw_msg2.Text = "密码不一致"; return; } SqliteHelper.Insert(TableName.User, new UserModule { UserName = name, PassWord = password }, out string msg); if (string.IsNullOrEmpty(msg)) { this.DialogResult = DialogResult.OK; } else { lbl_name_msg.Text = msg; return; } }
/// <summary> /// 新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_add_Click(object sender, EventArgs e) { using (ChangeIndicatorOne dialog = new ChangeIndicatorOne()) { dialog.ChangeTitle = "新增 一级指标"; if (dialog.ShowDialog() == DialogResult.OK) { BasicDataModule module = dialog.GetModule; SqliteHelper.Insert(TableName.BasicData, module, out string msg); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DataRefresh(); } } }
/// <summary> /// 新增 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_add_Click(object sender, EventArgs e) { using (CompanyChange dialog = new CompanyChange()) { dialog.ChangeTitle = "新增单位"; if (dialog.ShowDialog() == DialogResult.OK) { UserModule module = dialog.GetModule; module.PassWord = "******"; SqliteHelper.Insert(TableName.User, module, out string msg); if (!string.IsNullOrEmpty(msg)) { MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DataRefresh(); } } }
/// <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(); } } }
public static void ImportData(string path, out string msg) { msg = string.Empty; try { FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); IWorkbook workbook = null; if (Path.GetExtension(path).Equals(".xls")) { workbook = new HSSFWorkbook(fs); } else if (Path.GetExtension(path).Equals(".xlsx")) { workbook = new XSSFWorkbook(fs); } else { msg = "错误的文件类型"; return; } ISheet sheet = workbook.GetSheetAt(0); if (sheet == null) { msg = "无可用工作簿"; return; } int rowCount = sheet.LastRowNum; if (rowCount <= 6) { msg = "无有效评价数据"; return; } IRow row = null; TimeCycleModule timeCycle = new TimeCycleModule(); int timeCycleId = -1; List <EvalutationDataModule> evalutationData = new List <EvalutationDataModule>(); for (int i = 0; i <= rowCount; i++) { if (i == 0)//用户名 { timeCycle.UserName = sheet.GetRow(i).GetCell(1).StringCellValue; if (string.IsNullOrEmpty(timeCycle.UserName)) { msg = "用户名为空"; return; } } else if (i == 3)//评价阶段 { row = sheet.GetRow(i); timeCycle.Name = row.GetCell(0).StringCellValue; timeCycle.StartTime = row.GetCell(1).DateCellValue; timeCycle.EndTime = row.GetCell(2).DateCellValue; timeCycle.CreateTime = row.GetCell(3).DateCellValue; timeCycle.LatestCommitTime = row.GetCell(4).DateCellValue; timeCycle.State = (int)TimeCycleState.Commit; SqliteHelper.Insert(TableName.TimeCycle, timeCycle, out msg); if (string.IsNullOrEmpty(msg)) { timeCycleId = ((List <TimeCycleModule>)SqliteHelper.Select(TableName.TimeCycle, TimeCycleState.Commit, timeCycle.Name, timeCycle.UserName))[0].ID; } else { return; } } else if (i > 6) { row = sheet.GetRow(i); EvalutationDataModule evalutation = new EvalutationDataModule(); evalutation.TimeCycle = timeCycleId; string currentFour = row.GetCell(3).StringCellValue; currentFour = currentFour.Substring(0, currentFour.LastIndexOf("(")); List <BasicFourModule> fourModules = (List <BasicFourModule>)SqliteHelper.Select(TableName.BasicFour, currentFour); if (fourModules.Count == 1) { evalutation.IndicatorFour = fourModules[0].ID; } else { msg = $"四级指标 {currentFour} 不存在"; return; } evalutation.Description = row.GetCell(7).StringCellValue; evalutation.Grade = (int)row.GetCell(8).NumericCellValue; evalutation.DataSource = row.GetCell(9).StringCellValue.Split("\r\n".ToArray(), StringSplitOptions.RemoveEmptyEntries); evalutationData.Add(evalutation); } } SqliteHelper.Insert(TableName.EvalutationData, evalutationData, out msg); } catch (Exception ex) { msg = "导入失败"; } }