//**************************************************************************************************************************************************************// private static async Task <bool> LoadCustomerCollection(bool Notify = true) { int count = 0; try { for (int i = 0; i < dtCust.Rows.Count; i++) { Custinternalcollection.Add(new CustomerViewModel { Id = Convert.ToInt32(dtCust.Rows [i] [0]), CustNo = dtCust.Rows [i] [1].ToString( ), BankNo = dtCust.Rows [i] [2].ToString( ), AcType = Convert.ToInt32(dtCust.Rows [i] [3]), FName = dtCust.Rows [i] [4].ToString( ), LName = dtCust.Rows [i] [5].ToString( ), Addr1 = dtCust.Rows [i] [6].ToString( ), Addr2 = dtCust.Rows [i] [7].ToString( ), Town = dtCust.Rows [i] [8].ToString( ), County = dtCust.Rows [i] [9].ToString( ), PCode = dtCust.Rows [i] [10].ToString( ), Phone = dtCust.Rows [i] [11].ToString( ), Mobile = dtCust.Rows [i] [12].ToString( ), Dob = Convert.ToDateTime(dtCust.Rows [i] [13]), ODate = Convert.ToDateTime(dtCust.Rows [i] [14]), CDate = Convert.ToDateTime(dtCust.Rows [i] [15]) }); count = i; } } catch (Exception ex) { Console.WriteLine($"CUSTOMERS : ERROR {ex . Message} + {ex . Data} ...."); MessageBox.Show($"CUSTOMERS : ERROR :\n Error was : [{ex . Message}] ...."); } if (Notify) { EventControl.TriggerCustDataLoaded(null, new LoadedEventArgs { CallerDb = "CUSTOMER", DataSource = Custinternalcollection, RowCount = Custinternalcollection.Count }); } Flags.CustCollection = Custinternalcollection; return(true); }
//**************************************************************************************************************************************************************// private static async Task <bool> LoadCustomerCollection( ) { int count = 0; for (int i = 0; i < dtCust.Rows.Count; i++) { Custcollection.Add(new CustomerViewModel { Id = Convert.ToInt32(dtCust.Rows [i] [0]), CustNo = dtCust.Rows [i] [1].ToString( ), BankNo = dtCust.Rows [i] [2].ToString( ), AcType = Convert.ToInt32(dtCust.Rows [i] [3]), FName = dtCust.Rows [i] [4].ToString( ), LName = dtCust.Rows [i] [5].ToString( ), Addr1 = dtCust.Rows [i] [6].ToString( ), Addr2 = dtCust.Rows [i] [7].ToString( ), Town = dtCust.Rows [i] [8].ToString( ), County = dtCust.Rows [i] [9].ToString( ), PCode = dtCust.Rows [i] [10].ToString( ), Phone = dtCust.Rows [i] [11].ToString( ), Mobile = dtCust.Rows [i] [12].ToString( ), Dob = Convert.ToDateTime(dtCust.Rows [i] [13]), ODate = Convert.ToDateTime(dtCust.Rows [i] [14]), CDate = Convert.ToDateTime(dtCust.Rows [i] [15]) }); count = i; } Console.WriteLine($"Sql data loaded into Customers Observable Collection \"CustCollection\"[{count}] ...."); return(true); }