/// <summary> /// 加载相关链接列表 /// </summary> private void LoadFileLinkList(object fileId) { DataGridViewStyleHelper.ResetDataGridView(dgv_link, false); object[] links = SqlHelper.ExecuteSingleColumnQuery($"SELECT code FROM file_link WHERE fid='{fileId}'"); if (links.Length > 0) { int rowCount = links.Length % dgv_link.ColumnCount == 0 ? links.Length / dgv_link.ColumnCount : links.Length / dgv_link.ColumnCount + 1; int index = 0; for (int i = 0; i < rowCount; i++) { int j = dgv_link.Rows.Add(); if (links.Length > index) { dgv_link.Rows[j].Cells[0].Value = links[index++]; } if (links.Length > index) { dgv_link.Rows[j].Cells[1].Value = links[index++]; } if (links.Length > index) { dgv_link.Rows[j].Cells[2].Value = links[index++]; } } } }
private void LoadDataGridView(string unitId) { DataGridViewStyleHelper.ResetDataGridView(dgv_DataShow, true); dgv_DataShow.Columns.AddRange(new DataGridViewColumn[] { new DataGridViewTextBoxColumn() { Name = "id" }, new DataGridViewTextBoxColumn() { Name = "unit", HeaderText = "来源单位", FillWeight = 15 }, new DataGridViewTextBoxColumn() { Name = "code", HeaderText = "批次编号", FillWeight = 20 }, new DataGridViewTextBoxColumn() { Name = "name", HeaderText = "批次名称", FillWeight = 20 }, new DataGridViewButtonColumn() { Name = "file", HeaderText = "必备文件", FillWeight = 7 }, new DataGridViewButtonColumn() { Name = "control", HeaderText = "操作", FillWeight = 7, Text = "结束", UseColumnTextForButtonValue = true }, }); dgv_DataShow.Columns["id"].Visible = false; string querySql = $"SELECT * FROM transfer_registration_pc LEFT JOIN data_dictionary ON dd_id = com_id " + $"WHERE trp_work_status=2 "; if (!string.IsNullOrEmpty(unitId)) { querySql += $" AND dd_id='{unitId}' "; } querySql += "ORDER BY trp_code"; DataTable table = SqlHelper.ExecuteQuery(querySql); for (int i = 0; i < table.Rows.Count; i++) { DataGridViewRow newRow = dgv_DataShow.Rows[dgv_DataShow.Rows.Add()]; newRow.Cells["id"].Value = table.Rows[i]["trp_id"]; newRow.Cells["unit"].Value = table.Rows[i]["dd_name"]; newRow.Cells["code"].Value = table.Rows[i]["trp_code"]; newRow.Cells["name"].Value = table.Rows[i]["trp_name"]; newRow.Cells["file"].Value = GetFileCompleteResult(table.Rows[i]["trp_id"]); } }
/// <summary> /// 加载光盘数据 /// </summary> /// <param name="trpId">批次主键</param> private void LoadCDDataScoure(object trpId, object trpName) { DataGridViewStyleHelper.ResetDataGridView(dgv_SWDJ, true); dgv_SWDJ.Columns.AddRange(new DataGridViewColumn[] { new DataGridViewTextBoxColumn() { Name = "trc_id", HeaderText = "主键", SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewTextBoxColumn() { Name = "trc_code", HeaderText = "光盘编号", FillWeight = 8, SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewTextBoxColumn() { Name = "trc_name", HeaderText = "光盘名称", FillWeight = 10, SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewTextBoxColumn() { Name = "trc_remark", HeaderText = "备注", FillWeight = 20, SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewButtonColumn() { Name = "trc_read", HeaderText = "操作", FillWeight = 5, Text = "读写", UseColumnTextForButtonValue = true, SortMode = DataGridViewColumnSortMode.NotSortable }, }); string querySql = $"SELECT trc_id, trc_name, trc_code, trc_remark FROM transfer_registraion_cd WHERE trp_id='{trpId}' ORDER BY trc_sort"; DataTable dataTable = SqlHelper.ExecuteQuery(querySql); for (int i = 0; i < dataTable.Rows.Count; i++) { DataRow row = dataTable.Rows[i]; int index = dgv_SWDJ.Rows.Add(); dgv_SWDJ.Rows[index].Cells["trc_id"].Value = row["trc_id"]; dgv_SWDJ.Rows[index].Cells["trc_code"].Value = row["trc_code"]; dgv_SWDJ.Rows[index].Cells["trc_name"].Value = row["trc_name"]; dgv_SWDJ.Rows[index].Cells["trc_remark"].Value = row["trc_remark"]; dgv_SWDJ.Rows[index].Tag = trpId; dgv_SWDJ.Rows[index].Cells["trc_read"].Tag = trpName; } btn_Back.Enabled = true; btn_Add.Enabled = false; dgv_SWDJ.Columns["trc_id"].Visible = false; btn_Delete.Tag = 2; this.BatchID = trpId; this.BatchName = trpName; }
/// <summary> /// 加载批次数据 /// </summary> /// <param name="querySql">待加载的数据SQL</param> private void LoadPCDataScoure(string _querySql) { DataGridViewStyleHelper.ResetDataGridView(dgv_SWDJ, true); DataTable dataTable = null; //加载实物登记数据【默认加载状态为1(未提交)的数据】 if (string.IsNullOrEmpty(_querySql)) { StringBuilder querySql = new StringBuilder("SELECT pc.trp_id, dd_name, trp_name, trp_code,trp_submit_status,trp_cd_amount " + "FROM transfer_registration_pc pc LEFT JOIN data_dictionary dd ON pc.com_id = dd.dd_id WHERE 1=1 "); if (!chk_AllP.Checked) { querySql.Append($"AND trp_submit_status={(int)SubmitStatus.NonSubmit} "); } querySql.Append("ORDER BY trp_submit_status, trp_code;"); dataTable = SqlHelper.ExecuteQuery(querySql.ToString()); } else { dataTable = SqlHelper.ExecuteQuery(_querySql); } dgv_SWDJ.Columns.AddRange(new DataGridViewColumn[] { new DataGridViewTextBoxColumn() { Name = "trp_id", HeaderText = "主键", FillWeight = 10, SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewTextBoxColumn() { Name = "dd_name", HeaderText = "来源单位", FillWeight = 20, SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewTextBoxColumn() { Name = "trp_name", HeaderText = "批次名称", FillWeight = 25, SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewTextBoxColumn() { Name = "trp_code", HeaderText = "批次编号", FillWeight = 20, SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewLinkColumn() { Name = "trp_cd_amount", HeaderText = "光盘数", FillWeight = 8, SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewButtonColumn() { Name = "addpc", HeaderText = "添加光盘", FillWeight = 10, Text = "添加", UseColumnTextForButtonValue = true, SortMode = DataGridViewColumnSortMode.NotSortable }, new DataGridViewButtonColumn() { Name = "submit", HeaderText = "提交", FillWeight = 10, SortMode = DataGridViewColumnSortMode.NotSortable }, }); for (int i = 0; i < dataTable.Rows.Count; i++) { DataRow row = dataTable.Rows[i]; int index = dgv_SWDJ.Rows.Add(); dgv_SWDJ.Rows[index].Cells["trp_id"].Value = row["trp_id"]; dgv_SWDJ.Rows[index].Cells["dd_name"].Value = row["dd_name"]; dgv_SWDJ.Rows[index].Cells["trp_name"].Value = row["trp_name"]; dgv_SWDJ.Rows[index].Cells["trp_code"].Value = row["trp_code"]; dgv_SWDJ.Rows[index].Cells["trp_cd_amount"].Value = row["trp_cd_amount"]; dgv_SWDJ.Rows[index].Cells["submit"].Value = Convert.ToInt32(row["trp_submit_status"]) == 1 ? "提交" : "已提交"; } //设置链接按钮样式 DataGridViewStyleHelper.SetAlignWithCenter(dgv_SWDJ, new string[] { "trp_cd_amount" }); dgv_SWDJ.Columns["trp_id"].Visible = false; btn_Back.Enabled = false; btn_Add.Enabled = true; btn_Delete.Tag = 1; }