public void CreateNew(string modeName = "") { DataWorkingState = WorkingStateEnum.Creating; if (RegulationTables.Contains(this.TableName)) { RegulationFrom rf = new RegulationFrom() { Text = this.TableName, TableName = this.TableName, EditEnable = true, CurrentFieldTable = DBHelper.GetDBHelper().GetTableFields(this.TableName) }; if (rf.ShowDialog() == DialogResult.OK) { DataSource = DBHelper.GetDBHelper().GetDataFromTable(0, 0, this.TableName, ""); } this.DataWorkingState = WorkingStateEnum.Search; } else { NewDataForm ndf = new NewDataForm() { TableModeName = modeName, TableName = this.TableName }; if (ndf.CreateFromFieldTable(DBHelper.GetDBHelper().GetTableFields(this.TableName), WorkingStateEnum.Creating, false)) { if (ndf.ShowDialog() == DialogResult.OK) { this.DataSource = DBHelper.GetDBHelper().GetDataFromTable(0, 0, this.TableName, ""); } ; } this.DataWorkingState = WorkingStateEnum.Search; } }
public void CreateFromField(IFieldTable table, DataGridViewRow row, WorkingStateEnum workingState, bool uploadFile) { var file = Directory.GetFiles("RDLC").Where(f => this.TemplateName.Equals(Path.GetFileNameWithoutExtension(f))).FirstOrDefault(); if (workingState == WorkingStateEnum.View && file != null) { ViewDataForm ndf = new ViewDataForm(file); if (ndf.CreateFromFieldTable(table, WorkingStateEnum.View, false)) { ndf.TableName = table.TableName; if (ndf.ShowDialog() == DialogResult.OK) { DataSource = DBHelper.GetDBHelper().GetDataFromTable(0, 0, TemplateName, ""); } } } else if (row != null && RegulationTables.Contains(this.TableName)) { string fileName = ""; foreach (DataGridViewColumn col in row.DataGridView.Columns) { if (col.HeaderText.Contains("名称")) { fileName = row.Cells[col.Name].Value.ToString(); } } if (fileName == "") { fileName = this.TableName + row.Cells["ID"].Value.ToString(); } Byte[] bytes = DBHelper.GetDBHelper().GetDocFromTableRecordBytes(this.TableName, row.Cells["ID"].Value.ToString(), fileName); MemoryStream stream = new MemoryStream(bytes); RegulationFrom rf = new RegulationFrom() { Text = this.TableName, TableName = this.TableName, EditEnable = false, RegulationFileStream = stream, CurrentFieldTable = table }; rf.ShowDialog(); } else { NewDataForm ndf = new NewDataForm() { TableName = this.TableName, TableModeName = this.TableModeName }; if (ndf.CreateFromFieldTable(table, workingState, uploadFile)) { ndf.TableName = table.TableName; if (ndf.ShowDialog() == DialogResult.OK) { DataSource = DBHelper.GetDBHelper().GetDataFromTable(0, 0, TableName, ""); } } } }