예제 #1
0
        public static int Create(TransactionTypeDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("TransactionType.Insert", sql, DataStoreKey);

            return(Convert.ToInt32(newId));
        }
예제 #2
0
        public void Delete(string value)
        {
            var dataDelete = new TransactionTypeDataModel();

            dataDelete.TransactionTypeId = int.Parse(value);
            TransactionTypeDataManager.Delete(dataDelete, SessionVariables.RequestProfile);
        }
예제 #3
0
        public static string Save(TransactionTypeDataModel data, string action, RequestProfile requestProfile)
        {
            var sql = "EXEC ";

            FormatData(data);

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

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

            default:
                break;
            }
            sql = sql + ", " + ToSQLParameter(data, TransactionTypeDataModel.DataColumns.TransactionTypeId);
            sql = sql + ", " + ToSQLParameter(data, TransactionTypeDataModel.DataColumns.Name);
            sql = sql + ", " + ToSQLParameter(data, TransactionTypeDataModel.DataColumns.Description);
            sql = sql + ", " + ToSQLParameter(data, TransactionTypeDataModel.DataColumns.SortOrder);
            sql = sql + ", " + ToSQLParameter(data, TransactionTypeDataModel.DataColumns.Code);

            return(sql);
        }
예제 #4
0
        public TransactionTypeDataModel GetById(string value)
        {
            var dataQuery = new TransactionTypeDataModel();

            dataQuery.TransactionTypeId = int.Parse(value);

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

            return(result[0]);
        }
예제 #5
0
        public static bool DoesExist(TransactionTypeDataModel data, RequestProfile requestProfile)
        {
            var doesExistRequest = new TransactionTypeDataModel();

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

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

            return(list.Count > 0);
        }
예제 #6
0
        public static void Delete(TransactionTypeDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.TransactionTypeDelete ";

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

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

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

            List <TransactionTypeDataModel> result;

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

            return(result);
        }
예제 #8
0
        public static string ToSQLParameter(TransactionTypeDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

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

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


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

            return(returnValue);
        }
예제 #9
0
        public static void Update(TransactionTypeDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("TransactionType.Update", sql, DataStoreKey);
        }
예제 #10
0
 public static void FormatData(TransactionTypeDataModel data)
 {
     data.Code = Formatter.FormatCode(data.Code);
 }
예제 #11
0
        public static DataTable Search(TransactionTypeDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }