Exemplo n.º 1
0
        private void setRelatedData()
        {
            Double lnContOSLoansRatio;

            if (lbAddFlag || lbEdit)
            {
                return;
            }
            if (DEALERcomboBox.Text.ToString().TrimEnd().Length > 0)
            {
                iacDataSet.DEALER.Clear();
                iacDataSet.DEALHIST.Clear();
                dEALERTableAdapter.Fill(iacDataSet.DEALER, DEALERcomboBox.Text.ToString().TrimEnd());
                if (iacDataSet.DEALER.Rows.Count > 0)
                {
                    dEALHISTTableAdapter.FillAllByDealerAcc(iacDataSet.DEALHIST, DEALERcomboBox.Text.ToString().TrimEnd());
                    lnContOSLoansRatio = 0;
                    if (iacDataSet.DEALER.Rows[0].Field <Nullable <Decimal> >("DEALER_YTD_OLOAN") != null)
                    {
                        if (iacDataSet.DEALER.Rows[0].Field <Decimal>("DEALER_YTD_OLOAN") != 0)
                        {
                            lnContOSLoansRatio = Convert.ToDouble(iacDataSet.DEALER.Rows[0].Field <Decimal>("DEALER_YTD_CONT") / iacDataSet.DEALER.Rows[0].Field <Decimal>("DEALER_YTD_OLOAN"));
                        }
                    }
                    ResperOSLoanstextBox.Text  = (lnContOSLoansRatio != 0) ? lnContOSLoansRatio.ToString("P", new System.Globalization.CultureInfo("en-US")):"";
                    ResperOSLoanstextBox2.Text = ResperOSLoanstextBox.Text;
                    dLRLISTBYNUMTableAdapter.Fill(iacDataSet.DLRLISTBYNUM);
                    dEALERLISTTableAdapter.FillAll(iacDataSet.DEALERLIST);
                    DEALERcomboBox.Text = (Program.gsKey != null) ? Program.gsKey : "";
                    //DealerListbindingSource.Position = DealerListbindingSource.Find("DEALER_ACC_NO", (object)DEALERcomboBox.Text);
                }
                else
                {
                    var ldlgAnswer = MessageBox.Show("Sorry no dealer found that matches your selected dealer number! Would you like to add a new record?", "Add New Prompt", MessageBoxButtons.YesNo);
                    if (ldlgAnswer == DialogResult.No)
                    {
                        DealerNamecomboBox.Text = "";
                        ActiveControl           = DealerNamecomboBox;
                        DealerNamecomboBox.SelectAll();
                    }
                    else
                    {
                        lbAddFlag = true;
                        iacDataSet.DEALER.Clear();
                        DealerbindingSource.AddNew();
                        DealerbindingSource.EndEdit();

                        // Set NULL VALUES to empty string
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("DEALER_ACC_NO", DEALERcomboBox.Text);
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("DEALER_STATUS", "A");
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <DateTime>("DEALER_POST_DATE", DateTime.Now.Date);
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <DateTime>("DealerStartDate", DateTime.Now.Date);
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("CellPhone", "");
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("DEALER_NAME", "");
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("DEALER_ADDR", "");
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("DEALER_HOME_PHONE", "");
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("DEALER_CITY", "");
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("DEALER_ST", "");
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("DEALER_WORK_PHONE", "");
                        iacDataSet.DEALER.Rows[DealerbindingSource.Position].SetField <String>("DEALER_ZIP", "");

                        DealerNamecomboBox.Enabled = false;
                        nullableDateTimePickerDealerStartDate.Enabled = true;
                        DEALER_STREETTextBox.Enabled   = true;
                        DealerCityTextBox.Enabled      = true;
                        DealerStateTextBox.Enabled     = true;
                        DealerZipTextBox.Enabled       = true;
                        DealerHomePhoneTextBox.Enabled = true;
                        maskedTextBoxCellPhone.Enabled = true;
                        DEALERWorkPhoneTextBox.Enabled = true;
                        textBoxDealerEmail.Enabled     = true;
                        dEALER_NAMETextBox.Enabled     = true;
                        toolStripButtonEdit.Enabled    = false;
                        DEALERcomboBox.Enabled         = false;
                        DealerNamecomboBox.Enabled     = false;
                        ActiveControl = dEALER_NAMETextBox;
                        dEALER_NAMETextBox.SelectAll();
                    }
                }
            }
        }
Exemplo n.º 2
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();
                    }
                }
            }
        }