Пример #1
0
        private async void getData(string _orderId)
        {
            progressBar1.Visible = true;
            string orderId = _orderId;

            if (!_orderId.Contains("PO-"))
            {
                orderId = "PO-" + _orderId;
            }

            purchaseOrder = await DatabaseOperations.getPurchaseOderByOrderId(orderId);

            if (purchaseOrder != null)
            {
                supplierNameTextBox.Text       = purchaseOrder.supplierName;
                statusTextBox.Text             = purchaseOrder.status;
                dateCreatedTextBox.Text        = purchaseOrder.dateCreated.ToString();
                deliveryDateTextBox.Text       = purchaseOrder.deliveryDate.ToString();
                grandTotalPriceTextBox.Text    = FormatPrice.format(purchaseOrder.grandTotalPrice);
                grandTotalQuantityTextBox.Text = purchaseOrder.grandTotalQuantity.ToString();

                if (purchaseOrder.productsList != null && purchaseOrder.productsList.Any())
                {
                    foreach (var data in purchaseOrder.productsList)
                    {
                        quantityOnPurchaseOrder.Add(data.quantityToSupply);
                        stocksOnPurchaseOrder.Add(await DatabaseOperations.getStockById(data.stockId));
                    }

                    updateDataGrid.addPurchaseToDataGrid(stocksOnPurchaseOrder, quantityOnPurchaseOrder, dataGridView1);
                }

                saveButton.Enabled   = true;
                addAllButton.Enabled = true;
            }
            else
            {
                MessageBox.Show("The order ref does not exist. You can check Purchases page for the correct purchase orderId");
            }
            progressBar1.Visible = false;
        }
Пример #2
0
        private async void loadDataFromDb()
        {
            DateTime dateFrom = dateTimePicker1.Value;
            DateTime dateTo   = dateTimePicker2.Value;

            if (dateFrom > dateTo)
            {
                MessageBox.Show("Invalid dates selected. ");
                return;
            }

            progressBar1.Visible = true;
            noDataLabel.Visible  = false;
            var data = await DatabaseOperations.getPurchasedStocksByDate(dateFrom, dateTo);

            decimal total_price = 0;

            if (data != null && data.Any())
            {
                List <StockDataModel> stocksList   = new List <StockDataModel>();
                List <int>            quantityList = new List <int>();
                foreach (var datum in data)
                {
                    var stocks = await DatabaseOperations.getStockById(datum.stockId);

                    total_price = datum.quantityToSupply * stocks.lastCostPrice;
                    stocksList.Add(stocks);
                    quantityList.Add(datum.quantityToSupply);
                }
                progressBar1.Visible = false;
                new UpdateDataGridView().addPurchaseToDataGrid(stocksList, quantityList, this.dataGridView1);
            }
            else
            {
                noDataLabel.Visible = true;
            }

            totalPricetextBox.Text = FormatPrice.format(total_price);
        }
Пример #3
0
        private void addproductToDatagridView()
        {
            //string productName = stockscomboBox.Text;
            int quantityToSupply = int.Parse(quantityToSupplytextBox.Text);
            var stock            = stocks.ElementAt(stockscomboBox.SelectedIndex);


            new UpdateDataGridView().addProductsToDataGridView(stock, quantityToSupply, this.dataGridView1);
            purchasedStocks.Add(new PurchaseOrderDataModel.PurchasedStock
            {
                stockId          = stock.id,
                quantityToSupply = quantityToSupply
            });


            grandTotalPrice    += getTotalPrice(quantityToSupplytextBox.Text);
            grandTotalQuantity += quantityToSupply;

            grandTotalPricetextBox.Text    = FormatPrice.format(grandTotalPrice + getTotalPrice(quantityToSupplytextBox.Text));
            grandTotalQuantitytextBox.Text = getTotalQuantity(quantityToSupplytextBox.Text);
            totalPriceTextBox.Text         = FormatPrice.format(getTotalPrice(quantityToSupplytextBox.Text));
        }
Пример #4
0
        private void ItemClicked(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            if (btn != null)
            {
                try
                {
                    int index = int.Parse(btn.Tag.ToString());
                    var data  = recipeData.ElementAt(index);
                    data.dateCreated = DateTime.Now;
                    data.soldBy      = "Cashier 1";
                    new UpdateDataGridView().updateSelectedRecipeDataGrid(data, cartDataGridView);
                    selectedRecipes.Add(data);
                    totalPrice            += data.price;
                    totalPriceTextBox.Text = FormatPrice.format(totalPrice);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        public void addProductsToDataGridView(List <StockDataModel> stock, List <int> quantityToSupply, DataGridView datagridview)
        {
            decimal totalPrice = 0;

            for (int i = 0; i < stock.Count(); i++)
            {
                totalPrice = stock.ElementAt(i).lastCostPrice *quantityToSupply.ElementAt(i);
                datagridview.Rows.Add((datagridview.RowCount + 1).ToString(), stock.ElementAt(i).name,
                                      FormatPrice.format(stock.ElementAt(i).lastCostPrice), FormatPrice.format(stock.ElementAt(i).highestCostPrice),
                                      FormatPrice.format(stock.ElementAt(i).lowestCostPrice), quantityToSupply.ElementAt(i),
                                      FormatPrice.format(totalPrice), stock.ElementAt(i).quantity);
            }
        }
        public void addProductsToDataGridView(StockDataModel stock, int quantityToSupply, DataGridView datagridview)
        {
            decimal totalPrice = stock.lastCostPrice * quantityToSupply;

            datagridview.Rows.Add((datagridview.RowCount + 1).ToString(), stock.name, FormatPrice.format(stock.lastCostPrice),
                                  FormatPrice.format(stock.highestCostPrice), FormatPrice.format(stock.lowestCostPrice), quantityToSupply,
                                  FormatPrice.format(totalPrice), stock.quantity);
        }
 public void updateSelectedRecipeDataGrid(RecipesDataModel recipe, DataGridView dataGridView)
 {
     dataGridView.Rows.Add((dataGridView.RowCount + 1).ToString(), recipe.name, FormatPrice.format(recipe.price));
 }
 public void addExpensesToDataGridView(ExpensesDataModel data, DataGridView datagridView)
 {
     datagridView.Rows.Add((datagridView.RowCount + 1), data.name, FormatPrice.format(data.amount), data.desc, data.date);
 }
 public void addServiceChargeToDataGridView(IEnumerable <ServiceChargeDataModel> serviceCharge, DataGridView datagridview)
 {
     foreach (var data in serviceCharge)
     {
         datagridview.Rows.Add((datagridview.RowCount + 1).ToString(), data.title, FormatPrice.format(data.discount), data.percent + "%");
     }
 }
 public void addTransferedItemsToDataGridView(List <StockDataModel> data, List <int> quantity, DataGridView datagridview)
 {
     for (int i = 0; i < data.Count(); i++)
     {
         datagridview.Rows.Add((datagridview.RowCount + 1), data.ElementAt(i).name, FormatPrice.format(data.ElementAt(i).highestCostPrice),
                               FormatPrice.format(data.ElementAt(i).lowestCostPrice), FormatPrice.format(data.ElementAt(i).lastCostPrice),
                               FormatPrice.format(data.ElementAt(i).unitPrice), quantity.ElementAt(i));
     }
 }
 public void addReceiptsToDataGridView(IEnumerable <ReceiptDataModel> receipts, DataGridView datagridView)
 {
     foreach (var data in receipts)
     {
         datagridView.Rows.Add((datagridView.RowCount + 1).ToString(), data.salesRep, data.repId, data.invoiceNo,
                               FormatPrice.format(data.totalPrice), FormatPrice.format(data.discount), FormatPrice.format(data.amountPayable),
                               FormatPrice.format(data.totalAmtPaid), data.salesType, FormatPrice.format(data.serviceCharge), data.date);
     }
 }
 public void addSoldItemsToDataGridView(IEnumerable <StockDataModel> stocks, List <string> categoryNames,
                                        List <string> storeName, List <DateTime> dates, DataGridView datagridView)
 {
     for (int i = 0; i < stocks.Count(); i++)
     {
         datagridView.Rows.Add((datagridView.RowCount + 1), stocks.ElementAt(i).name, FormatPrice.format(stocks.ElementAt(i).highestCostPrice),
                               FormatPrice.format(stocks.ElementAt(i).lowestCostPrice), FormatPrice.format(stocks.ElementAt(i).lastCostPrice),
                               FormatPrice.format(stocks.ElementAt(i).unitPrice), dates.ElementAt(i), categoryNames.ElementAt(i), storeName.ElementAt(i));
     }
 }
 public void salesReportAddItemToDataGridView(List <StockDataModel> availableStocks, List <StockDataModel> soldStocks,
                                              List <SalesDataModel> sales, DataGridView avStockDg, DataGridView soldStockDg)
 {
     avStockDg.Rows.Clear();
     soldStockDg.Rows.Clear();
     foreach (var data in availableStocks)
     {
         avStockDg.Rows.Add((avStockDg.RowCount + 1), data.name, FormatPrice.format(data.highestCostPrice),
                            FormatPrice.format(data.lowestCostPrice), FormatPrice.format(data.lastCostPrice), FormatPrice.format(data.unitPrice),
                            data.quantity);
     }
     for (int i = 0; i < soldStocks.Count(); i++)
     {
         soldStockDg.Rows.Add(i + 1, soldStocks.ElementAt(i).name, FormatPrice.format(soldStocks.ElementAt(i).highestCostPrice),
                              FormatPrice.format(soldStocks.ElementAt(i).lowestCostPrice), FormatPrice.format(sales.ElementAt(i).lastCostPrice),
                              FormatPrice.format(sales.ElementAt(i).soldPrice));
     }
 }
 public void removeStockFromDataGridView(List <StockDataModel> stocks, DataGridView datagridview)
 {
     datagridview.Rows.Clear();
     foreach (var stock in stocks)
     {
         datagridview.Rows.Add(datagridview.RowCount + 1, stock.name, FormatPrice.format(stock.highestCostPrice),
                               FormatPrice.format(stock.lowestCostPrice), FormatPrice.format(stock.lastCostPrice), FormatPrice.format(stock.unitPrice), "Remove");
     }
 }
        public void addSelectedStockToDataGridView(StockDataModel stock, DataGridView datagridView)
        {
            int index = datagridView.RowCount + 1;

            datagridView.Rows.Add(index, stock.name, FormatPrice.format(stock.highestCostPrice),
                                  FormatPrice.format(stock.lowestCostPrice), FormatPrice.format(stock.lastCostPrice), FormatPrice.format(stock.unitPrice), "Remove");
        }
 public void addStocksToPOSDataGridView(IEnumerable <StockDataModel> stocks, List <string> categoryNames,
                                        List <string> storeName, DataGridView datagridView)
 {
     for (int i = 0; i < stocks.Count(); i++)
     {
         datagridView.Rows.Add((datagridView.RowCount + 1).ToString(), stocks.ElementAt(i).name, categoryNames.ElementAt(i),
                               FormatPrice.format(stocks.ElementAt(i).highestCostPrice), FormatPrice.format(stocks.ElementAt(i).lowestCostPrice),
                               FormatPrice.format(stocks.ElementAt(i).lastCostPrice), FormatPrice.format(stocks.ElementAt(i).unitPrice),
                               stocks.ElementAt(i).quantity, stocks.ElementAt(i).unit, storeName.ElementAt(i));
     }
 }
 public void addPurchaseToDataGrid(List <StockDataModel> stocks, List <int> Quantity, DataGridView datagridview)
 {
     for (int i = 0; i < stocks.Count(); i++)
     {
         datagridview.Rows.Add((datagridview.RowCount + 1).ToString(), stocks.ElementAt(i).name,
                               FormatPrice.format(stocks.ElementAt(i).highestCostPrice), FormatPrice.format(stocks.ElementAt(i).lowestCostPrice),
                               FormatPrice.format(stocks.ElementAt(i).lastCostPrice), FormatPrice.format(stocks.ElementAt(i).unitPrice),
                               Quantity.ElementAt(i));
     }
 }
 public void addIssuedStockToDataGridView(StockDataModel stock, int quantity, DataGridView datagridview)
 {
     datagridview.Rows.Add((datagridview.RowCount + 1), stock.name, FormatPrice.format(stock.lastCostPrice),
                           FormatPrice.format(stock.unitPrice), quantity);
 }
 public void addPurcharseOrderToDataGridView(IEnumerable <PurchaseOrderDataModel> purchase, DataGridView datagridview)
 {
     foreach (var data in purchase)
     {
         datagridview.Rows.Add((datagridview.RowCount + 1).ToString(), data.dateCreated, data.orderNo, data.supplierName,
                               data.staffName, data.status, data.deliveryDate, FormatPrice.format(data.grandTotalPrice));
     }
 }
Пример #20
0
        private async void processData(bool isEdit)
        {
            string   supplierName = getSupplier().name;
            string   status       = statusComboBox.Text;
            DateTime dateCreated  = dateCreatedDateTimePicker.Value;
            DateTime deliveryDate = expectedDateofDeliveryDateTimePicker.Value;
            string   order        = orderRefTextBox.Text;
            string   clientId     = getClient().id;
            string   supplierId   = getSupplier().id;
            string   staffName    = clientComboBox.Text;

            if (isEdit)
            {
                if (!MessagePrompt.displayPrompt("Edit", "edit this purchase order"))
                {
                    return;
                }

                purchases.productsList       = purchasedStocks;
                purchases.supplierName       = supplierName;
                purchases.supplierId         = supplierId;
                purchases.status             = status;
                purchases.dateCreated        = dateCreated;
                purchases.deliveryDate       = deliveryDate;
                purchases.orderNo            = order;
                purchases.staffName          = staffName;
                purchases.staffId            = clientId;
                purchases.grandTotalPrice    = grandTotalPrice;
                purchases.grandTotalQuantity = grandTotalQuantity;


                MessageBox.Show(await DatabaseOperations.editpurchases(this.purchases) ? "Data updated successfully" :
                                "Data updating failed");

                if (MessagePrompt.printPrompt("purchase order"))
                {
                    print(purchases);
                }
            }
            else
            {
                if (!MessagePrompt.displayPrompt("Create New", "Create new purchase order"))
                {
                    return;
                }

                var purchaseOrder = new PurchaseOrderDataModel();

                purchaseOrder.supplierName       = supplierName;
                purchaseOrder.staffName          = staffName;
                purchaseOrder.status             = status;
                purchaseOrder.dateCreated        = dateCreated;
                purchaseOrder.deliveryDate       = deliveryDate;
                purchaseOrder.orderNo            = order;
                purchaseOrder.staffId            = clientId;
                purchaseOrder.supplierId         = supplierId;
                purchaseOrder.grandTotalPrice    = grandTotalPrice;
                purchaseOrder.grandTotalQuantity = grandTotalQuantity;
                purchaseOrder.productsList       = purchasedStocks;

                DatabaseOperations.addPurchases(purchaseOrder);

                MessageBox.Show("Purchase saved successfull");

                if (MessagePrompt.printPrompt("purchase order"))
                {
                    print(purchaseOrder);
                }

                this.orderRefTextBox.Text = GenerateIDs.purchaseOrderId();
                this.dataGridView1.Rows.Clear();
                grandTotalPrice                = 0;
                grandTotalQuantity             = 0;
                totalPriceTextBox.Text         = FormatPrice.format(getTotalPrice(quantityToSupplytextBox.Text));
                grandTotalQuantitytextBox.Text = getTotalQuantity(quantityToSupplytextBox.Text);
                grandTotalPricetextBox.Text    = FormatPrice.format(getTotalPrice(quantityToSupplytextBox.Text));
            }
        }
Пример #21
0
        private async void getEditData(string _orderId)
        {
            progressBar1.Visible = true;
            string orderId = _orderId;

            if (!_orderId.Contains("PO-"))
            {
                orderId = "PO-" + _orderId;
            }

            purchaseOrder = await DatabaseOperations.getPurchaseOderByOrderId(orderId);

            if (purchaseOrder != null)
            {
                supplierNameTextBox.Text       = purchaseOrder.supplierName;
                statusTextBox.Text             = purchaseOrder.status;
                dateCreatedTextBox.Text        = purchaseOrder.dateCreated.ToString();
                deliveryDateTextBox.Text       = purchaseOrder.deliveryDate.ToString();
                grandTotalPriceTextBox.Text    = FormatPrice.format(purchaseOrder.grandTotalPrice);
                grandTotalQuantityTextBox.Text = purchaseOrder.grandTotalQuantity.ToString();

                if (purchaseOrder.productsList != null && purchaseOrder.productsList.Any())
                {
                    var purchaseStocks       = purchaseOrder.productsList;
                    var purchasedStockList   = new List <string>();
                    var receivedStockList    = new List <string>();
                    var purchaseQuantityList = new List <int>();
                    foreach (var ds in purchaseStocks)
                    {
                        purchasedStockList.Add(ds.stockId);
                        purchaseQuantityList.Add(ds.quantityToSupply);
                    }

                    if (receivedNotes != null && receivedNotes.goodsReceived != null && receivedNotes.goodsReceived.Any())
                    {
                        var receivedStocks = receivedNotes.goodsReceived;
                        foreach (var dr in receivedStocks)
                        {
                            receivedStockList.Add(dr.stockId);
                        }

                        for (int i = 0; i < receivedStockList.Count(); i++)
                        {
                            if (purchasedStockList.Contains(receivedStockList.ElementAt(i)))
                            {
                                purchaseQuantityList.RemoveAt(purchasedStockList.IndexOf(receivedStockList.ElementAt(i)));
                                purchasedStockList.Remove(receivedStockList.ElementAt(i));
                            }
                        }
                    }

                    quantityOnPurchaseOrder.AddRange(purchaseQuantityList);
                    foreach (var stockId in purchasedStockList)
                    {
                        stocksOnPurchaseOrder.Add(await DatabaseOperations.getStockById(stockId));
                    }

                    updateDataGrid.addPurchaseToDataGrid(stocksOnPurchaseOrder, quantityOnPurchaseOrder, dataGridView1);
                    updateDataGrid.addSelectedNoteToDataGridView(selectedStocks, selectedQuantity, dataGridView2);
                }
            }
            else
            {
                MessageBox.Show("The order ref does not exist. You can check Purchases page for the correct purchase orderId");
            }
            progressBar1.Visible = false;
        }
Пример #22
0
 private void quantityToSupplytextBox_TextChanged(object sender, EventArgs e)
 {
     grandTotalQuantitytextBox.Text = getTotalQuantity(quantityToSupplytextBox.Text);
     totalPriceTextBox.Text         = FormatPrice.format(getTotalPrice(quantityToSupplytextBox.Text));
     grandTotalPricetextBox.Text    = FormatPrice.format(grandTotalPrice + getTotalPrice(quantityToSupplytextBox.Text));
 }
        public void addSelectedNoteToDataGridView(List <StockDataModel> stocks, List <int> quantity, DataGridView datagridview)
        {
            decimal amt = 0;

            datagridview.Rows.Clear();
            for (int i = 0; i < stocks.Count(); i++)
            {
                amt = quantity.ElementAt(i) * stocks.ElementAt(i).lastCostPrice;
                datagridview.Rows.Add((datagridview.RowCount + 1), stocks.ElementAt(i).name,
                                      FormatPrice.format(stocks.ElementAt(i).lastCostPrice), quantity.ElementAt(i), FormatPrice.format(amt), "Edit", "Delete");
            }
        }
 public void addReceiptSoldItemsToDataGridView(IEnumerable <StockDataModel> stocks, List <SalesDataModel> soldItems, List <string> categoryNames,
                                               DataGridView datagridView)
 {
     datagridView.Rows.Clear();
     for (int i = 0; i < stocks.Count(); i++)
     {
         datagridView.Rows.Add((datagridView.RowCount + 1).ToString(), stocks.ElementAt(i).name,
                               FormatPrice.format(stocks.ElementAt(i).highestCostPrice), FormatPrice.format(stocks.ElementAt(i).lowestCostPrice),
                               FormatPrice.format(soldItems.ElementAt(i).lastCostPrice), FormatPrice.format(soldItems.ElementAt(i).soldPrice),
                               categoryNames.ElementAt(i));
     }
 }
 public void addRecipeItemsToDataGridView(List <StockDataModel> stocks, List <int> quantity, DataGridView datagridview)
 {
     datagridview.Rows.Clear();
     for (int i = 0; i < stocks.Count(); i++)
     {
         datagridview.Rows.Add((datagridview.RowCount + 1), stocks.ElementAt(i).name, FormatPrice.format(stocks.ElementAt(i).lastCostPrice),
                               FormatPrice.format(stocks.ElementAt(i).unitPrice), quantity.ElementAt(i));
     }
 }
 public void addStocksToRecipeDataGridView(List <StockDataModel> stock, List <int> qty, DataGridView dataGridView)
 {
     for (int i = 0; i < stock.Count(); i++)
     {
         dataGridView.Rows.Add((dataGridView.RowCount + 1), stock.ElementAt(i).name, qty.ElementAt(i),
                               FormatPrice.format(stock.ElementAt(i).unitPrice), FormatPrice.format(stock.ElementAt(i).lastCostPrice));
     }
 }
Пример #27
0
        private async void processData(bool isEdit)
        {
            string   name = nametextBox.Text;
            decimal  amt  = decimal.Parse(amtTextBox.Text);
            DateTime date = dateTimePicker1.Value;
            string   desc = descTextBox.Text;
            decimal  amt_ = 0;

            if (isEdit)
            {
                if (expense != null)
                {
                    amt_           = expense.amount;
                    expense.name   = name;
                    expense.amount = amt;
                    expense.date   = date;
                    expense.desc   = desc;

                    if (!MessagePrompt.displayPrompt("Edit", "edit this expense"))
                    {
                        return;
                    }

                    bool success = await DatabaseOperations.editExpenses(expense);

                    if (success)
                    {
                        MessageBox.Show("Data updated successfully");
                        totalAmount         -= amt_;
                        totalAmount         += amt;
                        totalAmtTextBox.Text = FormatPrice.format(totalAmount);
                    }
                    else
                    {
                        MessageBox.Show("Data updating failed");
                    }
                }
            }
            else
            {
                ExpensesDataModel expense = new ExpensesDataModel
                {
                    name   = name,
                    amount = amt,
                    date   = date,
                    desc   = desc
                };

                if (!MessagePrompt.displayPrompt("Create new expense", "create new expense"))
                {
                    return;
                }

                DatabaseOperations.addExpenses(expense);

                MessageBox.Show("Expenses created successfully");

                loadDataFromDb();

                nametextBox.Clear();
                amtTextBox.Clear();
                descTextBox.Clear();

                totalAmount         += amt;
                totalAmtTextBox.Text = FormatPrice.format(totalAmount);
            }
        }
        public void addCustomerToDataGridView(List <CustomerDataModel> customers, DataGridView datagridView)
        {
            string code = "";

            foreach (var data in customers)
            {
                if (data.isVoucherAvailable)
                {
                    code = data.voucherCode;
                }
                else
                {
                    code = "";
                }
                datagridView.Rows.Add((datagridView.RowCount + 1).ToString(), data.customerName, FormatPrice.format(data.balance),
                                      data.phone, code, data.address, data.other);
            }
        }