private void OpenFile_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { string ids = ToolHelper.GetFullStringBySplit(GetValue(trcId), ';', ",", "'"); if (string.IsNullOrEmpty(ids)) { XtraMessageBox.Show("尚未导入文件。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Frm_DiskList diskList = new Frm_DiskList(ids); if (diskList.ShowDialog() == DialogResult.OK) { string querySQL = "SELECT bfi_id FROM backup_files_info A " + "LEFT JOIN transfer_registraion_cd B ON A.bfi_trcid = B.trc_id " + $"WHERE bfi_trcid IN({diskList.objectCode}) AND bfi_type = -1 " + "ORDER BY trc_code"; object[] rootId = SqlHelper.ExecuteSingleColumnQuery(querySQL); if (rootId.Length == 0) { XtraMessageBox.Show("生成文件树失败,请确认当前编号已导入对应电子文件。", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Frm_FileSelect frm = new Frm_FileSelect(rootId); if (frm.ShowDialog() == DialogResult.OK) { string[] fullPath = frm.SelectedFileName; for (int i = 0; i < fullPath.Length; i++) { if (File.Exists(fullPath[i])) { if (NotExist(fullPath[i])) { AddFileToList(fullPath[i], frm.SelectedFileId[i]); } else { XtraMessageBox.Show($"{Path.GetFileName(fullPath[i])}文件已存在,不可重复添加。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } else { XtraMessageBox.Show($"无法访问指定文件[{Path.GetFileName(fullPath[i])}]", "打开失败", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } } } }
/// <summary> /// 根据指定批次ID获取其补录的其他批次根节点ID /// </summary> /// <param name="batchId">待查找批次ID</param> /// <param name="type">查找类型<para>0:计划</para><para>1:专项</para></param> public static object[] GetOtherBatchRootIds(object batchId, int type) { object otherBatchIds = ExecuteOnlyOneQuery($"SELECT br_auxiliary_id FROM batch_relevance WHERE br_main_id='{batchId}'"); string otherBatchIdString = ToolHelper.GetFullStringBySplit(ToolHelper.GetValue(otherBatchIds), ',', ",", "'"); if (otherBatchIdString.Length > 0) { if (type == 0) { string querySql = $"SELECT pi_id FROM project_info WHERE pi_categor = 1 AND pi_obj_id IN ({otherBatchIdString})"; return(ExecuteSingleColumnQuery(querySql)); } else { string querySql = "SELECT idi.imp_id FROM imp_info ii " + "INNER JOIN imp_dev_info idi ON idi.imp_obj_id = ii.imp_id " + $"WHERE ii.imp_obj_id IN ({otherBatchIdString})"; return(ExecuteSingleColumnQuery(querySql)); } } return(null); }
/// <summary> /// 添加信息到指定表格 /// </summary> private void SaveFileInfo(bool isAdd) { bool isOtherType = cbo_categor.SelectedIndex == -1; object primaryKey = Guid.NewGuid().ToString(); object stage = cbo_stage.SelectedValue; object categor = cbo_categor.SelectedValue ?? cbo_categor.Tag; object categorName = isOtherType ? cbo_categor.Text.Split('-')[1].Trim() : null; object code = txt_fileCode.Text; object name = txt_fileName.Text.Replace("'", "''"); object user = txt_User.Text; object type = GetRadioValue(pal_type); object pages = num_Pages.Value; object count = num_Count.Value; object amount = num_Amount.Value; object date = txt_date.Text; object unit = txt_Unit.Text; object carrier = GetCarrierValue(); object link = GetFullStringBySplit(GetLinkList(2), ";", string.Empty); string _fileId = GetFullStringBySplit(GetLinkList(1), ",", "'"); object remark = txt_Remark.Text; object[] flink = GetFileLink(); if (isAdd) { if (isOtherType) { categor = Guid.NewGuid().ToString(); object pid = cbo_stage.SelectedValue; string value = txt_fileCode.Text.Split('-')[0]; int sort = cbo_categor.Items.Count - 1; object dicId = SqlHelper.ExecuteOnlyOneQuery($"SELECT dd_id FROM data_dictionary WHERE dd_name='{value}' AND dd_pId='{pid}'"); string sqlString = string.Empty; if (dicId != null) { categor = dicId; sqlString += $"DELETE FROM data_dictionary WHERE dd_name='{value}' AND dd_pId='{stage}';"; } sqlString += "INSERT INTO data_dictionary (dd_id, dd_name, dd_note, dd_pId, dd_sort, extend_3, extend_4) " + $"VALUES('{categor}', '{value}', '{name}', '{pid}', '{sort}', '{categorName}', '{1}');"; SqlHelper.ExecuteNonQuery(sqlString); } StringBuilder insertSql = new StringBuilder(); insertSql.Append("INSERT INTO processing_file_list (pfl_id, pfl_stage, pfl_categor, pfl_code, pfl_name, pfl_user, pfl_type, pfl_pages, pfl_count, pfl_amount, pfl_date, pfl_unit, pfl_carrier, pfl_link, pfl_file_id, pfl_obj_id, pfl_status, pfl_sort, pfl_remark, pfl_worker_id, pfl_worker_date) " + $"VALUES( '{primaryKey}', '{stage}', '{categor}', '{code}', '{name}', '{user}', '{type}', '{pages}', '{count}', '{amount}', '{date}', '{unit}', '{carrier}', '{link}', '{GetFullStringBySplit(GetLinkList(1), ",", string.Empty)}', '{parentId}', -1, '{view.RowCount}', '{remark}', '{UserHelper.GetUser().UserKey}', '{DateTime.Now}');"); //将备份表中的文件标记为已选取 if (!string.IsNullOrEmpty(_fileId)) { insertSql.Append($"UPDATE backup_files_info SET bfi_state=1 WHERE bfi_id IN ({_fileId});"); } foreach (object item in flink) { insertSql.Append($"INSERT INTO file_link(id, code, fid) VALUES('{Guid.NewGuid().ToString()}', '{item}', '{primaryKey}');"); } SqlHelper.ExecuteNonQuery(insertSql.ToString()); LogsHelper.AddWorkLog(WorkLogType.File, 1, BATCH_ID, 1, primaryKey); } else { string oldFileId = GetValue(SqlHelper.ExecuteOnlyOneQuery($"SELECT pfl_file_id FROM processing_file_list WHERE pfl_id='{fileId}';")); StringBuilder updateSql = new StringBuilder(); if (!string.IsNullOrEmpty(oldFileId)) { updateSql.Append($"UPDATE backup_files_info SET bfi_state=0 WHERE bfi_id IN ({ToolHelper.GetFullStringBySplit(oldFileId, ',', ",", "'")});"); } updateSql.Append("UPDATE processing_file_list SET " + $"[pfl_stage] = '{stage}'" + $",[pfl_categor] = '{categor}'" + $",[pfl_code] = '{code}'" + $",[pfl_name] = '{name}'" + $",[pfl_user] = '{user}'" + $",[pfl_type] = '{type}'" + $",[pfl_pages] = '{pages}'" + $",[pfl_count] = '{count}'" + $",[pfl_amount] = '{amount}'" + $",[pfl_date] = '{date}'" + $",[pfl_unit] = '{unit}'" + $",[pfl_carrier] = '{carrier}'" + $",[pfl_link] = '{link}'" + $",[pfl_remark] = '{remark}'" + $",[pfl_file_id] = '{GetFullStringBySplit(GetLinkList(1), ",", string.Empty)}'" + $" WHERE pfl_id= '{fileId}';"); if (!string.IsNullOrEmpty(_fileId)) { updateSql.Append($"UPDATE backup_files_info SET bfi_state=1 WHERE bfi_id IN ({_fileId});"); } updateSql.Append($"DELETE FROM file_link WHERE fid='{fileId}';"); foreach (object item in flink) { updateSql.Append($"INSERT INTO file_link(id, code, fid) VALUES('{Guid.NewGuid().ToString()}', '{item}', '{fileId}');"); } SqlHelper.ExecuteNonQuery(updateSql.ToString()); } XtraMessageBox.Show("操作成功。", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); UpdateDataSource?.Invoke(view, parentId, -1); }