Exemplo n.º 1
0
        private CodeMemberMethod BuildPocoUpdate(TableViewTableTypeBase table)
        {
            CodeMemberMethod cmUpdate = new CodeMemberMethod();

            cmUpdate.Attributes = MemberAttributes.Public;
            cmUpdate.Name       = "Update";
            CodeParameterDeclarationExpression cpPocoPar = new CodeParameterDeclarationExpression();

            cpPocoPar.Name = "query";
            cpPocoPar.Type = new CodeTypeReference(table.Name);
            cmUpdate.Parameters.Add(cpPocoPar);

            String cp_name = "cp_" + table.Name;

            cmUpdate.Statements.Add(new CodeSnippetExpression("this.Access.CreateProcedureCommand(\"ProcedureName\")".Replace("ProcedureName", cp_name)));
            cmUpdate.Statements.Add(new CodeSnippetExpression("this.Access.AddParameter(\"Operation\", 4, ParameterDirection.Input)"));

            CodeStatementCollection AttributeValidationStatements = GraphAttributeSet.BuildAttributeSetStatement(table);

            foreach (CodeStatement AttributeValidationStatment in AttributeValidationStatements)
            {
                cmUpdate.Statements.Add(AttributeValidationStatment);
            }

            cmUpdate.Statements.Add(new CodeSnippetExpression("int value = this.Access.ExecuteNonQuery()"));
            cmUpdate.Statements.Add(new CodeSnippetExpression("return value"));
            cmUpdate.ReturnType = new CodeTypeReference("System.Int32");
            cmUpdate.Comments.Add(new CodeCommentStatement("Updates a Record"));
            return(cmUpdate);
        }
Exemplo n.º 2
0
        private CodeMemberMethod BuildPocoInsert(TableViewTableTypeBase table)
        {
            CodeMemberMethod cmInsert = new CodeMemberMethod();

            cmInsert.Name = "Insert";
            String cp_name = "cp_" + table.Name;

            cmInsert.Attributes = MemberAttributes.Public;
            cmInsert.ReturnType = new CodeTypeReference("System.Int32");
            cmInsert.Parameters.Add(this.PocoQueryParameter(table.Name));

            cmInsert.Statements.Add(new CodeSnippetExpression("this.Access.CreateProcedureCommand(\"ProcedureName\")".Replace("ProcedureName", cp_name)));
            cmInsert.Statements.Add(new CodeSnippetExpression("this.Access.AddParameter(\"Operation\", 5, ParameterDirection.Input)"));

            CodeStatementCollection AttributeValidationStatmenets = GraphAttributeSet.BuildAttributeSetStatement(table);

            foreach (CodeStatement AttributeValidationStatmenet in AttributeValidationStatmenets)
            {
                cmInsert.Statements.Add(AttributeValidationStatmenet);
            }

            cmInsert.Statements.Add(new CodeSnippetExpression("return this.Access.ExecuteNonQuery()"));
            cmInsert.Comments.Add(new CodeCommentStatement("Inserts a record"));
            return(cmInsert);
        }
Exemplo n.º 3
0
        public CodeMemberMethod BuildIsDirtyMethod(TableViewTableTypeBase baseobj)
        {
            CodeMemberMethod cmd = new CodeMemberMethod();

            cmd.Name       = "IsDirty";
            cmd.Attributes = MemberAttributes.Public;
            cmd.ReturnType = new CodeTypeReference("System.Boolean");

            CodeStatementCollection cssDirtyCode = GraphAttributeSet.BuildValidationSetStatement(baseobj);

            foreach (CodeStatement cs in GraphAttributeSet.BuildValidationSetStatement(baseobj))
            {
                cmd.Statements.Add(cs);
            }
            return(cmd);
        }