旅行表格,送货表格,取货表格
在主窗体上,我有一个按钮,可将您带到您将一些数据输入到文本框中的行程,然后当您按添加时,它将添加取件或交付,具体取决于您listbox
在主窗体上输入的数据方式
我将如何获得它,以便如果我将交付添加到listbox
主表单中,它还会将交付添加到listbox
交付表单中的a
或者,如果我listbox
在主表格上添加一个取件,它也会listbox
在取件表格上添加一个取件
我如何添加交付的一些示例代码:
主窗体添加交付按钮:
private void btnDelivery_Click(object sender, EventArgs e)
{
deliveryForm.deliverytrips = new DeliveryTrips();
//New delivery- note added to the deliveryForm object
deliveryForm.ShowDialog();
//Show the deliveryForm. ShowDialog ensures that the form has the exclusive focus until it is closed.
if (deliveryForm.deliverytrips != null)
//if null then the "cancel" button was pressed
{
DeliveryTrips newApp = deliveryForm.deliverytrips;
//Get the delivery object from the form
theDelivery.addDeliveryTrip(newApp);
//Add the delivery to the summary
}
updateList();
//Update the list object to reflect the delivery in the summary
将交付添加到主窗体上的列表框的旅行代码:
public partial class frmDelivery : Form
{
private DeliveryTrips theDeliveryTrips;
//The DeliveryTrips object being created/edited
public DeliveryTrips deliverytrips
{ //Property to allow access to theDeliveryTrips
get { return theDeliveryTrips; }
set { theDeliveryTrips = value; }
}
public frmDelivery()
{ //Constructor
InitializeComponent();
}
private void frmDelivery_Load(object sender, EventArgs e)
{
//When makeing the form visible, set the text boxes to reflect the values in
//theDeliveryTrips.
if (theDeliveryTrips != null)
{
txtDescription.Text = "Delivery";
txtDescription.ReadOnly = true;
txtCustomerName.Text = theDeliveryTrips.customername;
txtCustomerAddress.Text = theDeliveryTrips.customeraddress;
txtTime.Text = theDeliveryTrips.arrivaltime.ToString();
}
}
private void btnAdd_Click_1(object sender, EventArgs e)
{
theDeliveryTrips.description = txtDescription.Text;
theDeliveryTrips.customername = txtCustomerName.Text;
theDeliveryTrips.customeraddress = txtCustomerAddress.Text;
theDeliveryTrips.arrivaltime = TimeSpan.Parse(txtTime.Text);
this.Hide();
//Hide the forum
}
private void btnCancel_Click_1(object sender, EventArgs e)
{
theDeliveryTrips = null;
//Set theDeliveryTrips to null as to remove any changes made
this.Hide();
//Hide the forum
}
}