Пример #1
0
 private void toolStripButtonCancel_Click(object sender, EventArgs e)
 {
     lbAdd  = false;
     lbEdit = false;
     toolStripButtonCancel.Visible = false;
     toolStripButtonCancel.Enabled = false;
     if (CONTINGiacDataSet.CONTING.Rows.Count > 1 && CONTINGbindingSource.Position != -1)
     {
         CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].CancelEdit();
         CONTINGbindingSource.RemoveCurrent();
         CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].AcceptChanges();
     }
     if (CONTINGiacDataSet.CONTING.Rows.Count > 0)
     {
         CONTINGiacDataSet.CONTING.Clear();
     }
     else
     {
         DEALERcomboBox.Text = "";
     }
     DealerNamecomboBox.Text = "";
     DefaultSettings();
     setRelatedData();
     ActiveControl = dateTimePickerPostDate;
     dateTimePickerPostDate.Select();
     if (CONTINGiacDataSet.CONTING.Rows.Count > 0)
     {
         CONTINGbindingSource.MoveLast();
         CONTINGbindingSource.MoveFirst();
     }
     toolStripButtonAdd.Enabled    = true;
     toolStripButtonEdit.Enabled   = true;
     toolStripButtonDelete.Enabled = true;
     toolStripButtonSave.Enabled   = false;
     bindingNavigator.Enabled      = true;
     bindingNavigator.Visible      = true;
     Text = "Closed Dealer Contingents (VIEW Mode)";
 }
Пример #2
0
        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();
            }
        }
Пример #3
0
        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();
                }
            }
        }
Пример #4
0
        private void DEALERcomboBox_Validated(object sender, EventArgs e)
        {
            if (lbFormClosing || DEALERcomboBox.Text.TrimEnd() == "")
            {
                return;
            }

            int lnContingentPos = 0, lnSeq = 0;

            Object loContingentSeq = null;

            String lsDealerNo = "";

            if (DEALERcomboBox.Text.ToString().Trim().Length < 3 && DEALERcomboBox.Text.ToString().Trim().Length > 0)
            {
                lbFromDealerNameChange = true;
                DEALERcomboBox.Text    = DEALERcomboBox.Text.PadLeft(3, '0');
            }

            lsDealerNo = DEALERcomboBox.Text;
            if (!lbEdit)
            {
                setRelatedData();
            }
            if (CONTINGiacDataSet.CONTING.Rows.Count != 0)
            {
                if (CONTINGbindingSource.Position == -1)
                {
                    lnContingentPos = CONTINGbindingSource.Find("CONTING_DEALER", lsDealerNo);
                }
                else
                {
                    lnContingentPos = CONTINGbindingSource.Position;
                }
                if (lnContingentPos > -1)
                {
                    if (lbAdd)
                    {
                        return;
                    }
                    else
                    {
                        CONTINGbindingSource.Position = lnContingentPos;
                    }
                }
                else
                {
                    if (!lbAdd)
                    {
                        lsDealerNo = CONTINGiacDataSet.CONTING.Rows[0].Field <String>("CONTINGENT_DEALER");
                        CONTINGbindingSource.MoveFirst();
                    }
                }
            }
            else
            {
                if (!lbAdd)
                {
                    return;
                }
            }

            if (CONTINGiacDataSet.DEALER.Rows.Count == 0 && DEALERcomboBox.Text.TrimEnd().Length != 0)
            {
                MessageBox.Show("Sorry no dealer found that matches your selected dealer number!");
                DEALERcomboBox.Text     = "";
                DealerNamecomboBox.Text = "";
                ActiveControl           = DealerNamecomboBox;
                DealerNamecomboBox.SelectAll();
            }
            else
            {
                if (lbEdit)
                {
                    if (CONTINGiacDataSet.CONTING.Rows.Count == 0)
                    {
                        MessageBox.Show("Sorry no contingent records found that match your selected dealer number!");
                        ActiveControl = DEALERcomboBox;
                        DEALERcomboBox.Select();
                    }
                }
                if (lbAdd && DEALERcomboBox.Text.ToString().TrimEnd() != "")
                {
                    CONTINGbindingSource.AddNew();
                    CONTINGbindingSource.EndEdit();

                    CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].SetField <String>("CONTING_DEALER", DEALERcomboBox.Text.ToString());
                    CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].SetField <DateTime>("CONTING_POST_DATE", DateTime.Now.Date);
                    loContingentSeq = cONTINGTableAdapter.MaxSeqQuery(DEALERcomboBox.Text.ToString(), DateTime.Now.Date);
                    if (loContingentSeq != null)
                    {
                        lnSeq = (int)loContingentSeq + 1;
                    }
                    else
                    {
                        lnSeq = 0;   //Closed and Open contingents start with 0 for first sequence number
                    }
                    CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].SetField <Int32>("CONTING_ENTRY_SEQ", lnSeq);
                    CONTINGiacDataSet.CONTING.Rows[CONTINGbindingSource.Position].SetField <Char>("CONTING_POST_IND", (Char)(255));
                    if (CONTINGiacDataSet.CONTING.Rows.Count != 0)
                    {
                        toolStripButtonSave.Enabled = true;
                    }
                }
                if (CONTINGiacDataSet.DEALER.Rows.Count > 0 && !lbAdd)
                {
                    //DealerNamecomboBox.Text = CONTINGiacDataSet.DEALER.Rows[0].Field<String>("DEALER_NAME");
                    if (lbAdd || lbEdit)
                    {
                        dateTimePickerPostDate.Enabled = true;
                        ActiveControl = dateTimePickerPostDate;
                        dateTimePickerPostDate.Select();
                    }
                }
            }
        }