Example #1
0
        private void btn_genarel_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(BaseFloder))
            {
                MessageBox.Show("请先选择文件夹!");
                return;
            }
            if (string.IsNullOrEmpty(tx_namespc.Text.Trim()))
            {
                MessageBox.Show("请先输入命名空间!");
                return;
            }
            DataTable dt = new DataTable();

            foreach (string s in tbnames)
            {
                toollb_tbname.Text = s;
                la_curr.Text       = "当前执行的表:" + s;
                dt = GetDataSet("EXEC sp_help {0}", s).Tables[1];
                dgv_fields.DataSource = dt;
                GenaralInfo g = new GenaralInfo()
                {
                    floder    = BaseFloder,
                    tablename = s,
                    content   = GenaralCodeText(dt, s)
                };
                ThreadPool.QueueUserWorkItem(new WaitCallback(WriteIntoFile), g);
                //WriteIntoFile(BaseFloder, s, GenaralCodeText(dt, s));
            }
            MessageBox.Show("生成成功!");
            System.Diagnostics.Process.Start("explorer.exe", BaseFloder);
        }
Example #2
0
        public void WriteIntoFile(object ginfo)
        {
            GenaralInfo  g        = (GenaralInfo)ginfo;
            string       path     = g.floder;
            string       tbname   = g.tablename;
            string       content  = g.content;
            string       filename = path + "\\" + tbname + ".cs";
            FileStream   fs       = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            StreamWriter sw       = new StreamWriter(fs);

            sw.Write(content);
            sw.Close();
            //return filename;
        }