Int64 IACBankAccountPaymentDataAccess.Add(ACBankAccountPaymentEntity aCBankAccountPaymentEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

                switch (reqTran)
                {
                case TransactionRequired.No:
                {
                    retValues = Add(aCBankAccountPaymentEntity, option);
                    break;
                }

                case TransactionRequired.Yes:
                {
                    retValues = AddTran(aCBankAccountPaymentEntity, option);
                    break;
                }

                default:
                {
                    retValues = -99;
                    break;
                }
                }

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void PrepareEditView()
        {
            ACBankAccountPaymentEntity aCBankAccountPaymentEntity = CurrentACBankAccountPaymentEntity;

            IsBankAmountOrCashAmount();

            if (!aCBankAccountPaymentEntity.IsNew)
            {
                txtPaymentDate.Text = aCBankAccountPaymentEntity.PaymentDate.ToStringDefault();
                if (ddlPayToID.Items.Count > 0 && aCBankAccountPaymentEntity.PayToID != null)
                {
                    ddlPayToID.SelectedValue = aCBankAccountPaymentEntity.PayToID.ToString();
                }

                BuildReferenceByPayTo();

                if (ddlReferenceID.Items.Count > 0 && aCBankAccountPaymentEntity.ReferenceID != null)
                {
                    ddlReferenceID.SelectedValue = aCBankAccountPaymentEntity.ReferenceID.ToString();
                }

                if (ddlBankAccountID.Items.Count > 0 && aCBankAccountPaymentEntity.BankAccountID != null)
                {
                    ddlBankAccountID.SelectedValue = aCBankAccountPaymentEntity.BankAccountID.ToString();
                }

                txtReference.Text = aCBankAccountPaymentEntity.Reference.ToString();
                txtName.Text      = aCBankAccountPaymentEntity.Name.ToString();
                txtMemo.Text      = aCBankAccountPaymentEntity.Memo.ToString();

                btnSubmit.Text = "Update";
            }
        }
        private Int64 UpdateTran(ACBankAccountPaymentEntity aCBankAccountPaymentEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACBankAccountPayment_SET";

            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand cmd = db.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option, db);
                AddOutputParameter(cmd, db);
                AddFilterExpressionParameter(cmd, filterExpression, db);

                db.AddInParameter(cmd, "@BankAccountPaymentID", DbType.Int64, aCBankAccountPaymentEntity.BankAccountPaymentID);
                db.AddInParameter(cmd, "@PaymentDate", DbType.DateTime, aCBankAccountPaymentEntity.PaymentDate);
                db.AddInParameter(cmd, "@PayToID", DbType.Int64, aCBankAccountPaymentEntity.PayToID);
                db.AddInParameter(cmd, "@ReferenceID", DbType.Int64, aCBankAccountPaymentEntity.ReferenceID);
                db.AddInParameter(cmd, "@BankAccountID", DbType.Int64, aCBankAccountPaymentEntity.BankAccountID);
                db.AddInParameter(cmd, "@Reference", DbType.String, aCBankAccountPaymentEntity.Reference);
                db.AddInParameter(cmd, "@Name", DbType.String, aCBankAccountPaymentEntity.Name);
                db.AddInParameter(cmd, "@Memo", DbType.String, aCBankAccountPaymentEntity.Memo);
                db.AddInParameter(cmd, "@BankAccountPaymentApprovalStatusID", DbType.Int64, aCBankAccountPaymentEntity.BankAccountPaymentApprovalStatusID);
                db.AddInParameter(cmd, "@PreparedByEmployeeID", DbType.Int64, aCBankAccountPaymentEntity.PreparedByEmployeeID);

                DbConnection connection = db.CreateConnection();
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    using (IDataReader reader = db.ExecuteReader(cmd, transaction))
                    {
                        returnCode = GetReturnCodeFromParameter(cmd);
                    }

                    if (returnCode > 0)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        throw new ArgumentException("Error Code." + returnCode.ToString());
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                finally
                {
                    transaction.Dispose();
                    connection.Close();
                    connection = null;
                }
            }

            return(returnCode);
        }
        private void SaveACBankAccountPaymentEntity()
        {
            if (ValidationInput())
            {
                if (IsValid)
                {
                    try
                    {
                        ACBankAccountPaymentEntity aCBankAccountPaymentEntity = BuildACBankAccountPaymentEntity();

                        Int64 result = -1;

                        if (aCBankAccountPaymentEntity.IsNew)
                        {
                            result = FCCACBankAccountPayment.GetFacadeCreate().Add(aCBankAccountPaymentEntity, DatabaseOperationType.Add, TransactionRequired.No);
                        }
                        else
                        {
                            String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(ACBankAccountPaymentEntity.FLD_NAME_BankAccountPaymentID, aCBankAccountPaymentEntity.BankAccountPaymentID.ToString(), SQLMatchType.Equal);
                            result = FCCACBankAccountPayment.GetFacadeCreate().Update(aCBankAccountPaymentEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                        }

                        if (result > 0)
                        {
                            BindACBankAccountPaymentList();
                            PrepareInitialViewPaymentItem();
                            CurrentACBankAccountPaymentItemList = new List <ACBankAccountPaymentItem_DetailedEntity>();
                            BindACBankAccountPaymentItemList();
                            BuildTotalValueLabel();

                            if (aCBankAccountPaymentEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Bank Account Payment Information has been added successfully.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Bank Account Payment Information has been updated successfully.", false);
                            }
                        }
                        else
                        {
                            if (aCBankAccountPaymentEntity.IsNew)
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to add Bank Account Payment Information.", false);
                            }
                            else
                            {
                                MiscUtil.ShowMessage(lblMessage, "Failed to update Bank Account Payment Information.", false);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        private Int64 DeleteTran(ACBankAccountPaymentEntity aCBankAccountPaymentEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACBankAccountPayment_SET";

            Database db = DatabaseFactory.CreateDatabase();


            using (DbCommand cmd = db.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd, db);
                AddFilterExpressionParameter(cmd, filterExpression, db);


                DbConnection connection = db.CreateConnection();
                connection.Open();
                DbTransaction transaction = connection.BeginTransaction();

                try
                {
                    using (IDataReader reader = db.ExecuteReader(cmd, transaction))
                    {
                        returnCode = GetReturnCodeFromParameter(cmd);
                    }

                    if (returnCode >= 0)
                    {
                        transaction.Commit();
                    }
                    else
                    {
                        throw new ArgumentException("Error Code." + returnCode.ToString());
                    }
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    throw ex;
                }
                finally
                {
                    transaction.Dispose();
                    connection.Close();
                    connection = null;
                }
            }

            return(returnCode);
        }
        private Int64 Update(ACBankAccountPaymentEntity aCBankAccountPaymentEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACBankAccountPayment_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);

                Database.AddInParameter(cmd, "@BankAccountPaymentID", DbType.Int64, aCBankAccountPaymentEntity.BankAccountPaymentID);
                Database.AddInParameter(cmd, "@PaymentDate", DbType.DateTime, aCBankAccountPaymentEntity.PaymentDate);
                Database.AddInParameter(cmd, "@PayToID", DbType.Int64, aCBankAccountPaymentEntity.PayToID);
                Database.AddInParameter(cmd, "@ReferenceID", DbType.Int64, aCBankAccountPaymentEntity.ReferenceID);
                Database.AddInParameter(cmd, "@BankAccountID", DbType.Int64, aCBankAccountPaymentEntity.BankAccountID);
                Database.AddInParameter(cmd, "@Reference", DbType.String, aCBankAccountPaymentEntity.Reference);
                Database.AddInParameter(cmd, "@Name", DbType.String, aCBankAccountPaymentEntity.Name);
                Database.AddInParameter(cmd, "@Memo", DbType.String, aCBankAccountPaymentEntity.Memo);
                Database.AddInParameter(cmd, "@BankAccountPaymentApprovalStatusID", DbType.Int64, aCBankAccountPaymentEntity.BankAccountPaymentApprovalStatusID);
                Database.AddInParameter(cmd, "@PreparedByEmployeeID", DbType.Int64, aCBankAccountPaymentEntity.PreparedByEmployeeID);

                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("ACBankAccountPaymentEntity already exists. Please specify another ACBankAccountPaymentEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("ACBankAccountPaymentEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("ACBankAccountPaymentEntity already exists. Please specify another ACBankAccountPaymentEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
        private Int64 Delete(ACBankAccountPaymentEntity aCBankAccountPaymentEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACBankAccountPayment_SET";

            using (DbCommand cmd = Database.GetStoredProcCommand(SP))
            {
                AddOptionParameter(cmd, option);
                AddOutputParameter(cmd);
                AddFilterExpressionParameter(cmd, filterExpression);


                using (IDataReader reader = Database.ExecuteReader(cmd))
                {
                    returnCode = GetReturnCodeFromParameter(cmd);

                    switch (returnCode)
                    {
                    case SqlConstants.DB_STATUS_CODE_DATAALREADYEXIST:
                    {
                        throw new ArgumentException("ACBankAccountPaymentEntity already exists. Please specify another ACBankAccountPaymentEntity.");
                    }

                    case SqlConstants.DB_STATUS_CODE_DATAUPDATEDFROMOTHERSESSION:
                    {
                        throw new ArgumentException("ACBankAccountPaymentEntity data already updated from different session.");
                    }

                    case SqlConstants.DB_STATUS_CODE_FAIL_OPERATION:
                    {
                        throw new ArgumentException("ACBankAccountPaymentEntity already exists. Please specify another ACBankAccountPaymentEntity.");
                    }
                    }
                }
            }

            return(returnCode);
        }
        private ACBankAccountPaymentEntity BuildACBankAccountPaymentEntity()
        {
            ACBankAccountPaymentEntity aCBankAccountPaymentEntity = CurrentACBankAccountPaymentEntity;

            if (txtPaymentDate.Text.Trim().IsNotNullOrEmpty())
            {
                aCBankAccountPaymentEntity.PaymentDate = MiscUtil.ParseToDateTime(txtPaymentDate.Text);
            }

            if (ddlPayToID.Items.Count > 0)
            {
                if (ddlPayToID.SelectedValue == "0")
                {
                }
                else
                {
                    aCBankAccountPaymentEntity.PayToID = Int64.Parse(ddlPayToID.SelectedValue);
                }
            }

            if (ddlBankAccountID.Items.Count > 0)
            {
                if (ddlBankAccountID.SelectedValue == "0")
                {
                }
                else
                {
                    aCBankAccountPaymentEntity.BankAccountID = Int64.Parse(ddlBankAccountID.SelectedValue);
                }
            }

            aCBankAccountPaymentEntity.BankAccountPaymentApprovalStatusID = MasterDataConstants.ACMDBankAccountPaymentApprovalStatus.INITIATED;
            aCBankAccountPaymentEntity.Reference = txtReference.Text.Trim();
            aCBankAccountPaymentEntity.Name      = txtName.Text.Trim();
            aCBankAccountPaymentEntity.Memo      = txtMemo.Text.Trim();

            return(aCBankAccountPaymentEntity);
        }
Beispiel #9
0
 Int64 IACBankAccountPaymentFacade.Delete(ACBankAccountPaymentEntity aCBankAccountPaymentEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACBankAccountPaymentDataAccess().Delete(aCBankAccountPaymentEntity, filterExpression, option, reqTran));
 }
Beispiel #10
0
 Int64 IACBankAccountPaymentFacade.Add(ACBankAccountPaymentEntity aCBankAccountPaymentEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACBankAccountPaymentDataAccess().Add(aCBankAccountPaymentEntity, option, reqTran));
 }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _BankAccountPaymentID       = 0;
     _ACBankAccountPaymentEntity = new ACBankAccountPaymentEntity();
     PrepareInitialView();
 }