This file contains hidden or 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
| Module Module1 | |
| Sub Main() | |
| Console.WriteLine("----------------- Exemplo com Stack -----------------") | |
| Dim _stack As New Stack | |
| _stack.Push("item1") | |
| _stack.Push("item2") | |
| _stack.Push("item3") | |
| _stack.Push("item4") | |
| Console.WriteLine("Stack: O primeiro a ser inserido é o ultimo a sair.") |
This file contains hidden or 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
| using System.Web.UI.WebControls; | |
| using System.Web.UI; | |
| // Isso serve para adicionar o arquivo .js no controle. | |
| // Para usar isso, deve mudar o valor da propriedade "Build Action" para "Embedded Resource" do arquivo. | |
| // E o nome é: Nome do projeto . nome do arquivo . extensão do arquivo | |
| [assembly: WebResource("CSharp_Controle_TextBox.ControleTextBox.js", "application/x-javascript")] | |
| namespace CSharp_Controle_TextBox | |
| { |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |