private void Button1_Click(System.Object sender, System.EventArgs e) { //Setup the schedule Schedule1.SetMinMaxDate(new DateTime(2004, 1, 1), new DateTime(2004, 1, 4)); Schedule1.StartTime = new DateTime(2004, 1, 1, 8, 0, 0); Schedule1.DayLength = 10; Schedule1.ColumnHeader.AutoFit = true; Schedule1.AllowRemove = true; //Create a dataset with an "Appointment" table System.Data.DataSet ds = new System.Data.DataSet(); System.Data.DataTable dt = ds.Tables.Add("appointment"); //Create the necessary columns dt.Columns.Add("appointment_guid", typeof(string)); dt.Columns.Add("start_date", typeof(DateTime)); dt.Columns.Add("start_time", typeof(DateTime)); dt.Columns.Add("length", typeof(int)); //Mark to disallow DBNull dt.Columns["appointment_guid"].AllowDBNull = false; dt.Columns["start_date"].AllowDBNull = false; dt.Columns["start_time"].AllowDBNull = false; dt.Columns["length"].AllowDBNull = false; //Mark the 'appointment_guid' column as a unique appointment_guid dt.Columns["appointment_guid"].Unique = true; //Optional Columns dt.Columns.Add("subject", typeof(string)); dt.Columns.Add("ToolTipText", typeof(string)); //Add datarows. This will be displayed by the schedule when it is databound System.Data.DataRow dr; dr = CreateDataRow(dt, Guid.NewGuid().ToString(), new DateTime(2004, 1, 1), new DateTime(2004, 1, 1, 8, 0, 0), 60, "Appointment 1"); dr["ToolTipText"] = "This is a tip!"; dr = CreateDataRow(dt, Guid.NewGuid().ToString(), new DateTime(2004, 1, 2), new DateTime(2004, 1, 2, 9, 0, 0), 60, "Appointment 2"); dr = CreateDataRow(dt, Guid.NewGuid().ToString(), new DateTime(2004, 1, 3), new DateTime(2004, 1, 3, 10, 0, 0), 60, "Appointment 3"); //Bind the dataset to the schedule Schedule1.DataSource = ds; Schedule1.Bind(); DisplayAppointmentCount(); this.Button2.Enabled = true; this.Button3.Enabled = true; }
private void PopulateSchedule(DataSet ds) { //Map fields //Clear all bindings schedule1.DataBindings.FromXML(""); //Appointment schedule1.DataBindings.AppointmentBinding.DataSource = ds.Tables["A_Table"]; schedule1.DataBindings.AppointmentBinding.DataFieldBindingCollection.Add("appointment_guid", "key"); schedule1.DataBindings.AppointmentBinding.DataFieldBindingCollection.Add("start_date", "the_start"); schedule1.DataBindings.AppointmentBinding.DataFieldBindingCollection.Add("length", "the_length"); schedule1.DataBindings.AppointmentBinding.DataFieldBindingCollection.Add("subject", "the_text"); //Category schedule1.DataBindings.CategoryBinding.DataSource = ds.Tables["C_Table"]; schedule1.DataBindings.CategoryBinding.DataFieldBindingCollection.Add("category_guid", "key"); schedule1.DataBindings.CategoryBinding.DataFieldBindingCollection.Add("name", "the_text"); schedule1.DataBindings.CategoryBinding.DataFieldBindingCollection.Add("color", "the_color"); //Appointment-Category Link table schedule1.DataBindings.AppointmentCategoryBinding.DataSource = ds.Tables["AC_Table"]; schedule1.DataBindings.AppointmentCategoryBinding.DataFieldBindingCollection.Add("appointment_guid", "key1"); schedule1.DataBindings.AppointmentCategoryBinding.DataFieldBindingCollection.Add("category_guid", "key2"); //Provider schedule1.DataBindings.ProviderBinding.DataSource = ds.Tables["P_Table"]; schedule1.DataBindings.ProviderBinding.DataFieldBindingCollection.Add("provider_guid", "key"); schedule1.DataBindings.ProviderBinding.DataFieldBindingCollection.Add("name", "the_text"); schedule1.DataBindings.ProviderBinding.DataFieldBindingCollection.Add("color", "the_color"); //Appointment-Provider Link table schedule1.DataBindings.AppointmentProviderBinding.DataSource = ds.Tables["AP_Table"]; schedule1.DataBindings.AppointmentProviderBinding.DataFieldBindingCollection.Add("appointment_guid", "key1"); schedule1.DataBindings.AppointmentProviderBinding.DataFieldBindingCollection.Add("provider_guid", "key2"); //Room schedule1.DataBindings.RoomBinding.DataSource = ds.Tables["R_Table"]; schedule1.DataBindings.RoomBinding.DataFieldBindingCollection.Add("room_guid", "key"); schedule1.DataBindings.RoomBinding.DataFieldBindingCollection.Add("name", "the_text"); //Bind the dataset to the schedule schedule1.DataSource = ds; schedule1.Bind(); MessageBox.Show("Load Success!", "Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void Form1_Load(object sender, System.EventArgs e) { //Setup the schedule Schedule1.SetMinMaxDate(new DateTime(2004, 1, 1), new DateTime(2004, 1, 5)); Schedule1.StartTime = new DateTime(2004, 1, 1, 8, 0, 0); Schedule1.DayLength = 10; Schedule1.TimeIncrement = Gravitybox.Controls.Schedule.TimeIncrementConstants.Minute30; Schedule1.ColumnHeader.AutoFit = true; Schedule1.EventHeader.AllowHeader = false; Schedule1.HeaderDateFormat = "MMM dd"; //Setup the dataset MyDataset = new GravityboxDataset(); this.OleDbDataAdapter1.Fill(MyDataset, "Appointment"); Schedule1.DataSource = MyDataset; Schedule1.Bind(); }
private void button1_Click(object sender, System.EventArgs e) { // string connectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" + // @"ocking Mode=1;Data Source=""Schedule.mdb"";Jet OLEDB:Engine Type=5;Provider=""Micro" + // @"soft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist secur" + // @"ity info=False;Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Datab" + // @"ase=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on " + // @"Compact=False;Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet O" + // @"LEDB:Global Bulk Transactions=1"; string connectionString = "data source=(local);database=gravitybox;uid=sa;pwd=;"; //Command Text string cmdText = "select * from a_table;select * from c_table;select * from ac_table;select * from p_table;select * from ap_table;select * from r_table"; //Connection System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString); System.Data.SqlClient.SqlCommand selectCommand = new System.Data.SqlClient.SqlCommand(cmdText); System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(selectCommand); //Select command DataSet ds = new DataSet(); selectCommand.Connection = connection; adapter.Fill(ds); //************************************************** //Map fields //************************************************** schedule1.DataBindings.AppointmentBinding.DataFieldBindingCollection.Clear(); schedule1.DataBindings.AppointmentCategoryBinding.DataFieldBindingCollection.Clear(); schedule1.DataBindings.AppointmentProviderBinding.DataFieldBindingCollection.Clear(); schedule1.DataBindings.CategoryBinding.DataFieldBindingCollection.Clear(); schedule1.DataBindings.ProviderBinding.DataFieldBindingCollection.Clear(); schedule1.DataBindings.RoomBinding.DataFieldBindingCollection.Clear(); //Appointment ds.Tables[0].Columns["the_key"].AllowDBNull = false; ds.Tables[0].Columns["the_key"].Unique = true; ds.Tables[0].Columns["s_time"].AllowDBNull = false; ds.Tables[0].Columns["duration"].AllowDBNull = false; schedule1.DataBindings.AppointmentBinding.DataSource = ds.Tables[0]; schedule1.DataBindings.AppointmentBinding.DataFieldBindingCollection.Add("appointment_guid", "the_key"); schedule1.DataBindings.AppointmentBinding.DataFieldBindingCollection.Add("start_date", "s_time"); schedule1.DataBindings.AppointmentBinding.DataFieldBindingCollection.Add("length", "duration"); schedule1.DataBindings.AppointmentBinding.DataFieldBindingCollection.Add("subject", "mytext"); //Category ds.Tables[1].Columns["the_key"].AllowDBNull = false; ds.Tables[1].Columns["the_key"].Unique = true; ds.Tables[1].Columns["mytext"].AllowDBNull = false; ds.Tables[1].Columns["mycolor"].AllowDBNull = false; schedule1.DataBindings.CategoryBinding.DataSource = ds.Tables[1]; schedule1.DataBindings.CategoryBinding.DataFieldBindingCollection.Add("category_guid", "the_key"); schedule1.DataBindings.CategoryBinding.DataFieldBindingCollection.Add("name", "mytext"); schedule1.DataBindings.CategoryBinding.DataFieldBindingCollection.Add("color", "mycolor"); //Link table ds.Tables[2].Columns["key1"].AllowDBNull = false; ds.Tables[2].Columns["key2"].AllowDBNull = false; schedule1.DataBindings.AppointmentCategoryBinding.DataSource = ds.Tables[2]; schedule1.DataBindings.AppointmentCategoryBinding.DataFieldBindingCollection.Add("appointment_guid", "key1"); schedule1.DataBindings.AppointmentCategoryBinding.DataFieldBindingCollection.Add("category_guid", "key2"); //Provider ds.Tables[3].Columns["the_key"].AllowDBNull = false; ds.Tables[3].Columns["the_key"].Unique = true; ds.Tables[3].Columns["mytext"].AllowDBNull = false; ds.Tables[3].Columns["mycolor"].AllowDBNull = false; schedule1.DataBindings.ProviderBinding.DataSource = ds.Tables[3]; schedule1.DataBindings.ProviderBinding.DataFieldBindingCollection.Add("provider_guid", "the_key"); schedule1.DataBindings.ProviderBinding.DataFieldBindingCollection.Add("name", "mytext"); schedule1.DataBindings.ProviderBinding.DataFieldBindingCollection.Add("color", "mycolor"); //Link table ds.Tables[4].Columns["key1"].AllowDBNull = false; ds.Tables[4].Columns["key2"].AllowDBNull = false; schedule1.DataBindings.AppointmentProviderBinding.DataSource = ds.Tables[4]; schedule1.DataBindings.AppointmentProviderBinding.DataFieldBindingCollection.Add("appointment_guid", "key1"); schedule1.DataBindings.AppointmentProviderBinding.DataFieldBindingCollection.Add("provider_guid", "key2"); //Room ds.Tables[5].Columns["the_key"].AllowDBNull = false; ds.Tables[5].Columns["the_key"].Unique = true; ds.Tables[5].Columns["mytext"].AllowDBNull = false; schedule1.DataBindings.RoomBinding.DataSource = ds.Tables[5]; schedule1.DataBindings.RoomBinding.DataFieldBindingCollection.Add("room_guid", "the_key"); schedule1.DataBindings.RoomBinding.DataFieldBindingCollection.Add("name", "mytext"); // schedule1.DataBindings.SaveXML(@"c:\myxml.xml"); // schedule1.DataBindings.LoadXML(@"c:\myxml.xml"); schedule1.DataSource = ds; schedule1.Bind(); MessageBox.Show("Loaded"); schedule1.DataSourceUpdated += new Gravitybox.Objects.RefreshDelegate(schedule1_DataSourceUpdated); }