This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
catch (DbEntityValidationException e) | |
{ | |
string erro = string.Empty; | |
foreach (var eve in e.EntityValidationErrors) | |
{ | |
erro += (string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", | |
eve.Entry.Entity.GetType().Name, eve.Entry.State)); | |
foreach (var ve in eve.ValidationErrors) | |
{ | |
erro += (string.Format("- Property: \"{0}\", Error: \"{1}\"", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String.prototype.RemoverAcentos = function () { | |
return this.replace(/[ÄÅÁÂÀÃ]/gi, "A") | |
.replace(/[äáâàã]/gi, "a") | |
.replace(/[ÉÊËÈ]/gi, "E") | |
.replace(/[éêëè]/gi, "e") | |
.replace(/[ÍÎÏÌ]/gi, "I") | |
.replace(/[íîïì]/gi, "i") | |
.replace(/[ÖÓÔÒÕ]/gi, "O") | |
.replace(/[öóôòõ]/gi, "o") | |
.replace(/[ÜÚÛ]/gi, "U") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Por: Ycaro Afonso | |
/// Data: 20/08/2014 | |
/// | |
/// Atualiza apenas os parametros informados de uma tabela. | |
/// Exemplo: Tabela Pessoa, atualizar apenas Nome e Idade | |
/// | |
/// UpdateParametro(Contexto, instancia | |
/// , c => c.Nome | |
/// , c => c.Idade) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ActionResult Download(int id) | |
{ | |
var objetoEntity = ...; | |
ViewEngineResult result = ViewEngines.Engines.FindView(this.ControllerContext, "Visualizar", "_Layout"); | |
string htmlTextView = GetViewToString(this.ControllerContext, result, objetoEntity); | |
byte[] toBytes = System.Text.Encoding.Unicode.GetBytes(htmlTextView); | |
return File(toBytes, "application/file", "template.doc"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Exemplo 1: | |
Tuple<int, string, DateTime> pessoa = new Tuple<int, string, DateTime>(1, "Ycaro", new DateTime(2015, 2, 6)); | |
Console.Write(string.Format("ID: {0}, Nome: {1}, Data: {2:dd/MM/yyyy}", pessoa.Item1, pessoa.Item2, pessoa.Item3)); | |
// Exemplo 2: | |
int id = 2; | |
string nome = "Ycaro 2"; | |
DateTime data = new DateTime(2015, 2, 7); | |
pessoa = Tuple.Create(id, nome, data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT CONVERT(DATETIME, '15/02/2015', 103) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER FUNCTION dbo.Convert_DDMMYY_To_DateTime (@DiaMesAno INT) | |
RETURNS DATETIME | |
AS | |
BEGIN | |
-- Ycaro Afonso (2015-04-19) | |
DECLARE @Data VARCHAR(20) = STUFF(STUFF(@DiaMesAno, 3, 0, '/'), 6, 0, '/') | |
RETURN CONVERT(DATETIME, @Data, 3) | |
END | |
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @Tabela VARCHAR(200) = 'Nome da Tabela', | |
@TABLE_SCHEMA VARCHAR(200)= 'dbo' | |
-- Por Ycaro Afonso 2015-06-07 | |
/* | |
DROP TABLE #VW_FRAMEWORK_COLUMN | |
DROP TABLE #VW_FRAMEWORK_TABLE | |
DROP TABLE #VW_FRAMEWORK_CUSTOM_CONSTRAINT_ITEM_UNICO | |
DROP TABLE #VW_FRAMEWORK_CONSTRAINT | |
DROP TABLE #VW_FRAMEWORK_MAPEAMENTO_ENTITY_PROPRIEDADES | |
DROP TABLE #VW_FRAMEWORK_MAPEAMENTO_ENTITY_PROPRIEDADES_COM_FILHOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @NomeProcedure VARCHAR(200)= 'Nome da Tabela', | |
@NomeSchema VARCHAR(200)= 'dbo' | |
DECLARE @SqlProcedure VARCHAR(MAX)= '', | |
@Sql VARCHAR(MAX)= '' | |
SELECT @SqlProcedure += ', ' + PARAMETER_NAME + ' = ' + CASE DATA_TYPE | |
WHEN 'datetime' | |
THEN '''' + CONVERT(VARCHAR(10), GETDATE(), 120) + '''' | |
WHEN 'int' THEN '0' | |
ELSE 'NULL' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER FUNCTION NumeroExtenso(@Num INT) | |
RETURNS VARCHAR(500) | |
AS BEGIN | |
--Por Ycaro Afonso 2013-09-18 | |
--V 2.0 | |
DECLARE @FAT INT, @_FAT INT | |
DECLARE @NumRes INT = @Num, @_NumRes INT, @_NumT INT | |
DECLARE @Ret VARCHAR(500) = '' |
OlderNewer