コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //Datagridview selected row
                selectedItem = dataGridViewReturn.SelectedRows[0].Index;
                dataGridViewReturn.Rows.Remove(dataGridViewReturn.SelectedRows[0]);


                //Updates users loaned materials list +
                loanedMaterials[selectedItem].ReturnStatus = true;
                loanedMaterials[selectedItem].ReturnDate   = DateTime.Now;

                //prideda ta daikta y evento duomenu baze. Add item to event database
                int selectedItemID = loanedMaterials[selectedItem].Item_Id;
                materials.Find(x => x.ID == selectedItemID).Quantity++;
                dataHelper.UpdateAMaterial(selectedItemID, materials);
                //Update Invoice

                invoiceDataHelper.UpdateMaterialInvoiceItems(loanedMaterials);

                //Refund deposit +
                eaDataHelper.UpdateAccountBalance(person.AccountId, ((Material)materials.Find(x => x.ID == selectedItemID)).DepositAmount);

                lblcurrentStatus.Text = "Selected item is returned.";
            }
            catch
            {
                MessageBox.Show("Please selected the returned material");
            }
        }
コード例 #2
0
        /// <summary>
        /// Update table F_Invoice, Food_Invoice
        /// Update food instances in list of sold items
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (currentAccount.Balance >= total)
                {
                    //Update the new balance
                    decimal balanceupdate = 0 - total;
                    AccountdData.UpdateAccountBalance(currentAccount.AccountId, balanceupdate);

                    //Update the quantity of sold food into database
                    int nbofSoldFood = 0;
                    foreach (var f in ListOfUpdateFood)
                    {
                        nbofSoldFood += ItemData.UpdateAFood(f.ID, ListOfUpdateFood);
                    }

                    //Insert a new food invoice into database
                    List <Invoice> invoices = InvoiceData.GetAllFoodInvoices();
                    InvoiceID = InvoiceData.GenerateInvoiceID(invoices);
                    string soldDate    = (DateTime.Now).ToString("dd-MM-yyyy");
                    int    AccountID   = currentAccount.AccountId; // This one will be provide by RFID after the scaning functionality completed
                    int    nbofInvoice = InvoiceData.AddAFoodInvoice(InvoiceID, soldDate, AccountID);

                    //Insert rows into food_invoice (association table between food and invoice)
                    int InvoiceItemRows = 0;
                    foreach (var f in ListOfSoldFoods)
                    {
                        InvoiceItemRows += ItemInvoiceData.AddNewSoldFood(InvoiceID, f.Quantity, f.ID);
                    }
                    if (nbofInvoice == 1 && nbofSoldFood >= 1 & InvoiceItemRows == nbofSoldFood)
                    {
                        btnPrint.Enabled      = true;
                        lblBalance.Text       = (currentAccount.Balance - total).ToString("0.00");
                        lblcurrentStatus.Text = "Transaction is done successfully!";
                    }
                }
                else
                {
                    lblcurrentStatus.Text = "You don't have enough money, please add more!";
                }
            }
            catch
            {
                lblcurrentStatus.Text = "Please scan the RFID";
            }
        }
コード例 #3
0
        private void btnLoan_Click(object sender, EventArgs e)
        {
            if (currentAccount.Balance >= total)
            {
                //Update the new balance
                decimal balanceupdate = 0 - total;
                AccountdData.UpdateAccountBalance(currentAccount.AccountId, balanceupdate);

                lblBalance.Text = currentAccount.Balance.ToString("0.00");

                //Update the quantity of loaned material into database
                int nbofLoanedMaterial = 0;
                foreach (var f in ListOfUpdateMaterials)
                {
                    nbofLoanedMaterial += ItemData.UpdateAMaterial(f.ID, ListOfUpdateMaterials);
                }

                //Insert a new material invoice into database
                List <Invoice> invoices = InvoiceData.GetAllMaterialInvoices();
                InvoiceID = InvoiceData.GenerateInvoiceID(invoices);
                string startingDate = (DateTime.Now).ToString("dd-MM-yyyy");
                int    AccountID    = currentAccount.AccountId; // This one will be provide by RFID after the scaning functionality completed
                int    nbofInvoice  = InvoiceData.AddAMaterialInvoice(InvoiceID, startingDate, AccountID, false);

                //Insert rows into material_invoice (association table between material and invoice)
                int InvoiceItemRows = 0;
                foreach (var f in ListOfMaterialsInInvoice)
                {
                    InvoiceItemRows += ItemInvoiceData.AddNewLoanedMaterial(InvoiceID, f.Quantity, f.Item_Id, f.ReturnDate, false);
                }
                if (nbofInvoice == 1 && nbofLoanedMaterial >= 1)
                {
                    btnPrint.Enabled      = true;
                    lblBalance.Text       = (currentAccount.Balance - total).ToString("0.00");
                    lblcurrentStatus.Text = "Transaction is done successfully!";
                }
                else
                {
                    lblcurrentStatus.Text = "Problems occurs with updating database";
                }
            }
        }