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
// 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
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
/// <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
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
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
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 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 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 Queue -----------------") | |
Dim queueList As New Queue | |
queueList.Enqueue("Item1") | |
queueList.Enqueue("Item2") | |
queueList.Enqueue("Item3") | |
queueList.Enqueue("Item4") | |
Console.WriteLine("* Queue: O primeiro a ser inserido é o primeiro a sair.") | |
Console.WriteLine("* O primeiro da fila é o -> " & queueList.Peek) |
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
Module Module1 | |
Sub Main() | |
Dim ajax As New XMLHttpRequest | |
' Teste com GET | |
ajax.Open(XMLHttpRequest.EnumMethod.GET, "http://site.ycaro.net/teste.php?teste=123") | |
ajax.Send() | |
If ajax.readystate = 4 Then | |
If ajax.Status = 200 Then |