Пример #1
0
        private bool CreateFromFieldTable(IFieldTable table, WorkingStateEnum workingState)
        {
            TableName = table.TableName;
            if (table == null)
            {
                return(false);
            }
            var proList = workingState.GetType().GetField(workingState.ToString()).GetCustomAttributes(typeof(Exportable), false).FirstOrDefault();

            this.Text = proList != null ? (proList as Exportable).Name.ToString() : "";

            var fields = table.GetTableFields();

            tableLayoutPanel1.SuspendLayout();
            flp_DataField.SuspendLayout();
            if (fields.Where(f => !f.IsExtend).Select(f => f.Name).Any(f => flp_DataField.Controls.Find(f, true).Length == 0))
            {
                flp_DataField.Controls.Clear();
            }

            foreach (TableField field in fields)
            {
                if (!field.IsExtend)
                {
                    AddTextField(flp_DataField, field);
                }
            }
            flp_DataField.ResumeLayout(false);
            flp_DataField.PerformLayout();
            tableLayoutPanel1.ResumeLayout(false);
            tableLayoutPanel1.PerformLayout();
            return(true);
        }
Пример #2
0
        /// <summary>
        /// 重新布局界面
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="table"></param>
        /// <param name="enable"></param>
        public bool CreateFromFieldTable(IFieldTable table, WorkingStateEnum workingState, bool uploadFile)
        {
            RecordID = table.GetFieldValue("ID");
            if (GoalTables.Contains(TableName) && workingState == WorkingStateEnum.View)
            {
                DataDetailFrom ddf = new DataDetailFrom(this.TableModeName)
                {
                    Text = bt_CreateDetail.Text, Name = this.TableName, DataID = RecordID
                };
                ddf.ShowDialog();
                this.DialogResult = DialogResult.OK;
                return(false);
            }
            TableName         = table.TableName;
            pictureBox1.Image = null;
            if (table == null)
            {
                return(false);
            }
            CurrentTable = table;
            lv_Doc.Items.Clear();
            if (uploadFile)
            {
                OpenFileDialogForm ofd = new OpenFileDialogForm();
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    foreach (var file in ofd.FileNames)
                    {
                        lv_Doc.Items.Add(new ListViewItem(Path.GetFileName(file))
                        {
                            Name = file
                        });
                    }
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                    return(false);
                }
            }
            var proList = workingState.GetType().GetField(workingState.ToString()).GetCustomAttributes(typeof(Exportable), false).FirstOrDefault();

            this.Text = proList != null?(proList as Exportable).Name.ToString():"";

            var fields = table.GetTableFields();

            tableLayoutPanel1.SuspendLayout();
            flp_DataField.SuspendLayout();
            if (fields.Where(f => !f.IsExtend).Select(f => f.Name).Any(f => flp_DataField.Controls.Find(f, true).Length == 0))
            {
                flp_DataField.Controls.Clear();
            }

            foreach (TableField field in fields)
            {
                if (field.IsExtend)
                {
                    if (field.Name == "ID" && field.Value != "")
                    {
                        var files = DBHelper.GetDBHelper().GetTableRecordDocList(table.TableName, field.Value);
                        if (files.Length > 0)
                        {
                            lv_Doc.Items.AddRange(files.Select(f => new ListViewItem(Path.GetFileName(f))
                            {
                                Name = f
                            }).ToArray());
                        }
                    }
                    continue;
                }
                AddTextField(flp_DataField, field);
            }
            flp_DataField.ResumeLayout(false);
            flp_DataField.PerformLayout();
            tableLayoutPanel1.ResumeLayout(false);
            tableLayoutPanel1.PerformLayout();
            return(true);
        }
Пример #3
0
        /// <summary>
        /// 重新布局界面
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="table"></param>
        /// <param name="enable"></param>
        public bool CreateFromFieldTable(IFieldTable table, WorkingStateEnum workingState, bool uploadFile)
        {
            TableName         = table.TableName;
            pictureBox1.Image = null;
            if (table == null)
            {
                return(false);
            }
            CurrentTable = table;
            lv_Doc.Items.Clear();
            if (uploadFile)
            {
                OpenFileDialogForm ofd = new OpenFileDialogForm();
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    foreach (var file in ofd.FileNames)
                    {
                        lv_Doc.Items.Add(new ListViewItem(Path.GetFileName(file))
                        {
                            Name = file
                        });
                    }
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                    return(false);
                }
            }
            var proList = workingState.GetType().GetField(workingState.ToString()).GetCustomAttributes(typeof(Exportable), false).FirstOrDefault();

            this.Text = proList != null?(proList as Exportable).Name.ToString():"";

            var fields = table.GetTableFields();

            tableLayoutPanel1.SuspendLayout();
            DataTable     dt     = new DataTable();
            List <string> values = new List <string>();

            dt.Columns.AddRange(fields.Where(f => !f.IsExtend || f.Name != "ID").Select(f => new DataColumn(f.Name)).ToArray());
            dt.Rows.Add(fields.Where(f => !f.IsExtend || f.Name != "ID").Select(f => f.Value).ToArray());
            string id = fields.Where(f => f.Name == "ID").Select(f => f.Value).FirstOrDefault();

            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", dt));

            this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet2", GetImages(id)));
            this.reportViewer1.RefreshReport();
            foreach (TableField field in fields)
            {
                if (field.IsExtend)
                {
                    if (field.Name == "ID" && field.Value != "")
                    {
                        RecordID = field.Value;
                        var files = DBHelper.GetDBHelper().GetTableRecordDocList(table.TableName, field.Value);
                        if (files.Length > 0)
                        {
                            lv_Doc.Items.AddRange(files.Select(f => new ListViewItem(Path.GetFileName(f))
                            {
                                Name = f
                            }).ToArray());
                        }
                        break;
                    }
                }
            }
            tableLayoutPanel1.ResumeLayout(false);
            tableLayoutPanel1.PerformLayout();
            return(true);
        }