public void grd1_ItemDataBound(object sender, DataGridItemEventArgs e) { Whitfieldcore _wc = new Whitfieldcore(); String DetailId = ""; //(a.EnghourRate * b.eng_hours + a.fabhourrate * b.fab_hours + a.insthourrate * b.install_hours + a.mischourrate*b.misc_hours + a.fabhourrate*b.fin_hours) total_labor if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DetailId = grdpl1.DataKeys[Convert.ToInt32(e.Item.ItemIndex)].ToString(); String TotMatPriceWO = _wc.GetTotalMaterialPriceForWorkOrder(Convert.ToInt32(ViewState["EstNum"].ToString()), DetailId); if (TotMatPriceWO == "0") { TotMatPriceWO = "1"; } Decimal TotMatPriceProj = _wc.GetTotalMaterialPriceForEstimation(Convert.ToInt32(ViewState["EstNum"])); if (TotMatPriceProj == 0) { TotMatPriceProj = 100; } //Contingency Dispersement ((Label)(e.Item.FindControl("lblContDisp"))).Text = ((Convert.ToDecimal(TotMatPriceWO) / TotMatPriceProj) * 100).ToString("00.00"); //Material Cost ((Label)(e.Item.FindControl("lblMatCost"))).Text = _wc.GetTotalMaterialPriceForWorkOrder(Convert.ToInt32(ViewState["EstNum"].ToString()), DetailId); String tmpContDisp = ((Label)(e.Item.FindControl("lblContDisp"))).Text; if (((Label)(e.Item.FindControl("lblContDisp"))).Text == "1") tmpContDisp = "0"; //Contengency //Response.Write("Contengency:" + _contAmt.ToString() + " tmpContDisp:" + tmpContDisp); _contAmt = Convert.ToDecimal(_wc.GetContengency(Convert.ToInt32(ViewState["EstNum"].ToString()))); String TotalContengency = (Convert.ToDecimal(_contAmt) * Convert.ToDecimal(Convert.ToDecimal(tmpContDisp) / 100)).ToString("00.00"); ((Label)(e.Item.FindControl("lblContigency"))).Text = TotalContengency; //Material Cost + Contingency ((Label)(e.Item.FindControl("lblMatPlusCont"))).Text = (Convert.ToDecimal(((Label)(e.Item.FindControl("lblMatCost"))).Text) + Convert.ToDecimal(TotalContengency)).ToString("00.00"); //Overhead = (Total Labor + total Material + Contingency)* Overhead percent //(Total Labor + total Material + Contingency)* Overhead percent //Response.Write("OHPercent:" + _wc.GetOverHeadPercent(Convert.ToInt32(ViewState["EstNum"].ToString()))); //Response.Write("<br>Profit Markup:" + _wc.GetProfitMarkUp(Convert.ToInt32(ViewState["EstNum"].ToString()))); //Overhead = (Total Labor + total Material + Contingency)* Overhead percent //((Label)(e.Item.FindControl("lbloverhead"))).Text = ((Convert.ToDecimal(((Label)(e.Item.FindControl("lblTotlabor"))).Text) + Convert.ToDecimal(((Label)(e.Item.FindControl("lblMatPlusCont"))).Text)) * Convert.ToDecimal(Convert.ToDecimal(_wc.GetOverHeadPercent(Convert.ToInt32(ViewState["EstNum"].ToString()))) / 100)).ToString("00.00"); ((Label)(e.Item.FindControl("lbloverhead"))).Text = ((Convert.ToDecimal(((Label)(e.Item.FindControl("lblfinhours"))).Text) + Convert.ToDecimal(((Label)(e.Item.FindControl("lblMiscHours"))).Text) + Convert.ToDecimal(((Label)(e.Item.FindControl("lblEnghours"))).Text) + Convert.ToDecimal(((Label)(e.Item.FindControl("lblfabhours"))).Text)) * Convert.ToDecimal(((HiddenField)(e.Item.FindControl("hdntot_rate"))).Value)).ToString("00.00"); //Profit = (Total Labor + Total Material + Contingency + Overhead) * profit percent //txtMarkUpPercent.Text.Trim() ((Label)(e.Item.FindControl("lblProfit"))).Text = ((Convert.ToDecimal(((Label)(e.Item.FindControl("lbloverhead"))).Text) + Convert.ToDecimal(((Label)(e.Item.FindControl("lblTotlabor"))).Text) + Convert.ToDecimal(((Label)(e.Item.FindControl("lblMatPlusCont"))).Text)) * Convert.ToDecimal(Convert.ToDecimal(_wc.GetProfitMarkUp(Convert.ToInt32(ViewState["EstNum"].ToString()))) / 100)).ToString("00.00"); ((Label)(e.Item.FindControl("lblSellPrice"))).Text = (Convert.ToDecimal(((Label)(e.Item.FindControl("lbloverhead"))).Text) + Convert.ToDecimal(((Label)(e.Item.FindControl("lblProfit"))).Text) + Convert.ToDecimal(((Label)(e.Item.FindControl("lblTotlabor"))).Text) + Convert.ToDecimal(((Label)(e.Item.FindControl("lblMatPlusCont"))).Text)).ToString("00.00"); Grandlabor += Convert.ToDecimal(((Label)(e.Item.FindControl("lblTotlabor"))).Text.Trim()); GrandContDisp += Convert.ToDecimal(((Label)(e.Item.FindControl("lblContDisp"))).Text.Trim()); GrandCont += Convert.ToDecimal(((Label)(e.Item.FindControl("lblContigency"))).Text.Trim()); GrandTotal += Convert.ToDecimal(((Label)(e.Item.FindControl("lblMatPlusCont"))).Text.Trim()); GrandOverHead += Convert.ToDecimal(((Label)(e.Item.FindControl("lbloverhead"))).Text.Trim()); GrandProfit += Convert.ToDecimal(((Label)(e.Item.FindControl("lblProfit"))).Text.Trim()); GrandSellPrice += Convert.ToDecimal(((Label)(e.Item.FindControl("lblSellPrice"))).Text.Trim()); TotalFabHours += Convert.ToInt32(((Label)(e.Item.FindControl("lblfabhours"))).Text); TotalfinHours += Convert.ToInt32(((Label)(e.Item.FindControl("lblfinhours"))).Text); TotalInstallHours += Convert.ToInt32(((Label)(e.Item.FindControl("lblinstallhours"))).Text); TotalEngHours += Convert.ToInt32(((Label)(e.Item.FindControl("lblEnghours"))).Text); TotalMiscHours += Convert.ToInt32(((Label)(e.Item.FindControl("lblMiscHours"))).Text); TotalMatCost += Convert.ToDecimal(((Label)(e.Item.FindControl("lblMatCost"))).Text); } else if (e.Item.ItemType == ListItemType.Footer) { e.Item.Cells[6].Text = "Item Totals:"; e.Item.Cells[6].Font.Bold = true; e.Item.Cells[6].HorizontalAlign = HorizontalAlign.Right; e.Item.Cells[7].Text = TotalEngHours.ToString(); e.Item.Cells[7].Font.Bold = true; e.Item.Cells[7].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[8].Text = TotalFabHours.ToString(); e.Item.Cells[8].Font.Bold = true; e.Item.Cells[8].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[9].Text = TotalfinHours.ToString(); e.Item.Cells[9].Font.Bold = true; e.Item.Cells[9].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[10].Text = TotalInstallHours.ToString(); e.Item.Cells[10].Font.Bold = true; e.Item.Cells[10].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[11].Text = TotalMiscHours.ToString(); e.Item.Cells[11].Font.Bold = true; e.Item.Cells[11].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[12].Text = String.Format("{0:0.##}", Decimal.Floor(Grandlabor)); e.Item.Cells[12].Font.Bold = true; e.Item.Cells[12].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[13].Text = String.Format("{0:0.##}", Decimal.Floor(TotalMatCost)); e.Item.Cells[13].Font.Bold = true; e.Item.Cells[13].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[14].Text = String.Format("{0:0.##}", Decimal.Floor(GrandCont)); e.Item.Cells[14].Font.Bold = true; e.Item.Cells[14].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[15].Text = String.Format("{0:0.##}", Decimal.Floor(GrandContDisp)) + "%"; e.Item.Cells[15].Font.Bold = true; e.Item.Cells[15].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[16].Text = String.Format("{0:0.##}", Decimal.Floor(GrandTotal)); e.Item.Cells[16].Font.Bold = true; e.Item.Cells[16].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[17].Text = String.Format("{0:0.##}", Decimal.Floor(GrandOverHead)); e.Item.Cells[17].Font.Bold = true; e.Item.Cells[17].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[18].Text = String.Format("{0:0.##}", Decimal.Floor(GrandProfit)); e.Item.Cells[18].Font.Bold = true; e.Item.Cells[18].HorizontalAlign = HorizontalAlign.Center; e.Item.Cells[19].Text = String.Format("{0:0.##}", Decimal.Floor(GrandSellPrice)); e.Item.Cells[19].Font.Bold = true; e.Item.Cells[19].HorizontalAlign = HorizontalAlign.Center; } }