private void InitializeConsts() { SQLiteDatabase db = new SQLiteDatabase(); string fundQuery = "Select * from FundType"; AppGlobalData.lifundTypes = db.GetDataList <FundTypes>(fundQuery); FillComboBox <FundTypes>(cbFundType, AppGlobalData.lifundTypes, "FundType", "FundType"); string TxnQuery = "Select * from TransactionType"; AppGlobalData.liTxnTypes = db.GetDataList <TransactionType>(TxnQuery); FillComboBox <TransactionType>(cbByType, AppGlobalData.liTxnTypes, "TxnType", "TxnType"); }
private void LoadData() { try { LoadSearchDonData();; return; if (dtDonFrom.Text == "" || dtDonTo.Text == "") { return; } string dtfrom = Convert.ToDateTime(dtDonFrom.Text).ToSqlLiteDatetime(); string dtto = Convert.ToDateTime(dtDonTo.Text + " 23:59:59").ToSqlLiteDatetime(); splDonCommands.Visibility = Visibility.Visible; SQLiteDatabase db = new SQLiteDatabase(); // string expenseQuery = "Select * from Donations ORDER BY Created DESC LiMIT 1000"; // DataTable dtd = db.GetDataTable(expenseQuery); string expenseQuery = "Select * from Donations where Created BETWEEN '" + dtfrom + "' AND '" + dtto + "' " + (string.IsNullOrEmpty(txtDonSearch.Text) ? "" : "AND Name Like '%" + txtREName.Text + "%'") + " ORDER BY Created DESC Limit 1000"; List <Donation> lidon = db.GetDataList <Donation>(expenseQuery); //dtd.DataTableToList<Donation>(); grdDonations.ItemsSource = lidon; } catch (Exception) { MessageBox.Show("Please enter Valid Values", "Error"); } }
private void btnDExpExcel_Click(object sender, RoutedEventArgs e) { try { if (dpRDFrom.Text == "" || dpRDTo.Text == "") { MessageBox.Show("Please select date"); return; } string dtfrom = Convert.ToDateTime(dpRDFrom.Text).ToSqlLiteDatetime(); string dtto = Convert.ToDateTime(dpRDTo.Text + " 23:59:59").ToSqlLiteDatetime(); db = new SQLiteDatabase(); string expenseQuery = "Select * from Donations where Created BETWEEN '" + dtfrom + "' AND '" + dtto + "' " + (string.IsNullOrEmpty(txtRDName.Text) ? "" : "AND VendorName Like '%" + txtRDName.Text + "%'") + " ORDER BY Created DESC"; DataTable dtd = db.GetDataTable(expenseQuery); List <Donation> ld = db.GetDataList <Donation>(expenseQuery); List <Donation> lidon = dtd.DataTableToList <Donation>(); SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.FileName = "Donation_" + (new Random(1000)).Next(0, 1000).ToString() + ".csv"; saveFileDialog.Filter = "|*.csv"; saveFileDialog.DefaultExt = ".csv"; if (saveFileDialog.ShowDialog() == true) { Utility.CreateCSVFromGenericList <Donation>(lidon, saveFileDialog.FileName); } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
private void btnRDLoad_Click(object sender, RoutedEventArgs e) { try { if (dpRDFrom.Text == "" || dpRDTo.Text == "") { MessageBox.Show("Please select date"); return; } string dtfrom = Convert.ToDateTime(dpRDFrom.Text).ToSqlLiteDatetime(); //.ToString(dateFormat); string dtto = Convert.ToDateTime(dpRDTo.Text + " 23:59:00").ToSqlLiteDatetime(); //.ToString(dateFormat); db = new SQLiteDatabase(); string expenseQuery = "Select * from Donations where Created BETWEEN '" + dtfrom + "' AND '" + dtto + "' " + (string.IsNullOrEmpty(txtRDName.Text) ? "" : "AND Name Like '%" + txtRDName.Text + "%'") + " ORDER BY Created DESC"; // DataTable dtd = db.GetDataTable(expenseQuery); List <Donation> lidon = db.GetDataList <Donation>(expenseQuery); //dtd.DataTableToList<Donation>(); grdRepDonations.ItemsSource = lidon; string countqry = "Select Count(*) as Count,SUM(Amount) as Total from Donations where Created BETWEEN '" + dtfrom + "' AND '" + dtto + "' " + (string.IsNullOrEmpty(txtRDName.Text) ? "" : "AND Name Like '%" + txtRDName.Text + "%'"); DataTable ctd = db.GetDataTable(countqry); if (ctd.Rows.Count > 0) { lblDrows.Content = Convert.ToString(ctd.Rows[0]["Count"] != DBNull.Value ? ctd.Rows[0].Field <Int64>("Count") : 0); lblDTotal.Content = Convert.ToString(ctd.Rows[0]["Total"] != DBNull.Value ? ctd.Rows[0].Field <Int64>("Total") : 0); } else { lblDrows.Content = lblDTotal.Content = "0"; } } catch (Exception ex) { } }
private void btnMisc_Click(object sender, RoutedEventArgs e) { foreach (var x in MainGrid.Children.OfType <StackPanel>()) { x.Visibility = Visibility.Collapsed; } Misc.Visibility = Visibility.Visible; string sql = "Select * from FundType"; db = new SQLiteDatabase(); List <FundTypes> ft = db.GetDataList <FundTypes>(sql); grdFundtype.ItemsSource = ft; stpMisc.Children.Clear(); stpMisc.Visibility = Visibility.Collapsed; }