示例#1
0
        /// <summary>
        /// 获取类的创建语句
        /// </summary>
        /// <param name="type"></param>
        private void GetClassSQL()
        {
            _lstSql = new List <string>();
            List <KeyWordTableParamItem> lstTable = new List <KeyWordTableParamItem>();
            DBConfigInfo dbcinfo = FrmDBSetting.GetDBConfigInfo(DesignerInfo, "DataAccess.");
            DBInfo       dbInfo  = dbcinfo.CreateDBInfo();

            foreach (ClrClass curType in SelectedClass)
            {
                EntityConfig entity = new EntityConfig(curType, DesignerInfo);

                if (string.IsNullOrEmpty(entity.TableName) || !entity.IsTable)
                {
                    continue;
                }
                string typeName = null;
                Stack <EntityConfig>          stkConfig   = EntityConfig.GetEntity(entity, DesignerInfo);
                List <EntityParam>            lstParam    = new List <EntityParam>();
                List <TableRelationAttribute> lstRelation = new List <TableRelationAttribute>();
                string lastTableName = null;
                string lastSummary   = null;
                while (stkConfig.Count > 0)
                {
                    EntityConfig centity = stkConfig.Pop();
                    FillParams(centity, lstParam, lstRelation);
                    lastTableName = centity.TableName;
                    lastSummary   = centity.Summary;
                }
                KeyWordTableParamItem table = new KeyWordTableParamItem(lstParam, lstRelation, lastTableName, null);
                table.Description = lastSummary;
                lstTable.Add(table);
            }
            try
            {
                using (BatchAction ba = dbInfo.DefaultOperate.StarBatchAction())
                {
                    _lstSql = TableChecker.CheckTable(dbInfo, lstTable);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("生成语句失败:" + ex.Message);
            }
            ShowSql();
        }
示例#2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            DBConfigInfo dbcinfo = FrmDBSetting.GetDBConfigInfo(DesignerInfo, "");
            DBInfo       dbInfo  = dbcinfo.CreateDBInfo();

            rtbOutput.Text = "";
            if (_lstSql == null || _lstSql.Count == 0)
            {
                return;
            }
            List <string> resault = DBChecker.ExecuteSQL(dbInfo.DefaultOperate, _lstSql);
            StringBuilder sbRet   = new StringBuilder();

            foreach (string res in resault)
            {
                sbRet.AppendLine(res);
            }
            rtbOutput.Text = sbRet.ToString();
        }