Exemplo n.º 1
0
 /// <summary>
 /// A specialist version  to reload data WITHOUT changing global version
 /// </summary>
 /// <returns></returns>
 public static BankCollection LoadBankTest(BankCollection temp)
 {
     try
     {
         for (int i = 0; i < dtBank.Rows.Count; i++)
         {
             temp.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]),
             });
         }
     }
     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
     {
         Console.WriteLine($"BANK : Completed load into Bankcollection :  {temp . Count} records loaded successfully ....");
     }
     return(temp);
 }
        public async static Task <bool> LoadBankCollection( )
        {
            int count = 0;

            Console.WriteLine($"Entered LoadBankCollection in Bankcollection ....");
            try
            {
                for (int i = 0; i < dtBank.Rows.Count; i++)
                {
                    Bankcollection.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($"SQL Error in BankCollection load function : {ex . Message}, {ex . Data}");
            }
            finally
            {
                Console.WriteLine($"Completed load into Bankcollection :  {Bankcollection . Count} records in Bankcollection ....");
            }
            return(true);
        }
Exemplo n.º 3
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);
        }