//添加明细 private void button1_Click(object sender, EventArgs e) { try { OrderDetails newDetails = new OrderDetails(textBox3.Text, Convert.ToDouble(textBox4.Text), int.Parse(textBox5.Text)); tempOrder.orderDetailsList.Add(newDetails); } catch (System.FormatException) { } //OrderDetailsBindingSource.DataSource = tempOrder.orderDetailsList; OrderDetailsBindingSource.ResetBindings(false); }
//删除明细 private void button3_Click(object sender, EventArgs e) { try { tempOrder.orderDetailsList.RemoveAt(No); //OrderDetailsBindingSource.DataSource = tempOrder.orderDetailsList; OrderDetailsBindingSource.ResetBindings(false); } catch (System.FormatException) { } catch (System.ArgumentOutOfRangeException) { } }
//修改明细 private void button2_Click(object sender, EventArgs e) { try { tempOrder.orderDetailsList[No].orderName = textBox3.Text; tempOrder.orderDetailsList[No].orderPrice = Convert.ToDouble(textBox4.Text); tempOrder.orderDetailsList[No].orderNum = int.Parse(textBox5.Text); //OrderDetailsBindingSource.DataSource = tempOrder.orderDetailsList; OrderDetailsBindingSource.ResetBindings(false); } catch (System.FormatException) { } catch (System.ArgumentOutOfRangeException) { } }