Beispiel #1
0
        /// <summary>
        /// 三级指标改变事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void combo_three_SelectedIndexChanged(object sender, EventArgs e)
        {
            ClearData();
            int id = dataHelper.GetCurrentId(basicModules, ((ComboBox)sender).SelectedItem.ToString());

            if (id == -1)
            {
                return;
            }
            List <EvalutationDataModule> evalutationDatas = (List <EvalutationDataModule>)SqliteHelper.Select(TableName.EvalutationData, -1, id, currentTime);

            if (evalutationDatas == null || evalutationDatas.Count == 0)
            {
                return;
            }
            ChartRefresh(evalutationDatas);
        }
 /// <summary>
 /// 刷新数据
 /// </summary>
 public void DataRefresh()
 {
     cycleModules             = (List <TimeCycleModule>)SqliteHelper.Select(TableName.TimeCycle, TimeCycleState.Local, null, currentUser.UserName);
     dataGridView1.DataSource = cycleModules;
     dataGridView1.Refresh();
 }
Beispiel #3
0
        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 = "导入失败";
            }
        }