Int64 IACAccountResourceAccountMapDataAccess.Add(ACAccountResourceAccountMapEntity aCAccountResourceAccountMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
        {
            try
            {
                long retValues = -99;

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

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

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

                return(retValues);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private ACAccountResourceAccountMapEntity BuildACAccountResourceAccountMapEntity()
        {
            ACAccountResourceAccountMapEntity aCAccountResourceAccountMapEntity = CurrentACAccountResourceAccountMapEntity;

            if (hdEmpID.Value != "0")
            {
                aCAccountResourceAccountMapEntity.AccountID = Int64.Parse(hdEmpID.Value);
            }

            if (accountResourceCategory > 0)
            {
                aCAccountResourceAccountMapEntity.AccountResourceCategoryID = accountResourceCategory;
            }

            if (referenceID > 0)
            {
                aCAccountResourceAccountMapEntity.ReferenceID = referenceID;
            }

            if (!txtRemarks.Text.Trim().IsNullOrEmpty())
            {
                aCAccountResourceAccountMapEntity.Remarks = txtRemarks.Text.Trim();
            }
            else
            {
                aCAccountResourceAccountMapEntity.Remarks = null;
            }


            return(aCAccountResourceAccountMapEntity);
        }
        private Int64 UpdateTran(ACAccountResourceAccountMapEntity aCAccountResourceAccountMapEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACAccountResourceAccountMap_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, "@ResourceAccountMapID", DbType.Int64, aCAccountResourceAccountMapEntity.ResourceAccountMapID);
                db.AddInParameter(cmd, "@AccountID", DbType.Int64, aCAccountResourceAccountMapEntity.AccountID);
                db.AddInParameter(cmd, "@AccountResourceCategoryID", DbType.Int64, aCAccountResourceAccountMapEntity.AccountResourceCategoryID);
                db.AddInParameter(cmd, "@ReferenceID", DbType.Int64, aCAccountResourceAccountMapEntity.ReferenceID);
                db.AddInParameter(cmd, "@Remarks", DbType.String, aCAccountResourceAccountMapEntity.Remarks);

                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 SaveACAccountResourceAccountMapEntity()
        {
            if (IsValid)
            {
                try
                {
                    ACAccountResourceAccountMapEntity aCAccountResourceAccountMapEntity = BuildACAccountResourceAccountMapEntity();

                    Int64 result = -1;

                    if (aCAccountResourceAccountMapEntity.IsNew)
                    {
                        result = FCCACAccountResourceAccountMap.GetFacadeCreate().Add(aCAccountResourceAccountMapEntity, DatabaseOperationType.Add, TransactionRequired.No);
                    }
                    else
                    {
                        String filterExpression = SqlExpressionBuilder.PrepareFilterExpression(ACAccountResourceAccountMapEntity.FLD_NAME_ResourceAccountMapID, aCAccountResourceAccountMapEntity.ResourceAccountMapID.ToString(), SQLMatchType.Equal);
                        result = FCCACAccountResourceAccountMap.GetFacadeCreate().Update(aCAccountResourceAccountMapEntity, filterExpression, DatabaseOperationType.Update, TransactionRequired.No);
                    }

                    if (result > 0)
                    {
                        _ResourceAccountMapID = 0;
                        _ACAccountResourceAccountMapEntity = new ACAccountResourceAccountMapEntity();
                        PrepareInitialView();
                        BindACAccountResourceAccountMapList();

                        if (aCAccountResourceAccountMapEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Account Resource Account Map Information has been added successfully.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Account Resource Account Map Information has been updated successfully.", false);
                        }
                    }
                    else
                    {
                        if (aCAccountResourceAccountMapEntity.IsNew)
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to add Account Resource Account Map Information.", false);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to update Account Resource Account Map Information.", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
        protected void lvACAccountResourceAccountMap_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 ResourceAccountMapID;

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

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

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

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(ACAccountResourceAccountMapEntity.FLD_NAME_ResourceAccountMapID, ResourceAccountMapID.ToString(), SQLMatchType.Equal);

                        ACAccountResourceAccountMapEntity aCAccountResourceAccountMapEntity = new ACAccountResourceAccountMapEntity();


                        result = FCCACAccountResourceAccountMap.GetFacadeCreate().Delete(aCAccountResourceAccountMapEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _ResourceAccountMapID = 0;
                            _ACAccountResourceAccountMapEntity = new ACAccountResourceAccountMapEntity();
                            PrepareInitialView();
                            BindACAccountResourceAccountMapList();

                            MiscUtil.ShowMessage(lblMessage, "A CAccount Resource Account Map has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete A CAccount Resource Account Map.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }
        private Int64 Update(ACAccountResourceAccountMapEntity aCAccountResourceAccountMapEntity, String filterExpression, DatabaseOperationType option)
        {
            long         returnCode = -99;
            const string SP         = "dbo.ACAccountResourceAccountMap_SET";

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

                Database.AddInParameter(cmd, "@ResourceAccountMapID", DbType.Int64, aCAccountResourceAccountMapEntity.ResourceAccountMapID);
                Database.AddInParameter(cmd, "@AccountID", DbType.Int64, aCAccountResourceAccountMapEntity.AccountID);
                Database.AddInParameter(cmd, "@AccountResourceCategoryID", DbType.Int64, aCAccountResourceAccountMapEntity.AccountResourceCategoryID);
                Database.AddInParameter(cmd, "@ReferenceID", DbType.Int64, aCAccountResourceAccountMapEntity.ReferenceID);
                Database.AddInParameter(cmd, "@Remarks", DbType.String, aCAccountResourceAccountMapEntity.Remarks);

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

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

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

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

            return(returnCode);
        }
        private void PrepareEditView()
        {
            ACAccountResourceAccountMapEntity aCAccountResourceAccountMapEntity = CurrentACAccountResourceAccountMapEntity;


            if (!aCAccountResourceAccountMapEntity.IsNew)
            {
                if (aCAccountResourceAccountMapEntity.AccountID > 0)
                {
                    //txtItemName.Text = aCAccountResourceAccountMapEntity..ToString();
                    hdEmpID.Value = aCAccountResourceAccountMapEntity.AccountID.ToString();
                }

                txtRemarks.Text = aCAccountResourceAccountMapEntity.Remarks.ToString();

                btnSubmit.Text    = "Update";
                btnAddNew.Visible = true;
            }
        }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     _ResourceAccountMapID = 0;
     _ACAccountResourceAccountMapEntity = new ACAccountResourceAccountMapEntity();
     PrepareInitialView();
 }
Esempio n. 9
0
 Int64 IACAccountResourceAccountMapFacade.Delete(ACAccountResourceAccountMapEntity aCAccountResourceAccountMapEntity, String filterExpression, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACAccountResourceAccountMapDataAccess().Delete(aCAccountResourceAccountMapEntity, filterExpression, option, reqTran));
 }
Esempio n. 10
0
 Int64 IACAccountResourceAccountMapFacade.Add(ACAccountResourceAccountMapEntity aCAccountResourceAccountMapEntity, DatabaseOperationType option, TransactionRequired reqTran)
 {
     return(DataAccessFactory.CreateACAccountResourceAccountMapDataAccess().Add(aCAccountResourceAccountMapEntity, option, reqTran));
 }