Пример #1
0
        private void button10_Click(object sender, EventArgs e)
        {
            OFDScript.Title    = "数据库概要设计文档模板";
            OFDScript.FileName = "";
            //为了获取特定的系统文件夹,可以使用System.Environment类的静态方法GetFolderPath()。该方法接受一个Environment.SpecialFolder枚举,其中可以定义要返回路径的哪个系统目录
            OFDScript.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            OFDScript.Filter           = "EXCEL文件(*.xls)|*.xls";
            OFDScript.ValidateNames    = true; //文件有效性验证ValidateNames,验证用户输入是否是一个有效的Windows文件名
            OFDScript.CheckFileExists  = true; //验证路径有效性
            OFDScript.CheckPathExists  = true; //验证文件有效性
            try
            {
                //生成功能外部设计文档
                if (OFDScript.ShowDialog() == DialogResult.OK)
                {
                    //MyEXCEL.数据库概要设计文档(dtTableExtendedPropert, OFDScript.FileName, 概要设计字段DT());//FiledDt);

                    MyEXCEL.f_barcode(OFDScript.FileName);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Пример #2
0
        private DataTable 概要设计字段DT()
        {
            System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
            string connstr = configurationAppSettings.GetValue("universal_analyse_connstr", typeof(string)).ToString();

            OleDbConnection myConn = new OleDbConnection(connstr);

            OleDbCommand     cmd  = new OleDbCommand(MyEXCEL.获取所有FK(), myConn);
            OleDbDataAdapter oda  = new OleDbDataAdapter(cmd);
            DataTable        FKDt = new DataTable();

            oda.Fill(FKDt);

            cmd = new OleDbCommand(MyEXCEL.获取所有索引(), myConn);
            oda = new OleDbDataAdapter(cmd);
            DataTable indexDt = new DataTable();

            oda.Fill(indexDt);

            DataTable TepDt = FiledDt.Copy();

            TepDt.Columns.Add("fk_name");     //fk名称
            TepDt.Columns.Add("fk_r_name");   //关联表名
            TepDt.Columns.Add("fk_r_c_name"); //关联字段

            string tabname = string.Empty;
            string colname = string.Empty;

            DataRow[] tepIndexDr = null;
            DataRow[] tepFkDr    = null;

            for (int i = 0; i < TepDt.Rows.Count; i++)
            {
                colname = TepDt.Rows[i][3].ToString().Trim();
                if (TepDt.Rows[i][0].ToString().Trim() != "")
                {
                    tabname    = TepDt.Rows[i][0].ToString();
                    tepIndexDr = indexDt.Select("i_t_name='" + tabname + "'");
                    tepFkDr    = FKDt.Select("fk_t_name='" + tabname + "'");
                }
                if (tepIndexDr != null)
                {
                    if (tepIndexDr.Length > 0)
                    {
                        for (int indexi = 0; indexi < tepIndexDr.Length; indexi++)
                        {
                            if (tepIndexDr[indexi]["i_c_name"].ToString().Trim() == colname)
                            {
                                TepDt.Rows[i]["IndexName"] = tepIndexDr[indexi][0].ToString();
                            }
                        }
                    }
                }

                if (tepFkDr != null)
                {
                    if (tepFkDr.Length > 0)
                    {
                        for (int indexf = 0; indexf < tepFkDr.Length; indexf++)
                        {
                            if (tepFkDr[indexf]["fk_t_c_name"].ToString().Trim() == colname)
                            {
                                TepDt.Rows[i]["fk_name"]     = tepFkDr[indexf][0].ToString();
                                TepDt.Rows[i]["fk_r_name"]   = tepFkDr[indexf][2].ToString();
                                TepDt.Rows[i]["fk_r_c_name"] = tepFkDr[indexf][4].ToString();
                            }
                        }
                    }
                }
            }

            return(TepDt);
        }