private void btnAdd_Click(object sender, EventArgs e) { FormEdit form2 = new FormEdit(new Order()); form2.ShowDialog(); Order newOrder = form2.getResult(); if (newOrder != null) { bool idOK, phoneOK; Regex idRx = new Regex("20[0-9]{2}((0[0-9])|(1[12]))(([012][0-9])|(3[01]))[0-9]{3}"); Regex phoneRx = new Regex("[0-9]{11}"); idOK = idRx.IsMatch(Convert.ToString(newOrder.Id)); phoneOK = phoneRx.IsMatch(Convert.ToString(newOrder.Phone)); if (idOK) { if (phoneOK) { orderService.AddOrder(newOrder); orderBindingSource.DataSource = orderService.QueryAllOrders(); } else { MessageBox.Show("用户手机格式不正确!"); } } else { MessageBox.Show("订单号格式不正确!"); } } }
private void btnAdd_Click(object sender, EventArgs e) { FormEdit form2 = new FormEdit(new Order()); form2.ShowDialog(); Order newOrder = form2.getResult(); if (newOrder != null) { orderService.AddOrder(newOrder); orderBindingSource.DataSource = orderService.QueryAllOrders(); } }
private void btnModify_Click(object sender, EventArgs e) { FormEdit form2 = new FormEdit((Order)orderBindingSource.Current); form2.ShowDialog(); Order newOrder = form2.getResult(); orderService.Add(newOrder); orderBindingSource.DataSource = orderService.GetAllOrders(); Order nowOrder = (Order)orderBindingSource.Current; orderItemBindingSource.DataSource = nowOrder.Items; }
private void btnModify_Click(object sender, EventArgs e) { FormEdit form2 = new FormEdit((Order)orderBindingSource.Current); btnDelete_Click(sender, e); form2.ShowDialog(); Order newOrder = form2.getResult(); if (newOrder != null) { orderService.Add(newOrder); orderBindingSource.DataSource = orderService.GetAllOrders(); } }
private void btnAdd_Click(object sender, EventArgs e) { FormEdit form2 = new FormEdit(new Order()); form2.ShowDialog(); Order newOrder = form2.getResult(); if (newOrder != null) { int flag = orderService.AddOrder(newOrder); if (flag == 0) { MessageBox.Show("您输入的订单号已存在!"); } else { orderBindingSource.DataSource = orderService.QueryAllOrders(); } } }