Exemple #1
0
        private async void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (
                (Car_info.Visibility == Visibility.Visible &&
                 (fid.Text == "" || fname.Text == "" || faddress.Text == "" ||
                  cid.Text == "" || cbrand.Text == "" || cprice.Text == "")) ||
                (Custom_info.Visibility == Visibility.Visible &&
                 (cuid.Text == "" || cuname.Text == "" || cuaddress.Text == "")) ||
                (Garage_info.Visibility == Visibility.Visible &&
                 (qid.Text == "" || ctnum.Text == "" || cid2.Text == "")) ||
                (in_info.Visibility == Visibility.Visible &&
                 (ftid.Text == "" || ftprice.Text == "" || ftnum.Text == "" ||
                  fid2.Text == "" || cid3.Text == "")) ||
                (out_info.Visibility == Visibility.Visible &&
                 (ctid.Text == "" || ctprice.Text == "" || ctnum2.Text == "" ||
                  cuid2.Text == "" || cid4.Text == ""))
                )
            {
                var dialog = new ContentDialog()
                {
                    Content           = "请不要留空",
                    PrimaryButtonText = "确定",
                    FullSizeDesired   = false,
                };
                await dialog.ShowAsync();

                return;
            }

            if (nowIndex == 0)
            {
                if (smallIndex == 0)
                {
                    Car car = new Car();
                    car.cid    = cid.Text;
                    car.cbrand = cbrand.Text;
                    int x = 0;
                    if (!String2int(cprice.Text, ref x))
                    {
                        showNumberErrorDialogAsync();
                        return;
                    }
                    car.cprice = x;
                    car.fid    = fid.Text;
                    Factory factory = new Factory();
                    factory.fid      = fid.Text;
                    factory.faddress = faddress.Text;
                    factory.fname    = fname.Text;

                    String feedback = "";
                    SqlHelper.AddFactory(factory, "factory");
                    String message2 = SqlHelper.AddCar(car, "car");

                    if (message2 != "not an error")
                    {
                        feedback += message2 + "\n";
                    }

                    Cleanhelp();
                    var dialog = new ContentDialog()
                    {
                        Content           = feedback == "" ? "创建成功" : feedback,
                        PrimaryButtonText = "确定",
                        FullSizeDesired   = false,
                    };
                    await dialog.ShowAsync();
                }
                else if (smallIndex == 1)
                {
                    Customer customer = new Customer();
                    customer.cuid      = cuid.Text;
                    customer.cuname    = cuname.Text;
                    customer.cuaddress = cuaddress.Text;
                    String feedback = SqlHelper.AddCustomer(customer, "customer");
                    Cleanhelp();
                    var dialog = new ContentDialog()
                    {
                        Content           = feedback == "not an error" ? "创建成功" : feedback,
                        PrimaryButtonText = "确定",
                        FullSizeDesired   = false,
                    };
                    await dialog.ShowAsync();
                }
            }
        }