protected void gvItemTypeFieldPreference_ItemDataBound(object sender, GridItemEventArgs e) { var dataItem = e.Item.DataItem; if (e.Item is GridDataItem) { foreach (ItemTypeData itemTypeData in ItemTypeDataList) { var rowArray = ((global::System.Data.DataRowView)(dataItem)).Row.ItemArray; ItemFieldTypeData itemFieldTypeData = (ItemFieldTypeData)(rowArray.Where(i => (i is ItemFieldTypeData) && ((ItemFieldTypeData)i).ItemTypeId == itemTypeData.Id).FirstOrDefault()); CheckBox chk = e.Item.FindControl(itemTypeData.Id.ToString()) as CheckBox; if (chk != null) { chk.Checked = itemFieldTypeData.IsSelected; chk.Enabled = !itemFieldTypeData.IsSelected; chk.Attributes.Add("data-fieldid", itemFieldTypeData.FieldId.ToString(CultureInfo.InvariantCulture)); chk.Attributes.Add("data-itemtypeid", itemFieldTypeData.ItemTypeId.ToString(CultureInfo.InvariantCulture)); } } } if (e.Item is GridGroupHeaderItem) { GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; DataRowView groupDataRow = (DataRowView)e.Item.DataItem; item.DataCell.Text = groupDataRow["GroupName"].ToString(); } }
protected void grdProductAdon_ItemCreated(object sender, GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditFormItem item = e.Item as GridEditFormItem; RadComboBox ddlPAdOnType = item.FindControl("txtAdonType") as RadComboBox; ddlPAdOnType.DataSource = _adonTypeManager.GetAllAdonType(); } else if (e.Item is GridGroupHeaderItem) { GridGroupHeaderItem item = e.Item as GridGroupHeaderItem; } }
protected void rgResultados_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridGroupHeaderItem) { GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; if (item.DataCell.Text != null && item.DataCell.Text != "") { EventoCapacitacionNegocio neg = new EventoCapacitacionNegocio(); var vParticipante = neg.ObtieneEventoParticipanteCompetencia(ID_PARTICIPANTE: int.Parse(item.DataCell.Text.Substring(16)), ID_EMPRESA: vIdEmpresa).FirstOrDefault(); if (vParticipante != null) { item.DataCell.Text = "<strong>Participante: </strong>" + vParticipante.CL_PARTICIPANTE + " - " + vParticipante.NB_PARTICIPANTE; } } } }
protected void tennisCourtsRadGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridGroupHeaderItem) { GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; DataRowView groupDataRow = (DataRowView)e.Item.DataItem; item.DataCell.Text = "Tennis Courts in " + groupDataRow["City"].ToString(); } else if (e.Item is GridDataItem) { int mapId = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["MapId"]); ImageButton imageButton = (ImageButton)e.Item.FindControl("zoomImageButton"); imageButton.Attributes.Add("onClick", string.Format("zoomToTennisCourt({0});", --mapId)); TennisCourt dataRow = (TennisCourt)e.Item.DataItem; ImageButton directionsImageButton = (ImageButton)e.Item.FindControl("directionsImageButton"); string zip = dataRow.Zip.HasValue ? dataRow.Zip.Value.ToString() : string.Empty; directionsImageButton.Attributes.Add("onClick", string.Format("showStartEndPoints('{0},{1},{2} {3}');", dataRow.Address, dataRow.City, dataRow.State, zip)); } }
private void TraverseHeaderItems(GridItem[] headerCollection, string[] groupIndexArray) { if (currentHeaderItemIndex == headerCollection.Length) { return; } string[] headerIndex = headerCollection[currentHeaderItemIndex].GroupIndex.Split('_'); for (int j = 0; j < headerIndex.Length; j++) { if (headerIndex[j] != groupIndexArray[j]) { return; } } GridGroupHeaderItem currentHeaderItem = headerCollection[currentHeaderItemIndex] as GridGroupHeaderItem; table.Cells[headerIndex.Length, row].Value = currentHeaderItem.DataCell.Text; currentHeaderItemIndex++; row++; TraverseHeaderItems(headerCollection, groupIndexArray); }
void grdDeliveries_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { CheckBox chk = e.Item.FindControl("chkOrderID") as CheckBox; HtmlGenericControl spnPalletSpaces = (HtmlGenericControl)e.Item.FindControl("spnPalletSpaces"); //HtmlImage imgOrderCollectionDeliveryNotes = (HtmlImage)e.Item.FindControl("imgOrderCollectionDeliveryNotes"); HtmlImage imgOrderBookedIn = (HtmlImage)e.Item.FindControl("imgOrderBookedIn"); List <int> orders = new List <int>(); if (Session[C_GRID_NAME] != null) { orders = (List <int>)Session[C_GRID_NAME]; } DataRowView drv = (DataRowView)e.Item.DataItem; // Colour the row if the order has been exported if (bool.Parse(drv["IsExported"].ToString()) == true) { e.Item.BackColor = System.Drawing.Color.Violet; } if (orders.Count > 0) { if (orders.Contains((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["OrderID"])) { if (chk != null) { chk.Checked = true; e.Item.Selected = true; NoPallets += (int)drv["NoPallets"]; } } } if (chk != null) { chk.Attributes.Add("onclick", string.Format("javascript:ChangeList(event, this, {0}, {1}, {2}, {3}, {4}, {5});", drv["OrderID"], drv["NoPallets"], drv["OrderGroupID"], drv["OrderGroupGroupedPlanning"].ToString().ToLower(), drv["PalletSpaces"], drv["Weight"].ToString())); } if (spnPalletSpaces != null) { switch (spnPalletSpaces.InnerText) { case "0.25": spnPalletSpaces.InnerText = "¼"; break; case "0.5": spnPalletSpaces.InnerText = "½"; break; default: break; } } //if (imgOrderCollectionDeliveryNotes != null) //{ // // if it is the orders 1st collection or orders delivery destination - show the collection / delivery note. // if (!string.IsNullOrEmpty(drv["DeliveryNotes"].ToString())) // { // imgOrderCollectionDeliveryNotes.Attributes.Add("onmouseover", "javascript:ShowOrderCollectionDeliveryNotes(this," + drv["OrderID"].ToString() + ",'" + bool.FalseString + "');"); // imgOrderCollectionDeliveryNotes.Attributes.Add("onmouseout", "javascript:hideAd();"); // imgOrderCollectionDeliveryNotes.Attributes.Add("class", "orchestratorLink"); // } // else // imgOrderCollectionDeliveryNotes.Visible = false; //} imgOrderBookedIn.Visible = Convert.ToBoolean(drv["BookedIn"].ToString()); // Collect At column ITextControl lblCollectAt = (ITextControl)e.Item.FindControl("lblCollectAt"); bool hasBeenCollected = (bool)drv["HasBeenCollected"]; DateTime colFrom = (DateTime)drv["DeliveryRunCollectionDateTime"]; DateTime colBy = colFrom; if (!hasBeenCollected) { if (drv["CollectionByDateTime"] != DBNull.Value) { colBy = (DateTime)drv["CollectionByDateTime"]; } } if (colFrom == colBy) { // Not timed window. lblCollectAt.Text = GetDate(colFrom, false); } else { // Timed window, may be anytime. bool collectionIsAnyTime = colFrom.Date == colBy.Date && colFrom.Hour == 0 && colBy.Hour == 0 && colFrom.Millisecond == 0 && colBy.Minute == 59; if (collectionIsAnyTime) { lblCollectAt.Text = GetDate(colFrom, true); } else { lblCollectAt.Text = GetDate(colFrom, false) + " to " + GetDate(colBy, false); } } // Delivery At column Label lblDeliverAt = (Label)e.Item.FindControl("lblDeliverAt"); DateTime delFrom = Convert.ToDateTime(drv["DeliveryFromDateTime"].ToString()); DateTime delBy = Convert.ToDateTime(drv["DeliveryDateTime"].ToString()); if (lblDeliverAt != null) { if (delFrom == delBy) { // Timed booking... only show a single date. lblDeliverAt.Text = GetDate(Convert.ToDateTime(drv["DeliveryDateTime"].ToString()), false); } else { // If the times span from mignight to 23:59 on the same day then // it's an 'anytime' window. if (delFrom.Date == delBy.Date && delFrom.Hour == 0 && delFrom.Minute == 0 && delBy.Hour == 23 && delBy.Minute == 59) { // It's anytime lblDeliverAt.Text = GetDate(Convert.ToDateTime(drv["DeliveryDateTime"].ToString()), true); } else { // It's a booking window lblDeliverAt.Text = GetDate(Convert.ToDateTime(drv["DeliveryFromDateTime"].ToString()), false) + " to " + GetDate(Convert.ToDateTime(drv["DeliveryDateTime"].ToString()), false); } } } // Surcharges columns ITextControl lblSurcharge = (ITextControl)e.Item.FindControl("lblSurcharge"); lblSurcharge.Text = string.Empty; int orderID = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["OrderID"]; if (this.SurchargeLookupData.ContainsKey(orderID)) { lblSurcharge.Text = this.SurchargeLookupData[orderID]; } } else if (e.Item is GridGroupHeaderItem) { GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; DataRowView groupDataRow = (DataRowView)e.Item.DataItem; item.DataCell.Text = string.Format("{0} ({1})", groupDataRow["TrafficAreaShortName"], groupDataRow["Count"]); } }
void grdOrders_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { CheckBox chk = e.Item.FindControl("chkOrderID") as CheckBox; HtmlGenericControl spnPalletSpaces = (HtmlGenericControl)e.Item.FindControl("spnPalletSpaces"); HtmlImage imgOrderCollectionDeliveryNotes = (HtmlImage)e.Item.FindControl("imgOrderCollectionDeliveryNotes"); List <int> orders = new List <int>(); if (Session[C_GRID_NAME] != null) { orders = (List <int>)Session[C_GRID_NAME]; } DataRowView drv = (DataRowView)e.Item.DataItem; if ((bool)drv["PlannedForCollection"]) { e.Item.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFDFBF"); } if (orders.Count > 0) { if (orders.Contains((int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["OrderID"])) { if (chk != null) { chk.Checked = true; e.Item.Selected = true; NoPallets += (int)drv["NoPallets"]; } } } if (chk != null) { chk.Attributes.Add("onclick", string.Format("javascript:ChangeList(event, this, {0}, {1}, {2}, {3});", drv["OrderID"], drv["NoPallets"], drv["OrderGroupID"], drv["OrderGroupGroupedPlanning"].ToString().ToLower())); } if (spnPalletSpaces != null) { switch (spnPalletSpaces.InnerText) { case "0.25": spnPalletSpaces.InnerText = "¼"; break; case "0.5": spnPalletSpaces.InnerText = "½"; break; default: break; } } if (imgOrderCollectionDeliveryNotes != null) { // if it is the orders 1st collection or orders delivery destination - show the collection / delivery note. if (!string.IsNullOrEmpty(drv["CollectionNotes"].ToString())) { imgOrderCollectionDeliveryNotes.Attributes.Add("onmouseover", "javascript:ShowOrderCollectionDeliveryNotes(this," + drv["OrderID"].ToString() + ",'" + bool.TrueString + "');"); imgOrderCollectionDeliveryNotes.Attributes.Add("onmouseout", "javascript:closeToolTip();"); imgOrderCollectionDeliveryNotes.Attributes.Add("class", "orchestratorLink"); } else { imgOrderCollectionDeliveryNotes.Visible = false; } } } else if (e.Item is GridGroupHeaderItem) { GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item; DataRowView groupDataRow = (DataRowView)e.Item.DataItem; item.DataCell.Text = string.Format("{0} ({1})", groupDataRow["TrafficAreaShortName"], groupDataRow["Count"]); } }
protected void RadGridSalesReport_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridGroupHeaderItem) { GridGroupHeaderItem item = e.Item as GridGroupHeaderItem; (item.DataCell).Text = (item.DataCell).Text.Replace("MonthAndYear: ", string.Empty); this.HeaderText = (item.DataCell).Text; string monthPart = (item.DataCell).Text.Substring(4); if (monthPart == "01") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "January"; } else if (monthPart == "02") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "February"; } else if (monthPart == "03") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "March"; } else if (monthPart == "04") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "April"; } else if (monthPart == "05") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "May"; } else if (monthPart == "06") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "June"; } else if (monthPart == "07") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "July"; } else if (monthPart == "08") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "August"; } else if (monthPart == "09") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "September"; } else if (monthPart == "10") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "October"; } else if (monthPart == "11") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "November"; } else if (monthPart == "12") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "December"; } } else if (e.Item is GridFooterItem) { var footeritem = (GridFooterItem)e.Item; try { var totalGrossProfit = decimal.Parse(e.Item.Cells[10].Text.Replace("$", string.Empty).Replace(",", string.Empty)); var totalSalesPrice = decimal.Parse(e.Item.Cells[6].Text.Replace("$", string.Empty).Replace(",", string.Empty)); e.Item.Cells[11].Text = ((totalGrossProfit / totalSalesPrice) * 100).ToString("0.00") + "%"; } catch (Exception) { //ignored } //footeritem.Cells[5].Text = string.Empty; //footeritem.Cells[7].Text = string.Empty; //footeritem.Style.Add("text-align", "right"); footeritem.Style.Add("color", "green"); footeritem.Style.Add("font-weight", "bold"); } else if (e.Item is GridDataItem) { var item = (GridDataItem)e.Item; if (!(item.ItemIndex > -1 && item.DataItem is ReturnOrderQuantitiesAndAmountBO)) { return; } var obj = (ReturnOrderQuantitiesAndAmountBO)item.DataItem; var lnkQuentity = (HyperLink)item.FindControl("lnkQuantity"); lnkQuentity.Text = Convert.ToString(obj.Quantity); lnkQuentity.NavigateUrl = "DrillDownReport.aspx?id=" + obj.ID + "&DistributorName=" + obj.Name + "&Start=" + DateTime.Parse(this.txtCheckin.Value).ToShortDateString() + "&End=" + DateTime.Parse(this.txtCheckout.Value).ToShortDateString() + "&Current=" + HeaderText + "&Name=" + txtName.Text + "&Type=" + ((rdoDirectSales.Checked) ? "1" : "2"); var litGrossMargin = (Literal)item.FindControl("litGrossMargin"); litGrossMargin.Text = obj.GrossMargin.ToString("0.00") + "%"; //HyperLink lnkDistributor = (HyperLink)item.FindControl("lnkDistributor"); // lnkDistributor.NavigateUrl = "DrillDownReport.aspx?id=" + obj.ID.ToString() + "&Start=" + DateTime.Parse(this.txtCheckin.Value).ToShortDateString() + "&End=" + DateTime.Parse(this.txtCheckout.Value).ToShortDateString() + "&Current=" + this.HeaderText + "&Name=" + this.txtName.Text + "&Type=" + ((this.rdoDirectSales.Checked)? "1" : "2"); //lnkDistributor.Text = obj.Name; // Literal litGrossMargin = (Literal)item.FindControl("litGrossMargin"); //litGrossMargin.Text = obj.GrossMargin.ToString("0.00") + "%"; } else if (e.Item is GridGroupFooterItem) { GridGroupFooterItem groupFooter = e.Item as GridGroupFooterItem; decimal totalGrossProfit = decimal.Parse(e.Item.Cells[10].Text.Replace("$", string.Empty).Replace(",", string.Empty)); decimal totalSalesPrice = decimal.Parse(e.Item.Cells[6].Text.Replace("$", string.Empty).Replace(",", string.Empty)); e.Item.Cells[11].Text = ((totalGrossProfit / totalSalesPrice) * 100).ToString("0.00") + "%"; groupFooter.Style.Add("color", "blue"); groupFooter.Style.Add("font-weight", "bold"); } }
protected void RadGridDrillDownReport_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridGroupHeaderItem) { GridGroupHeaderItem item = e.Item as GridGroupHeaderItem; (item.DataCell).Text = (item.DataCell).Text.Replace("MonthAndYear: ", string.Empty); string monthPart = (item.DataCell).Text.Substring(4); if (monthPart == "01") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "January"; } else if (monthPart == "02") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "February"; } else if (monthPart == "03") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "March"; } else if (monthPart == "04") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "April"; } else if (monthPart == "05") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "May"; } else if (monthPart == "06") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "June"; } else if (monthPart == "07") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "July"; } else if (monthPart == "08") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "August"; } else if (monthPart == "09") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "September"; } else if (monthPart == "10") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "October"; } else if (monthPart == "11") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "November"; } else if (monthPart == "12") { (item.DataCell).Text = (item.DataCell).Text.Substring(0, 4) + " - " + "December"; } } else if (e.Item is GridFooterItem) { GridFooterItem footeritem = e.Item as GridFooterItem; //footeritem.Cells[5].Text = string.Empty; try { var totalGrossProfit = decimal.Parse(e.Item.Cells[9].Text.Replace("$", string.Empty).Replace(",", string.Empty)); var totalSalesPrice = decimal.Parse(e.Item.Cells[5].Text.Replace("$", string.Empty).Replace(",", string.Empty)); e.Item.Cells[10].Text = ((totalGrossProfit / totalSalesPrice) * 100).ToString("0.00") + "%"; } catch (Exception) { //ignored } footeritem.Style.Add("color", "green"); footeritem.Style.Add("font-weight", "bold"); } else if (e.Item is GridGroupFooterItem) { var totalGrossProfit = decimal.Parse(e.Item.Cells[10].Text.Replace("$", string.Empty).Replace(",", string.Empty)); var totalSalesPrice = decimal.Parse(e.Item.Cells[6].Text.Replace("$", string.Empty).Replace(",", string.Empty)); e.Item.Cells[11].Text = ((totalGrossProfit / totalSalesPrice) * 100).ToString("0.00") + "%"; GridGroupFooterItem groupFooter = e.Item as GridGroupFooterItem; groupFooter.Cells[2].BackColor = Color.Red; groupFooter.Style.Add("color", "blue"); groupFooter.Style.Add("font-weight", "bold"); } else if (e.Item is GridDataItem) { var item = (GridDataItem)e.Item; if (!(item.ItemIndex > -1 && item.DataItem is ReturnDetailReportByDistributorBO)) { return; } var obj = (ReturnDetailReportByDistributorBO)item.DataItem; var lnkQuantity = (HyperLink)item.FindControl("lnkQuantity"); lnkQuantity.NavigateUrl = "DrillDownReportByClient.aspx?Start=" + this.Start.ToShortDateString() + "&End=" + this.End.ToShortDateString() + "&Distributor=" + this.Distributor.ToString() + "&Client=" + obj.ID.ToString() + "&Current=" + this.Current + "&Name=" + this.DistributorName + "&Type=" + this.DistributorType + "&ClientName=" + obj.Client + "&DistributorName=" + CurrentDistributorName; lnkQuantity.Text = Convert.ToString(obj.Quantity); } }