private void butEnter_Click(object sender, EventArgs e) { string[] strSupervisor; string[] strWorker; int intRows = 0; string strSQL; objDatabase Database = new objDatabase(); strSupervisor = cmbSupervisor.SelectedItem.ToString().Split(' '); //Loop through all entries in dtWorkers foreach (DataRow objRow in dtWorkers.Rows) { strWorker = objRow["Name"].ToString().Split(' '); if (objRow["Action"].ToString() == "Add") { strSQL = "spUpdateSupervisor " + "'" + strSupervisor[0] + "','" + strSupervisor[1] + "','" + strWorker[0] + "','" + strWorker[1] + "','" + dtDay.Text.ToString() + "','" + cmbShift.SelectedItem.ToString() + "'"; intRows = intRows + Database.AddData(strSQL); } else if (objRow["Action"].ToString() == "Delete") { strSQL = "spRemoveSupervisor " + "'" + strSupervisor[0] + "','" + strSupervisor[1] + "','" + strWorker[0] + "','" + strWorker[1] + "','" + dtDay.Text.ToString() + "','" + cmbShift.SelectedItem.ToString() + "'"; intRows = intRows + Database.AddData(strSQL); } } MessageBox.Show(intRows.ToString() + " rows have been updated."); strDtDay = dtDay.Value.ToShortDateString(); intCmbShift = cmbShift.SelectedIndex; intCmbSupervisor = cmbSupervisor.SelectedIndex; LoadControl(); }
private int UpdateDB(string strSQL) { objDatabase Database = new objDatabase(); int intRows; return(intRows = Database.AddData(strSQL)); }
private int UpdateDatabase(string strSQL) { objDatabase Database = new objDatabase(); return(Database.AddData(strSQL)); }
private void butEnter_Click(object sender, EventArgs e) { objDatabase Database = new objDatabase(); string strSQL; string strMsg = ""; int intRows = 0, intDelete = 0, intAdd = 0; Cursor.Current = Cursors.WaitCursor; foreach (DataRow objRow in dtSchedule.Rows) { if (objRow["Action"].ToString().Length > 0) { strSQL = "spAddSchedule '" + objRow["Worker"] + "','" + objRow["shift"] + "','" + dtDay.Text + "','" + objRow["Action"] + "'"; //update database intRows = Database.AddData(strSQL); if (objRow["Action"].ToString() == "delete") { intDelete = intRows + intDelete; } else if (objRow["Action"].ToString() == "new") { intAdd = intRows + intAdd; } } } Cursor.Current = Cursors.Default; if (intAdd > 0) { strMsg = intAdd.ToString() + " worker(s) have been added to the " + cmbShift.Text + "."; } if (intDelete > 0) { if (strMsg.Length > 0) { strMsg = strMsg + "\r\n"; } strMsg = strMsg + intDelete.ToString() + " worker(s) have been removed from the " + cmbShift.Text + "."; } MessageBox.Show(strMsg); intCmbShiftIndex = cmbShift.SelectedIndex; strDtDay = dtDay.Value.ToLongDateString(); lstScheduled.Items.Clear(); lstWorkers.Items.Clear(); strAction = ""; LoadControl(); }
private void butRole_Click(object sender, EventArgs e) { objDatabase Database = new objDatabase(); string strSQL; int intRows; strSQL = "spUpdateRole '" + txtFirstName.Text + "','" + txtLastName.Text + "','" + cmbRole.Text + "'"; intRows = Database.AddData(strSQL); if (intRows > 0) { MessageBox.Show(txtFirstName.Text + " " + txtLastName.Text + "'s role has been updated."); } ClearControl(); }
private void butDelete_Click(object sender, EventArgs e) { objDatabase Database = new objDatabase(); string strSQL = "Delete From Shift Where Shift.Name = '" + cmbShift.Text + "'"; Cursor.Current = Cursors.WaitCursor; int intRows = Database.AddData(strSQL); LoadControl(); Cursor.Current = Cursors.Default; if (intRows > 0) { MessageBox.Show("The shift has been deleted."); } }
private void butEnter_Click(object sender, EventArgs e) { if (VerifyData() == true) { objDatabase Database = new objDatabase(); string strSQL = "spAddShift '" + cmbShift.Text + "', '" + dtStartTime.Text + "', '" + dtEndTime.Text + "'"; Cursor.Current = Cursors.WaitCursor; int intRows = Database.AddData(strSQL); LoadControl(); Cursor.Current = Cursors.Default; if (intRows > 0) { MessageBox.Show("The shift has been successfully updated."); } } }
private void AddPerson() { string strSQL; objDatabase Database = new objDatabase(); int intRows; bool blReady; blReady = CheckControl(); if (blReady == true) { strSQL = "spAddPerson '" + txtFirstName.Text + "','" + txtLastName.Text + "','" + cmbRole.SelectedItem.ToString() + "','" + strPicPath + "'"; intRows = Database.AddData(strSQL); if (intRows > 0) { MessageBox.Show(txtFirstName.Text + " " + txtLastName.Text + " has been added to the database."); ClearControl(); } } }