void SetPlateTypeIsDefault(PlateTypeItem pti, bool isDefault) { bool success; if (wgDB == null) { wgDB = new WaveguideDB(); } if (isDefault) // setting isDefault to true, need to set any other PlateTypeItem.PlateType.IsDefault that is true to false, so // that there's only on of them set to default { foreach (PlateTypeItem ptItem in VM.PlateTypeList) { if (ptItem.PlateType.IsDefault) { ptItem.PlateType.IsDefault = false; success = wgDB.UpdatePlateType(ptItem.PlateType); } } } // setting isDefault to false, do just have to update the PlateType pti.PlateType.IsDefault = isDefault; success = wgDB.UpdatePlateType(pti.PlateType); if (!success) { MessageBox.Show("Failed to Update PlateType", wgDB.GetLastErrorMsg(), MessageBoxButton.OK, MessageBoxImage.Error); } }
bool UpdatePlateTypeFromPlateTypeItem(PlateTypeItem pti) { PlateTypeContainer ptc = new PlateTypeContainer(); ptc.Cols = pti.Cols; ptc.Rows = pti.Rows; ptc.Description = pti.Description; ptc.IsDefault = pti.IsDefault; ptc.PlateTypeID = pti.PlateTypeID; return(wgDB.UpdatePlateType(ptc)); }
private void xamDataGrid_EditModeEnded(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndedEventArgs e) { // use this method to update a record after one of the cells of the record has been edited if (((string)e.Cell.Record.Tag) == "AddRecord") { return; // not updating the AddRecord here } PlateTypeContainer pt = (PlateTypeContainer)e.Cell.Record.DataItem; if (ValidateData(pt)) { if (pt.PlateTypeID != 0) // if PlateTypeID != 0 then we know that this PlateType is already in the database, so we can call Update { bool success = wgDB.UpdatePlateType(pt); } } }