Пример #1
0
        private void createbutton_Click(object sender, EventArgs e)
        {
            AddForm addForm = new AddForm(null);

            addForm.ShowDialog();
            find();
            if (orderbindingsource.Current != null)
            {
                AddForm editForm = new AddForm((Order)orderbindingsource.Current);
                editForm.ShowDialog();
                find();
            }
            else
            {
                MessageBox.Show("No Order is selected!");
            }

            ////正则表达式判断2018-2050年间输入的年月日是否正确
            //string orderPattern = "^20((1[8-9]|2[1235679]|3[01345789]|4[1235679]|50)((0[469]|11)(0[1-9]|(1|2)[0-9]|30)|(02(0[1-9]|1[0-9]|2[0-8]))|(0[13578]|1(0|2))(0[1-9]|(1|2)[0-9]|3(0|1))))|((2[048]|3[26]|4[048])((0[469]|11)(0[1-9]|(1|2)[0-9]|30)|(02(0[1-9]|1[0-9]|2[0-9])|(0[13578]|1(0|2))(0[1-9]|(1|2)[0-9]|3(0|1)))))[0-9]{3}$";
            ////判断电话号码是否正确
            //string phonePattern = "^1[0-9]{10}";

            //Order order3 = new Order(20480229003, "William", 13876904585);
            //order3.AddOrderDetail(orderDetail1);
            //order3.AddOrderDetail(orderDetail2);
            //string s3 = order3.orderNumber.ToString();
            //string p3 = order3.guestPhone.ToString();
            //if (Regex.IsMatch(p3, phonePattern)&& Regex.IsMatch(s3, orderPattern) && (!orderservice.orderDictionary.ContainsKey(order3.orderNumber)))
            //{
            //    orderservice.AddOrder(order3);
            //    orderbindingsource.DataSource = orderservice.FindAll();
            //}
            //else
            //{
            //    throw new Exception("You have add a wrong order.");
            //}

            //Order order4 = new Order(20190101004, "John", 13876904586);
            //order4.AddOrderDetail(orderDetail2);
            //order4.AddOrderDetail(orderDetail3);
            //string s4 = order4.orderNumber.ToString();
            //string p4 = order4.guestPhone.ToString();
            //if (Regex.IsMatch(p4, phonePattern) && Regex.IsMatch(s4, orderPattern) && (!orderservice.orderDictionary.ContainsKey(order4.orderNumber)))
            //{
            //    orderservice.AddOrder(order4);
            //    orderbindingsource.DataSource = orderservice.FindAll();
            //}
            //else
            //{
            //    throw new Exception("You have add a wrong order.");
            //}
        }
Пример #2
0
        private void changebutton_Click(object sender, EventArgs e)
        {
            AddForm editForm = new AddForm(null);

            editForm.ShowDialog();
            find();
            //long goodId = 5;
            //string goodname = "Tally ho";
            //double singleprice = 13.5;
            //int number = 5;
            //orderDetail1.goodName = goodname;
            //orderDetail1.goodNumber = number;
            //orderDetail1.singlePrice = singleprice;
            //orderDetail1.goodId = goodId;
            //orderbindingsource.DataSource = orderservice.FindAll();
        }