Esempio n. 1
0
        private SmartCollection<PriorityRestriction> GetCatalogItemPriorityRestrictions(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int catalogid, Identification identification)
        {
            try {
                SmartCollection<PriorityRestriction> result = new SmartCollection<PriorityRestriction>();
                if (dbConnection.IsConnected()) {
                    dbCommand.CommandType = CommandType.StoredProcedure;
                    dbCommand.CommandText = "uspGetPriorityRestrictions";
                    dbCommand.Parameters.Clear();
                    dbCommand.Parameters.Add("@CatalogId", System.Data.SqlDbType.Int).Value = catalogid;
                    DataTable returnDT = dbConnection.ExecuteQuery(dbCommand);
                    foreach (DataRow row in returnDT.Rows) {
                        PriorityRestriction catalogItemPriority = new PriorityRestriction();
                        catalogItemPriority.PriorityRestrictionId = (int)row["PriorityRestrictionID"];
                        catalogItemPriority.CatalogId = row["CatalogID"] != DBNull.Value ? (int)row["CatalogID"] : 0;
                        catalogItemPriority.PriorityId = row["PriorityID"] != DBNull.Value ? (int)row["PriorityID"] : 0;
                        catalogItemPriority.CreatedBy = row["CreatedBy"] != DBNull.Value ? Convert.ToInt32(row["CreatedBy"]) : 0;
                        catalogItemPriority.CreatedUser = row["CreatedUser"].ToString();
                        catalogItemPriority.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null;
                        catalogItemPriority.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(row["ModifiedBy"]) : 0;
                        catalogItemPriority.ModifiedUser = row["ModifiedUser"].ToString();
                        catalogItemPriority.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null;

                        using (SystemDAO systemDao = new SystemDAO()) {
                            catalogItemPriority.Priority = systemDao.GetPriority(catalogItemPriority.PriorityId);
                        }
                        result.Add(catalogItemPriority);
                    }
                    returnDT = null;
                }else {
                    throw new Exception("Unable to Connect");
                }
                return result;
            }catch {
                throw;
            }
        }
 public PriorityRestriction CreateCatalogItemPriority()
 {
     PriorityRestriction newItem = new PriorityRestriction();
     newItem.PriorityRestrictionId = addingCatalogItemPriorityId--;
     newItem.CatalogId = CatalogItem.CatalogId;
     this.selectedCatalogItemPriority = newItem.Clone();
     return newItem;
 }
Esempio n. 3
0
        private PriorityRestriction GetCatalogItemPriority(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int? priorityId)
        {
            try
            {
                PriorityRestriction catalogItemPriority = new PriorityRestriction();
                if (dbConnection.IsConnected())
                {
                    dbCommand.CommandType = CommandType.StoredProcedure;
                    dbCommand.CommandText = "uspGetPriorityRestriction";
                    dbCommand.Parameters.Clear();
                    dbCommand.Parameters.Add("@PriorityRestrictionId", System.Data.SqlDbType.Int).Value = priorityId;
                    DataTable returnDT = dbConnection.ExecuteQuery(dbCommand);
                    if (returnDT.Rows.Count == 1)
                    {
                        DataRow row = returnDT.Rows[0];
                        catalogItemPriority.PriorityRestrictionId = (int)row["PriorityRestrictionID"];
                        catalogItemPriority.CatalogId = row["CatalogID"] != DBNull.Value ? (int)row["CatalogID"] : 0;
                        catalogItemPriority.PriorityId = row["PriorityID"] != DBNull.Value ? (int)row["PriorityID"] : 0;
                        catalogItemPriority.CreatedBy = row["CreatedBy"] != DBNull.Value ? Convert.ToInt32(row["CreatedBy"]) : 0;
                        catalogItemPriority.CreatedUser = row["CreatedUser"].ToString();
                        catalogItemPriority.CreatedDate = row["CreatedDate"] != DBNull.Value ? (DateTime)row["CreatedDate"] : (DateTime)SqlDateTime.Null;
                        catalogItemPriority.ModifiedBy = row["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(row["ModifiedBy"]) : 0;
                        catalogItemPriority.ModifiedUser = row["ModifiedUser"].ToString();
                        catalogItemPriority.ModifiedDate = row["ModifiedDate"] != DBNull.Value ? (DateTime)row["ModifiedDate"] : (DateTime)SqlDateTime.Null;

                        using (SystemDAO systemDao = new SystemDAO())
                        {
                            catalogItemPriority.Priority = systemDao.GetPriority(catalogItemPriority.PriorityId);
                        }
                        returnDT = null;
                    }
                    else
                    {
                        returnDT = null;
                        return null;
                    }
                }
                else
                {
                    throw new Exception("Unable to Connect");
                }
                return catalogItemPriority;
            }
            catch
            {
                throw;
            }
        }