Пример #1
0
        private void lsv_LinkList_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = lsv_LinkList.SelectedItems.Count;

            if (index > 0 && MessageBox.Show("是否打开文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                ListViewItem item     = lsv_LinkList.SelectedItems[0];
                string       filePath = item.SubItems[1].Text;
                if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
                {
                    WinFormOpenHelper.OpenWinForm(Handle.ToInt32(), "open", filePath, null, null, ShowWindowCommands.SW_NORMAL);
                }
            }
        }
Пример #2
0
        private void listBox1_MouseDoubleClick(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            EntityList item = (EntityList)listBox1.SelectedItem;

            if (MessageBox.Show("是否打开文件?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
            {
                if (System.IO.File.Exists(item.Path))
                {
                    Hide();
                    WinFormOpenHelper.OpenWinForm(0, "open", item.Path, null, null, ShowWindowCommands.SW_NORMAL);
                }
                else
                {
                    MessageBox.Show("文件不存在。");
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 移交
        /// </summary>
        private void Btn_Export_Click(object sender, EventArgs e)
        {
            int amount = lsv_DataList.CheckedItems.Count;

            if (amount > 0)
            {
                string targetPath = txt_ExportPath.Text;
                if (!string.IsNullOrEmpty(targetPath))
                {
                    pic_Wait.Visible   = true;
                    btn_Export.Enabled = false;

                    for (int i = 0; i < amount; i++)
                    {
                        string code        = lsv_DataList.CheckedItems[i].Text;
                        string _targetPath = targetPath + "\\" + code;
                        if (!Directory.Exists(_targetPath))
                        {
                            Directory.CreateDirectory(_targetPath);
                        }
                        string   rootFolder  = pro_GuiDang.Tag + "\\" + UserHelper.GetUser().SpecialName;
                        string[] directories = Directory.GetDirectories(rootFolder, code, SearchOption.AllDirectories);
                        if (directories.Length > 0)
                        {
                            DirectoryInfo directory = new DirectoryInfo(directories[0]);
                            FileInfo[]    files     = directory.GetFiles();
                            foreach (FileInfo file in files)
                            {
                                string targetFilePath = _targetPath + "\\" + file.Name;
                                if (!File.Exists(targetFilePath))
                                {
                                    File.Create(targetFilePath).Close();
                                }
                                File.Copy(file.FullName, targetFilePath, true);
                            }
                        }

                        object id        = lsv_DataList.CheckedItems[i].Tag;
                        object historyId = SQLiteHelper.ExecuteOnlyOneQuery($"SELECT hr_id FROM handover_record WHERE hr_obj_id='{id}'");
                        if (historyId == null)
                        {
                            SQLiteHelper.ExecuteNonQuery($"INSERT INTO handover_record (hr_id, hr_obj_id, hr_lastupdate) " +
                                                         $"VALUES('{Guid.NewGuid().ToString()}', '{id}', '{DateTime.Now.ToString("s")}'); ");
                        }
                        else
                        {
                            SQLiteHelper.ExecuteNonQuery($"UPDATE handover_record SET hr_lastupdate='{DateTime.Now.ToString("s")}', hr_isupdate=0 WHERE hr_id = '{historyId}'");
                        }
                    }

                    string destPath = targetPath + $"\\ISTIC_{DateTime.Now.ToString("yyyyMMddHHmm")}.db";
                    if (!Directory.Exists(Path.GetDirectoryName(destPath)))
                    {
                        Directory.CreateDirectory(Path.GetDirectoryName(destPath));
                    }
                    if (!File.Exists(destPath))
                    {
                        File.Create(destPath).Close();
                    }
                    string sourFile = Application.StartupPath + @"\ISTIC.db";
                    File.Copy(sourFile, destPath, true);

                    pic_Wait.Visible   = false;
                    btn_Export.Enabled = true;
                    if (MessageBox.Show("移交完毕,是否现在打开文件夹?", "温馨提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                    {
                        WinFormOpenHelper.OpenWinForm(0, "open", null, null, targetPath, ShowWindowCommands.SW_NORMAL);
                    }
                    LoadDataList();
                }
                else
                {
                    MessageBox.Show("请指定移交路径。", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                MessageBox.Show("请至少选择一条待移交的数据。", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Пример #4
0
        private void btn_Sure_Click(object sender, System.EventArgs e)
        {
            string path = txt_Path.Text;

            if (!string.IsNullOrEmpty(path))
            {
                bool result = false;
                Text             = "正在合成Word文档,请稍等。。。";
                pic_Wait.Visible = true;
                btn_Sure.Enabled = false;
                new Thread(delegate()
                {
                    //档案清单
                    if (chk_DocumentList.Checked)
                    {
                        string filePath = path + "\\重大专项项目(课题)档案清单.doc";
                        if (!File.Exists(filePath))
                        {
                            File.Create(filePath).Close();
                        }
                        DataTable table = SQLiteHelper.ExecuteQuery($"SELECT fi.fi_id, fi.fi_name name, fi_code categor, dd2.dd_name carrier, fi.fi_pages pages, fi.fi_remark remark FROM files_info fi " +
                                                                    "LEFT JOIN data_dictionary dd ON dd.dd_id = fi.fi_categor  " +
                                                                    "LEFT JOIN data_dictionary dd2 ON dd2.dd_id = fi.fi_carrier " +
                                                                    $"WHERE fi.fi_obj_id='{objId}';");
                        result = MicrosoftWordExportHelper.WriteDocumentList(filePath, table, SpeName, SpeCode, objId);
                    }
                    //汇总表
                    if (chk_TotalTable.Checked)
                    {
                        string filePath = path + "\\重大专项项目(课题)档案汇总表.doc";
                        if (!File.Exists(filePath))
                        {
                            File.Create(filePath).Close();
                        }
                        DataTable table = new DataTable();
                        table.Columns.AddRange(new DataColumn[]
                        {
                            new DataColumn("id"),
                            new DataColumn("code"),
                            new DataColumn("name"),
                            new DataColumn("user"),
                            new DataColumn("count")
                        });
                        if (controlType == ControlType.Plan_Project)
                        {
                            string querySql = $"SELECT pi_id id, pi_code code, pi_name name, pi_project_user user, COUNT(fi_id) count FROM project_info " +
                                              $"LEFT JOIN files_info ON fi_obj_id = pi_id WHERE pi_id='{objId}' GROUP BY id;";
                            DataRow proRow = SQLiteHelper.ExecuteSingleRowQuery(querySql);
                            table.ImportRow(proRow);

                            querySql = $"SELECT ti_id id, ti_code code, ti_name name, ti_project_user user, COUNT(fi_id) count FROM topic_info " +
                                       $"LEFT JOIN files_info ON fi_obj_id = ti_id WHERE ti_obj_id='{proRow["id"]}' GROUP BY id";
                            DataTable topTable = SQLiteHelper.ExecuteQuery(querySql);
                            foreach (DataRow row in topTable.Rows)
                            {
                                table.ImportRow(row);
                                string _querySql = $"SELECT si_id id, si_code code, si_name name, si_project_user user, COUNT(fi_id) count FROM subject_info " +
                                                   $"LEFT JOIN files_info ON fi_obj_id = si_id WHERE si_obj_id='{row["id"]}' GROUP BY id";
                                DataTable subTable = SQLiteHelper.ExecuteQuery(_querySql);
                                foreach (DataRow _row in subTable.Rows)
                                {
                                    table.ImportRow(_row);
                                }
                            }

                            string __querySql = $"SELECT si_id id, si_code code, si_name name, si_project_user user, COUNT(fi_id) count FROM subject_info " +
                                                $"LEFT JOIN files_info ON fi_obj_id = si_id WHERE si_obj_id='{proRow["id"]}' GROUP BY id";
                            DataTable _subTable = SQLiteHelper.ExecuteQuery(__querySql);
                            foreach (DataRow _row in _subTable.Rows)
                            {
                                table.ImportRow(_row);
                            }
                        }
                        else if (controlType == ControlType.Topic)
                        {
                            string querySql = $"SELECT ti_id id, ti_code code, ti_name name, ti_project_user user, COUNT(fi_id) count FROM topic_info " +
                                              $"LEFT JOIN files_info ON fi_obj_id = ti_id WHERE ti_id='{objId}' GROUP BY id";
                            DataRow topRow = SQLiteHelper.ExecuteSingleRowQuery(querySql);
                            table.ImportRow(topRow);

                            string _querySql = $"SELECT si_id id, si_code code, si_name name, si_project_user user, COUNT(fi_id) count FROM subject_info " +
                                               $"LEFT JOIN files_info ON fi_obj_id = si_id WHERE si_obj_id='{topRow["id"]}' GROUP BY id";
                            DataTable subTable = SQLiteHelper.ExecuteQuery(_querySql);
                            foreach (DataRow _row in subTable.Rows)
                            {
                                table.ImportRow(_row);
                            }
                        }

                        result = MicrosoftWordExportHelper.WriteTotalTable(filePath, table, SpeName);
                    }
                    //缺失文件清单
                    if (chk_LostFileList.Checked)
                    {
                        string filePath = path + "\\重大专项项目(课题)缺失文件清单.doc";
                        if (!File.Exists(filePath))
                        {
                            File.Create(filePath).Close();
                        }
                        string querySql = "SELECT dd_name name, dd_name||' '||extend_3 dd_name, dd_note, extend_2 FROM data_dictionary WHERE dd_pId in(" +
                                          "SELECT dd_id FROM data_dictionary WHERE dd_pId = (SELECT dd_id FROM data_dictionary  WHERE dd_code = 'dic_file_jd')) " +
                                          $"AND name NOT IN(SELECT dd.dd_name FROM files_info fi LEFT JOIN data_dictionary dd ON fi.fi_categor = dd.dd_id where fi.fi_obj_id='{objId}') AND name<>'其他' " +
                                          $"ORDER BY dd_name";
                        DataTable table = SQLiteHelper.ExecuteQuery(querySql);
                        result          = MicrosoftWordExportHelper.WriteLostDocumentList(filePath, table, SpeName, SpeCode, objId);
                    }
                    pic_Wait.Visible = false;
                    btn_Sure.Enabled = true;

                    if (result)
                    {
                        if (MessageBox.Show("合成完毕,是否现在打开所在文件夹?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            WinFormOpenHelper.OpenWinForm(0, "open", path, null, null, ShowWindowCommands.SW_NORMAL);
                        }
                        Close();
                    }
                }).Start();
            }
        }