Beispiel #1
0
        /// <summary>
        /// 简历文件导出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (dgvData.SelectedRows.Count > 0)
            {
                int    resumeid     = int.Parse(dgvData.SelectedRows[0].Cells[1].Value.ToString());
                string templatefile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "技術者履歴書_模板.xlsx");
                if (!File.Exists(templatefile))
                {
                    MessageBox.Show("テンプレートファイルが存在しません。");
                    return;
                }
                SaveFileDialog dlg = new SaveFileDialog();

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    NCExcel excel = new NCExcel();
                    excel.OpenExcelFile(templatefile);
                    excel.SelectSheet(1);
                    ExportBaseInfo(excel, resumeid);
                    ExportStudyInfo(excel, resumeid);
                    ExportWorkInfo(excel, resumeid);
                    excel.SaveAs(dlg.FileName);
                    excel.Close();
                }
            }
        }
Beispiel #2
0
        private void btnConvertToPdf_Click(object sender, EventArgs e)
        {
            string         dbt_wfile = "";
            OpenFileDialog dlg       = new OpenFileDialog();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                dbt_wfile = dlg.FileName;
                string pdf_file = Path.ChangeExtension(dbt_wfile, ".pdf");
                string ext      = Path.GetExtension(dbt_wfile).Replace(".", "");
                switch (ext.ToLower())
                {
                case "docx":
                case "doc":
                    if (!File.Exists(pdf_file))
                    {
                        NCWord.ConvertWordPDF(dbt_wfile, pdf_file);
                    }
                    break;

                case "xlsx":
                case "xls":
                    if (!File.Exists(pdf_file))
                    {
                        NCExcel excel = new NCExcel();
                        excel.OpenExcelFile(dbt_wfile);
                        excel.SaveAsPDF(pdf_file);
                        excel.Close();
                    }
                    break;

                case "pptx":
                case "ppt":

                    if (!File.Exists(pdf_file))
                    {
                        NCPPT ppt = new NCPPT();
                        if (ppt.PPTOpen(dbt_wfile))
                        {
                            ppt.PPTSaveAsPDF(pdf_file);
                            ppt.PPTClose();
                        }
                    }
                    break;
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 文件导入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLoad_Click(object sender, EventArgs e)
        {
            if (!File.Exists(txtExcelFile.Text))
            {
                MessageBox.Show("導入ファイルが存在しません。");
                return;
            }
            NCExcel excel = new NCExcel();

            excel.OpenExcelFile(txtExcelFile.Text);
            excel.SelectSheet(1);
            //MessageBox.Show("名前:"+excel.getValue(5, 6));
            int resumeid = importBaseInfo(excel);

            if (resumeid > 0)
            {
                importWorkInfo(excel, resumeid, 58);
                excel.SelectSheet(2);
                importWorkInfo(excel, resumeid, 9);
            }
            excel.Close();
        }
Beispiel #4
0
 /// <summary>
 /// 文件导入
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnLoad_Click(object sender, EventArgs e)
 {
     if (!File.Exists(txtExcelFile.Text))
     {
         return;
     }
     if (cmbClass.Text != null)
     {
         string classId = ((DataTable)(cmbClass.DataSource)).Rows[cmbClass.SelectedIndex]["ClassId"].ToString();
         deleteData(classId);
         string prefix = "";
         if (classId == "1")
         {
             prefix = AUDIOPATH_PREFIX_L;
         }
         else if (classId == "2")
         {
             prefix = AUDIOPATH_PREFIX_M;
         }
         else
         {
             prefix = AUDIOPATH_PREFIX_H;
         }
         NCExcel excel = new NCExcel();
         excel.OpenExcelFile(txtExcelFile.Text);
         progressBar1.Value = 0;
         for (int i = 1; i <= 24; i++)
         {
             progressBar1.Value++;
             Application.DoEvents();
             excel.SelectSheet(i);
             string lessonId = addLesson(classId, excel.getSheetName());
             int    startRow = 0;
             for (startRow = 1; ; startRow++)
             {
                 if (classId != "2")
                 {
                     if (excel.getValue(1, startRow).IndexOf("第") == 0)
                     {
                         readTitle(startRow, lessonId, excel, prefix);
                     }
                     if (excel.getValue(1, startRow).IndexOf("十六字訣") == 0 ||
                         excel.getValue(1, startRow).IndexOf("汉字口诀") == 0)
                     {
                         readTitle2(startRow, lessonId, excel, prefix);
                     }
                     if (excel.getValue(1, startRow).IndexOf("漢字子音") > 0 ||
                         excel.getValue(1, startRow).IndexOf("漢字母音") > 0)
                     {
                         readTitle3(startRow, lessonId, excel, prefix);
                         break;
                     }
                 }
                 else
                 {
                     if (excel.getValue(3, startRow).IndexOf("第") == 0)
                     {
                         readTitle(startRow, lessonId, excel, prefix);
                     }
                     if (excel.getValue(3, startRow).IndexOf("十六字訣") == 0 ||
                         excel.getValue(3, startRow).IndexOf("汉字口诀") == 0)
                     {
                         readTitle2(startRow, lessonId, excel, prefix);
                     }
                     if (excel.getValue(3, startRow).IndexOf("漢字子音") > 0 ||
                         excel.getValue(3, startRow).IndexOf("母音表") > 0)
                     {
                         readTitle3(startRow, lessonId, excel, prefix);
                         break;
                     }
                 }
             }
             startRow += 4;
             int rowNum = 0;
             int idx    = 1;
             while (readContent(classId, startRow, lessonId, excel, idx, ref rowNum, prefix))
             {
                 startRow += rowNum;
                 idx++;
                 rowNum = 0;
             }
             readTail(50, lessonId, excel, prefix);
         }
         cmbClass_SelectedIndexChanged(null, null);
         excel.Close();
         MessageBox.Show("数据导入完成");
     }
 }
Beispiel #5
0
        /// <summary>
        /// 导入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnImport_Click(object sender, EventArgs e)
        {
            NCExcel excel = new NCExcel();

            if (File.Exists(txtFile.Text))
            {
                excel.OpenExcelFile(txtFile.Text);
                int recordNum = 0;
                for (int i = 1; i < 10000; i++)
                {
                    string id = excel.getValue(1, i + 1);
                    if (string.IsNullOrEmpty(id))
                    {
                        recordNum = i;
                        break;
                    }
                }
                pgbImport.Minimum = 1;
                pgbImport.Maximum = recordNum;
                for (int i = 1; i < recordNum; i++)
                {
                    pgbImport.Value = i;
                    Application.DoEvents();

                    string id = excel.getValue(1, i + 1);
                    if (string.IsNullOrEmpty(id))
                    {
                        break;
                    }
                    string content = excel.getValue(2, i + 1);
                    string answerA = excel.getValue(3, i + 1);
                    string answerB = excel.getValue(4, i + 1);
                    string answerC = excel.getValue(5, i + 1);
                    string answerD = excel.getValue(6, i + 1);
                    string answer  = excel.getValue(7, i + 1);
                    string score   = excel.getValue(8, i + 1);
                    if (string.IsNullOrEmpty(score))
                    {
                        score = "5";
                    }
                    if (isQuestionExist(id))
                    {
                        string sql = "update tbl_Question_Single set "
                                     + "Content='" + content + "'"
                                     + ",SelectionA='" + answerA + "'"
                                     + ",SelectionB='" + answerB + "'"
                                     + ",SelectionC='" + answerC + "'"
                                     + ",SelectionD='" + answerD + "'"
                                     + ",Score=" + score + ""
                                     + ",Answer='" + answer + "'"
                                     + " where ID=" + id.ToString();

                        if (!db.ExeSQL(sql))
                        {
                            MessageBox.Show("数据更新失败!");
                            break;
                        }
                    }
                    else
                    {
                        string sql = "insert into tbl_Question_Single (Content, SelectionA,SelectionB,SelectionC,SelectionD,Score,Answer) values("
                                     + "'" + content + "'"
                                     + ",'" + answerA + "'"
                                     + ",'" + answerB + "'"
                                     + ",'" + answerC + "'"
                                     + ",'" + answerD + "'"
                                     + "," + score + ""
                                     + ",'" + answer + "')";

                        if (!db.ExeSQL(sql))
                        {
                            MessageBox.Show("数据追加失败!");
                            break;
                        }
                    }
                }
                excel.Close();
                MessageBox.Show("数据导入完成!");
            }
        }