Esempio n. 1
0
        /// <summary>生成Model
        ///
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void cmdGenModel_Click(object sender, EventArgs e)
        {
            IModelMaker modelMaker = ModelMakerManager.GetModelMaker(m_dbSchema.SqlType);

            if (m_codeGenType == CodeGenType.WinFromParentChildEditWithDialog)
            {
                BasicParameter basicParameterDetail = ParameterManager.GetBasicParameter(cboTableDetail.Text.Trim());
                string         strContentDetail     = modelMaker.GenModelCode(basicParameterDetail.NameSpace, cboTableDetail.Text,
                                                                              basicParameterDetail.ClassName, m_dbSchema.DatabaseSchema.ConnectionString, basicParameterDetail.Author);
                string strFolderDetail = basicParameterDetail.OutFolderPath + "\\Model\\";
                FileHelper.GenFile(strFolderDetail, basicParameterDetail.ClassName + ".cs", strContentDetail, false);
            }
            BasicParameter basicParameter = ParameterManager.GetBasicParameter(cboTable.Text.Trim());
            string         strContent     = modelMaker.GenModelCode(basicParameter.NameSpace, basicParameter.TableName, basicParameter.ClassName, m_dbSchema.DatabaseSchema.ConnectionString, basicParameter.Author);
            string         strFolder      = basicParameter.OutFolderPath + "\\Model\\";

            FileHelper.GenFile(strFolder, basicParameter.ClassName + ".cs", strContent);
        }
Esempio n. 2
0
        /// <summary>生成CS
        ///
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void cmdGenCode_Click(object sender, EventArgs e)
        {
            CodeMakeDirector director       = new CodeMakeDirector();
            BasicParameter   basicParameter = ParameterManager.GetBasicParameter(cboTable.Text.Trim());

            basicParameter.Conn = m_dbSchema.DatabaseSchema.ConnectionString;
            m_baseParameter     = GetBaseParameter();
            switch (m_codeGenType)
            {
                #region WinFromSimpleQuery/WinFromEditWithDialog
            case CodeGenType.WinFromSimpleQuery:
            case CodeGenType.WinFromEditWithDialog:
                if (m_codeGenType == CodeGenType.WinFromEditWithDialog)
                {
                    CodeMakeBulider bulider  = new TemplateWinFromEditWithDialog();
                    string[]        strArray = director.Construct(bulider, basicParameter, m_baseParameter);
                    string          strFrmDialogClassName         = "Frm" + basicParameter.ClassName + "SimpleDialog.cs";
                    string          strFrmDialogClassNameDesigner = "Frm" + basicParameter.ClassName + "SimpleDialog.Designer.cs";
                    FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmDialogClassName, strArray[0], false);
                    FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmDialogClassNameDesigner, strArray[1], false);
                }
                CodeMakeBulider buliderSimple           = new TemplateWinFormSimpleQuery();
                string[]        strArraySimple          = director.Construct(buliderSimple, basicParameter, m_baseParameter);
                string          strFrmClassName         = "Frm" + basicParameter.ClassName + "SimpleQuery.cs";
                string          strFrmClassNameDesigner = "Frm" + basicParameter.ClassName + "SimpleQuery.Designer.cs";
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmClassName, strArraySimple[0], false);
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmClassNameDesigner, strArraySimple[1]);
                break;
                #endregion

                #region WinFromTreeEditWithDialog
            case CodeGenType.WinFromTreeEditWithDialog:

                CodeMakeBulider buliderTree  = new TemplateWinFromTreeEditWithDialog();
                string[]        strArrayTree = director.Construct(buliderTree, basicParameter, m_baseParameter);
                string          strFrmTreeDialogClassName         = "Frm" + basicParameter.ClassName + "TreeDialog.cs";
                string          strFrmTreeDialogClassNameDesigner = "Frm" + basicParameter.ClassName + "TreeDialog.Designer.cs";
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmTreeDialogClassName, strArrayTree[0], false);
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmTreeDialogClassNameDesigner, strArrayTree[1], false);

                CodeMakeBulider buliderTreeQuery            = new TemplateWinFormTreeQuery();
                string[]        strArrayTreeQuery           = director.Construct(buliderTreeQuery, basicParameter, m_baseParameter);
                string          strFrmTreeClassName         = "Frm" + basicParameter.ClassName + "TreeQuery.cs";
                string          strFrmTreeClassNameDesigner = "Frm" + basicParameter.ClassName + "TreeQuery.Designer.cs";
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmTreeClassName, strArrayTreeQuery[0], false);
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmTreeClassNameDesigner, strArrayTreeQuery[1]);

                break;
                #endregion

                #region WinFromParentChildEditWithDialog
            case CodeGenType.WinFromParentChildEditWithDialog:
                CodeMakeBulider buliderParentChild  = new   TemplateWinFromParentChildEditWithDialog();
                string[]        strArrayParentChild = director.Construct(buliderParentChild, basicParameter, m_baseParameter);
                string          strFrmParentChildDialogClassName         = "Frm" + basicParameter.ClassName + "MasterDetailDialog.cs";
                string          strFrmParentChildDialogClassNameDesigner = "Frm" + basicParameter.ClassName + "MasterDetailDialog.Designer.cs";
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmParentChildDialogClassName, strArrayParentChild[0], false);
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmParentChildDialogClassNameDesigner, strArrayParentChild[1], false);

                CodeMakeBulider buliderParentChildQuery            = new TemplateWinFormParentChildQuery();
                string[]        strArrayParentChildQuery           = director.Construct(buliderParentChildQuery, basicParameter, m_baseParameter);
                string          strFrmParentChildClassName         = "Frm" + basicParameter.ClassName + "MasterDetailQuery.cs";
                string          strFrmParentChildClassNameDesigner = "Frm" + basicParameter.ClassName + "MasterDetailQuery.Designer.cs";
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmParentChildClassName, strArrayParentChildQuery[0], false);
                FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmParentChildClassNameDesigner, strArrayParentChildQuery[1]);
                break;
                #endregion
            }
        }