public override void Generate(CSourceWriter sw)
        {
            CSharpProject.WriteVisibility(sw, this.Visibility);
            sw.Space();
            if (this.IsStatic)
            {
                sw.Write("static");
                sw.Space();
            }
            if (this.IsOverride)
            {
                sw.Write("override");
                sw.Space();
            }
            this.Type.Generate(sw);
            sw.Space();
            sw.Write(this.Name);
            sw.Write("(");
            bool Primero = true;

            foreach (CParam p in this.lParam)
            {
                sw.WriteComma(ref Primero);
                p.Generate(sw);
            }
            sw.Write(")");
            sw.WriteLn("{");
            sw.AddTab();
            foreach (CSentence sen in lSentence)
            {
                sen.Generate(sw);
            }
            sw.DelTab();
            sw.WriteLn("}");
        }
        public override void Generate(CSourceWriter sw)
        {
            CSharpProject.WriteVisibility(sw, this.Visibility);
            sw.Space();
            if (this.Class == null)
            {
                throw new NullReferenceException("El constructor ha de tener una clase.");
            }
            sw.Write(this.Class.Name);
            sw.Write("(");
            bool Primero = true;

            foreach (CParam p in this.lParam)
            {
                sw.WriteComma(ref Primero);
                p.Generate(sw);
            }
            sw.Write(")");
            sw.OpenBracesLn();
            sw.AddTab();
            foreach (CSentence sen in lSentence)
            {
                sen.Generate(sw);
            }
            sw.DelTab();
            sw.CloseBracesLn();
        }
 private void GenerateNamespace(CSourceWriter sw)
 {
     sw.Write("namespace");
     sw.Space();
     sw.Write(this.Namespace);
     sw.OpenBracesLn();
     sw.AddTab();
 }
Example #4
0
 private void GeneraSelectAll(CSourceWriter sw)
 {
     sw.Write("select");
     sw.Space();
     this.CamposPorComas(sw);
     sw.Space();
     sw.Write("from");
     sw.Space();
     sw.Write(this.Name);
 }
Example #5
0
        internal void GenerateSql(CSourceWriter sw)
        {
            sw.WriteLn("create table dbo." + this.Name + "(");
            bool primero = true;

            sw.AddTab();
            foreach (CFieldM f in this.lFieldAll)
            {
                f.GeneraSql(sw, ref primero);
            }
            if (this.lFieldPk.Count > 0)
            {
                sw.WriteLn(",CONSTRAINT PK_" + this.Name + " PRIMARY KEY (");
                primero = true;
                sw.AddTab();
                foreach (CFieldM f in this.lFieldPk)
                {
                    sw.Write("");
                    sw.WriteComma(ref primero);
                    sw.WriteLn(f.Name);
                }
                sw.DelTab();
                sw.WriteLn(")");
            }
            foreach (CUniqueConstraintM u in this.LUniqueConstraint)
            {
                u.GeneraSql(sw);
            }
            sw.DelTab();
            sw.WriteLn(")");

            sw.EndLine();
            sw.WriteLn("GO");
            //Genera las unique constraints
        }
Example #6
0
        private void GeneraSelectByPk(CSourceWriter sw)
        {
            sw.Write("select");
            sw.Space();
            this.CamposPorComas(sw);
            sw.Space();
            sw.Write("from");
            sw.Space();
            sw.Write(this.Name);
            bool Primero = true;
            var  sb      = new StringBuilder();

            foreach (CFieldM f in this.lFieldPk)
            {
                SUtilBD.AddCondicion(ref Primero, sb, f.Name + " = @" + SUtilBD.ParamName(f.Name));
            }
            sw.Space();
            sw.Write(sb.ToString());
        }
Example #7
0
        private void CamposPorComas(CSourceWriter sw)
        {
            bool Primero = true;

            foreach (CFieldM f in this.lFieldAll)
            {
                sw.WriteComma(ref Primero);
                sw.Write(f.Name);
            }
        }
Example #8
0
        private void ParametrosCamposNoClavePorComas(CSourceWriter sw)
        {
            bool Primero = true;

            foreach (CFieldM f in this.lFieldData)
            {
                sw.WriteComma(ref Primero);
                sw.Write(SUtilBD.Param(f.Name));
            }
        }
 public override void Generate(CSourceWriter sw)
 {
     CSharpProject.WriteVisibility(sw, this.CSharpVisibility);
     sw.Space();
     if (this.IsStatic)
     {
         sw.Write("static");
         sw.Space();
     }
     this.Type.Generate(sw);
     sw.Space();
     sw.Write(this.Name);
     if (!string.IsNullOrWhiteSpace(this.InitialValue))
     {
         sw.Write(" = ");
         sw.Write(this.InitialValue);
     }
     sw.SemicolonLn();
 }
        internal static void WriteVisibility(CSourceWriter sw, CSharpVisibility cSharpVisibility)
        {
            switch (cSharpVisibility)
            {
            case CSharpVisibility.cvPublic:
                sw.Write("public");
                break;

            case CSharpVisibility.cvPrivate:
                sw.Write("private");
                break;

            case CSharpVisibility.cvProtected:
                sw.Write("protected");
                break;

            case CSharpVisibility.cvInternal:
                sw.Write("internal");
                break;
            }
        }
 public override void Generate(CSourceWriter sw)
 {
     CSharpProject.WriteVisibility(sw, this.CSharpVisibility);
     sw.Space();
     if (this.IsStatic)
     {
         sw.Write("static");
         sw.Space();
     }
     if (this.IsPartial)
     {
         sw.Write("partial");
         sw.Space();
     }
     sw.Write("class");
     sw.Space();
     sw.Write(this.Name);
     if (!string.IsNullOrWhiteSpace(this.ParentClassName))
     {
         sw.Write(" : ");
         sw.Write(this.ParentClassName);
     }
     //*** Interfaces
     sw.OpenBracesLn();
     sw.AddTab();
     foreach (CClassElement item in this.lElement)
     {
         item.Generate(sw);
     }
     sw.DelTab();
     sw.CloseBracesLn();
 }
Example #12
0
        private void ParametrosCamposNoIdPorComas(CSourceWriter sw)
        {
            bool Primero = true;

            foreach (CFieldM f in this.lFieldAll)
            {
                if (!f.IsIdentity)
                {
                    sw.WriteComma(ref Primero);
                    sw.Write(SUtilBD.Param(f.Name));
                }
            }
        }
Example #13
0
 public void GeneraInsert(CSourceWriter sw)
 {
     sw.Write("insert into ");
     sw.Write(this.Name);
     sw.Write("(");
     this.CamposNoIdPorComas(sw);
     sw.Write(")");
     sw.Write("values");
     sw.Write("(");
     this.ParametrosCamposNoIdPorComas(sw);
     sw.Write(")");
 }
Example #14
0
        private void GeneraUpdate(CSourceWriter sw)
        {
            sw.Write("update ");
            sw.Write(this.Name);
            sw.Write(" set ");
            bool Primero = true;

            foreach (CFieldM f in this.lFieldData)
            {
                sw.WriteComma(ref Primero);
                sw.Write(f.Name);
                sw.Write(" = ");
                sw.Write(SUtilBD.Param(f.Name));
            }
            sw.Write(" where ");
            Primero = true;
            foreach (CFieldM f in this.lFieldPk)
            {
                sw.WriteComma(ref Primero);
                sw.Write(f.Name);
                sw.Write(" = ");
                sw.Write(SUtilBD.Param(f.Name));
            }
        }
Example #15
0
 public void GeneraSql(CSourceWriter sw, ref bool primero)
 {
     sw.WriteComma(ref primero);
     sw.Write(this.Name);
     sw.Write(" ");
     sw.Write(this.CadenaTDSqlServer);
     if ((this.Td == SqlDbType.VarChar) || (this.Td == SqlDbType.VarBinary))
     {
         sw.Write("(");
         sw.Write(this.Lenght.ToString());
         sw.Write(")");
     }
     if (this.IsIdentity)
     {
         sw.Write(" identity ");
     }
     if (!this.IsNullable)
     {
         sw.Write(" not null ");
     }
     sw.EndLine();
 }
Example #16
0
        public void GeneraInsertMethod(CSourceWriter sw)
        {
            sw.Write("public static int Insert");
            sw.Write(this.Name);
            sw.Write("(");
            bool primero = true;

            foreach (CFieldM f in this.lFieldAll)
            {
                if (!f.IsIdentity)
                {
                    sw.WriteComma(ref primero);
                    sw.Write(f.csDataTypeName());
                    sw.Write(" ");
                    sw.Write(f.Name);
                }
            }
            sw.WriteComma(ref primero);
            sw.Write("SqlConnection con");
            sw.Write(")");
            sw.WriteLn("{");
        }
Example #17
0
        private void GeneraDelete(CSourceWriter sw)
        {
            sw.Write("delete from ");
            sw.Write(this.Name);
            sw.Write(" where ");
            bool Primero = true;

            foreach (CFieldM f in this.lFieldPk)
            {
                sw.WriteAnd(ref Primero);
                sw.Write(f.Name);
                sw.Write(" = ");
                sw.Write(SUtilBD.Param(f.Name));
            }
        }
 public override void Generate(CSourceWriter sw)
 {
     sw.Write("byte[]");
 }
Example #19
0
 public void GeneraParametersCSharp(CSourceWriter sw)
 {
     foreach (var f in this.lFieldData)
     {
         if (f.IsNullable)
         {
             sw.Write("com.Parameters.AddWithValue(UtilBD.Param(\"");
             sw.Write(f.Name);
             sw.Write("\"), ");
             sw.Write(f.Name);
             sw.WriteLn(");");
         }
         else
         {
             sw.Write("if (");
             sw.Write(f.Name);
             sw.Write(" == null){");
             sw.Write("com.Parameters.AddWithValue(UtilBD.Param(\"");
             sw.Write(f.Name);
             sw.Write("\"), ");
             sw.Write("DBNull.Value");
             sw.WriteLn(");");
             sw.WriteLn("} else {");
             sw.Write("com.Parameters.AddWithValue(UtilBD.Param(\"");
             sw.Write(f.Name);
             sw.Write("\"), ");
             sw.Write(f.Name);
             sw.WriteLn(");");
             sw.WriteLn("}");
         }
     }
 }
 public override void Generate(CSourceWriter sw)
 {
     CSharpProject.WriteVisibility(sw, this.Visibility);
     sw.Space();
     if (this.Override)
     {
         sw.Write("override");
         sw.Space();
     }
     this.Type.Generate(sw);
     sw.Space();
     sw.Write(this.Name);
     sw.OpenBracesLn();
     sw.AddTab();
     if (this.HasGet)
     {
         if (this.Visibility != this.GetVisibility)
         {
             CSharpProject.WriteVisibility(sw, this.GetVisibility);
             sw.Space();
         }
         sw.Write("get");
         if (this.lSentenceGet.Count > 0)
         {
             sw.OpenBracesLn();
             sw.AddTab();
             foreach (CSentence s in this.lSentenceGet)
             {
                 s.Generate(sw);
             }
             sw.DelTab();
             sw.CloseBracesLn();
         }
         else
         {
             sw.SemicolonLn();
         }
     }
     if (this.HasSet)
     {
         if (this.Visibility != this.SetVisibility)
         {
             CSharpProject.WriteVisibility(sw, this.SetVisibility);
             sw.Space();
         }
         sw.Write("set");
         if (this.lSentenceSet.Count > 0)
         {
             sw.OpenBracesLn();
             sw.AddTab();
             foreach (CSentence s in this.lSentenceSet)
             {
                 s.Generate(sw);
             }
             sw.DelTab();
             sw.CloseBracesLn();
         }
         else
         {
             sw.SemicolonLn();
         }
     }
     sw.DelTab();
     sw.CloseBracesLn();
 }
 public void Generate(CSourceWriter sw)
 {
     Type.Generate(sw);
     sw.Space();
     sw.Write(this.Name);
 }
 public override void Generate(CSourceWriter sw)
 {
     sw.Write(this.Text);
 }
 public override void Generate(CSourceWriter sw)
 {
     sw.Write("short");
 }
 public override void Generate(CSourceWriter sw)
 {
     sw.Write("bool?");
 }
 public override void Generate(CSourceWriter sw)
 {
     sw.Write("float?");
 }
 public override void Generate(CSourceWriter sw)
 {
     sw.Write("double?");
 }
 public override void Generate(CSourceWriter sw)
 {
     sw.Write("DateTime ?");
 }
 public override void Generate(CSourceWriter sw)
 {
     sw.Write("string");
 }