⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbtoword.cs

📁 通过数据库结构自动 生成三层结构代码,相当不错的一款软件
💻 CS
📖 第 1 页 / 共 3 页
字号:
            this.labelNum.Size = new Size(0x2e, 0x16);
            this.labelNum.TabIndex = 9;
            this.labelNum.TextAlign = ContentAlignment.MiddleCenter;
            this.btn_Addlist.Enabled = false;
            this.btn_Addlist.FlatStyle = FlatStyle.Popup;
            this.btn_Addlist.Location = new Point(0xd0, 0x1d);
            this.btn_Addlist.Name = "btn_Addlist";
            this.btn_Addlist.Size = new Size(40, 0x17);
            this.btn_Addlist.TabIndex = 7;
            this.btn_Addlist.Text = ">>";
            this.btn_Addlist.Click += new EventHandler(this.btn_Addlist_Click);
            this.btn_Add.Enabled = false;
            this.btn_Add.FlatStyle = FlatStyle.Popup;
            this.btn_Add.Location = new Point(0xd0, 60);
            this.btn_Add.Name = "btn_Add";
            this.btn_Add.Size = new Size(40, 0x17);
            this.btn_Add.TabIndex = 8;
            this.btn_Add.Text = ">";
            this.btn_Add.Click += new EventHandler(this.btn_Add_Click);
            this.btn_Del.Enabled = false;
            this.btn_Del.FlatStyle = FlatStyle.Popup;
            this.btn_Del.Location = new Point(0xd0, 0x5b);
            this.btn_Del.Name = "btn_Del";
            this.btn_Del.Size = new Size(40, 0x17);
            this.btn_Del.TabIndex = 5;
            this.btn_Del.Text = "<";
            this.btn_Del.Click += new EventHandler(this.btn_Del_Click);
            this.btn_Dellist.Enabled = false;
            this.btn_Dellist.FlatStyle = FlatStyle.Popup;
            this.btn_Dellist.Location = new Point(0xd0, 0x7a);
            this.btn_Dellist.Name = "btn_Dellist";
            this.btn_Dellist.Size = new Size(40, 0x17);
            this.btn_Dellist.TabIndex = 6;
            this.btn_Dellist.Text = "<<";
            this.btn_Dellist.Click += new EventHandler(this.btn_Dellist_Click);
            this.listTable2.ItemHeight = 12;
            this.listTable2.Location = new Point(0x120, 0x18);
            this.listTable2.Name = "listTable2";
            this.listTable2.SelectionMode = SelectionMode.MultiExtended;
            this.listTable2.Size = new Size(0x98, 0x94);
            this.listTable2.TabIndex = 1;
            this.listTable2.DoubleClick += new EventHandler(this.listTable2_DoubleClick);
            this.listTable1.ItemHeight = 12;
            this.listTable1.Location = new Point(0x10, 0x18);
            this.listTable1.Name = "listTable1";
            this.listTable1.SelectionMode = SelectionMode.MultiExtended;
            this.listTable1.Size = new Size(0x98, 0x94);
            this.listTable1.TabIndex = 0;
            this.listTable1.DoubleClick += new EventHandler(this.listTable1_DoubleClick);
            this.listTable1.Click += new EventHandler(this.listTable1_Click);
            this.btn_Creat._Image = null;
            this.btn_Creat.BackColor = Color.FromArgb(0, 0xec, 0xe9, 0xd8);
            this.btn_Creat.DefaultScheme = false;
            this.btn_Creat.DialogResult = DialogResult.None;
            this.btn_Creat.Image = null;
            this.btn_Creat.Location = new Point(240, 0x13f);
            this.btn_Creat.Name = "btn_Creat";
            this.btn_Creat.Scheme = ButtonXP.Schemes.Blue;
            this.btn_Creat.Size = new Size(0x4b, 0x1a);
            this.btn_Creat.TabIndex = 0x2a;
            this.btn_Creat.Text = "生  成";
            this.btn_Creat.Click += new EventHandler(this.btn_Creat_Click);
            this.btn_Cancle._Image = null;
            this.btn_Cancle.BackColor = Color.FromArgb(0, 0xec, 0xe9, 0xd8);
            this.btn_Cancle.DefaultScheme = false;
            this.btn_Cancle.DialogResult = DialogResult.None;
            this.btn_Cancle.Image = null;
            this.btn_Cancle.Location = new Point(0x158, 0x13f);
            this.btn_Cancle.Name = "btn_Cancle";
            this.btn_Cancle.Scheme = ButtonXP.Schemes.Blue;
            this.btn_Cancle.Size = new Size(0x4b, 0x1a);
            this.btn_Cancle.TabIndex = 0x2a;
            this.btn_Cancle.Text = "取  消";
            this.btn_Cancle.Click += new EventHandler(this.btn_Cancle_Click);
            this.label2.AutoSize = true;
            this.label2.Location = new Point(12, 300);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0, 12);
            this.label2.TabIndex = 0x2b;
            this.label4.AutoSize = true;
            this.label4.Location = new Point(8, 0x16b);
            this.label4.Name = "label4";
            this.label4.Size = new Size(0x149, 12);
            this.label4.TabIndex = 0x2c;
            this.label4.Text = "注:如果生成失败,请检查本机是否安装了Office 2003/2007";
            this.AutoScaleBaseSize = new Size(6, 14);
            base.ClientSize = new Size(480, 0x17b);
            base.Controls.Add(this.label4);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.btn_Creat);
            base.Controls.Add(this.groupBox2);
            base.Controls.Add(this.groupBox1);
            base.Controls.Add(this.btn_Cancle);
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "DbToWord";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "生成数据库文档";
            base.Load += new EventHandler(this.DbToWord_Load);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            ((ISupportInitialize) this.pictureBox1).EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void IsHasItem()
        {
            if (this.listTable1.Items.Count > 0)
            {
                this.btn_Add.Enabled = true;
                this.btn_Addlist.Enabled = true;
            }
            else
            {
                this.btn_Add.Enabled = false;
                this.btn_Addlist.Enabled = false;
            }
            if (this.listTable2.Items.Count > 0)
            {
                this.btn_Del.Enabled = true;
                this.btn_Dellist.Enabled = true;
                this.btn_Creat.Enabled = true;
            }
            else
            {
                this.btn_Del.Enabled = false;
                this.btn_Dellist.Enabled = false;
                this.btn_Creat.Enabled = false;
            }
        }

        private void listTable1_Click(object sender, EventArgs e)
        {
            if (this.listTable1.SelectedItem != null)
            {
                this.IsHasItem();
            }
        }

        private void listTable1_DoubleClick(object sender, EventArgs e)
        {
            if (this.listTable1.SelectedItem != null)
            {
                this.listTable2.Items.Add(this.listTable1.SelectedItem);
                this.listTable1.Items.Remove(this.listTable1.SelectedItem);
                this.IsHasItem();
            }
        }

        private void listTable2_DoubleClick(object sender, EventArgs e)
        {
            if (this.listTable2.SelectedItem != null)
            {
                this.listTable1.Items.Add(this.listTable2.SelectedItem);
                this.listTable2.Items.Remove(this.listTable2.SelectedItem);
                this.IsHasItem();
            }
        }

        public void SetBtnDisable()
        {
            if (this.btn_Creat.InvokeRequired)
            {
                SetBtnDisableCallback method = new SetBtnDisableCallback(this.SetBtnDisable);
                base.Invoke(method, null);
            }
            else
            {
                this.btn_Creat.Enabled = false;
            }
        }

        public void SetBtnEnable()
        {
            if (this.btn_Creat.InvokeRequired)
            {
                SetBtnEnableCallback method = new SetBtnEnableCallback(this.SetBtnEnable);
                base.Invoke(method, null);
            }
            else
            {
                this.btn_Creat.Enabled = true;
            }
        }

        public void SetlblStatuText(string text)
        {
            if (this.labelNum.InvokeRequired)
            {
                SetlblStatuCallback method = new SetlblStatuCallback(this.SetlblStatuText);
                base.Invoke(method, new object[] { text });
            }
            else
            {
                this.labelNum.Text = text;
            }
        }

        public void SetprogressBar1Max(int val)
        {
            if (this.progressBar1.InvokeRequired)
            {
                SetProBar1MaxCallback method = new SetProBar1MaxCallback(this.SetprogressBar1Max);
                base.Invoke(method, new object[] { val });
            }
            else
            {
                this.progressBar1.Maximum = val;
            }
        }

        public void SetprogressBar1Val(int val)
        {
            if (this.progressBar1.InvokeRequired)
            {
                SetProBar1ValCallback method = new SetProBar1ValCallback(this.SetprogressBar1Val);
                base.Invoke(method, new object[] { val });
            }
            else
            {
                this.progressBar1.Value = val;
            }
        }

        private unsafe void ThreadWork()
        {
            try
            {
                this.SetBtnDisable();
                string str = "数据库名:" + this.dbname;
                int count = this.listTable2.Items.Count;
                this.SetprogressBar1Max(count);
                this.SetprogressBar1Val(1);
                this.SetlblStatuText("0");
                object template = Missing.Value;
                object obj3 = @"\endofdoc";
                _Application application = new ApplicationClass();
                application.Visible = false;
                _Document document = application.Documents.Add(ref template, ref template, ref template, ref template);
                application.ActiveWindow.View.Type = WdViewType.wdOutlineView;
                application.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
                application.ActiveWindow.ActivePane.Selection.InsertAfter("动软自动生成器 www.maticsoft.com");
                application.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
                application.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;
                Paragraph paragraph = document.Content.Paragraphs.Add(ref template);
                paragraph.Range.Text = str;
                paragraph.Range.Font.Bold = 1;
                paragraph.Range.Font.Name = "宋体";
                paragraph.Range.Font.Size = 12f;
                paragraph.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
                paragraph.Format.SpaceAfter = 5f;
                paragraph.Range.InsertParagraphAfter();
                for (int i = 0; i < count; i++)
                {
                    string tableName = this.listTable2.Items[i].ToString();
                    string str3 = "表名:" + tableName;
                    List<ColumnInfo> columnInfoList = this.dbobj.GetColumnInfoList(this.dbname, tableName);
                    int num3 = columnInfoList.Count;
                    if ((columnInfoList != null) && (columnInfoList.Count > 0))
                    {
                        object obj4 = document.Bookmarks[&obj3].Range;
                        Paragraph paragraph2 = document.Content.Paragraphs.Add(ref obj4);
                        paragraph2.Range.Text = str3;
                        paragraph2.Range.Font.Bold = 1;
                        paragraph2.Range.Font.Name = "宋体";
                        paragraph2.Range.Font.Size = 10f;
                        paragraph2.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
                        paragraph2.Format.SpaceBefore = 15f;
                        paragraph2.Format.SpaceAfter = 1f;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -