private void LockContingRecord() { Object loLockedBy = cONTINGTableAdapter.LockedBy(DEALERcomboBox.Text, (DateTime)dateTimePickerPostDate.Value, CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <Int32>("CONTING_ENTRY_SEQ")), loLockedTime = cONTINGTableAdapter.LockTime(DEALERcomboBox.Text, (DateTime)dateTimePickerPostDate.Value, CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <Int32>("CONTING_ENTRY_SEQ")); if (loLockedBy != null && ((String)loLockedBy).TrimEnd() != "") { IACDataSetTableAdapters.ULISTTableAdapter ULISTTableAdapter = new IACDataSetTableAdapters.ULISTTableAdapter(); ULISTTableAdapter.FillById(CONTINGiacDataSet.ULIST, Program.gsUserID); MessageBox.Show("*** (CONTINGENT RECORD) DEALER#: " + DEALERcomboBox.Text + " POST DATE:" + dateTimePickerPostDate.Text + " SEQUENCE #: " + CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <Int32>("CONTING_ENTRY_SEQ").ToString().TrimStart() + " WAS LOCKED BY USER: "******" " + CONTINGiacDataSet.ULIST.Rows[0].Field <String>("LIST_NAME") + "\nON: " + ((DateTime)loLockedTime).ToLongDateString() + " " + ((DateTime)loLockedTime).ToLongTimeString() + "\n" + "YOU MUST WAIT UNTIL THEY RELEASE IT! ***", "RECORD LOCKED", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); toolStripButtonSave.Enabled = false; ULISTTableAdapter.Dispose(); loLockedBy = null; lbEdit = false; CONTINGiacDataSet.Clear(); StartUpConfiguration(); } else { cONTINGTableAdapter.LockRecord(Program.gsUserID, DEALERcomboBox.Text, (DateTime)dateTimePickerPostDate.Value, CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <Int32>("CONTING_ENTRY_SEQ")); lbILockedIt = true; // Make sure other instances of form don't unlock this record! } }
private void toolStripButtonDelete_Click(object sender, EventArgs e) { if (CONTINGiacDataSet.CONTING.Rows.Count < 1) { return; } String lsDealer = CONTINGiacDataSet.CONTING.Rows[0].Field <String>("CONTING_DEALER"); DateTime ldSrchDate = CONTINGiacDataSet.CONTING.Rows[0].Field <DateTime>("CONTING_POST_DATE"); Validate(); CONTINGbindingSource.EndEdit(); if (CONTINGiacDataSet.DEALER.Rows.Count == 0) { return; } tableAdapConn = new System.Data.SqlClient.SqlConnection(); tableAdapConn.ConnectionString = IAC2018SQL.Properties.Settings.Default.IAC2010SQLConnectionString; tableAdapConn.Open(); cONTINGTableAdapter.Connection = tableAdapConn; tableAdapTran = cONTINGTableAdapter.BeginTransaction(); cONTINGTableAdapter.Transaction = tableAdapTran; try { cONTINGTableAdapter.Delete(CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <String>("CONTING_DEALER"), CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <DateTime>("CONTING_POST_DATE"), CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <Int32>("CONTING_ENTRY_SEQ")); tableAdapTran.Commit(); } catch (System.Data.SqlClient.SqlException ex) { tableAdapTran.Rollback(); MessageBox.Show("This is a Microsoft SQL Server database error: " + ex.Message.ToString()); } catch (System.InvalidOperationException ex) { tableAdapTran.Rollback(); MessageBox.Show("Invalid Operation Error: " + ex.Message.ToString()); } catch (Exception ex) { tableAdapTran.Rollback(); MessageBox.Show("General Exception Error: " + ex.Message.ToString()); } finally { tableAdapConn.Close(); tableAdapConn = null; tableAdapTran = null; toolStripButtonSave.Enabled = false; CONTINGiacDataSet.AcceptChanges(); CONTINGiacDataSet.CONTING.Clear(); lbFromDealerNameChange = true; DEALERcomboBox.Text = lsDealer; dateTimePickerPostDate.Value = ldSrchDate; setRelatedData(); DefaultSettings(); ActiveControl = dateTimePickerPostDate; dateTimePickerPostDate.Select(); } }
private void toolStripButtonSave_Click(object sender, EventArgs e) { Validate(); CONTINGbindingSource.EndEdit(); if (CONTINGiacDataSet.DEALER.Rows.Count == 0) { return; } tableAdapConn = new System.Data.SqlClient.SqlConnection(); tableAdapConn.ConnectionString = IAC2018SQL.Properties.Settings.Default.IAC2010SQLConnectionString; tableAdapConn.Open(); cONTINGTableAdapter.Connection = tableAdapConn; tableAdapTran = cONTINGTableAdapter.BeginTransaction(); cONTINGTableAdapter.Transaction = tableAdapTran; try { cONTINGTableAdapter.Update(CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position]); tableAdapTran.Commit(); } catch (System.Data.SqlClient.SqlException ex) { tableAdapTran.Rollback(); MessageBox.Show("This is a Microsoft SQL Server database error: " + ex.Message.ToString()); } catch (System.InvalidOperationException ex) { tableAdapTran.Rollback(); MessageBox.Show("Invalid Operation Error: " + ex.Message.ToString()); } catch (Exception ex) { tableAdapTran.Rollback(); MessageBox.Show("General Exception Error: " + ex.Message.ToString()); } finally { cONTINGTableAdapter.UnlockRecord(Program.gsUserID, CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <String>("CONTING_DEALER"), CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <DateTime>("CONTING_POST_DATE"), CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].Field <Int32>("CONTING_ENTRY_SEQ")); tableAdapConn.Close(); tableAdapConn = null; tableAdapTran = null; toolStripButtonSave.Enabled = false; CONTINGiacDataSet.AcceptChanges(); if (lbEdit) { lbEdit = false; } if (lbAdd) { CONTINGiacDataSet.CONTING.Clear(); } StartUpConfiguration(); // Moses Newman 09/18/2013 Set dealer number as Active Control if in ADD Mode! if (!lbAdd) { ActiveControl = dateTimePickerPostDate; dateTimePickerPostDate.Select(); } else { ActiveControl = DEALERcomboBox; DEALERcomboBox.SelectAll(); } } }