Exemplo n.º 1
0
        /// <summary>
        /// 修改提交信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Submit(object sender, RoutedEventArgs e)
        {
            //对数据进行校验
            if ((this.img.Source != null && this.datePicker.Text != null) &&
                (this.nameTxtBox.Text != "" && this.codeTxtBox.Text != "" && this.img.Source.ToString() != "" && this.datePicker.Text != "")
                )
            {
                Equipment equ = new Equipment
                {
                    Index          = 0,
                    Name           = this.nameTxtBox.Text,
                    Code           = this.codeTxtBox.Text,
                    Picture        = this.img.Source as BitmapImage,
                    TermOfValidity = Convert.ToDateTime(this.datePicker.Text.Trim())
                };

                //触发Command更新数据,必须使用同一个视图数据模型
                if (this.operationFlag == "add")
                {
                    var MyVM = equipmentViewModelSelf;
                    if (MyVM != null && MyVM.InsertCommand.CanExecute(equ))
                    {
                        MyVM.InsertCommand.Execute(equ);
                    }
                }
                else if (this.operationFlag == "Update")
                {
                    equ.Index = this.equSelf.Index;
                    OKWindow okWindow = new OKWindow("提交数据", "确实要提交这条数据吗?");
                    okWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    okWindow.ShowDialog();
                    if (okWindow.Ret == true)
                    {
                        var MyVM = equipmentViewModelSelf;
                        if (MyVM != null && MyVM.UpdateCommand.CanExecute(equ))
                        {
                            MyVM.UpdateCommand.Execute(equ);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("有一点小问题!");
                }
            }
            else
            {
                MessageBox.Show("请检查数据格式是否正确!");
            }
            this.Close();
        }
Exemplo n.º 2
0
 /// <summary>
 /// 提交路面类型信息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Submit(object sender, RoutedEventArgs e)
 {
     if (Verify() == true)
     {
         OKWindow okWindow = new OKWindow("提交数据", "确实要提交这条数据吗?");
         okWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
         okWindow.ShowDialog();
         if (okWindow.Ret == true)
         {
             this.Close();
         }
         else
         {
             return;
         }
     }
     else
     {
         MessageBox.Show("请检查数据格式!");
     }
 }
Exemplo n.º 3
0
        //提交信息
        private void Submit(object sender, RoutedEventArgs e)
        {
            //校验  后面考虑使用校验
            if ((this.carPicture.Source != null) && (
                    this.carType.Text != "" &&
                    this.carNumber.Text != "" &&
                    this.carSeatNum.Text != "" &&
                    this.carFullRated.Text != "" &&
                    this.carCurbWeight.Text != "" &&
                    this.carDisplacement.Text != "" &&
                    this.carFrontSuspensionSystem.Text != "" &&
                    this.carRearSuspensionSystem.Text != "" &&
                    this.carDriveMethod.Text != "" &&
                    this.carGearbox.Text != "" &&
                    this.carBrake.Text != "" &&
                    this.carBuyingTime.Text != "" &&
                    this.carInitialOdometerReading.Text != "" &&
                    this.carPicture.Source.ToString() != ""
                    ))
            {
                try
                {
                    Car car = new Car
                    {
                        Index                  = 0,
                        Type                   = this.carType.Text,
                        CarNumber              = this.carNumber.Text,
                        SeatNum                = Convert.ToInt16(this.carSeatNum.Text),
                        FullRated              = Convert.ToDouble(this.carFullRated.Text),
                        CurbWeight             = Convert.ToDouble(this.carCurbWeight.Text),
                        Displacement           = Convert.ToDouble(this.carDisplacement.Text),
                        FrontSuspensionSystem  = this.carFrontSuspensionSystem.Text,
                        RearSuspensionSystem   = this.carRearSuspensionSystem.Text,
                        DriveMethod            = this.carDriveMethod.Text,
                        Gearbox                = this.carGearbox.Text,
                        Brake                  = this.carBrake.Text,
                        BuyingTime             = Convert.ToDateTime(this.carBuyingTime.Text.Trim()),
                        InitialOdometerReading = Convert.ToInt16(this.carInitialOdometerReading.Text),
                        Picture                = new BitmapImage(new Uri(this.carPicture.Source.ToString(), UriKind.RelativeOrAbsolute))
                    };

                    //新增数据
                    if (this.operationFlag == "Insert")
                    {
                        var MyVM = carViewModelSelf;
                        if (MyVM != null && MyVM.InsertCommand.CanExecute(car))
                        {
                            MyVM.InsertCommand.Execute(car);
                            this.Close();
                        }
                    }
                    //修改数据
                    else if (this.operationFlag == "Update")
                    {
                        //修改索引值
                        car.Index = this.carSelf.Index;
                        var MyVM = carViewModelSelf;

                        OKWindow okWindow = new OKWindow("提交数据", "确实要提交这条数据吗?");
                        okWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                        okWindow.ShowDialog();
                        if (okWindow.Ret == true)
                        {
                            if (MyVM != null && MyVM.UpdateCommand.CanExecute(car))
                            {
                                MyVM.UpdateCommand.Execute(car);
                                this.Close();
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("有一点小问题!");
                    }
                }
                catch
                {
                    MessageBox.Show("录入失败,请检查数据格式是否有误,请重新录入!");
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("录入失败,请检查数据格式是否有误,请重新录入!");
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 提交 需要判断新增还是编辑,通过父窗口传过来的提交测试路线信息还是修改测试路线信息
        /// 调用对应的command命令
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="OperationFlag">操作类型</param>
        private void Submit(object sender, RoutedEventArgs e)
        {
            //先校验数据格式是否正确
            if (Verify() == false)
            {
                MessageBox.Show("请检查数据格式!");
                return;
            }

            //确认提交
            OKWindow okWindow = new OKWindow("提交数据", "确实要提交这条数据吗?");

            okWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            okWindow.ShowDialog();
            if (okWindow.Ret == false)
            {
                return;
            }

            //再执行相关操作
            if (OperationFlag == "Insert")
            {
                TestRouteBase trb = new TestRouteBase
                {
                    Index       = 0,
                    LineMileage = this.trbLineMileage.Text,
                    Material    = this.trbMaterial.Text,
                    Picture     = this.trbPicture.Source as BitmapImage,
                    TestRoutes  = this.trbTestRoutes.Text,
                    Time        = this.trbTime.Text
                };

                //如果是Insert必须保证路面类型必须有一条
                TestRoute tr = new TestRoute {
                    TestRouteBase = trb, PavementTypeInfo = ptInfo
                };

                var MyVM = this.testRouteViewModelSelf;
                if (MyVM != null && MyVM.InsertCommand.CanExecute(tr))
                {
                    MyVM.InsertCommand.Execute(tr);
                }
            }
            else if (OperationFlag == "Update")
            {
                TestRouteBase trb = new TestRouteBase
                {
                    Index       = this.trSelf.TestRouteBase.Index,
                    LineMileage = this.trbLineMileage.Text,
                    Material    = this.trbMaterial.Text,
                    Picture     = this.trbPicture.Source as BitmapImage,
                    TestRoutes  = this.trbTestRoutes.Text,
                    Time        = this.trbTime.Text
                };

                TestRoute tr = new TestRoute {
                    TestRouteBase = trb, PavementTypeInfo = ptInfo
                };

                var MyVM = this.testRouteViewModelSelf;
                if (MyVM != null && MyVM.UpdateCommand.CanExecute(tr))
                {
                    MyVM.UpdateCommand.Execute(tr);
                }
            }

            this.Close();
        }