private void MeasuereDelete(object sender, RoutedEventArgs e)
        {
            MenuItem     raw  = sender as MenuItem;
            MeasureShort data = raw.DataContext as MeasureShort;

            Charge.Delete(data.charge_id);
            Search_list.ItemsSource = MeasureShort.GetSearched(SearchData());
        }
        private void txtCustomerID_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            #region txtCustomerID
            if (sender == txtCustomerID)
            {
                if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.F3)
                {
                    return;
                }


                if (e.KeyCode.ToString() == "F2")
                {
                    if (oCustomer.View())
                    {
                        oPayment.CustomerID  = oCustomer.ID;
                        txtCustomerID.Text   = oCustomer.ID;
                        txtName.Text         = oCustomer.Name;
                        txtAmountDue.Enabled = false;
                        txtAmountDue.Text    = oCustomer.StatementAmountDue.ToString();
                        ctrType.Focus();
                        //txtAmount.Focus();
                    }
                    return;
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtCustomerID.Text.Trim().Length == 0)
                    {
                        Clear();
                        txtCustomerID.Focus();
                    }

                    if (oCustomer.Find(txtCustomerID.Text))
                    {
                        oPayment.CustomerID  = oCustomer.ID;
                        txtCustomerID.Text   = oCustomer.ID;
                        txtName.Text         = oCustomer.Name;
                        txtAmountDue.Enabled = false;
                        txtAmountDue.Text    = oCustomer.StatementAmountDue.ToString();
                        //txtAmount.Focus();
                        ctrType.Focus();
                        return;
                    }
                    else
                    {
                        Clear();
                    }
                }
            }
            #endregion
            #region txtChargeID
            if (sender == txtChargeID)
            {
                if (e.KeyCode.ToString() == "F2")
                {
                    if (oPayment.View())
                    {
                        Display();
                        txtChargeID.Text = oPayment.ID;
                    }
                    return;
                }

                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (oPayment.Find(txtChargeID.Text))
                    {
                        Display();
                        txtChargeID.Text = oPayment.ID;
                    }
                    return;
                }
            }
            #endregion
            #region txtAmount
            if (sender == txtAmount)
            {
                if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Tab)
                {
                    if (txtAmount.Number != 0.00)
                    {
                        txtComment.Focus();
                    }

                    return;
                }
            }
            #endregion
            #region txtText
            if (sender == txtComment)
            {
                if (e.KeyCode != Keys.PageDown)
                {
                    return;
                }
            }
            #endregion


            #region Default Option
            //Default option
            switch (e.KeyCode)
            {
            case Keys.Tab:
                if (!e.Shift)
                {
                    this.SelectNextControl(this.ActiveControl, true, true, true, true);
                }
                break;

            case Keys.Enter:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Down:
                this.SelectNextControl(this.ActiveControl, true, true, true, true);
                break;

            case Keys.Up:
                this.SelectNextControl(this.ActiveControl, false, true, true, true);
                break;

            case Keys.F8:
                break;

            case Keys.F3:
            {
                if (txtChargeID.Text.Trim() != String.Empty)
                {
                    if (MessageBox.Show("Do you really want to Delete this Record?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                    {
                        MessageBox.Show("Operation Cancelled");
                        return;
                    }
                    else
                    {
                        oPayment.Delete();
                        oCustomer.GetPayments();
                        oCustomer.UpdateCurrentTotals();
                        oCustomer.HasChanged = true;
                        Clear();
                        txtCustomerID.Focus();
                    }
                }
            }
            break;

            case Keys.F7:
                this.Close();
                break;

            case Keys.PageDown:

                oPayment.ID   = txtChargeID.Text;
                oPayment.Date = (DateTime)txtDate.Value;

                oPayment.Comment = txtComment.Text;
                switch (ctrType.Text)
                {
                case "Payment":
                    oPayment.Type   = "P";
                    oPayment.Amount = txtAmount.Number * -1;
                    break;

                case "Adjustment":
                    oPayment.Type   = "A";
                    oPayment.Amount = txtAmount.Number;
                    break;

                case "Invoice":
                    oPayment.Type = "I";
                    // if (txtAmount.Number < 0)
                    oPayment.Amount = txtAmount.Number;
                    break;

                default:
                    oPayment.Amount = txtAmount.Number;
                    break;
                }


                if (txtChargeID.Text == "")
                {
                    oPayment.Insert();
                    if (oPayment.Type == "P" && oCustomer.StatementAmountDue != 0)
                    {
                        oCustomer.PrintStatement(null, PrinterDevice.Printer);
                    }
                }
                else
                {
                    oPayment.Save();
                }
                oCustomer.GetPayments();
                oCustomer.UpdateCurrentTotals();
                oCustomer.HasChanged = true;
                Clear();
                //txtCustomerID.Clear();
                txtCustomerID.Focus();
                break;
            }
            #endregion
        }
 public override void DeleteAction()
 {
     Charge.Delete(ActiveItem.Oid);
     _action_result = DialogResult.OK;
 }