Exemple #1
0
        private void simpanBtn_Click(object sender, EventArgs e)
        {
            var pesan = MessageBox.Show("Apakah anda yakin ingin menyimpan record ini?", "Penyimpanan Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (pesan == DialogResult.Yes)
            {
                cekKondisi(0);

                /* This event will be called several times during form initialization.
                 * We don't want to do anything with it until the runtime authors
                 * list has been passed in. */

                // Exit if no project list
                if (m_Invoices == null)
                {
                    return;
                }

                // Get the item affected

                InvoiceItem changedInvoice = null;

                changedInvoice = (InvoiceItem)bindingInvoice.Current;

                CommandUpdateInvoice updateInvoice = new CommandUpdateInvoice(changedInvoice);
                m_AppController.ExecuteCommand(updateInvoice);
            }
        }
Exemple #2
0
        private void bindingInvoice_ListChanged(object sender, ListChangedEventArgs e)
        {
            // Exit if no project list
            if (m_Invoices == null)
            {
                return;
            }

            // Get the item affected
            int         index          = e.NewIndex;
            InvoiceItem changedInvoice = null;

            if ((index > -1) && (index < m_Invoices.Count))
            {
                changedInvoice = m_Invoices[index];
            }

            // Get the type of change that occured
            ListChangedType changeType = e.ListChangedType;

            /* We only need to respond to two types of changes here; updates
             * and moves. Adds are handled by bindingSourceProjects_AddingNew(),
             * and deletes are handled by menuItemAuthorsDelete_Click(). */

            // Dispatch a change handler

            switch (changeType)
            {
            case ListChangedType.ItemChanged:
                if (changedInvoice.Nomor != null)
                {
                    CommandUpdateInvoice updateAuthor = new CommandUpdateInvoice(changedInvoice);
                    m_AppController.ExecuteCommand(updateAuthor);
                }
                else
                {
                    CommandDeleteInvoice deleteInvoice = new CommandDeleteInvoice(m_Invoices, changedInvoice);
                    m_AppController.ExecuteCommand(deleteInvoice);
                }
                break;

            case ListChangedType.ItemMoved:
                // Not supported in this app
                break;
            }

            decimal totalValue = 0;

            foreach (InvoiceItem item in m_Invoices)
            {
                totalValue += item.Total;
            }

            toolStripLabel1.Text = "Total Tagihan : " + string.Format("{0:n0}", totalValue);
            toolStripLabel2.Text = "Count : " + string.Format("{0:n0}", m_Invoices.Count);
        }
        private void simpanBtn_Click(object sender, EventArgs e)
        {
            if (invoiceItemBindingSource.Current == null)
            {
                return;
            }
            InvoiceItem currentInvoice = (InvoiceItem)invoiceItemBindingSource.Current;

            switch (FrmStatus)
            {
            case FormStatus.OnEditMode:
                FrmStatus = FormStatus.Ready;

                CommandUpdateInvoice updateInvoice = new CommandUpdateInvoice(currentInvoice);
                m_AppController.ExecuteCommand(updateInvoice);

                foreach (DataGridViewRow row in dgItem.Rows)
                {
                    rotiItem item = row.DataBoundItem as rotiItem;
                    if (item != null)
                    {
                        CommandUpdateItem updateItem = new CommandUpdateItem(item);
                        m_AppController.ExecuteCommand(updateItem);
                    }
                }

                break;

            case FormStatus.Ready:
                FrmStatus = FormStatus.OnEditMode;
                break;

            case FormStatus.NewRecord:
                CommandInsertByDetailInvoice newInvoice = new CommandInsertByDetailInvoice(currentInvoice);
                m_AppController.ExecuteCommand(newInvoice);
                break;
            }
        }