public static int Create(AccountingParametersDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("AccountingParameters.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
        public static string Save(AccountingParametersDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";


            switch (action)
            {
            case "Create":
                sql += "dbo.AccountingParametersInsert  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) +
                       ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId);
                break;

            case "Update":
                sql += "dbo.AccountingParametersUpdate  " +
                       " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId);
                break;

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, AccountingParametersDataModel.DataColumns.AccountingParametersId);
            sql = sql + ", " + ToSQLParameter(data, AccountingParametersDataModel.DataColumns.Name);
            sql = sql + ", " + ToSQLParameter(data, AccountingParametersDataModel.DataColumns.Description);
            sql = sql + ", " + ToSQLParameter(data, AccountingParametersDataModel.DataColumns.SortOrder);

            return(sql);
        }
Esempio n. 3
0
        public void Delete(string value)
        {
            var dataDelete = new AccountingParametersDataModel();

            dataDelete.AccountingParametersId = int.Parse(value);
            AccountingParametersDataManager.Delete(dataDelete, SessionVariables.RequestProfile);
        }
        public static string ToSQLParameter(AccountingParametersDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

            switch (dataColumnName)
            {
            case AccountingParametersDataModel.DataColumns.AccountingParametersId:
                if (data.AccountingParametersId != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, AccountingParametersDataModel.DataColumns.AccountingParametersId, data.AccountingParametersId);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, AccountingParametersDataModel.DataColumns.AccountingParametersId);
                }
                break;

            case AccountingParametersDataModel.DataColumns.Name:
                if (!string.IsNullOrEmpty(data.Name))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, AccountingParametersDataModel.DataColumns.Name, data.Name);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, AccountingParametersDataModel.DataColumns.Name);
                }
                break;

            case AccountingParametersDataModel.DataColumns.Description:
                if (!string.IsNullOrEmpty(data.Description))
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, AccountingParametersDataModel.DataColumns.Description, data.Description);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, AccountingParametersDataModel.DataColumns.Description);
                }
                break;

            case AccountingParametersDataModel.DataColumns.SortOrder:
                if (data.SortOrder != null)
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, AccountingParametersDataModel.DataColumns.SortOrder, data.SortOrder);
                }
                else
                {
                    returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, AccountingParametersDataModel.DataColumns.SortOrder);
                }
                break;


            default:
                returnValue = BaseDataManager.ToSQLParameter(data, dataColumnName);
                break;
            }

            return(returnValue);
        }
Esempio n. 5
0
        public AccountingParametersDataModel GetById(string value)
        {
            var dataQuery = new AccountingParametersDataModel();

            dataQuery.AccountingParametersId = int.Parse(value);

            var result = AccountingParametersDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile, 1);

            return(result[0]);
        }
        public static bool DoesExist(AccountingParametersDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new AccountingParametersDataModel();

            doesExistRequest.ApplicationId = data.ApplicationId;
            doesExistRequest.Name          = data.Name;

            var list = GetEntityDetails(doesExistRequest, requestProfile, 0);

            return(list.Count > 0);
        }
        public static void Delete(AccountingParametersDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.AccountingParametersDelete ";

            var parameters =
                new
            {
                AuditId = requestProfile.AuditId
                , AccountingParametersId = data.AccountingParametersId
            };

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure);
            }
        }
        public static List <AccountingParametersDataModel> GetEntityDetails(AccountingParametersDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails)
        {
            const string sql = @"dbo.AccountingParametersSearch ";

            var parameters =
                new
            {
                AuditId                  = requestProfile.AuditId
                , ApplicationId          = requestProfile.ApplicationId
                , ReturnAuditInfo        = returnAuditInfo
                , AccountingParametersId = dataQuery.AccountingParametersId
                , Name = dataQuery.Name
            };

            List <AccountingParametersDataModel> result;

            using (var dataAccess = new DataAccessBase(DataStoreKey))
            {
                result = dataAccess.Connection.Query <AccountingParametersDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList();
            }

            return(result);
        }
        public static void Update(AccountingParametersDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("AccountingParameters.Update", sql, DataStoreKey);
        }
        public static DataTable Search(AccountingParametersDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }