protected void grvPro_RowCreated(object sender, GridViewRowEventArgs e)
{
switch (e.Row.RowType)
{
//判断是否表头
case DataControlRowType.Header:
//第一行表头
TableCellCollection tcHeader = e.Row.Cells;
tcHeader.Clear();
tcHeader.Add(new TableHeaderCell());
tcHeader[0].Attributes.Add("rowspan", "2");
tcHeader[0].Text = "日期";
tcHeader.Add(new TableHeaderCell());
tcHeader[1].Attributes.Add("colspan", "6");
tcHeader[1].Text = "通汇物流";
tcHeader.Add(new TableHeaderCell());
tcHeader[2].Attributes.Add("colspan", "6");
tcHeader[2].Text = DDlCompany.SelectedItem.Text+ "</th></tr><tr>";
//第二行表头
tcHeader.Add(new TableHeaderCell());
tcHeader[3].Attributes.Add("bgcolor", "#888888");
tcHeader[3].Attributes.Add("font-size", "30px");
tcHeader[3].Text = "分成率";
tcHeader.Add(new TableHeaderCell());
tcHeader[4].Attributes.Add("bgcolor", "#888888");
tcHeader[4].Text = "运费";
tcHeader.Add(new TableHeaderCell());
tcHeader[5].Attributes.Add("bgcolor", "#888888");
tcHeader[5].Text = "运费分成";
tcHeader.Add(new TableHeaderCell());
tcHeader[6].Attributes.Add("bgcolor", "#888888");
tcHeader[6].Text = "手续费";
tcHeader.Add(new TableHeaderCell());
tcHeader[7].Attributes.Add("bgcolor", "#888888");
tcHeader[7].Text = "手续费分成";
tcHeader.Add(new TableHeaderCell());
tcHeader[8].Attributes.Add("bgcolor", "#888888");
tcHeader[8].Text = "总分成";
tcHeader.Add(new TableHeaderCell());
tcHeader[9].Attributes.Add("bgcolor", "#888888");
tcHeader[9].Text = "分成率";
tcHeader.Add(new TableHeaderCell());
tcHeader[10].Attributes.Add("bgcolor", "#888888");
tcHeader[10].Text = "运费";
tcHeader.Add(new TableHeaderCell());
tcHeader[11].Attributes.Add("bgcolor", "#888888");
tcHeader[11].Text = "运费分成";
tcHeader.Add(new TableHeaderCell());
tcHeader[12].Attributes.Add("bgcolor", "#888888");
tcHeader[12].Text = "手续费";
tcHeader.Add(new TableHeaderCell());
tcHeader[13].Attributes.Add("bgcolor", "#888888");
tcHeader[13].Text = "手续费分成";
tcHeader.Add(new TableHeaderCell());
tcHeader[14].Attributes.Add("bgcolor", "#888888");
tcHeader[14].Text = "总分成";
break;
}
}
protected void grvPro_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex >= 0)
{
if (e.Row.Cells[3].Text != " " && e.Row.Cells[5].Text != " ")
{
if (e.Row.Cells[9].Text != " " && e.Row.Cells[11].Text != " ")
{
if (e.Row.Cells[6].Text != " " && e.Row.Cells[12].Text != " ")
{
sum1 += Convert.ToDouble(e.Row.Cells[3].Text);
sum2 += Convert.ToDouble(e.Row.Cells[5].Text);
sum3 += Convert.ToDouble(e.Row.Cells[9].Text);
sum4 += Convert.ToDouble(e.Row.Cells[11].Text);
sum5 += Convert.ToDouble(e.Row.Cells[6].Text);
sum6 += Convert.ToDouble(e.Row.Cells[12].Text);
}
}
}
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = "合计:";
e.Row.Cells[3].Text = sum1.ToString();
e.Row.Cells[5].Text = sum2.ToString();
e.Row.Cells[9].Text = sum3.ToString();
e.Row.Cells[11].Text = sum4.ToString();
e.Row.Cells[6].Text = sum5.ToString();
e.Row.Cells[12].Text = sum6.ToString();
}
}