private bool move() { if (contactNewRowRec == true) { MessageBox.Show("Please save or delete the new record being added in the grid on the Contacts tab before attempting to navigate to another record."); return(false); } GridViewOper.CloseEditor(); TextEditCode.Focus(); //bindingNavigatorPositionItem.Focus();//trigger field leave event temp = newRec; if (checkForms()) { errorProvider1.Clear(); if (!temp) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( OPERATOR)OperatorBindingSource.Current); } setReadOnly(true); newRec = false; modified = false; return(true); } return(false); }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { if (OperatorBindingSource.Current == null) { OperatorBindingSource.DataSource = from opt in context.OPERATOR where opt.CODE == "KJM9" select opt; OperatorBindingSource.AddNew(); TextEditCode.Focus(); setReadOnly(false); setValues(); newRec = true; return; } TextEditCode.Focus(); //bindingNavigatorPositionItem.Focus(); //trigger field leave event GridViewOper.CloseEditor(); temp = newRec; if (checkForms()) { errorProvider1.Clear(); if (!temp) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, ( OPERATOR)OperatorBindingSource.Current); } OperatorBindingSource.AddNew(); TextEditCode.Focus(); setReadOnly(false); setValues(); newRec = true; } }
private void oPERATORBindingNavigatorSaveItem_Click(object sender, EventArgs e) { TextEditCode.Focus(); int contactID = 0; if (OperatorBindingSource.Current == null) { return; } GridViewOper.CloseEditor(); if (GridViewAdditionalContacts.RowCount > 0) { contactID = (int)GridViewAdditionalContacts.GetFocusedRowCellValue("ID"); } bool temp = newRec; if (checkForms()) { contactNewRowRec = false; errorProvider1.Clear(); setReadOnly(true); if (contactID == int.MaxValue) { int newID = (int)GridViewAdditionalContacts.GetFocusedRowCellValue("ID"); var values1 = from rec in context.RPTTYPE where rec.RecipientType == "Operator" select new { rec.CODE }; foreach (var result in values1) { if (globalRptType.Contains(result.CODE)) { RptContact lol = new RptContact(); lol.Code = TextEditCode.Text; lol.RptType = result.CODE; lol.Contact_ID = newID; context.RptContact.AddObject(lol); } } globalRptType = string.Empty; context.SaveChanges(); } contactNewRowRec = false; panelControlStatus.Visible = true; LabelStatus.Text = "Record Saved"; rowStatusSave = new Timer(); rowStatusSave.Interval = 3000; rowStatusSave.Start(); rowStatusSave.Tick += TimedEventSave; } if (!temp && !modified) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, (OPERATOR)OperatorBindingSource.Current); } }
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e) { if (OperatorBindingSource.Current == null) { return; } GridViewOper.CloseEditor(); if (MessageBox.Show("Are you sure you want to delete?", "CONFIRM", MessageBoxButtons.YesNo) == DialogResult.Yes) { modified = false; newRec = false; IEnumerable <CONTACT> contactRecs = from contact in context.CONTACT where contact.LINK_VALUE == TextEditCode.Text select contact; foreach (CONTACT rec in contactRecs) { context.DeleteObject(rec); } IEnumerable <RptContact> rptContactRecs = from contact in context.RptContact where contact.Code == TextEditCode.Text select contact; foreach (RptContact rec in rptContactRecs) { context.DeleteObject(rec); } OperatorBindingSource.RemoveCurrent(); errorProvider1.Clear(); context.SaveChanges(); setReadOnly(true); panelControlStatus.Visible = true; LabelStatus.Text = "Record Deleted"; rowStatusDelete = new Timer(); rowStatusDelete.Interval = 3000; rowStatusDelete.Start(); rowStatusDelete.Tick += new EventHandler(TimedEventDelete); } TextEditCode.Focus(); currentVal = TextEditCode.Text; modified = false; newRec = false; }