Example #1
0
        public void Delete(string value)
        {
            var dataDelete = new PriceListDataModel();

            dataDelete.PriceListId = int.Parse(value);
            PriceListDataManager.Delete(dataDelete, SessionVariables.RequestProfile);
        }
Example #2
0
        public static int Create(PriceListDataModel data, RequestProfile requestProfile)
        {
            var sql   = Save(data, "Create", requestProfile);
            var newId = DBDML.RunScalarSQL("PriceList.Insert", sql, DataStoreKey);

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


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

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

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

            return(sql);
        }
Example #4
0
        public static string ToSQLParameter(PriceListDataModel data, string dataColumnName)
        {
            var returnValue = "NULL";

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

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

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

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


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

            return(returnValue);
        }
Example #5
0
        public PriceListDataModel GetById(string value)
        {
            var dataQuery = new PriceListDataModel();

            dataQuery.PriceListId = int.Parse(value);

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

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

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

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

            return(list.Count > 0);
        }
Example #7
0
        public static void Delete(PriceListDataModel data, RequestProfile requestProfile)
        {
            const string sql = @"dbo.PriceListDelete ";

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

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

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

            List <PriceListDataModel> result;

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

            return(result);
        }
Example #9
0
        public static void Update(PriceListDataModel data, RequestProfile requestProfile)
        {
            var sql = Save(data, "Update", requestProfile);

            DBDML.RunSQL("PriceList.Update", sql, DataStoreKey);
        }
Example #10
0
        public static DataTable Search(PriceListDataModel data, RequestProfile requestProfile)
        {
            var list = GetEntityDetails(data, requestProfile, 0);

            return(list.ToDataTable());
        }