Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace PlanningCalendar
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private String connectionString = "Data Source=.\\DATABAS;Initial Catalog=TestDB1;Integrated Security=SSPI;";
- private SqlConnection connection;
- private String testdatum1 = "Första värdet td1";
- private String testdatum2 = "Första värdet td2";
- public void dateTimePicker1_ValueChanged(object sender, EventArgs e)
- {
- string test = dateTimePicker1.Value.Date.ToShortDateString();
- LoadActivity();
- textBox1.Text = test;
- if (dateTimePicker1.Value.Date.ToShortDateString() == "10/24/2012")
- {
- textBox1.Text = this.testdatum1;
- }
- else if (dateTimePicker1.Value.Date.ToShortDateString() == "10/30/2012")
- {
- textBox1.Text = this.testdatum2;
- }
- }
- public void InsertActivity(object sender, EventArgs e)
- {
- string activityString = textBox1.Text;
- using (connection = new SqlConnection(connectionString))
- {
- SqlCommand command = new SqlCommand("INSERT INTO Activity VALUES('" + activityString + "')", connection);
- command.Connection.Open();
- command.ExecuteNonQuery();
- }
- if (dateTimePicker1.Value.Date.ToShortDateString() == "10/24/2012")
- {
- this.testdatum1 = textBox1.Text;
- }
- else if (dateTimePicker1.Value.Date.ToShortDateString() == "10/30/2012")
- {
- this.testdatum2 = textBox1.Text;
- }
- }
- public void LoadActivity()
- {
- using (connection = new SqlConnection(connectionString))
- {
- SqlCommand command = new SqlCommand("SELECT Activity FROM Planner", connection);
- command.Connection.Open();
- //SqlDataReader reader = command.ExecuteReader();
- //textBox1.Text = reader.GetString(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment