Exemplo n.º 1
0
        private void bt_CreateDetail_Click(object sender, EventArgs e)
        {
            DataDetailFrom ddf = new DataDetailFrom(this.TableModeName)
            {
                Text = bt_CreateDetail.Text, Name = this.TableName, DataID = RecordID
            };

            ddf.ShowDialog();
        }
Exemplo n.º 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);
        }