Int64 IACDebitCreditRuleDataAccess.Add(ACDebitCreditRuleEntity aCDebitCreditRuleEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        private ACDebitCreditRuleEntity BuildACDebitCreditRuleEntity()
        {
            ACDebitCreditRuleEntity aCDebitCreditRuleEntity = CurrentACDebitCreditRuleEntity;

            if (ddlDebitCreditActionID.Items.Count > 0)
            {
                if (ddlDebitCreditActionID.SelectedValue == "0")
                {
                }
                else
                {
                    aCDebitCreditRuleEntity.DebitCreditActionID = Int64.Parse(ddlDebitCreditActionID.SelectedValue);
                }
            }

            aCDebitCreditRuleEntity.IsUp = chkIsUp.Checked;

            aCDebitCreditRuleEntity.IsDown = chkIsDown.Checked;

            if (ddlMDDebitCreditID.Items.Count > 0)
            {
                if (ddlMDDebitCreditID.SelectedValue == "0")
                {
                }
                else
                {
                    aCDebitCreditRuleEntity.MDDebitCreditID = Int64.Parse(ddlMDDebitCreditID.SelectedValue);
                }
            }


            return(aCDebitCreditRuleEntity);
        }
Пример #3
0
        private void SaveACDebitCreditRuleEntity()
        {
            if (IsValid)
            {
                try
                {
                    ACDebitCreditRuleEntity aCDebitCreditRuleEntity = BuildACDebitCreditRuleEntity();

                    Int64 result = -1;

                    if (aCDebitCreditRuleEntity.IsNew)
                    {
                        result = FCCACDebitCreditRule.GetFacadeCreate().Add(aCDebitCreditRuleEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(ACDebitCreditRuleEntity.FLD_NAME_ACDebitCreditRuleID, aCDebitCreditRuleEntity.ACDebitCreditRuleID.ToString(), SQLMatchType.Equal);
                        result = FCCACDebitCreditRule.GetFacadeCreate().Update(aCDebitCreditRuleEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _ACDebitCreditRuleID     = 0;
                        _ACDebitCreditRuleEntity = new ACDebitCreditRuleEntity();
                        PrepareInitialView();
                        BindACDebitCreditRuleList();

                        if (aCDebitCreditRuleEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "A CDebit Credit Rule Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "A CDebit Credit Rule Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (aCDebitCreditRuleEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add A CDebit Credit Rule Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update A CDebit Credit Rule Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        private Int64 UpdateTran(ACDebitCreditRuleEntity aCDebitCreditRuleEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACDebitCreditRule_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, "@ACDebitCreditRuleID", DbType.Int64, aCDebitCreditRuleEntity.ACDebitCreditRuleID);
                db.AddInParameter(cmd, "@DebitCreditActionID", DbType.Int64, aCDebitCreditRuleEntity.DebitCreditActionID);
                db.AddInParameter(cmd, "@IsUp", DbType.Boolean, aCDebitCreditRuleEntity.IsUp);
                db.AddInParameter(cmd, "@IsDown", DbType.Boolean, aCDebitCreditRuleEntity.IsDown);
                db.AddInParameter(cmd, "@MDDebitCreditID", DbType.Int64, aCDebitCreditRuleEntity.MDDebitCreditID);

                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);
        }
Пример #5
0
        protected void lvACDebitCreditRule_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 ACDebitCreditRuleID;

            Int64.TryParse(e.CommandArgument.ToString(), out ACDebitCreditRuleID);

            if (ACDebitCreditRuleID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _ACDebitCreditRuleID = ACDebitCreditRuleID;

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(ACDebitCreditRuleEntity.FLD_NAME_ACDebitCreditRuleID, ACDebitCreditRuleID.ToString(), SQLMatchType.Equal);

                        ACDebitCreditRuleEntity aCDebitCreditRuleEntity = new ACDebitCreditRuleEntity();


                        result = FCCACDebitCreditRule.GetFacadeCreate().Delete(aCDebitCreditRuleEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _ACDebitCreditRuleID     = 0;
                            _ACDebitCreditRuleEntity = new ACDebitCreditRuleEntity();
                            PrepareInitialView();
                            BindACDebitCreditRuleList();

                            MiscUtil.ShowMessage(lblMessage, "A CDebit Credit Rule has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete A CDebit Credit Rule.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        private Int64 Update(ACDebitCreditRuleEntity aCDebitCreditRuleEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACDebitCreditRule_SET";

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

                Database.AddInParameter(cmd, "@ACDebitCreditRuleID", DbType.Int64, aCDebitCreditRuleEntity.ACDebitCreditRuleID);
                Database.AddInParameter(cmd, "@DebitCreditActionID", DbType.Int64, aCDebitCreditRuleEntity.DebitCreditActionID);
                Database.AddInParameter(cmd, "@IsUp", DbType.Boolean, aCDebitCreditRuleEntity.IsUp);
                Database.AddInParameter(cmd, "@IsDown", DbType.Boolean, aCDebitCreditRuleEntity.IsDown);
                Database.AddInParameter(cmd, "@MDDebitCreditID", DbType.Int64, aCDebitCreditRuleEntity.MDDebitCreditID);

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

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

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

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

            return(returnCode);
        }
Пример #7
0
        private void PrepareEditView()
        {
            ACDebitCreditRuleEntity aCDebitCreditRuleEntity = CurrentACDebitCreditRuleEntity;


            if (!aCDebitCreditRuleEntity.IsNew)
            {
                if (ddlDebitCreditActionID.Items.Count > 0 && aCDebitCreditRuleEntity.DebitCreditActionID != null)
                {
                    ddlDebitCreditActionID.SelectedValue = aCDebitCreditRuleEntity.DebitCreditActionID.ToString();
                }

                chkIsUp.Checked   = aCDebitCreditRuleEntity.IsUp;
                chkIsDown.Checked = aCDebitCreditRuleEntity.IsDown;
                if (ddlMDDebitCreditID.Items.Count > 0 && aCDebitCreditRuleEntity.MDDebitCreditID != null)
                {
                    ddlMDDebitCreditID.SelectedValue = aCDebitCreditRuleEntity.MDDebitCreditID.ToString();
                }


                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
Пример #8
0
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _ACDebitCreditRuleID     = 0;
     _ACDebitCreditRuleEntity = new ACDebitCreditRuleEntity();
     PrepareInitialView();
 }
Пример #9
0
 Int64 IACDebitCreditRuleFacade.Delete(ACDebitCreditRuleEntity aCDebitCreditRuleEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACDebitCreditRuleDataAccess().Delete(aCDebitCreditRuleEntity, filterExpression, option, reqTran));
 }
Пример #10
0
 Int64 IACDebitCreditRuleFacade.Add(ACDebitCreditRuleEntity aCDebitCreditRuleEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACDebitCreditRuleDataAccess().Add(aCDebitCreditRuleEntity, option, reqTran));
 }