Exemple #1
0
 private void AddReceivedGoods_Load(object sender, EventArgs e)
 {
     grnIdTextBox.Text = GenerateIDs.receivedNoteId();
 }
Exemple #2
0
        private async void processData(bool isEdit)
        {
            var goodsreceived = new List <ReceivedNotesDataModel.GoodsReceived>();

            for (int i = 0; i < selectedStocks.Count(); i++)
            {
                goodsreceived.Add(new ReceivedNotesDataModel.GoodsReceived
                {
                    stockId  = selectedStocks.ElementAt(i).id,
                    quantity = selectedQuantity.ElementAt(i)
                });
            }


            if (isEdit)
            {
                if (!MessagePrompt.displayPrompt("Edit", "edit this note"))
                {
                    return;
                }
                receivedNotes.goodsReceived = goodsreceived;
                bool success = await DatabaseOperations.editReceivedNotes(receivedNotes);

                MessageBox.Show(success ? "Data deleted successfully" : "Data deletion failed");
            }
            else
            {
                if (!MessagePrompt.displayPrompt("Add New", "add new Received Notes"))
                {
                    return;
                }

                await DatabaseOperations.addReceivedNotes(new ReceivedNotesDataModel
                {
                    purchaseId    = purchaseOrder != null ? purchaseOrder.id : "",
                    grnId         = grnIdTextBox.Text,
                    orderId       = "PO-" + orderIdTextBox.Text,
                    amount        = purchaseOrder != null ? purchaseOrder.grandTotalPrice : 0,
                    dateReceived  = DateTime.Now,
                    goodsReceived = goodsreceived
                });

                MessageBox.Show("Data created successfully");

                addAllButton.Enabled = false;
                saveButton.Enabled   = false;
                selectedQuantity.Clear();
                selectedStocks.Clear();
                stocksOnPurchaseOrder.Clear();
                quantityOnPurchaseOrder.Clear();
                dataGridView1.Rows.Clear();
                dataGridView2.Rows.Clear();
                supplierNameTextBox.Clear();
                statusTextBox.Clear();
                dateCreatedTextBox.Clear();
                deliveryDateTextBox.Clear();
                grandTotalPriceTextBox.Clear();
                grandTotalQuantityTextBox.Clear();
                orderIdTextBox.Clear();
                orderIdTextBox.Focus();
                grnIdTextBox.Text = GenerateIDs.receivedNoteId();
            }
        }