コード例 #1
0
ファイル: FEntry.cs プロジェクト: ashokgudur/Intune.Win
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current  = Cursors.WaitCursor;
                lblMessage.Text = "Trying to add this entry...";
                var txnType = (TxnType)cmbTxnType.SelectedValue;
                var entry   = new Entry
                {
                    UserId    = Session.CurrentUser.Id,
                    AccountId = Account.Id,
                    Notes     = txtNotes.Text.Trim(),
                    TxnType   = txnType,
                    TxnDate   = dtpTxnDate.Value,
                    Quantity  = Convert.ToDouble(txtQuantity.Text),
                    Amount    = Convert.ToDecimal(txtAmount.Text),
                    VoidId    = 0
                };

                if (!entry.IsValid())
                {
                    MessageBox.Show("Please enter details");
                    lblMessage.Text = "";
                    return;
                }

                IntuneService.AddAccountEntry(entry);
                lblMessage.Text = "Entry added successfully.";
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
コード例 #2
0
        private void lnkVoidEntry_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            try
            {
                if (!shouldVoidEntry())
                {
                    return;
                }

                Cursor.Current = Cursors.WaitCursor;
                var entry = lstEntries.SelectedItems[0].Tag as Entry;

                var voidEntry = new Entry
                {
                    UserId    = Session.CurrentUser.Id,
                    AccountId = entry.AccountId,
                    Notes     = composeVoidNotes(entry),
                    TxnType   = makeVoidTxnType(entry),
                    TxnDate   = DateTime.Now.Date,
                    Quantity  = entry.Quantity,
                    Amount    = entry.Amount,
                    VoidId    = entry.Id,
                };

                IntuneService.AddAccountEntry(voidEntry);
                refreshList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }