/// <summary> /// Handles the OnItemDataBound event of the rgTaskMembers control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridItemEventArgs"/> instance containing the event data.</param> protected void rgTaskMembers_OnItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditFormItem && e.Item.IsInEditMode) { var gridEditFormItem = (GridEditFormItem)e.Item; gridEditFormItem.FindControl("plContactPay").Visible = TypePaymentScheme == TaskTypePaymentScheme.ContactPayment; var dcbContractor = (DictionaryComboBox)gridEditFormItem.FindControl("dcbContractor"); dcbContractor.SiteID = SiteId; dcbContractor.BindData(); var ucContact = (ContactComboBox)gridEditFormItem.FindControl("ucContact"); //Если задача добавляется с карточки компании if (CompanyId.HasValue) { dcbContractor.SelectedId = (Guid)CompanyId; } //Если задача добавляется с карточки контакта if (ContactId.HasValue) { ucContact.SelectedValue = ContactId; } var dcbOrder = (DictionaryComboBox)gridEditFormItem.FindControl("dcbOrder"); dcbOrder.SiteID = SiteId; dcbOrder.BindData(); var ddlTaskMemberRole = (DropDownList)gridEditFormItem.FindControl("ddlTaskMemberRole"); BindTaskMemberRoles(ddlTaskMemberRole); ddlTaskMemberRole.SelectedIndex = ddlTaskMemberRole.Items.IndexOf(ddlTaskMemberRole.Items.FindByValue(((int)TaskMemberRole.Responsible).ToString())); ((RequiredFieldValidator)gridEditFormItem.FindControl("rfvTaskMemberRole")).InitialValue = "-1"; var item = e.Item as GridEditableItem; var ucOrderProduct = (OrderProductsComboBox)gridEditFormItem.FindControl("ucOrderProduct"); ucOrderProduct.ProductId = ProductId; if (!e.Item.OwnerTableView.IsItemInserted) { var taskMember = (TaskMemberMap)item.DataItem; if (taskMember.ContractorID.HasValue) { dcbContractor.SelectedId = (Guid)taskMember.ContractorID; } if (taskMember.OrderID.HasValue) { dcbOrder.SelectedId = (Guid)taskMember.OrderID; ucOrderProduct.OrderId = dcbOrder.SelectedId; ucOrderProduct.SelectedValue = taskMember.OrderProductsID; } ucContact.SelectedValue = taskMember.ContactID; ddlTaskMemberRole.SelectedIndex = ddlTaskMemberRole.Items.IndexOf(ddlTaskMemberRole.Items.FindByValue(taskMember.TaskMemberRoleID.ToString())); ((Literal)item.FindControl("lrlTaskMemberStatus")).Text = EnumHelper.GetEnumDescription((TaskMemberStatus)taskMember.TaskMemberStatusID); ((CheckBox)item.FindControl("chxIsInformed")).Checked = taskMember.IsInformed; ((TextBox)item.FindControl("txtComment")).Text = taskMember.Comment; ((TextBox)item.FindControl("txtUserComment")).Text = taskMember.UserComment; RefreshOrders(dcbOrder); } } else if (e.Item is GridDataItem) { var taskMember = e.Item.DataItem as TaskMemberMap; if (taskMember != null) { if (taskMember.ContractorID.HasValue) { ((Literal)e.Item.FindControl("lrlContractor")).Text = string.Format("<a href=\"{0}\">{1}</a>", UrlsData.AP_Company((Guid)taskMember.ContractorID), _dataManager.Company.SelectById(SiteId, (Guid)taskMember.ContractorID).Name); } ((Literal)e.Item.FindControl("lrlContact")).Text = string.Format("<a href=\"{0}\">{1}</a>", UrlsData.AP_Contact((Guid)taskMember.ContactID), _dataManager.Contact.SelectById(SiteId, (Guid)taskMember.ContactID).UserFullName); if (taskMember.OrderID.HasValue) { ((Literal)e.Item.FindControl("lrlOrder")).Text = string.Format("<a href=\"{0}\">{1}</a>", UrlsData.AP_OrderEdit((Guid)taskMember.OrderID), _dataManager.Order.SelectById(SiteId, (Guid)taskMember.OrderID).Number); } if (taskMember.OrderProductsID.HasValue) { var orderProduct = _dataManager.OrderProducts.SelectById((Guid)taskMember.OrderProductsID); ((Literal)e.Item.FindControl("lrlOrderProduct")).Text = string.Format( "<a href=\"{0}\">{1}</a>", UrlsData.AP_ProductEdit(orderProduct.ProductID), orderProduct.tbl_Product.Title); } ((Literal)e.Item.FindControl("lrlRole")).Text = EnumHelper.GetEnumDescription((TaskMemberRole)taskMember.TaskMemberRoleID); ((Literal)e.Item.FindControl("lrlStatus")).Text = EnumHelper.GetEnumDescription((TaskMemberStatus)taskMember.TaskMemberStatusID); ((CheckBox)e.Item.FindControl("chxIsInformed")).Checked = taskMember.IsInformed; } } }