Ejemplo n.º 1
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 TemplateWinFromEditWithDialog();
                string[]        strArrayTree = director.Construct(buliderTree, basicParameter, m_baseParameter);
                string          strFrmTreeDialogClassName         = "Frm" + basicParameter.ClassName + "TreeDialog.cs";
                string          strFrmTreeDialogClassNameDesigner = "Frm" + basicParameter.ClassName + "TreeDialog.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
            }
        }
Ejemplo n.º 2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string strReturnMsg = CheckInput(m_codeGenType);

            if (strReturnMsg != string.Empty)
            {
                MessageBox.Show(strReturnMsg);
                return;
            }

            BasicParameter basicParameter = ParameterManager.GetBasicParameter(string.Empty);

            StringBuilder sbSql = new StringBuilder();

            sbSql.Append("\"");
            sbSql.Append(txtSql.Text.Replace("\r\n", " "));
            sbSql.Append(" WHERE  \" + strWhere + \"  ");
            sbSql.Append(txtSql1.Text.Replace("\r\n", " "));
            sbSql.Append("    ");
            sbSql.Append(txtSql2.Text.Replace("\r\n", " "));
            sbSql.Append("\"");

            NestQueryParameter nestQueryParameter = new NestQueryParameter
            {
                CodeGenType    = CodeGenType.WinFromNestQuery,
                Key1           = txtKey.Text.Trim(),
                Key2           = txtKey1.Text.Trim(),
                Key3           = txtKey2.Text.Trim(),
                Sql            = sbSql.ToString(),
                DataTableQuery = m_dtQuery,
                FormClassName  = txtClassName.Text.Trim()
            };
            CodeMakeDirector director = new CodeMakeDirector();
            CodeMakeBulider  bulider  = new TemplateWinFormNestQuery();

            string[] strArray = director.Construct(bulider, basicParameter, nestQueryParameter);
            string   strFrmDialogClassName = txtClassName.Text.Trim() + ".cs";
            string   strContentCS          = strArray[0];

            FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmDialogClassName, strContentCS, false);
            string strFrmDialogClassNameDesigner = txtClassName.Text.Trim() + ".Designer.cs";
            string strContentDesigner            = strArray[1];

            FileHelper.GenFile(basicParameter.OutFolderPath + "\\Code\\", strFrmDialogClassNameDesigner, strContentDesigner);
        }