private void Form2_Load(object sender, EventArgs e)
{
conn = new SqlConnection("Server = ''; database = ''; User ID = ''; Password ='';Min Pool Size=0;Max Pool Size= 30000;Pooling=true");
SqlCommand cmd = new SqlCommand("select Choose,OrderID,OrderDate,SpecialityStores,CustomerName,Salesperson,CustomizedProductSituation,ProductionOrder1,OrderStatus,OrdersDate,QuantityOutgoing,AggregateAmount,PaymentStatus,PaymentDate,DeliveryDate,ShipmentStatus,Operator,OperateDate,CustomerPhone,SellTelephone,DeliveryAddress,AuditStatus,Auditor,DateApproval,Remarks1 from dbo.SalesOrderSheet where (AuditStatus ='审核'or AuditStatus ='已审核')and OrderStatus='定制已下订单'and ShipmentStatus='未出货'order by OrderID asc", conn);
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
DataSet ds = new DataSet();
sda.Fill(ds, "dbo.SalesOrderSheet");
dataGridView13.DataSource = ds.Tables["dbo.SalesOrderSheet"];
}
public void Total(DataGridView dg)
{
DataGridViewRow dgr = dg.Rows[dg.Rows.Count - 1];
dgr.ReadOnly = true;
dgr.Cells[0].Value = "合计";
for (int i = 0; i < dg.Rows.Count - 1; i++)
{
dgr.Cells[10].Value = Convert.ToSingle(dgr.Cells[10].Value) + Convert.ToSingle(dg.Rows[i].Cells[10].Value);
}
for (int m = 0; m < dg.Rows.Count - 1; m++)
{
dgr.Cells[11].Value = Convert.ToSingle(dgr.Cells[11].Value) + Convert.ToSingle(dg.Rows[m].Cells[11].Value);
}
}
private void button1_Click(object sender, EventArgs e)
{
dataGridView13.AllowUserToAddRows = true;
DataGridView gw = dataGridView13;
Total(gw);
}
private void dataGridView13_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
e.Cancel = true;
}
private void dataGridView13_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
DataGridViewRow dgr1 = dataGridView13.Rows[dataGridView13.Rows.Count - 1];
//dgr1.DefaultCellStyle.BackColor = Color.FromArgb(227, 244, 255);//背景颜色
dgr1.DefaultCellStyle.Font = new Font("宋体", 10, FontStyle.Bold);//字体大小
dgr1.DefaultCellStyle.ForeColor = Color.Red;//字体颜色
}