protected void ItemGrid_Update(object sender, BXUpdateEventArgs e)
    {
        int ID = (int)e.Keys["ID"];
        if (ID < 1)
            return;

        try
        {
            CustomerProfiles forum = CustomerProfiles.GetById(ID);
            if (forum == null)
                return;

            if (e.NewValues.Contains("active"))
                forum.active = (bool)e.NewValues["active"];

            if (e.NewValues.Contains("name"))
                forum.name = (string)e.NewValues["name"];

            forum.Update();
        }
        catch (Exception ex)
        {
            ErrorMessage.AddErrorMessage(ex.Message);
        }
    }
	protected void ItemGrid_Update(object sender, BXUpdateEventArgs e)
	{
		if (!canModify)
			return;
		int elementID = (int)e.Keys["Id"];
		if (elementID <= 0)
			return;

		try
		{
			BXContentTag tag = BXContentTag.GetById(e.Keys["Id"]);
			if (tag == null)
				return;

			if (e.NewValues.Contains("Status"))
			{
				try
				{
					tag.Status = (BXContentTagStatus)Enum.Parse(typeof(BXContentTagStatus), (string)e.NewValues["Status"]);
				}
				catch
				{
				}
			}
			tag.Save();
		}
		catch (BXEventException exception)
		{
			foreach (string s in exception.Messages)
				ErrorMessage.AddErrorMessage(Encode(s));
		}
		catch (Exception exception)
		{
			ErrorMessage.AddErrorMessage(Encode(exception.Message));
		}
	}
Example #3
0
 protected void GridView1_Update(object sender, BXUpdateEventArgs e)
 {
     BXRatingVoting v = BXRatingVoting.GetById(e.Keys["ID"]);
     v.XmlId = e.NewValues["XmlId"].ToString();
     v.Update();
 }
Example #4
0
	protected void BXForumGrid_Update(object sender, BXUpdateEventArgs e)
	{
		int forumID = (int)e.Keys["ID"];
		if (forumID < 1)
			return;

		try
		{
			BXForum forum = BXForum.GetById(forumID);
			if (forum == null || !BXPrincipal.Current.IsCanOperate(BXForum.Operations.ForumAdminManage, "forum", forum.Id))
				return;

			if (e.NewValues.Contains("Active"))
				forum.Active = (bool)e.NewValues["Active"];

			if (e.NewValues.Contains("Name") && !BXStringUtility.IsNullOrTrimEmpty((string)e.NewValues["Name"]))
				forum.Name = (string)e.NewValues["Name"];

			if (e.NewValues.Contains("Description"))
				forum.Description = (string)e.NewValues["Description"];

			if (e.NewValues.Contains("CategoryId"))
				forum.CategoryId = (int)e.NewValues["CategoryId"];

			int sortIndex;
			if (e.NewValues.Contains("Sort") && int.TryParse((string)e.NewValues["Sort"], out sortIndex))
				forum.Sort = sortIndex;

			if (e.NewValues.Contains("AllowBBCode"))
				forum.AllowBBCode = (bool)e.NewValues["AllowBBCode"];

			if (e.NewValues.Contains("AllowSmiles"))
				forum.AllowSmiles = (bool)e.NewValues["AllowSmiles"];

			if (e.NewValues.Contains("IndexContent"))
				forum.IndexContent = (bool)e.NewValues["IndexContent"];

			if (e.NewValues.Contains("Code"))
				forum.Code = (string)e.NewValues["Code"];

			if (e.NewValues.Contains("XmlId"))
				forum.XmlId = (string)e.NewValues["XmlId"];

			forum.Update();
		}
		catch (Exception ex)
		{
			ErrorMessage.AddErrorMessage(ex.Message);
		}
	}
Example #5
0
	protected void fileManGrid_Update(object sender, BXUpdateEventArgs e)
	{
		try
		{
			string source = BXPath.Combine(this.curPath, (string)e.Keys["name"]);
            string newName = (string)e.NewValues["name"];
			string destination = BXPath.Combine(this.curPath, newName);

			if ((string)e.Keys["type"] != "f" && (string)e.Keys["type"] != "d")
				throw new Exception(String.Format("{0}: {1}", GetMessageRaw("Message.UnknownItem"), source));

			bool isFile;
			if (BXSecureIO.FileExists(source))
				isFile = true;
			else if (BXSecureIO.DirectoryExists(source))
				isFile = false;
			else
				throw new Exception(String.Format("{0}: {1}", GetMessageRaw("Message.UnknownItem"), source));

			if (BXPathComparer.Instance.Equals(source, destination))
			{
				ShowOk();
				return;
			}

			if (BXSecureIO.FileOrDirectoryExists(destination))
				throw new Exception(String.Format("{0}: {1} -> {2}", GetMessageRaw("Message.TargetItemAlreadyExists"), source, destination));

            Regex validationRx = new Regex(BXPath.NameValidationRegexString, RegexOptions.CultureInvariant | RegexOptions.Compiled);
            if (!validationRx.IsMatch(newName))
                throw new Exception(string.Format(GetMessageRaw("IllegalCharactersIsDecetedInFileName"), newName));

			try
			{
				if (isFile)
					BXSecureIO.FileMove(source, destination);
				else
					BXSecureIO.DirectoryMove(source, destination);
			}
			catch (Exception ex)
			{
				throw new Exception(String.Format("{0}: {1} -> {2}", GetMessageRaw("Message.UnableToRename"), source, destination), ex);
			}

			ShowOk();
			e.UpdatedCount = 1;
		}
		catch (Exception ex)
		{
			ShowError(Encode(ex.Message));
		}
	}
	protected void GridView1_Update(object sender, BXUpdateEventArgs e)
	{
		//UpdatePanel1.Triggers.Add(

		int elementID = (int)e.Keys["ID"];
		string elementType = (string)e.Keys["CommonElementType"];

		if (elementID < 1)
			return;

		try
		{
			if (elementType == "S" && canModifySections)
			{
				BXIBlockSectionCollection sectionCollection = BXIBlockSection.GetList(
					new BXFilter(
						new BXFilterItem(BXIBlockSection.Fields.ID, BXSqlFilterOperators.Equal, elementID),
						new BXFilterItem(BXIBlockSection.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId)
					),
					null
				);


				if (sectionCollection == null || sectionCollection.Count != 1)
					return;

				BXIBlockSection section = sectionCollection[0];

				if (e.NewValues.Contains("Active"))
					section.Active = (bool)e.NewValues["Active"];

				if (e.NewValues.Contains("Name") && !BXStringUtility.IsNullOrTrimEmpty((string)e.NewValues["Name"]))
					section.Name = (string)e.NewValues["Name"];

				if (e.NewValues.Contains("Code"))
					section.Code = (string)e.NewValues["Code"];

				if (e.NewValues.Contains("XmlId"))
					section.XmlId = (string)e.NewValues["XmlId"];

				if (e.NewValues.Contains("DetailText"))
					section.Description = (string)e.NewValues["DetailText"];

				if (e.NewValues.Contains("DetailTextType"))
					section.DescriptionType = (string)e.NewValues["DetailTextType"] == "H" ? BXTextType.Html : BXTextType.Text;


				if (e.NewValues.Contains("DetailPicture"))
				{
					bitrix_ui_AdminImageField adminImageField = (bitrix_ui_AdminImageField)e.NewValues["DetailPicture"];

					BXFile detailPicture = SaveFile(adminImageField, sectionCollection[0].DetailImageId);
					if (detailPicture != null)
						section.DetailImageId = detailPicture.Id;
					else if (adminImageField.DeleteFile)
						section.DetailImageId = 0;
				}

				if (e.NewValues.Contains("PreviewPicture"))
				{
					bitrix_ui_AdminImageField adminImageField = (bitrix_ui_AdminImageField)e.NewValues["PreviewPicture"];

					BXFile previewPicture = SaveFile(adminImageField, sectionCollection[0].ImageId);
					if (previewPicture != null)
						section.ImageId = previewPicture.Id;
					else if (adminImageField.DeleteFile)
						section.ImageId = 0;
				}

				int sortIndex;
				if (e.NewValues.Contains("Sort") && int.TryParse((string)e.NewValues["Sort"], out sortIndex))
					section.Sort = sortIndex;


				section.ModifiedBy = (this.BXUser.Identity as BXIdentity).Id;
				section.Update();
			}
			else if (elementType == "E" && canModifyElements)
			{
				BXIBlockElementCollection elementCollection = BXIBlockElement.GetList(
					new BXFilter(
						new BXFilterItem(BXIBlockElement.Fields.ID, BXSqlFilterOperators.Equal, elementID),
						new BXFilterItem(BXIBlockElement.Fields.IBlock.ID, BXSqlFilterOperators.Equal, iblockId)
					),
					null
				);

				if (elementCollection == null || elementCollection.Count != 1)
					return;

				BXIBlockElement element = elementCollection[0];
				//element.Id = elementID;

				if (e.NewValues.Contains("Name") && !BXStringUtility.IsNullOrTrimEmpty((string)e.NewValues["Name"]))
					element.Name = (string)e.NewValues["Name"];

				if (e.NewValues.Contains("Code"))
					element.Code = (string)e.NewValues["Code"];

				if (e.NewValues.Contains("XmlId"))
					element.XmlId = (string)e.NewValues["XmlId"];

				if (e.NewValues.Contains("Tags"))
					element.Tags = (string)e.NewValues["Tags"];

				if (e.NewValues.Contains("Active"))
					element.Active = (bool)e.NewValues["Active"];

				if (e.NewValues.Contains("PreviewText"))
					element.PreviewText = (string)e.NewValues["PreviewText"];

				if (e.NewValues.Contains("PreviewTextType"))
					element.PreviewTextType = (string)e.NewValues["PreviewTextType"] == "H" ? BXTextType.Html : BXTextType.Text;

				if (e.NewValues.Contains("DetailText"))
					element.DetailText = (string)e.NewValues["DetailText"];

				if (e.NewValues.Contains("DetailTextType"))
					element.DetailTextType = (string)e.NewValues["DetailTextType"] == "H" ? BXTextType.Html : BXTextType.Text;
	
				if (e.NewValues.Contains("DetailPicture"))
				{
					bitrix_ui_AdminImageField adminImageField = (bitrix_ui_AdminImageField)e.NewValues["DetailPicture"];

					BXFile detailPicture = SaveFile(adminImageField, elementCollection[0].DetailImageId);
					if (detailPicture != null)
						element.DetailImageId = detailPicture.Id;
					else if (adminImageField.DeleteFile)
						element.DetailImageId = 0;
				}

				if (e.NewValues.Contains("PreviewPicture"))
				{
					bitrix_ui_AdminImageField adminImageField = (bitrix_ui_AdminImageField)e.NewValues["PreviewPicture"];

					BXFile previewPicture = SaveFile(adminImageField, elementCollection[0].PreviewImageId);
					if (previewPicture != null)
						element.PreviewImageId = previewPicture.Id;
					else if (adminImageField.DeleteFile)
						element.PreviewImageId = 0;
				}

				if (e.NewValues.Contains("ActiveFromDate"))
				{
					DateTime activeFrom;
					DateTime.TryParse((string)e.NewValues["ActiveFromDate"], out activeFrom);
					element.ActiveFromDate = activeFrom;
				}

				if (e.NewValues.Contains("ActiveToDate"))
				{
					DateTime activeTo;
					DateTime.TryParse((string)e.NewValues["ActiveToDate"], out activeTo);
					element.ActiveToDate = activeTo;
				}

				int sortIndex;
				if (e.NewValues.Contains("Sort") && int.TryParse((string)e.NewValues["Sort"], out sortIndex))
					element.Sort = sortIndex;


				BXGridView.FillCustomValues(e.NewValues, element, x => x.StartsWith("#"), x => x.Substring(1));

				element.ModifiedBy = (this.BXUser.Identity as BXIdentity).Id;

				element.Update();
			}

		}
		catch (BXEventException exception)
		{
			foreach (string s in exception.Messages)
				errorMessage.AddErrorMessage(s);
		}
		catch (Exception exception)
		{
			errorMessage.AddErrorMessage(exception.Message);
		}
	}
Example #7
0
	protected void MailerGridView_Update(object sender, BXUpdateEventArgs e)
	{
		if (!currentUserCanModify)
			return;
		BXMailerTemplate t = BXMailerTemplate.GetById(e.Keys["Id"]);
		if (t != null)
		{
			if (e.NewValues.Contains("Subject"))
				t.Subject = (string)e.NewValues["Subject"];
			if (e.NewValues.Contains("Active"))
				t.Active = (bool)e.NewValues["Active"];
			t.Save();
			e.UpdatedCount = 1;
		}
	}
    protected void ItemGrid_Update(object sender, BXUpdateEventArgs e)
    {
        int bannerID=0;
        if (!int.TryParse(e.Keys["ID"].ToString(), out bannerID)) return;
        
        if (bannerID < 1)
            return;

        try
        {
            BXAdvertisingBanner banner = BXAdvertisingBanner.GetById(bannerID);
            if (banner == null || !BXPrincipal.Current.IsCanOperate(BXAdvertisingModule.Operations.BannerManagement))
                return;

            if (e.NewValues.Contains("isActive"))
                banner.Active = (bool)e.NewValues["isActive"];

            if (e.NewValues.Contains("Name") && !BXStringUtility.IsNullOrTrimEmpty((string)e.NewValues["Name"]))
                banner.Name = (string)e.NewValues["Name"];

            int weight;
            if (e.NewValues.Contains("Weight") && int.TryParse((string)e.NewValues["Weight"], out weight))
                banner.Weight = weight;

            int spaceId;
            if (e.NewValues.Contains("SpaceId") && int.TryParse((string)e.NewValues["SpaceId"], out spaceId))
                banner.SpaceId = spaceId;

            banner.Update();
        }
        catch (Exception ex)
        {
            ErrorMessage.AddErrorMessage(ex.Message);
        }
    }