Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using MySql.Data.MySqlClient;
  8. using System.Globalization;
  9.  
  10. public partial class cadArtigos : System.Web.UI.Page
  11. {
  12.     protected void Page_Load(object sender, EventArgs e)
  13.     {
  14.  
  15.     }
  16.     protected void Btlimpar_Click(object sender, EventArgs e)
  17.     {
  18.         titulo.Text = string.Empty;
  19.         autor.Text = string.Empty;
  20.         texto.Text = string.Empty;
  21.         dia.Text = string.Empty;
  22.         mes.Text = string.Empty;
  23.         ano.Text = string.Empty;
  24.         publicar.Checked = false;
  25.     }
  26.     protected void BtSalvar_Click(object sender, EventArgs e)
  27.     {
  28.         string conexao = "Server=localhost;Database=Stonehenge;Uid=root;Pwd='';Connect Timeout=30;";
  29.         MySqlConnection conn;
  30.         conn = new MySqlConnection(conexao);
  31.         string pbl = publicar.Checked ? "1" : "0";
  32.         //DateTime dt = new DateTime(int.Parse(ano.Text),int.Parse(mes.Text),int.Parse(dia.Text),0,0,0);
  33.         //CultureInfo ci = new CultureInfo("en-US");
  34.         DateTime dt = new DateTime();
  35.         string dt1 = dia.Text + "/" + mes.Text + "/" + ano.Text;
  36.         dt = DateTime.Parse(dt1);
  37.         //Response.Write(dt.Date);
  38.         String data=String.Format("{0:u}", dt);
  39.         string comando = "INSERT INTO artigo ";
  40.         comando += "(autor,titulo,texto,data,publicar)";
  41.         comando += "VALUES (\"" + autor.Text + "\",\"" + titulo.Text + "\",";
  42.         comando += "\"" + texto.Text + "\",'"  + data+  "',";
  43.         comando += pbl + ")";
  44.         MySqlCommand cmd = new MySqlCommand(comando);
  45.         cmd.Connection = conn;
  46.         conn.Open();
  47.         cmd.ExecuteNonQuery();
  48.     }
  49. }