Exemplo n.º 1
0
 //Show customer's ledger on double click
 private void gvwCustomers_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     if (gvwCustomers.SelectedRows.Count > 0)
     {
         Data.Customer selectedCustomer = (Data.Customer)gvwCustomers.SelectedRows[0].DataBoundItem;
         ShowLedgerForm(selectedCustomer);
     }
 }
Exemplo n.º 2
0
 //Show customer's ledger
 private void mnuItemViewCustomer_Click(object sender, EventArgs e)
 {
     if (gvwCustomers.SelectedRows.Count > 0)
     {
         Data.Customer selectedCustomer = (Data.Customer)gvwCustomers.SelectedRows[0].DataBoundItem;
         ShowLedgerForm(selectedCustomer);
     }
 }
Exemplo n.º 3
0
 //Shows the ledger for a customer
 private void ShowLedgerForm(Data.Customer Customer)
 {
     using (frmCustomerLedger ledgerForm = new frmCustomerLedger())
     {
         ledgerForm.CustomerData = Customer;
         ledgerForm.ShowDialog();
         RefreshCustomers();
     }
 }
Exemplo n.º 4
0
        private void mnuItemDeleteCustomer_Click(object sender, EventArgs e)
        {
            //Retrieve selected customer from grid
            Data.Customer selectedCustomer = (Data.Customer)gvwCustomers.SelectedRows[0].DataBoundItem;

            string deleteConfirmationString  = Translator.Instance.Translate("confirm_delete_customer");
            string deleteConfirmationCaption = Translator.Instance.Translate("confirm_delete_customer_caption");

            //Delete customer if user confirms acknowledges
            if (MessageBox.Show(String.Format(deleteConfirmationString, selectedCustomer.Name), deleteConfirmationCaption, MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (selectedCustomer.DeleteFromDatabase())
                {
                    tssStatus.Text = String.Format(Translator.Instance.Translate("customer_deleted"), selectedCustomer.Name);
                }
                RefreshCustomers();
            }
        }
Exemplo n.º 5
0
        //Will work just for the new customer (for now)
        private void CustomerTypeChanged(object sender, EventArgs e)
        {
            if (rdbRetail.Checked && CustomerData is Data.WholesaleCustomer)
            {
                Data.Customer oldCustomerData = CustomerData;
                CustomerData             = new Data.RetailCustomer();
                CustomerData.Address     = oldCustomerData.Address;
                CustomerData.Phonenumber = oldCustomerData.Phonenumber;
            }
            else if (rdbWholesale.Checked && CustomerData is Data.RetailCustomer)
            {
                Data.Customer oldCustomerData = CustomerData;
                CustomerData             = new Data.WholesaleCustomer();
                CustomerData.Address     = oldCustomerData.Address;
                CustomerData.Phonenumber = oldCustomerData.Phonenumber;
            }

            UpdateInterface();
        }
Exemplo n.º 6
0
        private void mnuItemAddDebit_Click(object sender, EventArgs e)
        {
            //Retrieve selected customer from grid
            Data.Customer selectedCustomer = (Data.Customer)gvwCustomers.SelectedRows[0].DataBoundItem;

            //Pass customer name to a new transaction form along with a new debit transaction
            using (frmTransaction transactionForm = new frmTransaction())
            {
                transactionForm.TransactionData = new Data.Transaction(Data.Transaction.TransactionType.Debit);
                transactionForm.CustomerName    = selectedCustomer.Name;
                transactionForm.ShowDialog();
                if (transactionForm.DialogResult == DialogResult.OK)
                {
                    //Add transaction to the customer's transactions
                    if (selectedCustomer.Transactions is null)
                    {
                        selectedCustomer.Transactions = new List <Data.Transaction>();
                    }
                    selectedCustomer.Transactions.Add(transactionForm.TransactionData);
                    selectedCustomer.UpdateToDatabase();
                    RefreshCustomers();
                }
            }
        }