Пример #1
0
 private void StartForm_Load(object sender, EventArgs e)
 {
     TextBox.CheckForIllegalCrossThreadCalls = false;
     EntityListBind();
     this.txtDataName.Text = ORMBuilder.GetConfigAppSetValueByKey("connectionString");
     //DbFilePath = ORMBuilder.GetConfigAppSetValueByKey("dbFilePath");
     DbFilePath = AppDomain.CurrentDomain.BaseDirectory;
 }
Пример #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtDataName.Text))
     {
         MessageBox.Show("数据库名称不能为空");
         return;
     }
     if (DbFilePath.Equals("."))
     {
         DbFilePath = AppDomain.CurrentDomain.BaseDirectory;
     }
     BuildTable(txtDataName.Text, DbFilePath);
     ORMBuilder.SetValue("connectionString", txtDataName.Text);
 }
Пример #3
0
        private void BuildTable(string dataName, string DbfilePath)
        {
            //List<EntityInfo> list = DLLAnalysis.GetEntityInfoList();
            StringBuilder sb = null;

            foreach (Control ctrl in pnlChk.Controls)
            {
                if (!((CheckBox)ctrl).Checked)
                {
                    continue;
                }
                EntityInfo einfo = DLLAnalysis.GetEntityInfoByType(DLLAnalysis.GetEntityInstance(((CheckBox)ctrl).Name).GetType());
                sb = new StringBuilder();
                sb.Append("Begin Transaction;");
                sb.Append(ORMBuilder.DropTableIfExists(einfo));
                sb.Append("\r\n");
                sb.Append(ORMBuilder.GenerateTableByEntityInfo(einfo));
                sb.Append("\r\n");
                sb.Append("Commit Transaction;");
                ORMBuilder.AddSQLiteTable(dataName, DbfilePath, sb.ToString());
                sb.Append(string.Format("---------------------->>构造实体{0}数据表成功!", einfo.EntityName));
                sb.Append("\r\n");
                sb.Append("\r\n");
                textBox1.Text += sb.ToString();
            }
            string initData = ORMBuilder.LoadInitialData(pnlChk);

            if (string.IsNullOrEmpty(initData))
            {
                return;
            }
            textBox1.Text += "/**********************************************************************************************************************************************************************************/\r\n";
            DBSQLiteHelper.ExecuteUpdate(initData);
            textBox1.Text += "\r\n";
            textBox1.Text += initData;
            textBox1.Text += "\r\n";
            textBox1.Text += "************************>>实体数据初始化插入完成!";
        }