本文介绍了如何在gridview中添加新行来查找车辆的小计组号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

日期O.NO车辆没有特别数量(Rs)

04/07/2014 9 gj656 DIESEL 8 44 352

04/07/2014 7 gj656 DIESEL 3 44 132

04/07/2014 8 hj565 PETROL 2 60 120



这是我的报告在这里我想要小计的车辆明智。

那么我如何在gridview中添加一个新行来查找小计车辆没有明智的????





query =从[事务]中选择transdate,orderno,vehicleno,oiltype,qty,price,amount,其中custid =+ int.Parse(lblid.Text.Trim())+和orderno in(+ slipall.ToString ()+)和invoicestatus ='true'命令由vehicleno,transdate;

cmd = new SqlCommand(query,con);

// SqlCommand cmd = new SqlCommand(select * from [transaction],con);

SqlDataReader reader1 = cmd.ExecuteReader();





DataRow nr = dt.NewRow();

if(reader1.Read())

{



DataRow dr = dt.NewRow();

nextno = reader1 [vehicleno]。ToString();

afterno = reader1 [vehicleno ] .ToString();

amt = reader1 [amount]。ToString();



dr [DATE] = reader1 [transdate]。ToString();

dr [O.NO] = reader1 [orderno]。ToString();

dr [ VEHICLE NO] = reader1 [vehicleno]。ToString();

dr [PARTICULARS] = reader1 [oiltype]。ToString();

dr [QTY] = reader1 [qty]。ToString();

dr [RATE] = reader1 [price]。ToString();

博士[AMOUNT(Rs)] = reader1 [amount]。ToString();

dt.DefaultView.Sort =VEHICLE NO;





dt.Rows.Add(dr);

if(preVno == afterno)

{

IsSubTotalRowNeedToAdd = true;



}

else

{

IsSubTotalRowNeedToAdd = false;

}

preVno = afterno;

}











if(IsSubTotalRowNeedToAdd == true)

{

dt.Rows.Add(nr);

prevtot = prevtot + Double.Parse(amt);

nr [0] = prevtot;

}

else

{



nr [0] = 0;

prevtot = 0;

}

//}





GridView1.DataSource = reader1;

GridView1.DataBind( );

reader1.Close();



这就是我在这段代码中从数据库中检索数据的方法顶部位置我想在同一个车辆下面换新行,所以请帮我搞定....

DATEO.NOVEHICLE NOPARTICULARSQTYRATEAMOUNT(Rs)
04/07/20149gj656DIESEL 8 44 352
04/07/20147gj656DIESEL 3 44 132
04/07/20148hj565PETROL 2 60 120

This is my Report here i want subtotal vehicleno wise.
So how i add a new row in gridview to find subtotal vehicle no wise????


query = "select transdate,orderno,vehicleno,oiltype,qty,price,amount from [transaction] where custid=" + int.Parse(lblid.Text.Trim()) + "and orderno in (" + slipall.ToString() + ") and invoicestatus='true' order by vehicleno,transdate";
cmd = new SqlCommand(query, con);
// SqlCommand cmd = new SqlCommand("select * from [transaction]", con);
SqlDataReader reader1 = cmd.ExecuteReader();


DataRow nr = dt.NewRow();
if (reader1.Read())
{

DataRow dr = dt.NewRow();
nextno = reader1["vehicleno"].ToString();
afterno = reader1["vehicleno"].ToString();
amt = reader1["amount"].ToString();

dr["DATE"]= reader1["transdate"].ToString();
dr["O.NO"] = reader1["orderno"].ToString();
dr["VEHICLE NO"] = reader1["vehicleno"].ToString();
dr["PARTICULARS"]= reader1["oiltype"].ToString();
dr["QTY"]= reader1["qty"].ToString();
dr["RATE"] = reader1["price"].ToString();
dr["AMOUNT(Rs)"] = reader1["amount"].ToString();
dt.DefaultView.Sort = "VEHICLE NO";


dt.Rows.Add(dr);
if (preVno == afterno)
{
IsSubTotalRowNeedToAdd = true;

}
else
{
IsSubTotalRowNeedToAdd = false;
}
preVno = afterno;
}





if (IsSubTotalRowNeedToAdd == true)
{
dt.Rows.Add(nr);
prevtot = prevtot + Double.Parse(amt);
nr[0] = prevtot;
}
else
{

nr[0] = 0;
prevtot = 0;
}
//}


GridView1.DataSource = reader1;
GridView1.DataBind();
reader1.Close();

This is how i am retrieving data from database in this code a new row is added on the top position i want new row below the vehicles of same no so please help me to get this....

推荐答案


这篇关于如何在gridview中添加新行来查找车辆的小计组号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 05:47