public void UpdateCategorie()
        {
            CategorieDataService cds = new CategorieDataService();

            ValidationMessage = "This field is required.";
            // controleren of het veld "naam" is ingevuld met validatie
            if (MyValidation.ControleForm(SelectedCategorie.Naam))
            {
                return;
            }
            else
            {
                ValidationMessage = "";
                // controleren of de categorie al bestaat in de database
                string _categorieBestaat = cds.CategorieNaamExist(SelectedCategorie.Naam);
                if (_categorieBestaat != null)
                {
                    MessageBox.Show("This Category already exists.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    // controleren of update of insert moet zijn
                    if (SelectedCategorie.Id == 0)
                    {
                        cds.InsertCategorie(SelectedCategorie);
                        Messenger.Default.Send <UpdateFinishedMessage>(new UpdateFinishedMessage(UpdateFinishedMessage.MessageType.Inserted));
                    }
                    else
                    {
                        cds.UpdateCategorie(SelectedCategorie);
                        Messenger.Default.Send <UpdateFinishedMessage>(new UpdateFinishedMessage(UpdateFinishedMessage.MessageType.Updated));
                    }
                }
            }
        }
Exemplo n.º 2
0
 public VMvalidation(MyValidation root, VMfunction parent) : base(root, parent)
 {
     this.CommandOpen = new DelegateCommand(() => new ValidationWindow()
     {
         DataContext = this
     }.ShowDialog());
 }
Exemplo n.º 3
0
        private static string Convert(MyValidation input, Function f, ref int i)
        {
            var validations = new List <string>();

            foreach (var v in input.Validations)
            {
                validations.Add(Convert(v, f, ref i));
            }
            return(string.Join("\n", validations));
        }
Exemplo n.º 4
0
        public void CheckAuthenticationTest()
        {
            Validation target   = new MyValidation();
            string     id       = "id";
            string     pwd      = "pwd";
            bool       expected = true;
            bool       actual;

            actual = target.CheckAuthentication(id, pwd);
            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 5
0
        public void CheckAuthenticationTest()
        {
            Validation target = new MyValidation();

            string id       = "id anyone";
            string password = "******";

            bool expected = true;
            bool actual;

            actual = target.CheckAuthentication(id, password);
            Assert.AreEqual(expected, actual);
        }
        private void OnBuscarEndereco()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Endereco.Cep    = RemoveCarecteres.ObterStringSemAcentosECaracteresEspeciais(Endereco.Cep);
                CepError        = string.Empty;
                CepErrorVisible = false;
                if (MyValidation.ValidarCep(Endereco.Cep))
                {
                    var e = Util.Location.GetCEPPosition(Endereco.Cep);

                    if (e != null)
                    {
                        Endereco = e;
                    }
                }
                else
                {
                    CepError        = "CEP inválido.";
                    CepErrorVisible = true;
                }
            }
            catch (Exception ex)
            {
                Application.Current.MainPage.DisplayAlert("Erro", ex.Message, "Ok");
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 7
0
 public MyValidationTests()
 {
     _testee = new MyValidation();
 }
Exemplo n.º 8
0
        private MyValidation GetValidateResult()
        {
            var val = new MyValidation();

            if (_material == null)
            {
                val.IsValid = false;
                var err01 = new MyKeyValuePair()
                {
                    Key   = 1,
                    Value = "Request Failed, Can't find Specified Materil",
                };
                val.ErrorMessages.Add(err01);
                return(val);
            }


            //Table JobCosting Template
            var tempalteDetails = _db.EST_Cost_Template_Detail.Where(x => x.DbItemID == (int)_material.MaterialID &
                                                                     (x.TypeID == (int)NEstCostType.ShopMaterail
                                                                      ||
                                                                      x.TypeID ==
                                                                      (int)NEstCostType.InstallationMaterail)
                                                                     ).ToList();

            if (tempalteDetails.Any())
            {
                val.IsValid = false;
                var err02 = new MyKeyValuePair()
                {
                    Key   = 2,
                    Value = "Request Failed, This material has been used in Estimation Template",
                };
                val.ErrorMessages.Add(err02);
            }


            //Table JobCostingTransaction
            var transactions = _db.JobCostingTransactions.Where(x => x.MaterialID == (int)_material.MaterialID).ToList();

            if (transactions.Any())
            {
                //NJobCostingTransactionTypeID.DirectInput

                transactions = transactions.Where(x => x.TransactionType == 0).ToList();
                if (transactions.Any())
                {
                    val.IsValid = false;
                    var err03 = new MyKeyValuePair()
                    {
                        Key   = 3,
                        Value = "Request Failed, This material has been used in Job Costing",
                    };
                    val.ErrorMessages.Add(err03);
                }
            }


            //Table JobCostingMaterialTemplateDetail
            var est = _db.JobCostingMaterialTemplateDetails.Where(x => x.MaterialID == (int)_material.MaterialID).ToList();

            if (transactions.Any())
            {
                val.IsValid = false;
                var err04 = new MyKeyValuePair()
                {
                    Key   = 4,
                    Value = "Request Failed, This material has been used in Job Costing Template",
                };
                val.ErrorMessages.Add(err04);
            }

            return(val);
        }
Exemplo n.º 9
0
 public MaterialDeleteVm(int materialID)
 {
     _material        = _db.Materials.FirstOrDefault(x => x.MaterialID == materialID);
     DeleteValidation = GetValidateResult();
 }