Пример #1
0
        private async void InitialScreenSetup()
        {
            dbTransaction = DbTransaction.GetInstance();

            workLog = await dbTransaction.GetLatestWorkLog();

            if (workLog == null)
            {
                lblWorkStartTime.Text = "";
                workLog = new WorkLog();
                WorkStopState();
            }
            else
            {
                lblWorkStartTime.Text = workLog.StartTime?.ToString("hh:mm:ss");
                WorkStartState();
            }

            breakLog = await dbTransaction.GetLatestBreakLog();

            if (breakLog == null)
            {
                lblBreakStartTime.Text = "";
                breakLog = new BreakLog();
                BreakStopState();
            }
            else
            {
                lblBreakStartTime.Text = breakLog.StartTime?.ToString("hh:mm:ss");
                BreakStartState();
            }
        }
Пример #2
0
        private async void OnSearch(object sender, EventArgs e)
        {
            DbTransaction   dbTransaction = DbTransaction.GetInstance();
            List <Register> allRegisters  = await dbTransaction.GetRegisters();

            List <Register> filteredRegisters = GetFilteredRegisters(allRegisters);

            registerDataGrid.RowDefinitions = new RowDefinitionCollection();
            registerDataGrid.Children.Clear();
            for (int i = 0; i < filteredRegisters.Count; i++)
            {
                registerDataGrid.RowDefinitions.Add(new RowDefinition());
                registerDataGrid.Children.Add(new Label {
                    BackgroundColor = Color.White, Text = filteredRegisters[i].TransactionDate.ToString("dd/MM/yyyy")
                }, 0, i);
                registerDataGrid.Children.Add(new Label {
                    BackgroundColor = Color.White, Text = filteredRegisters[i].BillNo
                }, 1, i);
                registerDataGrid.Children.Add(new Label {
                    BackgroundColor = Color.White, Text = filteredRegisters[i].PartyName
                }, 2, i);
                registerDataGrid.Children.Add(new Label {
                    BackgroundColor = Color.White, Text = filteredRegisters[i].City
                }, 3, i);
                registerDataGrid.Children.Add(new Label {
                    BackgroundColor = Color.White, Text = filteredRegisters[i].Amount
                }, 4, i);
            }
        }
Пример #3
0
 public SearchPartyPage(string title, bool isSearch = true, PartyType?partyType = null) : this()
 {
     Title         = title;
     _isFromSearch = isSearch;
     _partyType    = partyType;
     dbTransaction = DbTransaction.GetInstance();
 }
Пример #4
0
        private async void OnTransactionsSearch(object sender, EventArgs e)
        {
            DbTransaction      dbTransaction = DbTransaction.GetInstance();
            List <Transaction> transactions  = await dbTransaction.GetTransactions();

            await DisplayAlert("Good", $"Transactions count: {transactions.Count}", "OK");
        }
Пример #5
0
        public ItemCreatePage(string title, Item item = null) : this()
        {
            this.Title = title;

            this._item = item ?? new Item();

            BindingContext = _item;

            dbTransaction = DbTransaction.GetInstance();
        }
Пример #6
0
        public PartyCreatePage(string title, Party party = null) : this()
        {
            partTypeList = Enum.GetValues(typeof(PartyType));

            LoadValuesInPicker();

            Title  = title;
            _party = party ?? new Party();

            BindingContext = _party;

            dbTransaction = DbTransaction.GetInstance();
        }
Пример #7
0
        private async void OnSave(object sender, EventArgs e)
        {
            string billNo = await Utils.GetBillNo(_party.PartyType);

            List <Transaction> transactions = new List <Transaction>();
            int gridRowCount = itemList.Children.Select(c => Grid.GetRow(c)).Max();


            for (int i = 1; i <= gridRowCount; i++)
            {
                var itemNameLabel = itemList.Children.Where(c => Grid.GetRow(c) == i && Grid.GetColumn(c) == 0).FirstOrDefault() as Label;
                if (string.IsNullOrWhiteSpace(itemNameLabel.Text))
                {
                    continue;
                }

                var qtyEntry = itemList.Children.Where(c => Grid.GetRow(c) == i && Grid.GetColumn(c) == 1).FirstOrDefault() as Entry;
                if (string.IsNullOrWhiteSpace(qtyEntry.Text))
                {
                    await DisplayAlert("Error", "Qty is required", "OK");

                    return;
                }

                var mrpEntry = itemList.Children.Where(c => Grid.GetRow(c) == i && Grid.GetColumn(c) == 2).FirstOrDefault() as Entry;
                if (string.IsNullOrWhiteSpace(mrpEntry.Text))
                {
                    mrpEntry.Text = "0";
                }

                var amountEntry = itemList.Children.Where(c => Grid.GetRow(c) == i && Grid.GetColumn(c) == 3).FirstOrDefault() as Entry;

                if (string.IsNullOrWhiteSpace(amountEntry.Text))
                {
                    amountEntry.Text = "0";
                }

                transactions.Add(new Transaction
                {
                    BillNo          = billNo,
                    TransactionType = Utils.GetTransactionType(_party.PartyType),
                    PartyName       = _party.PartyName,
                    PartyType       = _party.PartyType,
                    City            = _party.City,
                    ItemName        = itemNameLabel.Text,
                    Qty             = qtyEntry.Text,
                    MRP             = mrpEntry.Text,
                    Amount          = amountEntry.Text,
                    CreatedDate     = DateTime.Now
                });
            }

            DbTransaction dbTransaction = DbTransaction.GetInstance();

            dbTransaction.InsertAllAsync(transactions);

            Register register = new Register
            {
                BillNo          = billNo,
                TransactionDate = DateTime.Now,
                PartyName       = _party.PartyName,
                City            = _party.City,
                TransactionType = Utils.GetTransactionType(_party.PartyType),
                Amount          = transactions.Sum(t => Utils.ToDecimal(t.Amount)).ToString()
            };

            dbTransaction.InsertAsync(register);

            await DisplayAlert("Success", $"Bill No: {billNo} generated", "OK");

            OnClear(null, null);
        }
Пример #8
0
 public SearchItemPage(string title, bool isSearch = true) : this()
 {
     Title         = title;
     _isFromSearch = isSearch;
     dbTransaction = DbTransaction.GetInstance();
 }