private async Task <bool> SaveButton(object sender = null, RoutedEventArgs e = null)
        {
            //inprogress = true;
            //bindex = this . BankGrid . SelectedIndex;
            //cindex = this . CustomerGrid . SelectedIndex;
            //dindex = this . DetailsGrid . SelectedIndex;

            // Get the current rows data
            IsDirty = false;
            int CurrentSelection = this.BankGrid.SelectedIndex;

            this.BankGrid.SelectedItem = this.BankGrid.SelectedIndex;
            BankAccountViewModel bvm = new BankAccountViewModel();

            bvm = this.BankGrid.SelectedItem as BankAccountViewModel;

            SaveFieldData( );

            // update the current rows data content to send  to Update process
            bvm.BankNo  = Bankno.Text;
            bvm.CustNo  = Custno.Text;
            bvm.AcType  = Convert.ToInt32(acType.Text);
            bvm.Balance = Convert.ToDecimal(balance.Text);
            bvm.ODate   = Convert.ToDateTime(odate.Text);
            bvm.CDate   = Convert.ToDateTime(cdate.Text);
            // Call Handler to update ALL Db's via SQL
            SQLHandlers sqlh = new SQLHandlers();
            await sqlh.UpdateDbRow("BANKACCOUNT", bvm);

            EventControl.TriggerBankDataLoaded(BankViewercollection,
                                               new LoadedEventArgs
            {
                CallerDb   = "BANKACCOUNT",
                DataSource = BankViewercollection,
                RowCount   = this.BankGrid.SelectedIndex
            });

            //Gotta reload our data because the update clears it down totally to null
            this.BankGrid.SelectedIndex = CurrentSelection;
            this.BankGrid.SelectedItem  = CurrentSelection;
            this.BankGrid.Refresh( );

            SaveBttn.IsEnabled = false;
            return(true);
        }
Пример #2
0
        public async static Task <bool> LoadBankCollection(bool Notify = false)
        {
            int count = 0;

            try
            {
                BankCollection bc = new BankCollection( );
                for (int i = 0; i < dtBank.Rows.Count; i++)
                {
                    Bankinternalcollection.Add(new BankAccountViewModel
                    {
                        Id      = Convert.ToInt32(dtBank.Rows [i] [0]),
                        BankNo  = dtBank.Rows [i] [1].ToString( ),
                        CustNo  = dtBank.Rows [i] [2].ToString( ),
                        AcType  = Convert.ToInt32(dtBank.Rows [i] [3]),
                        Balance = Convert.ToDecimal(dtBank.Rows [i] [4]),
                        IntRate = Convert.ToDecimal(dtBank.Rows [i] [5]),
                        ODate   = Convert.ToDateTime(dtBank.Rows [i] [6]),
                        CDate   = Convert.ToDateTime(dtBank.Rows [i] [7]),
                    });
                    count = i;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"BANK : SQL Error in BankCollection load function : {ex . Message}, {ex . Data}");
                MessageBox.Show($"BANK : SQL Error in BankCollection load function : {ex . Message}, {ex . Data}");
            }
            finally
            {
                BankCollection bc = new BankCollection( );
                if (Notify)
                {
                    EventControl.TriggerBankDataLoaded(null,
                                                       new LoadedEventArgs
                    {
                        CallerDb   = "BankAccount",
                        DataSource = bc,
                        RowCount   = Bankinternalcollection.Count
                    });
                }
            }
            //			Flags . BankCollection = Bankcollection;
            return(true);
        }