Exemple #1
0
 private void CreateSchemaFile(SchemaTemplate schema)
 {
     outPutFile("Common\\Schema", schema.ClassName + ".cs", schema.TransformText());
 }
Exemple #2
0
        private void btCreate_Click(object sender, EventArgs e)
        {
            if (!CheckString())
            {
                return;
            }

            //if (string.IsNullOrEmpty(tbNameSpace.Text))
            //{
            //    MessageBox.Show("名称空间必须输入!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}
            if (clbTables.CheckedItems.Count <= 0)
            {
                MessageBox.Show(Resources.SelectTable, Resources.Alert, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            for (var i = 0; i < clbTables.CheckedItems.Count; i++)
            {
                var tableName         = string.Empty;
                var dtColunms         = Access.GetTableColunms(clbTables.CheckedItems[i].ToString(), _txtConn);
                var originalTableName = clbTables.CheckedItems[i].ToString();
                if (originalTableName.IndexOf('_') > 0)
                {
                    string[] arrayTableName = originalTableName.Split('_');
                    tableName = arrayTableName.Aggregate(tableName, (current, tName) => current + Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(tName.ToLower()));
                    //tableName = OriginalTableName.Substring(0, 1).ToUpper() + OriginalTableName.Substring(1, OriginalTableName.IndexOf("_")).ToLower()
                    //           + OriginalTableName.Substring(OriginalTableName.IndexOf("_") + 1, 1) + OriginalTableName.Substring(OriginalTableName.IndexOf("_") + 2).ToLower();
                }
                else
                {
                    tableName = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(originalTableName.ToLower());
                }
                var schema = new SchemaTemplate
                {
                    NameSpace         = tbNameSpace.Text,
                    DtColunms         = dtColunms,
                    TableName         = tableName,
                    OriginalTableName = originalTableName
                };
                CreateSchemaFile(schema);

                var entity = new EntityTemplate
                {
                    NameSpace = tbNameSpace.Text,
                    DtColunms = dtColunms,
                    TableName = tableName
                };
                CreateEntityFile(entity);

                var dataaccess = new DataAccessTemplate
                {
                    NameSpace = tbNameSpace.Text,
                    DtColunms = dtColunms,
                    TableName = tableName
                };
                CreateDataAccessFile(dataaccess);

                var business = new BusinessTemplate
                {
                    NameSpace = tbNameSpace.Text,
                    DtColunms = dtColunms,
                    TableName = tableName
                };
                CreateBusinessFile(business);

                var model = new ModelTemplate
                {
                    NameSpace = tbNameSpace.Text,
                    DtColunms = dtColunms,
                    TableName = tableName
                };
                CreateModelFile(model);
            }

            MessageBox.Show(Resources.OutPutSuccess);
        }