List<ReceiptTableDetail> list = new List<ReceiptTableDetail>();
for (int i = 1; i < 5; i++)
{
ReceiptTableDetail model = new ReceiptTableDetail();
model.FeeName = ((TextBox)this.Controls.Find("txtCharges" + i, true)[0]).Text;
model.Unit = ((TextBox)this.Controls.Find("txtUnit" + i, true)[0]).Text;
list.Add(model);
MessageBox.Show(model.Unit);
}
//--start
foreach (Control control in this.Controls)
{
for (int i=1;i<5;i++)
{
//遍历所有TextBox...
if (control is TextBox)
{
ReceiptTableDetail model = new ReceiptTableDetail();
if (control.Name == "txtCharges"+i) //第一行 第一个文本框 收费项名称
{
if (i==1)
{
}
if (i==2)
{
}
if (i==3)
{
}
if (i==4)
{
//dic.Add(4, control.Text);
}
}
if (control.Name == "txtUnit"+i) //第二个 单位
{
}
if (control.Name == "txtQuantity"+i) //第三个 数量
{
}
if (control.Name == "txtPrice"+i) //第四个 单价
{
Price = control.Text;
}
if (control.Name == "txtMemo"+i) //备注
{
Memo1 = control.Text;
}
}
if (control is NumericUpDown)
{
if (control.Name == "numericUpDown"+i) //金额
{
Total = control.Text;
}
}
}
}
//--end