public Form1(Merchant merchant) { this.currentMerchant = merchant; this.mof = new Manage_Order_Form(merchant); this.wcf = new waitCancelForm(merchant); this.af = new acceptedForm(merchant); //this.cf = new cancelForm(merchant); this.df = new deliverForm(merchant); this.ff = new finishForm(merchant); this.finishOrder1 = Order_Service.GetFinishOrderList(merchant).Count; this.waitOrder1 = Order_Service.GetOrderList(merchant).Count; this.cancelOrder1 = Order_Service.GetWaitCancelOrderList(merchant).Count; System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer(); timer1.Interval = 3000; timer1.Tick += new System.EventHandler(timer1_Tick); timer1.Start(); InitializeComponent(); }
private void timer1_Tick(object sender, EventArgs e) { int waitOrder2 = Order_Service.GetOrderList(currentMerchant).Count; int cancelOrder2 = Order_Service.GetWaitCancelOrderList(currentMerchant).Count; if (waitOrder2 + cancelOrder2 > waitOrder1 + cancelOrder1) { textBox1.Text += $"{DateTime.Now.ToLocalTime().ToString()}:您有新的订单啦!\r\n"; } //int cancelOrder = Order_Service.GetWaitCancelOrderList(currentMerchant).Count; if (cancelOrder2 > cancelOrder1) { textBox1.Text += $"{DateTime.Now.ToLocalTime().ToString()}:注意啦!有客户要取消订单!\r\n"; } waitOrder1 = waitOrder2; cancelOrder1 = cancelOrder2; int finishOrder = Order_Service.GetFinishOrderList(currentMerchant).Count; if (finishOrder > finishOrder1) { textBox1.Text += $"{DateTime.Now.ToLocalTime().ToString()}:订单已完成!\r\n"; } finishOrder1 = finishOrder; //更新mof mof.bindingSource1.DataSource = Order_Service.GetOrderList(currentMerchant); mof.bindingSource1.ResetBindings(false); if (mof.dataGridView3.Rows.Count <= 1) { mof.bindingSource2.DataSource = mof.bindingSource1.Current; } //mof.bindingSource2.DataSource = mof.bindingSource1.Current; //更新wcf wcf.bindingSource1.DataSource = Order_Service.GetWaitCancelOrderList(currentMerchant); wcf.bindingSource1.ResetBindings(false); if (wcf.dataGridView1.Rows.Count <= 1) { wcf.bindingSource2.DataSource = wcf.bindingSource1.Current; } //wcf.bindingSource2.DataSource = wcf.bindingSource1.Current; //更新af af.bindingSource1.DataSource = Order_Service.GetAcceptedOrderList(currentMerchant); af.bindingSource1.ResetBindings(false); if (af.dataGridView1.Rows.Count <= 1) { af.bindingSource2.DataSource = af.bindingSource1.Current; } //af.bindingSource2.DataSource = af.bindingSource1.Current; //更新df df.bindingSource1.DataSource = Order_Service.GetDeliverOrderList(currentMerchant); df.bindingSource1.ResetBindings(false); if (df.dataGridView1.Rows.Count <= 1) { df.bindingSource2.DataSource = df.bindingSource1.Current; } //df.bindingSource2.DataSource = df.bindingSource1.Current; //更新ff ff.bindingSource1.DataSource = Order_Service.GetFinishOrderList(currentMerchant); ff.bindingSource1.ResetBindings(false); }