Beispiel #1
0
 private static void CriarTabelaSql()
 {
     if (!VerificarExisteTabela.ExisteColunaNaTabela("PedidosItens", "ChavePedidoItem"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"CREATE TABLE `PedidosItens` (
                                       `ChavePedidoItem` BIGINT NOT NULL AUTO_INCREMENT,
                                       `ChavePedido` BIGINT NOT NULL,
                                       `ChaveProduto` BIGINT DEFAULT NULL,
                                       `Nome` varchar(300) DEFAULT NULL,  
                                       `Quatidade` BIGINT NULL,
                                     PRIMARY KEY (`ChavePedidoItem`))";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Tabela PedidosItens.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error Tabela PedidosItens: {error.Message}");
             }
         }
     }
 }
Beispiel #2
0
 private static void CriarTabelaSql()
 {
     if (!VerificarExisteTabela.ExisteColunaNaTabela("Banco", "ChaveBanco"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"CREATE TABLE `Banco` (
                                       `ChaveBanco` BIGINT NOT NULL AUTO_INCREMENT,
                                       `NomeBanco` varchar(300) DEFAULT NULL,
                                       `NumeroConta` BIGINT NULL,
                                       `Agencia` BIGINT NULL,
                                       `DataCadastro` datetime NOT NULL,
                                       `Saldo` double DEFAULT NULL,
                                       `Descricao` varchar(300) DEFAULT NULL,
                                       `Ativo` BOOLEAN DEFAULT NULL, 
                                     PRIMARY KEY (`ChaveBanco`))";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Tabela Banco.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error Tabela Banco: {error.Message}");
             }
         }
     }
 }
 private static void CriarTabelaSql()
 {
     if (!VerificarExisteTabela.ExisteColunaNaTabela("Pessoas", "ChavePessoa"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"CREATE TABLE `Pessoas` (
                                       `ChavePessoa` BIGINT NOT NULL AUTO_INCREMENT,
                                       `ChaveControleAcesso` BIGINT DEFAULT NULL,
                                       `Nome` varchar(100) DEFAULT NULL,
                                       `Email` varchar(100) DEFAULT NULL,
                                       `Senha` varchar(100) DEFAULT NULL,
                                       `CnpjCpf` varchar(14) DEFAULT NULL,                                              
                                       `Telefone` varchar(20) DEFAULT NULL,
                                       `DataCadastro` datetime NOT NULL,
                                       `Cep` varchar(8) DEFAULT NULL,
                                       `Endereco` varchar(500) DEFAULT NULL,
                                       `Observacoes` varchar(1000) DEFAULT NULL,
                                       `Ativo` BOOLEAN DEFAULT NULL,
                                     PRIMARY KEY (`ChavePessoa`))";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Tabela Pessoas.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error Tabela Pessoas: {error.Message}");
             }
         }
     }
 }
Beispiel #4
0
 private static void CriarTabelaSql()
 {
     if (!VerificarExisteTabela.ExisteColunaNaTabela("FormaPagamento", "ChaveFormaPagamento"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"CREATE TABLE `FormaPagamento` (
                                     `ChaveFormaPagamento` BIGINT NOT NULL AUTO_INCREMENT,
                                     `Tipo` varchar(200) DEFAULT NULL,
                                     `Categoria` varchar(100) DEFAULT NULL,
                                     `Descricao` varchar(100) DEFAULT NULL,
                                     `Ativo` BOOLEAN DEFAULT NULL,
                                     PRIMARY KEY (`ChaveFormaPagamento`))";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Tabela FormaPagamento.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error Tabela FormaPagamento: {error.Message}");
             }
         }
     }
 }
Beispiel #5
0
 private static void CriarTabelaSql()
 {
     if (!VerificarExisteTabela.ExisteColunaNaTabela("FileToUpload", "ChaveFile"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"CREATE TABLE `FileToUpload` (
                                     `ChaveFile` BIGINT NOT NULL AUTO_INCREMENT,
                                     `FileName` text(21845) COLLATE utf8_bin DEFAULT NULL,
                                     `FileSize` text(21845) COLLATE utf8_bin DEFAULT NULL,
                                     `FileType` text(21845) COLLATE utf8_bin DEFAULT NULL,
                                     `FileAsBase64` text(21845) COLLATE utf8_bin DEFAULT NULL,
                                     `LastModifiedDate` datetime NULL,
                                     PRIMARY KEY (`ChaveFile`))";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Tabela FileToUpload.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error Tabela FileToUpload: {error.Message}");
             }
         }
     }
 }
Beispiel #6
0
 private static void CriarTabelaSql()
 {
     if (!VerificarExisteTabela.ExisteColunaNaTabela("Pedidos", "ChavePedido"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"CREATE TABLE `Pedidos` (
                                     `ChavePedido` BIGINT NOT NULL AUTO_INCREMENT,
                                     `ChavePessoa` BIGINT DEFAULT NULL,
                                     `ChaveFormaPagamento` BIGINT DEFAULT NULL,
                                     `DataPedido` datetime NOT NULL,
                                     `Orcamento` BIGINT DEFAULT NULL,
                                     `LancamentoCaixa` bit(1) NOT NULL,
                                     `Status` varchar(300) COLLATE utf8_bin DEFAULT NULL,
                                     `Descricao` varchar(300) COLLATE utf8_bin DEFAULT NULL,
                                     `Quatidade` BIGINT DEFAULT NULL,
                                     `PrecoTotal` DECIMAL(12,2) DEFAULT NULL,
                                     `Parcela` BiGINT DEFAULT NULL,
                                     `ValorAntecipado` DECIMAL(12,2) DEFAULT NULL,
                                     PRIMARY KEY (`ChavePedido`))";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Tabela Pedidos.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error Tabela Pedidos: {error.Message}");
             }
         }
     }
 }
Beispiel #7
0
 private static void CriarTabelaSql()
 {
     if (!VerificarExisteTabela.ExisteColunaNaTabela("CaixaMovimentacao", "ChaveCaixaMovimentacao"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"CREATE TABLE `CaixaMovimentacao` (
                                         `ChaveCaixaMovimentacao` BIGINT NOT NULL AUTO_INCREMENT,
                                         `ChaveCaixa` BIGINT DEFAULT NULL,
                                         `ChavePessoa` BIGINT DEFAULT NULL,
                                         `ChavePedido` BIGINT DEFAULT NULL,
                                         `ChaveFile` BIGINT DEFAULT NULL,
                                         `ChaveFormaPagamento` BIGINT DEFAULT NULL,
                                         `Descricao` varchar(300) COLLATE utf8_bin DEFAULT NULL,
                                         `DataCadastro` datetime NULL,
                                         `DataPago` datetime NULL,
                                         `DataEstorno` datetime NULL,
                                         `TipoLancamento` BIGINT DEFAULT NULL,
                                         `FecharCaixaAutomatico` BOOLEAN DEFAULT NULL,     
                                         `Valor` DECIMAL(10,2) DEFAULT NULL,
                                         `ValorAntecipado` DECIMAL(10,2) DEFAULT NULL,
                                         `Ativo` BOOLEAN DEFAULT NULL,
                                         PRIMARY KEY (`ChaveCaixaMovimentacao`))";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Tabela CaixaMovimentacao.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error Tabela CaixaMovimentacao: {error.Message}");
             }
         }
     }
 }
Beispiel #8
0
 private static void CriarTabelaSql()
 {
     if (!VerificarExisteTabela.ExisteColunaNaTabela("Versao_Migration", "ChaveVersao"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"CREATE TABLE `Versao_Migration`(
                                         `ChaveVersao` BIGINT NOT NULL AUTO_INCREMENT,
                                         `Data` datetime NOT NULL,
                                         `Versao` BIGINT NOT NULL, 
                                     PRIMARY KEY(ChaveVersao))";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Tabela Versao_Migration.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error criação da Tabela Versao_Migration: {error.Message}");
             }
         }
     }
     if (!VerificarExisteTabela.ExisteRegistro("Versao_Migration", "versao", "1"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"INSERT INTO VERSAO_MIGRATION (DATA, VERSAO) VALUES(NOW(),'1')";
                 cmd.ExecuteNonQuery();
             }
             catch (Exception eX)
             {
                 throw new Exception($"Error preencher versão Versao_Migration: {eX.Message}");
             }
         }
     }
     //var M01 = _contexto.Versao_Migration.FirstOrDefault(px => px.Versao == 1);
     //if (M01 is null)
     //{
     //    try
     //    {
     //        _contexto.Versao_Migration.Add(new Versao_Migration { Data = DateTime.Now, Versao = 1 });
     //        _contexto.SaveChanges();
     //    }
     //    catch (Exception eX)
     //    {
     //        throw new Exception($"Error 'Versao_Migration': {eX.Message}");
     //    }
     //}
 }
Beispiel #9
0
 private static void InsertSql()
 {
     if (!VerificarExisteTabela.ExisteRegistro("ControleAcesso", "ChaveControleAcesso", "3"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"INSERT INTO `lojavirtual`.`ControleAcesso` (`ChaveControleAcesso`, `ChaveNivelAcesso`, `Descricao`) VALUES(1, 1, 'Administrador');
                                     INSERT INTO `lojavirtual`.`ControleAcesso` (`ChaveControleAcesso`, `ChaveNivelAcesso`, `Descricao`) VALUES(2, 2, 'Funcionario');
                                     INSERT INTO `lojavirtual`.`ControleAcesso` (`ChaveControleAcesso`, `ChaveNivelAcesso`, `Descricao`) VALUES(3, 3, 'Cliente');
                                 ";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Insert ControleAcesso.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error Insert ControleAcesso: {error.Message}");
             }
         }
     }
 }
Beispiel #10
0
 private static void CriarTabelaSql()
 {
     if (!VerificarExisteTabela.ExisteColunaNaTabela("ControleAcesso", "ChaveControleAcesso"))
     {
         using (var cmd = FactoryConnection.NewCommand())
         {
             try
             {
                 cmd.CommandText = @"CREATE TABLE `ControleAcesso` (
                                       `ChaveControleAcesso` BIGINT NOT NULL AUTO_INCREMENT,
                                       `ChaveNivelAcesso` BIGINT DEFAULT NULL,
                                       `Descricao` varchar(50) COLLATE utf8_bin DEFAULT NULL,
                                     PRIMARY KEY (`ChaveControleAcesso`))";
                 cmd.ExecuteNonQuery();
                 XLog.RegistraLog($"Tabela ControleAcesso.", "ModeloBanco");
             }
             catch (Exception error)
             {
                 throw new Exception($"Error Tabela ControleAcesso: {error.Message}");
             }
         }
     }
 }