internal static int Add(CatalogImage entity) { CatalogImage CatalogImageEntity = (CatalogImage)(entity); using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString)) { SqlCommand sqlCommand = new SqlCommand(SN_CATALOG_IMAGE_ADD, sqlConnection); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter sqlParameter = null; sqlParameter = new SqlParameter(PN_CATALOG_IMAGE_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Output; sqlParameter.Value = CatalogImageEntity.ID; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_CATALOG_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = CatalogImageEntity.CatalogID; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_CATALOG_IMAGE_NAME, System.Data.SqlDbType.NVarChar); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = CatalogImageEntity.Image; sqlCommand.Parameters.Add(sqlParameter); sqlParameter = new SqlParameter(PN_CATALOG_IMAGE_IS_COVER_IMAGE, System.Data.SqlDbType.Bit); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = CatalogImageEntity.IsCoverImage; sqlCommand.Parameters.Add(sqlParameter); try { sqlCommand.Connection.Open(); sqlCommand.ExecuteNonQuery(); sqlCommand.Connection.Close(); CatalogImageEntity.ID = Convert.ToInt32(sqlCommand.Parameters[PN_CATALOG_IMAGE_ID].Value); } catch (Exception ex) { throw ex; } } return CatalogImageEntity.ID; }
public static int Add(CatalogImage CatalogImage) { return CatalogImageDataMapper.Add(CatalogImage); }
public static void Update(CatalogImage CatalogImage) { CatalogImageDataMapper.Update(CatalogImage); }
internal static void FillFromReader(CatalogImage CatalogImage, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_CATALOG_IMAGE_ID); if (!reader.IsDBNull(colIndex)) CatalogImage.ID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATALOG_ID); if (!reader.IsDBNull(colIndex)) CatalogImage.CatalogID = reader.GetInt32(colIndex); colIndex = reader.GetOrdinal(CN_CATALOG_IMAGE_NAME); if (!reader.IsDBNull(colIndex)) CatalogImage.Image = reader.GetString(colIndex); colIndex = reader.GetOrdinal(CN_CATALOG_IMAGE_IS_COVER_IMAGE); if (!reader.IsDBNull(colIndex)) CatalogImage.IsCoverImage = reader.GetBoolean(colIndex); colIndex = reader.GetOrdinal(CN_CATALOG_IMAGE_IS_DELETED); if (!reader.IsDBNull(colIndex)) CatalogImage.IsDeleted = reader.GetBoolean(colIndex); }
internal static CatalogImage GetCatalogImage(List<CatalogImage> CatalogImages, SqlDataReader reader) { int colIndex = 0; colIndex = reader.GetOrdinal(CN_CATALOG_IMAGE_ID); int value = reader.GetInt32(colIndex); CatalogImage CatalogImage = CatalogImages.Where(c => c.ID == value).FirstOrDefault(); if (CatalogImage == null) { CatalogImage = new CatalogImage(); CatalogImages.Add(CatalogImage); } return CatalogImage; }
internal static CatalogImage GetCatalogImageByID(int id) { CatalogImage CatalogImage = null; using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString)) { SqlCommand sqlCommand = new SqlCommand(SN_CATALOG_IMAGE_GET_BY_ID, sqlConnection); sqlCommand.CommandType = System.Data.CommandType.StoredProcedure; SqlParameter sqlParameter = null; sqlParameter = new SqlParameter(PN_CATALOG_IMAGE_ID, System.Data.SqlDbType.Int); sqlParameter.Direction = System.Data.ParameterDirection.Input; sqlParameter.Value = id; sqlCommand.Parameters.Add(sqlParameter); sqlCommand.Connection.Open(); using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { while (sqlDataReader.Read()) { CatalogImage = new CatalogImage(); FillFromReader(CatalogImage, sqlDataReader); } sqlDataReader.Close(); sqlCommand.Connection.Close(); } } return CatalogImage; }
void btnSaveCatalogImage_Click(object sender, EventArgs e) { List<string> imagesNames = ucSWFUploadCatalogImage.GetFilesName(); if (imagesNames != null && imagesNames.Count > 0) { foreach (string name in imagesNames) { CatalogImage catalogImage = new CatalogImage { CatalogID = Convert.ToInt32(ViewState[CMSViewStateManager.CatalogID]), Image = name, IsCoverImage = cbIsCoverImage.Checked, IsDeleted = false, }; CatalogImageManager.Add(catalogImage); } } BeginCatalogImageAddMode(); FillCatalogImages(Convert.ToInt32(ViewState[CMSViewStateManager.CatalogID])); upnlCatalogImage.Update(); upnlCatalogItem.Update(); }