コード例 #1
0
        private void btnGenDALBusiness_Click(object sender, EventArgs e)
        {
            if (false == Msg.AskQuestion("确认要生成吗?"))
            {
                return;
            }

            Params4BusinessDAL param = new Params4BusinessDAL();

            param.ConcretelyName = txtConcretelyName_DAL.Text;
            param.DAL_Name       = txtDAL_DAL.Text;
            param.ORM_Name       = txtORM_DAL.Text;
            param.DAL_Namespace  = txtNamespace_DAL.Text;
            param.UsingNamespace = txtUsingNamespace_DAL.Lines;

            //生成源码
            string code = new GenerateDAL().GenerateBusinessDAL(param);

            if (chkPreviewDAL.Checked)
            {
                this.ShowCode(code);
            }

            //输出cs文件
            if (chkExportToFileDAL.Checked)
            {
                string fileName = txtOutpup_DAL_Business.Text + txtDAL_DAL.Text + ".cs";
                File.WriteAllText(fileName, code, Encoding.UTF8);
                MessageBox.Show("输出文件:" + fileName);
            }
        }
コード例 #2
0
        private void btnGenDALDataDict_Click(object sender, EventArgs e)
        {
            if (false == Msg.AskQuestion("确认要生成吗?"))
            {
                return;
            }

            //创建参数对象
            Params4DataDictDAL param = new Params4DataDictDAL();

            param.ConcretelyName = txtConcretelyName_DAL.Text;
            param.DAL_Name       = txtDAL_DAL.Text;
            param.ORM_Name       = txtORM_DAL.Text;
            param.DAL_Namespace  = txtNamespace_DAL.Text;
            param.UsingNamespace = txtUsingNamespace_DAL.Lines;

            //生成源码
            string code = new GenerateDAL().GenerateDataDictDAL(param);

            //显示代码
            if (chkPreviewDAL.Checked)
            {
                this.ShowCode(code);
            }

            //输出.cs文件
            if (chkExportToFileDAL.Checked)
            {
                string fileName = txtOutpup_DAL_DataDict.Text + txtDAL_DAL.Text + ".cs";
                if (!Directory.Exists(txtOutpup_DAL_DataDict.Text))
                {
                    Directory.CreateDirectory(txtOutpup_DAL_DataDict.Text);
                }
                File.WriteAllText(fileName, code, Encoding.UTF8);
                MessageBox.Show("输出文件:" + fileName);
            }
        }