private void FormCreateSale_Load(object sender, EventArgs e) { dateTimePicker1.Value = (DateTime)salesRow.Cells["time"].Value; tbSalesman.Text = salesRow.Cells["saleMan"].Value.ToString(); tbCustomer.Text = salesRow.Cells["customerName"].Value.ToString(); tbSalesman.Text = salesRow.Cells["saleMan"].Value.ToString(); cbPayment.Text = salesRow.Cells["paymentName"].Value.ToString(); lbSaleNumber.Text = salesRow.Cells["saleNumber"].Value.ToString(); sumPrice = double.Parse(salesRow.Cells["tatolPrice"].Value.ToString()); tbTotalPrice.Text = sumPrice.ToString("f") + "元"; //将支付方式绑定到支付方式文本框 list = db.GetDataInformation("payment_table", "payment_name");//从数据库中获取支付方式 foreach (string str in list) { cbPayment.Items.Add(str); } //将单位绑定到单位文本框 list = db.GetDataInformation("quantifier_table", "quantifier_name");//从数据库中获取单位名称 foreach (string str in list) { cbQuantifier.Items.Add(str); } dt = db.GetSalesDetails(lbSaleNumber.Text); dataGridView1.DataSource = dt; }