private void button1_Click(object sender, EventArgs e) { string pattern1 = "^[0-9]{4}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])[0-9]{3}"; string pattern2 = "[0-9]{11}"; if (Regex.IsMatch(this.textBox1.Text, pattern1)) { if (Regex.IsMatch(this.textBox7.Text, pattern2)) { this.DialogResult = DialogResult.OK; } else { Error.Form1 formn = new Error.Form1(); formn.label1.Text = "电话格式有误,请重新输入!!!"; formn.ShowDialog(); if (formn.DialogResult == DialogResult.OK) { this.textBox7.Text = ""; } } } else { Error.Form1 formn = new Error.Form1(); formn.label1.Text = "订单号格式有误,请重新输入!!!"; formn.ShowDialog(); if (formn.DialogResult == DialogResult.OK) { this.textBox1.Text = ""; } } }
private void button1_Click(object sender, EventArgs e) { Form2.Form1 form1 = new Form2.Form1(); form1.ShowDialog(); int t = 1; while (t == 1) { t = 0; if (form1.DialogResult == DialogResult.OK) { //Order m = form1.returnOrder(); //b.addOrder(form1.returnOrder()); foreach (Order c in b.orderList) { if (c.orderNum == form1.textBox1.Text) { t = 1; break; } } if (t == 0) { form1.Dispose(); Order m = new Order(form1.textBox1.Text, form1.textBox2.Text, form1.textBox3.Text, form1.textBox7.Text, form1.textBox4.Text, form1.textBox6.Text, form1.textBox5.Text); b.addOrder(m); this.orderServiceBindingSource1.DataSource = new BindingList <Order>(b.orderList); } else { Error.Form1 formn = new Error.Form1(); formn.label1.Text = "订单号重复,请重新输入"; formn.ShowDialog(); if (formn.DialogResult == DialogResult.OK) { form1.textBox1.Text = ""; form1.ShowDialog(); } } } } }