private void deleteCSFPServices(string deleteIDs) { int nbrRows = CCFBGlobal.executeQuery("Delete From CSFPLog " + "Where ID in (" + deleteIDs + ")"); MessageBox.Show(nbrRows.ToString() + " CSFP Service have been deleted." , "Delete CSFP Service", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void updateExistingService(string updateIDs) { int nbrRows = CCFBGlobal.executeQuery("Update CSFPLog Set TrxDate='" + dtpSvcDate.Value.ToString() + "', " + "Lbs=" + tbLbsCSFP.Text + ", Modified='" + DateTime.Now.ToString() + "', " + "ModifiedBy='" + CCFBGlobal.dbUserName + "' " + "Where ID in (" + updateIDs + ")"); MessageBox.Show("The TrxDate and Lbs on " + nbrRows.ToString() + " CSFP Transaction Log has been changed" , "Update Existing CSFP Service", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public int insert(int weekday, string jobid, string jobtitle, string shiftstart, string shiftend, string volidprimary, string volidbackup) { string sql = "INSERT INTO [FBJobsPlan] " + "([WeekDay],[JobID],[JobTitle],[ShiftStart],[ShiftEnd]" + ",[VolIdPrimary],[VolIdBackup]" + ",[Created],[CreatedBy],[Modified],[ModifiedBy]) " + "VALUES (" + weekday.ToString() + "," + jobid + ",'" + jobtitle + "'" + ",'" + shiftstart + "','" + shiftend + "'" + "," + volidprimary + "," + volidbackup + ",'" + DateTime.Now + "','" + CCFBGlobal.dbUserName + "'" + ",NULL,'')"; return(CCFBGlobal.executeQuery(sql)); }
private void btnProcess_Click(object sender, EventArgs e) { int nbrRows = 0; if (rdoBtn1.Checked == true) { nbrRows = CCFBGlobal.executeQuery("Update Household Set Inactive = 1 Where Inactive = 0"); } else { nbrRows = CCFBGlobal.executeQuery("Update Household Set Inactive = 1 Where InActive = 0 AND LatestService < '" + dateTimePicker1.Value.ToShortDateString() + "'"); } if (nbrRows != 0) { MessageBox.Show(nbrRows.ToString() + " households were marked as inactive.", "Mark Households Inactive Results", MessageBoxButtons.OK, MessageBoxIcon.Information); needToRefresh = true; } this.Hide(); }
private void btnSave_Click(object sender, EventArgs e) { string checkState = "0"; if (chkCSFP.Checked == true) { checkState = "1"; } string updateIDs = getHhMUpdateIds(); if (updateIDs != "") { int nbrRows = CCFBGlobal.executeQuery("Update HouseholdMembers Set CSFPExpiration =' " + dtpExpDate.Value.ToString() + "', CSFP = " + checkState + " Where ID IN (" + updateIDs + ")"); MessageBox.Show("The CSFP Expiration date on " + nbrRows.ToString() + " CSFP Clients has been changed to [" + dtpExpDate.Value.ToString() + "]" , "CSFP Expiration Date Change", MessageBoxButtons.OK, MessageBoxIcon.Information); } changeGroupBoxVisibility(0); refreshdgvCSFP(); }
private void tsbMarkStatus_Click(object sender, EventArgs e) { ToolStripButton btn = (ToolStripButton)sender; string newStatus = btn.Tag.ToString(); string updateIDs = getHhMUpdateIds(); if (updateIDs != "") { int nbrRows = CCFBGlobal.executeQuery("Update Householdmembers Set CSFPStatus=" + newStatus + ", Modified='" + DateTime.Now.ToString() + "', " + "ModifiedBy='" + CCFBGlobal.dbUserName + "' " + "Where ID in (" + updateIDs + ")"); MessageBox.Show("The CSFPStatus on " + nbrRows.ToString() + " CSFP Clients has been changed to [" + btn.Text.Replace("Mark", "") + "]" , "CSFP Status Change", MessageBoxButtons.OK, MessageBoxIcon.Information); refreshdgvCSFP(); } else { MessageBox.Show("No CSFP Clients are selected", "Change CSFP Status", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
} // end of grid_CellBeginEdit //----------------------------------------------------------------------------------------- /// <summary> /// Detect the DELETE button and delete the row from the grid and the database. Re-order /// the Sort Order values and decrement the values that are greater than the one deleted. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> //----------------------------------------------------------------------------------------- private void grid_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 4) { int row = CurrentRow; // Current row in the grid. // string sortOrder; // Sort Order value temp (used for renumbering). string sortOrderDeleted; // Sort order value of the deleted row. string typeCodeName; // The "Type" field from the DB. int NbrRows = 0; DialogResult retValue; //if (gridTypeCodes[e.ColumnIndex,e.RowIndex].ValueType switch (gridTypeCodes[e.ColumnIndex, e.RowIndex].Value.ToString()) { case BTN_TEXT_DELETE: typeCodeName = gridTypeCodes[COLUMN_GRID_TYPE, row].FormattedValue.ToString(); NbrRows = AreTypeCodesUsed(); if (NbrRows > 0) { retValue = MessageBox.Show("The type code '" + typeCodeName + "' has " + NbrRows.ToString() + " entries int the database. \r\n" + "Deleting this code will cause errors in the system.\r\n" + "Press Yes to delete anyway.\r\n" + "Press No to be prompted for a replacement code.\r\n" + "Press Cancel to skip the delete process." , "Delete Type Code Warning" , MessageBoxButtons.YesNoCancel , MessageBoxIcon.Question , MessageBoxDefaultButton.Button2); switch (retValue) { case DialogResult.Yes: //Delete anyway { break; } case DialogResult.No: //Prompt for new id { TypeCodeChangeForm frmChangeTypeCode = new TypeCodeChangeForm(TableName, Convert.ToInt32(gridTypeCodes.CurrentRow.Cells[0].Value)); frmChangeTypeCode.ShowDialog(); if (frmChangeTypeCode.Canceled == false) { CCFBGlobal.executeQuery("Update " + m_updatetypeCodeFields[cboTypeCodes_TableName.SelectedIndex] .Replace("xxx", frmChangeTypeCode.SelectedID.ToString()) + gridTypeCodes.CurrentRow.Cells[0].Value.ToString()); } return; } case DialogResult.Cancel: //Do nothing { return; } } } sortOrderDeleted = gridTypeCodes[COLUMN_GRID_SORT_ORDER, row].FormattedValue.ToString(); if (DialogResult.OK == MessageBox.Show( "Delete the \"" + typeCodeName + "\" Type Code?\r\n" + "Are you sure?", "Delete Type Code", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { // gridTypeCodes.Rows.RemoveAt (row); // Remove the current line from grid. string uid = gridTypeCodes[COLUMN_GRID_ID, e.RowIndex].Value.ToString(); if (CCFBGlobal.executeQuery("DELETE FROM " + TableName + " WHERE ID = " + uid) < 1) { MessageBox.Show("Deletion Failed"); } else { if (m_dataChanged == true) { Save(); } refreshFromDB(); m_dataChanged = false; } } break; case BTN_TEXT_UNDELETE: gridTypeCodes[COLUMN_GRID_BUTTON, row].Value = BTN_TEXT_DELETE; break; default: return; } // end of switch } } // end of grid_CellClick
public void updateField(string id, string fldname, int datavalue) { CCFBGlobal.executeQuery("UPDATE " + tblName + " SET " + fldname + " = " + datavalue.ToString() + " WHERE PlanID = " + id); }