Fredin

Untitled

Oct 11th, 2012
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 KB | None | 0 0
  1. namespace PlanningCalendar
  2. {
  3.     public partial class Form1 : Form
  4.     {
  5.         public Form1()
  6.         {
  7.             InitializeComponent();
  8.         }
  9.  
  10.         private String connectionString = "Data Source=.\\DATABAS;Initial Catalog=TestDB1;Integrated Security=SSPI;";
  11.         private SqlConnection connection;
  12.        
  13.         private String testdatum1 = "Första värdet td1";
  14.         private String testdatum2 = "Första värdet td2";
  15.  
  16.  
  17.         public void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  18.         {
  19.             string test = dateTimePicker1.Value.Date.ToShortDateString();
  20.             LoadActivity();
  21.             textBox1.Text = test;
  22.  
  23.             if (dateTimePicker1.Value.Date.ToShortDateString() == "10/24/2012")
  24.             {
  25.                 textBox1.Text = this.testdatum1;
  26.             }
  27.  
  28.             else if (dateTimePicker1.Value.Date.ToShortDateString() == "10/30/2012")
  29.             {
  30.                 textBox1.Text = this.testdatum2;
  31.             }
  32.         }
  33.  
  34.         public void InsertActivity(object sender, EventArgs e)
  35.         {
  36.             string activityString = textBox1.Text;
  37.             using (connection = new SqlConnection(connectionString))
  38.             {  
  39.                 SqlCommand command = new SqlCommand("INSERT INTO Activity VALUES('" + activityString + "')", connection);
  40.                 command.Connection.Open();
  41.                 command.ExecuteNonQuery();
  42.             }
  43.  
  44.  
  45.  
  46.  
  47.             if (dateTimePicker1.Value.Date.ToShortDateString() == "10/24/2012")
  48.             {
  49.                 this.testdatum1 = textBox1.Text;
  50.             }
  51.             else if (dateTimePicker1.Value.Date.ToShortDateString() == "10/30/2012")
  52.             {
  53.                 this.testdatum2 = textBox1.Text;
  54.             }
  55.         }
  56.  
  57.         public void LoadActivity()
  58.         {
  59.             using (connection = new SqlConnection(connectionString))
  60.             {
  61.                 SqlCommand command = new SqlCommand("SELECT Activity FROM Planner", connection);
  62.                 command.Connection.Open();
  63.                 //SqlDataReader reader = command.ExecuteReader();
  64.                 //textBox1.Text = reader.GetString(0);
  65.  
  66.             }
  67.         }
  68.  
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment