private void FillRecord(INVT dest, INVT source, DateTime date) { dest.DATE = date; dest.TYPE = source.TYPE; dest.CODE = source.CODE; dest.CAT = source.CAT; dest.TP = source.TP; dest.UPD_DATE = source.UPD_DATE; dest.UPD_BY = source.UPD_BY; dest.ORIG_AMT = source.ORIG_AMT; dest.AV_AMT = source.AV_AMT; dest.AV = source.AV; dest.MIN = source.MIN; dest.CANC = source.CANC; dest.REL = source.REL; dest.AGENCY = source.AGENCY; dest.RELCODE = source.RELCODE; dest.RELCAT = source.RELCAT; dest.RELTYP = source.RELTYP; dest.RELAGY = source.RELAGY; dest.ALLOCTD = source.ALLOCTD; dest.HOLD = source.HOLD; dest.MIN_BK_DAYS = source.MIN_BK_DAYS; dest.MAX = source.MAX; dest.Requestable = source.Requestable; dest.StartNumberRange = source.StartNumberRange; dest.EndNumberRange = source.EndNumberRange; dest.Time = source.Time; dest.SpecialValue_Code = source.SpecialValue_Code; }
private bool SaveContext(INVT rec, DateTime date) { try { _context.SaveChanges(); return(true); } catch (UpdateException) { _context.INVT.DeleteObject(rec); if (CheckEditSkip.Checked) { return(true); } if (CheckEditOverwrite.Checked) { INVT existing = _context.INVT.First(i => i.TYPE == _selectedRecord.TYPE && i.CODE == _selectedRecord.CODE && i.AGENCY == _selectedRecord.AGENCY && i.CAT == _selectedRecord.CAT && i.TP == _selectedRecord.TP && i.DATE == date); FillRecord(existing, _selectedRecord, date); try { _context.SaveChanges(); } catch (Exception ex) { this.DisplayError(ex); return(false); } return(true); } this.DisplayError("Records were found with the same values as the values being built. Build has been cancelled."); return(false); } catch (Exception ex) { this.DisplayError(ex); return(false); } }
private INVT CreateFilledRecord(INVT source, DateTime date) { INVT invt = new INVT(); FillRecord(invt, source, date); _context.INVT.AddObject(invt); return(invt); }
private bool IsModified(INVT record) { //Type-specific routine that takes into account relationships that should also be considered //when deciding if there are unsaved changes. The entity properties also return true if the //record is new or deleted. if (record == null) { return(false); } return(record.IsModified(_context)); }
void ClearBindings() { _ignoreLeaveRow = true; _ignorePositionChange = true; _selectedRecord = null; SetReadOnly(true); BarButtonItemDelete.Enabled = false; BarButtonItemSave.Enabled = false; BindingSource.DataSource = typeof(INVT); _ignoreLeaveRow = false; _ignorePositionChange = false; }
void SetBindings() { if (BindingSource.Current == null) { ClearBindings(); } else { _selectedRecord = ((INVT)BindingSource.Current); SetReadOnly(false); SetReadOnlyKeyFields(true); BarButtonItemDelete.Enabled = true; BarButtonItemSave.Enabled = true; } ErrorProvider.Clear(); }
private void BarButtonItemNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (BarToggleSwitchItemBuild.Checked) { _ignoreLeaveRow = true; _ignorePositionChange = true; BindingSource.Remove(_selectedRecord); _selectedRecord = (INVT)BindingSource.AddNew(); //set _selectedRecord here because SetBindings will not be called _ignorePositionChange = false; _ignoreLeaveRow = false; ErrorProvider.Clear(); } else { CreateNewRecord(); } }
private void GridViewLookup_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { if (!_ignoreLeaveRow) { GridView view = (GridView)sender; object row = view.GetRow(e.FocusedRowHandle); if (row != null && row.GetType() != typeof(DevExpress.Data.NotLoadedObject)) { ReadonlyThreadSafeProxyForObjectFromAnotherThread proxy = (ReadonlyThreadSafeProxyForObjectFromAnotherThread)view.GetRow(e.FocusedRowHandle); INVT record = (INVT)proxy.OriginalRow; BindingSource.DataSource = _context.INVT.Where(c => c.CODE == record.CODE); } else { ClearBindings(); } } }
private void PurgeButton_Click(object sender, EventArgs e) { if (gridView1.SelectedRowsCount == 0) { MessageBox.Show("Please select at least one row before attempting to purge records."); return; } List <int> values = new List <int>(); foreach (int val in gridView1.GetSelectedRows()) { values.Add((int)gridView1.GetRowCellValue(val, "ID")); } foreach (int ID in values) { INVT rec = (from hratRec in context.INVT where hratRec.ID == ID select hratRec).FirstOrDefault(); context.INVT.DeleteObject(rec); context.SaveChanges(); } }
public bool BuildRecords() { int days = 0; DateTime date; SetUpdateFields(_selectedRecord); do { INVT newRec = null; date = DateEditBuildFrom.DateTime.AddDays(days); if (int.TryParse(ComboBoxEditBuildEvery.Text, out int everyDays)) { if (days == everyDays) { int buildDays = 0; do { //Build the specified number of days while build days is less than the value of SpinEditBuildDays date = DateEditBuildFrom.DateTime.AddDays(days); newRec = CreateFilledRecord(_selectedRecord, date); if (!SaveContext(newRec, date)) { return(false); } buildDays++; days++; } while (buildDays < (int)SpinEditBuildDays.Value); } } else if (Enum.TryParse(ComboBoxEditBuildEvery.Text, out DayOfWeek dayOfWeek)) //If the "build every" field is a day of the week { if (date.DayOfWeek == dayOfWeek) //If the current date is the same day of the week as the "build every" day of the week { int buildDays = 0; do //Build the specified number of days while build days is less than the value of SpinEditBuildDays { date = DateEditBuildFrom.DateTime.AddDays(days); newRec = CreateFilledRecord(_selectedRecord, date); if (!SaveContext(newRec, date)) { return(false); } buildDays++; days++; } while (buildDays < (int)SpinEditBuildDays.Value); } else { days++; } } else { newRec = CreateFilledRecord(_selectedRecord, date); if (!SaveContext(newRec, date)) { return(false); } days++; } } while (date < DateEditBuildThrough.DateTime); ShowActionConfirmation("Records built"); return(true); }
private void SetUpdateFields(INVT record) { record.UPD_DATE = DateTime.Now; record.UPD_BY = _sys.User.Name; }