示例#1
0
        private void Button_Action_Click(object sender, RoutedEventArgs e)
        {
            MaintainVM.ValidationErrors.Clear();
            string            action = this.Button_Action.CommandParameter.ToString();
            RefundBalanceInfo entity = MaintainVM.ConvertVM <RefundBalanceMaintainVM, RefundBalanceInfo>();

            entity.IncomeBankInfo.BankName       = MaintainVM.BankName;
            entity.IncomeBankInfo.BranchBankName = MaintainVM.BranchBankName;
            entity.IncomeBankInfo.CardNumber     = MaintainVM.CardNo;
            entity.IncomeBankInfo.CardOwnerName  = MaintainVM.CardOwnerName;
            entity.IncomeBankInfo.PostAddress    = MaintainVM.PostAddress;
            entity.IncomeBankInfo.PostCode       = MaintainVM.PostCode;
            entity.IncomeBankInfo.ReceiverName   = MaintainVM.ReceiverName;
            entity.IncomeBankInfo.Note           = MaintainVM.IncomeNote;
            entity.ProductID   = ((KeyValuePair <int, string>)(((System.Windows.Controls.ComboBox)(Combox_BalanceType)).SelectionBoxItem)).Value;
            entity.CompanyCode = CPApplication.Current.CompanyCode;
            switch (action)
            {
                #region Create
            case "Create":
                if (!ValidationHelper.Validation(this.Text_CashAmount, ValidationAmount) ||
                    !ValidationHelper.Validation(this.TextBox_Note, ValidationEmpt))
                {
                    return;
                }
                entity.CashAmt = Convert.ToDecimal(Text_CashAmount.Text.Trim());
                facade.Create(entity, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    else
                    {
                        if (Dialog != null)
                        {
                            Dialog.ResultArgs.Data         = args;
                            Dialog.ResultArgs.DialogResult = DialogResultType.OK;
                            Dialog.Close();
                        }
                    }
                });
                break;

                #endregion
                #region Aduit
            case "Aduit":
                if (ValidationManager.Validate(this.LayoutRoot))
                {
                    facade.SubmitAudit(entity, (obj, args) =>
                    {
                        if (args.FaultsHandle())
                        {
                            return;
                        }
                        else
                        {
                            if (Dialog != null)
                            {
                                Dialog.ResultArgs.Data         = args;
                                Dialog.ResultArgs.DialogResult = DialogResultType.OK;
                                Dialog.Close();
                            }
                        }
                    });
                }
                break;
                #endregion
                #region Refund

            case "Refund":
                facade.Refund(entity, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    else
                    {
                        if (Dialog != null)
                        {
                            Dialog.ResultArgs.Data         = args;
                            Dialog.ResultArgs.DialogResult = DialogResultType.OK;
                            Dialog.Close();
                        }
                    }
                });
                break;

                #endregion
                #region Void
            case "Void":
                facade.Abandon(entity.SysNo.Value, (obj, args) =>
                {
                    if (args.FaultsHandle())
                    {
                        return;
                    }
                    else
                    {
                        if (Dialog != null)
                        {
                            Dialog.ResultArgs.Data         = args;
                            Dialog.ResultArgs.DialogResult = DialogResultType.OK;
                            Dialog.Close();
                        }
                    }
                });
                break;
                #endregion
            }
        }