public expences()
        {
            InitializeComponent();
            //var db = new dbctx();
            //financeaccounts = db.financeaccount.ToList();
            var financeaccountrepo     = new data.dapper.financeaccountrepo();
            var financetransactionrepo = new data.dapper.financetransactionrepo();

            financeaccounts = financeaccountrepo.get();
            //var list = db.financetransaction.Where(a => (a.financeaccount.type == "expence")).ToList();
            var list = financetransactionrepo.getmanybyfinanceaccounttype("expence");

            foreach (var item in list)
            {
                dg.Items.Add(item);
            }
            var assetaccounts = financeaccounts.Where(a => a.type == "asset").ToList();

            payingaccount_combobox.ItemsSource       = assetaccounts;
            payingaccount_combobox.DisplayMemberPath = "name";
            payingaccount_combobox.SelectedValuePath = "id";
            var expenceaccounts = financeaccounts.Where(a => a.type == "expence").ToList();

            expenceaccount_combobox.ItemsSource       = expenceaccounts;
            expenceaccount_combobox.DisplayMemberPath = "name";
            expenceaccount_combobox.SelectedValuePath = "id";
        }
        public ledger(int userid)
        {
            InitializeComponent();

            var financeaccountrepo     = new data.dapper.financeaccountrepo();
            var financetransactionrepo = new data.dapper.financetransactionrepo();
            var userrepo = new data.dapper.userrepo();

            financeaccounts = financeaccountrepo.get();
            user            = userrepo.get(userid);
            var list = financetransactionrepo.getusertransactions(userid);

            foreach (var item in list)
            {
                dg.Items.Add(item);
            }

            var totalpending = 0;

            if (user.role == "customer")
            {
                totalpending = financetransactionrepo.getuserreceiveablessum(userid);
            }
            else if (user.role == "vendor")
            {
                totalpending = financetransactionrepo.getuserpayablesum(userid);
            }
            remaining_label.Content = totalpending;
            var assetaccounts = financeaccountrepo.getmanybytype("asset");

            account_combobox.ItemsSource       = assetaccounts;
            account_combobox.DisplayMemberPath = "name";
            account_combobox.SelectedValuePath = "id";
        }
        public transactions()
        {
            InitializeComponent();
            var financeaccountrepo     = new data.dapper.financeaccountrepo();
            var financetransactionrepo = new data.dapper.financetransactionrepo();
            var financetransactions    = financetransactionrepo.get();

            financeaccounts = financeaccountrepo.get();
            //var db = new dbctx();
            foreach (var item in financetransactions)
            {
                dg.Items.Add(item);
            }

            //var allaccount = db.financeaccount.ToList();
            fromaccount_combobox.ItemsSource       = financeaccounts;
            fromaccount_combobox.DisplayMemberPath = "name";
            fromaccount_combobox.SelectedValuePath = "id";

            toaccount_combobox.ItemsSource       = financeaccounts;
            toaccount_combobox.DisplayMemberPath = "name";
            toaccount_combobox.SelectedValuePath = "id";
        }
        public salespurchases(string type)
        {
            InitializeComponent();
            listtype = type;
            var financeaccountrepo     = new data.dapper.financeaccountrepo();
            var financetransactionrepo = new data.dapper.financetransactionrepo();

            financeaccounts = financeaccountrepo.get();

            List <financetransactionextended> list = new List <financetransactionextended>();

            if (type == "sale")
            {
                list = financetransactionrepo.getmanybymanyfinanceaccountnames(new string[] { "pos sale", "sale", "service sale" });
            }
            else if (type == "purchase")
            {
                list = financetransactionrepo.getmanybyselfnameandfinanceaccountname("--inventory--on--purchase--", "inventory");
            }
            foreach (var item in list)
            {
                dg.Items.Add(item);
            }
        }