private void button5_Click(object sender, EventArgs e) { int storeIndex = findStore(selectedStore); bool changeStuff = false; scheduleSettingsForm scheduleSet = new scheduleSettingsForm(); scheduleSet.setUpScheduleSettings(dataGridView1, storeIndex); this.Hide(); scheduleSet.ShowDialog(); scheduleSet.sendBackStoreInfo(ref currentStore, ref changeStuff); if (changeStuff) { connection.Open(); SqlCommand cmd = connection.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "UPDATE storeTable " + "SET maxHoursWeekOne = " + currentStore.maxWeeklyHours[0] + ", maxHoursWeekTwo = " + currentStore.maxWeeklyHours[1] + ", [sunday from 1] = '" + currentStore.storeHours.fromOne[0].ToShortTimeString() + "', [sunday to 1] = '" + currentStore.storeHours.toOne[0].ToShortTimeString() + "', [monday from 1] = '" + currentStore.storeHours.fromOne[1].ToShortTimeString() + "', [monday to 1] = '" + currentStore.storeHours.toOne[1].ToShortTimeString() + "', [tuesday from 1] = '" + currentStore.storeHours.fromOne[2].ToShortTimeString() + "', [tuesday to 1] = '" + currentStore.storeHours.toOne[2].ToShortTimeString() + "', [wednesday from 1] = '" + currentStore.storeHours.fromOne[3].ToShortTimeString() + "', [wednesday to 1] = '" + currentStore.storeHours.toOne[3].ToShortTimeString() + "', [thursday from 1] = '" + currentStore.storeHours.fromOne[4].ToShortTimeString() + "', [thursday to 1] = '" + currentStore.storeHours.toOne[4].ToShortTimeString() + "', [friday from 1] = '" + currentStore.storeHours.fromOne[5].ToShortTimeString() + "', [friday to 1] = '" + currentStore.storeHours.toOne[5].ToShortTimeString() + "', [saturday from 1] = '" + currentStore.storeHours.fromOne[6].ToShortTimeString() + "', [saturday to 1] = '" + currentStore.storeHours.toOne[6].ToShortTimeString() + "' WHERE Id = " + dataGridView1.Rows[storeIndex].Cells[0].Value; cmd.ExecuteNonQuery(); connection.Close(); display_Data(); } else { } this.Show(); }
private void button33_Click(object sender, EventArgs e) { scheduleSettingsForm scheduleSet = new scheduleSettingsForm(); bool create = false; this.Hide(); scheduleSet.ShowDialog(); scheduleSet.sendBackStoreInfo(ref currentStore, ref create); this.Show(); connection.Open(); SqlCommand cmd = connection.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "CREATE TABLE [" + currentStore.nameOfStore + "]([employeeId] INT NOT NULL IDENTITY,[name] NCHAR(25) NOT NULL," + "[Pay] FLOAT(53) NOT NULL,[MaxPerWeek] FLOAT NOT NULL," + "[Sunday from 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Sunday to 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Sunday from 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Sunday to 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Monday from 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Monday to 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Monday from 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Monday to 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Tuesday from 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Tuesday to 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Tuesday from 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Tuesday to 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Wednesday from 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Wednesday to 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Wednesday from 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Wednesday to 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Thursday from 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Thursday to 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Thursday from 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Thursday to 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Friday from 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Friday to 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Friday from 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Friday to 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Saturday from 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Saturday to 1] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[Saturday from 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM'),[Saturday to 2] NCHAR(10) NOT NULL DEFAULT('12:00 AM')," + "[weekOneHours] FLOAT NOT NULL DEFAULT 0,[weekTwoHours] FLOAT NOT NULL DEFAULT 0," + "PRIMARY KEY CLUSTERED([employeeId] ASC))"; try { cmd.ExecuteNonQuery(); cmd.CommandText = "insert into [storeTable] (storeName,maxEmployeeDailyHours," + "maxHoursWeekOne,maxHoursWeekTwo,maxHoursWeekThree,maxHoursWeekFour," + "[Sunday from 1],[Sunday to 1],[Sunday from 2],[Sunday to 2]," + "[Monday from 1],[Monday to 1],[Monday from 2],[Monday to 2]," + "[Tuesday from 1],[Tuesday to 1],[Tuesday from 2],[Tuesday to 2]," + "[Wednesday from 1],[Wednesday to 1],[Wednesday from 2],[Wednesday to 2]," + "[Thursday from 1],[Thursday to 1],[Thursday from 2],[Thursday to 2]," + "[Friday from 1],[Friday to 1],[Friday from 2],[Friday to 2]," + "[Saturday from 1],[Saturday to 1],[Saturday from 2],[Saturday to 2]," + "coverLunch,lunchLength,breakLength,maxHoursBeforeLunch) " + "values ('" + currentStore.nameOfStore + "','" + currentStore.maxDailyHours + "','" + currentStore.maxWeeklyHours[0] + "','" + currentStore.maxWeeklyHours[1] + "','" + currentStore.maxWeeklyHours[2] + "','" + currentStore.maxWeeklyHours[3]; for (int i = 0; i < 7; i++) { cmd.CommandText = cmd.CommandText + "','" + currentStore.storeHours.fromOne[i].ToShortTimeString(); cmd.CommandText = cmd.CommandText + "','" + currentStore.storeHours.toOne[i].ToShortTimeString(); cmd.CommandText = cmd.CommandText + "','" + currentStore.storeHours.fromTwo[i].ToShortTimeString(); cmd.CommandText = cmd.CommandText + "','" + currentStore.storeHours.toTwo[i].ToShortTimeString(); } cmd.CommandText = cmd.CommandText + "','" + currentStore.lunchBreak + "','" + currentStore.lunchDuration + "','" + currentStore.breakLength + "','" + currentStore.maxBeforeLunch + "')"; cmd.ExecuteNonQuery(); for (int i = 0; i < 14; i++) { cmd.CommandText = "CREATE TABLE [" + currentStore.nameOfStore + daysOfWeek[i] + "]([employee] NCHAR (30) NOT NULL," + "[beginning] NCHAR(10) NOT NULL,[ending] NCHAR(10) NOT NULL)"; cmd.ExecuteNonQuery(); } /*cmd.CommandText = "insert into [storeTable] (storeName,maxEmployeeDailyHours," + * "maxHoursWeekOne,maxHoursWeekTwo,maxHoursWeekThree,maxHoursWeekFour," + * "'[Sunday from 1]','[Sunday to 1]','[Sunday from 2]','[Sunday to 2]'," + * "'[Monday from 1],'[Monday to 1]','[Monday from 2]','[Monday to 2]'," + * "'[Tuesday from 1]','[Tuesday to 1]','[Tuesday from 2]','[Tuesday to 2]'," + * "'[Wednesday from 1]','[Wednesday to 1]','[Wednesday from 2]','[Wednesday to 2]'," + * "'[Thursday from 1]','[Thursday to 1]','[Thursday from 2]','[Thursday to 2]'," + * "'[Friday from 1]','[Friday to 1]','[Friday from 2]','[Friday to 2]'," + * "'[Saturday from 1]','[Saturday to 1]','[Saturday from 2]','[Saturday to 2]'," + * "coverLunch,lunchLength,breakLength,maxHoursBeforeLunch) " + * "values ('" + currentStore.nameOfStore + "','" + currentStore.maxDailyHours + "','" + * currentStore.maxWeeklyHours[0] + "','" + currentStore.maxWeeklyHours[1] + "','" + * currentStore.maxWeeklyHours[2] + "','" + currentStore.maxWeeklyHours[3]; * * for (int i = 0; i < 7; i++) * { * cmd.CommandText = cmd.CommandText + "','" + currentStore.storeHours.fromOne[i].ToShortTimeString(); * cmd.CommandText = cmd.CommandText + "','" + currentStore.storeHours.toOne[i].ToShortTimeString(); * cmd.CommandText = cmd.CommandText + "','" + currentStore.storeHours.fromTwo[i].ToShortTimeString(); * cmd.CommandText = cmd.CommandText + "','" + currentStore.storeHours.toTwo[i].ToShortTimeString(); * } * cmd.CommandText = cmd.CommandText + "','" + currentStore.lunchBreak + "','" + currentStore.lunchDuration + "','" + * currentStore.breakLength + "','" + currentStore.maxBeforeLunch + "')"; * cmd.ExecuteNonQuery();*/ } catch { } connection.Close(); display_Data(); comboBox1.Items.Clear(); comboBox1.Items.AddRange(GetAllStores()); }