public Validation CheckoutBidder(long eventId, int number, long userId)
        {
            var val = new Validation();
            IAuctionTransaction trans = _factory.BuildTransaction("CheckoutBidder");

            try
            {
                var bidder = _bidderRepo.GetByNumberAndEvent(number, eventId, ref trans);
                var packages = _packageRepo.GetByBidder(bidder.Id, ref trans).Where(p => !p.Paid);

                if(packages.Count() == 0)
                {
                    throw new ApplicationException("No packages to checkout");
                }
                packages.ToList().ForEach(p => { p.Paid = true; _packageRepo.Update(ref p, ref trans); });

                bidder.CheckedoutBy = userId;
                _bidderRepo.Update(ref bidder, ref trans);
                trans.Commit();
            }
            catch (Exception ex)
            {
                trans.Rollback();
                val.AddError(string.Format("Unable to checkout bidder: {0}", ex.Message));
            }
            finally
            {
                trans.Dispose();
            }

            return val;
        }
        public Validation DeleteBidder(long eventId, int number)
        {
            //we need to check that they do not have any closedout/checkedout packages
            //we can delete only if they do not
            var val = new Validation();

            var trans = _factory.BuildTransaction("DeleteBidder");

            try
            {
                var bidder = _repo.GetByNumberAndEvent(number, eventId, ref trans);

                if (_packageRepo.GetByBidder(bidder.Id, ref trans).Count > 0)
                {
                    throw new ApplicationException("Bidder is associated with packages");
                }
                _repo.Delete(bidder.Id, ref trans);
                trans.Commit();
            }
            catch (Exception e)
            {
                trans.Rollback();
                val.AddError(string.Format("Unable to delete bidder: {0}", e.Message));
            }
            finally
            {
                trans.Dispose();
            }
            return val;
        }
Esempio n. 3
0
        internal void Execute()
        {
            this.validation = new Validation(this.database);

            this.AllowSnapshotIsolation();

            if (this.validation.IsValid)
            {
                this.TruncateTables();
            }
            else
            {
                this.CreateSchema();

                this.DropProcedures();

                this.DropTables();

                this.CreateTables();

                this.DropTableTypes();

                this.CreateTableTypes();

                this.CreateProcedures();

                this.CreateIndeces();
            }
        }
 public Validation RemoveDonorFromEvent(long donorId,
                                        long eventId)
 {
     var val = new Validation();
     //verify that they are not already in event
     var trans = _factory.BuildTransaction("RemoveDonorFromEvent");
     try
     {
         if (_itemRepo.GetByDonorAndEvent(donorId, eventId, ref trans).Count > 0)
         {
             throw new ApplicationException("Event items are associated with the donor");
         }
         _repo.RemoveFromEvent(donorId, eventId, ref trans);
         trans.Commit();
     }
     catch (Exception e)
     {
         trans.Rollback();
         val.AddError(string.Format("Unable to add donor to event: {0}", e.Message));
     }
     finally
     {
         trans.Dispose();
     }
     return val;
 }
        public Validation CreateEvent(ref Event auctionEvent,
                                      long currentUserId)
        {
            var val = new Validation();

            var trans = _factory.BuildTransaction("CreateEvent");

            try
            {
                val = _validator.ValidateNewEvent(auctionEvent, ref trans);
                if (val.IsValid)
                {
                    auctionEvent.CreatedBy = currentUserId;
                    _repo.Insert(ref auctionEvent, ref trans);
                }
                trans.Commit();
            }
            catch (Exception e)
            {
                trans.Rollback();
                val.AddError(string.Format("Unable to create auction: {0}", e.Message));
            }
            finally
            {
                trans.Dispose();
            }

            return val;
        }
Esempio n. 6
0
        private void Initialize()
        {
            try
            {
                classModule = new ClassModule(Global.ProjectConnectionString, Global.ProjectDataProvider);
                Validation = new Validation();
                Validation.Validate(this);

                if (Operation == Global.Operation.UPDATE || Operation == Global.Operation.VIEW)
                {                     
                    DataRow dr;

                    dr = classModule.GetProjectModuleDetails(ModuleId);

                    textBoxID.Text = ModuleId;
                    textBoxModuleName.Text = dr["mod_name"].ToString();
                    textBoxModuleName.Tag = dr["mod_name"].ToString();
                    textBoxDescription.Text = dr["mod_desc"].ToString();
                          
                    if (Operation == Global.Operation.VIEW)
                    {
                        userControlButtonsSave.Visible = false;
                        Lock();
                    }
                }

                textBoxModuleName.Focus();

            }
            catch (Exception)
            {
                throw;
            }
        }
        /// <summary>
        /// Check that the values of arguments specified for a newly created or edited instance of
        /// this modular input are valid. If they are valid, set <tt>errorMessage</tt> to <tt>""</tt>
        /// and return <tt>true</tt>. Otherwise, set <tt>errorMessage</tt> to an informative explanation 
        /// of what makes the arguments invalid and return <tt>false</tt>.
        /// </summary>
        /// <param name="validation">a Validation object specifying the new argument values.</param>
        /// <param name="errorMessage">an output parameter to pass back an error message.</param>
        /// <returns><tt>true</tt> if the arguments are valid and <tt>false</tt> otherwise.</returns>
        public override bool Validate(Validation validation, out string errorMessage)
        {
            bool returnValue = true;            
            errorMessage = "";

            try
            {

                string logfilepath = ((SingleValueParameter)(validation.Parameters["logfilepath"])).ToString();
                Int32 cycletimeint = ((SingleValueParameter)(validation.Parameters["cycletime"])).ToInt32();

                // Verify path is valid
                if (returnValue && !System.IO.Directory.Exists(logfilepath))
                {
                    errorMessage = "LogFilePath " + logfilepath + " does not exist on local machine";
                    return false;
                }

                //Verify cycle time is minimum value (250 ms)
                if (returnValue && (cycletimeint < 250))
                {
                    errorMessage = "cycle time must be at least 250ms";
                    return false;
                }

            }
            catch(Exception)
            {
                errorMessage = "Error processing validation logic.";
                returnValue = false;
            }

            return returnValue;
        }
Esempio n. 8
0
 public Validation DeleteItem(long itemId)
 {
     //we do not want to delete an item if it is in a package
     var trans = _factory.BuildTransaction("DeleteItem");
     var val = new Validation();
     try
     {
         var item = _repo.Get(itemId, ref trans);
         if (item.PackageId.HasValue)
         {
             throw new ApplicationException("Item is in a package");
         }
         _repo.Delete(itemId, ref trans);
         trans.Commit();
     }
     catch (Exception e)
     {
         trans.Rollback();
         val.AddError(string.Format("Unable to delete item: {0}", e.Message));
     }
     finally
     {
         trans.Dispose();
     }
     return val;
 }
 public void InternalExceptions_AddMultipleExceptions_ShouldPass()
 {
     Validation val = new Validation();
     val.AddException(new Exception());
     val.AddException(new Exception());
     Assert.True(val.Exceptions.Count() == 2);
 }
 public Validation AddDonorToEvent(long donorId,
                                   long eventId)
 {
     var val = new Validation();
     //verify that they are not already in event
     var trans = _factory.BuildTransaction("AddDonorToEvent");
     try
     {
         if (_eventRepo.GetEventListByDonor(donorId, ref trans).Contains(eventId))
         {
             throw new ApplicationException("Donor is already associated with the event");
         }
         _repo.AddToEvent(donorId, eventId, ref trans);
         trans.Commit();
     }
     catch (Exception e)
     {
         trans.Rollback();
         val.AddError(string.Format("Unable to add donor to event: {0}", e.Message));
     }
     finally
     {
         trans.Dispose();
     }
     return val;
 }
Esempio n. 11
0
 public Validation DeleteUser(long userId)
 {
     //why would we not want to delete a user?
     //we cannot delete a user if they are the account admin
     var trans = _factory.BuildTransaction("DeleteUser");
     var val = new Validation();
     try
     {
         var user = _repo.Get(userId, ref trans);
         if (_accountRepo.GetMainUserId(user.AccountId, ref trans) == userId)
         {
             throw new ApplicationException("User is account admin");
         }
         _repo.DeleteUser(userId, ref trans);
         trans.Commit();
     }
     catch (Exception e)
     {
         trans.Rollback();
         val.AddError(string.Format("Unable to create user: {0}", e.Message));
     }
     finally
     {
         trans.Dispose();
     }
     return val;
 }
        public Validation DeleteCategory(long categoryId)
        {
            var val = new Validation();
            IAuctionTransaction trans = _factory.BuildTransaction("DeleteCategory");

            try
            {
                if (_packageRepo.GetByCategory(categoryId, ref trans).Count > 0)
                {
                    throw new ApplicationException("Category is associated with packages");
                }
                _repo.Delete(categoryId, ref trans);

                trans.Commit();
            }
            catch (Exception e)
            {
                trans.Rollback();
                val.AddError(string.Format("Unable to delete category: {0}", e.Message));
            }
            finally
            {
                trans.Dispose();
            }
            return val;
        }
Esempio n. 13
0
        public Validation CreateBidder(ref Bidder eventBidder,
                                       long currentUserId)
        {
            var val = new Validation();

            var trans = _factory.BuildTransaction("CreateBidder");

            try
            {
                val = _validator.ValidateNewBidder(eventBidder, ref trans);
                if(val.IsValid)
                {
                    eventBidder.Number = _repo.GetByEvent(eventBidder.EventId, ref trans).Select(b => b.Number).Max() + 1;
                    eventBidder.CreatedBy = currentUserId;
                    _repo.Insert(ref eventBidder, ref trans);
                }
                trans.Commit();
            }
            catch(Exception e)
            {
                trans.Rollback();
                val.AddError(string.Format("Unable to create bidder: {0}", e.Message));
            }
            finally
            {
                trans.Dispose();
            }

            return val;
        }
Esempio n. 14
0
        public Validation InsertUser(ref User user)
        {
            var val = new Validation();

            var trans = _factory.BuildTransaction("InsertUser");
            try
            {
                //validate
                if (val.IsValid)
                {
                    _repo.Insert(ref user, ref trans);
                }
                trans.Commit();
            }
            catch (Exception e)
            {
                trans.Rollback();
                val.AddError(string.Format("Unable to create user: {0}", e.Message));
            }
            finally
            {
                trans.Dispose();
            }
            return val;
        }
Esempio n. 15
0
 public void ShouldNotAllowMultipleLogicalErrorsForMessageAndObjectPair()
 {
     Validation validation = new Validation();
     validation.AddError("test", "Hello", DateTime.Today.Date);
     validation.AddError("test", "Hello", DateTime.Today.Date);
     Assert.AreEqual(1, validation.ErrorOn(DateTime.Today.Date).Count);
 }
Esempio n. 16
0
        private void button_Save_Click(object sender, RoutedEventArgs e)
        {
            Validation validation = new Validation();
             //validation for emails
            if (validation.ValidateTextField(txtEmail.Text) ? validation.ValidateEmail(txtEmail.Text) : true)
            {

                exporter.Name = txtName.Text;
                exporter.RegNo = txtRegNo.Text;
                exporter.TelNo = txtTelNo.Text;
                exporter.ShortTag = txtShortTag.Text;
                exporter.Email = txtEmail.Text;
                exporter.Description = txtDescription.Text;
                exporter.Address = txtAddress.Text;
                //adding to data model
                model.AddToExporters(exporter);
                //applying changes to the database
                model.SaveChanges();
                ContentPresenter con = (ContentPresenter)this.VisualParent;
                con.Content = new AddDirector(exporter);
            }
            else
            {
                MessageBox.Show("Invalid Email");
            }
        }
        public Validation DeleteDonor(long donorId)
        {
            IAuctionTransaction trans = _factory.BuildTransaction("DeleteDonor");

            var val = new Validation();
            try
            {
                if (!_validator.CanDonorBeDeleted(donorId, ref trans))
                {
                    val.AddError("Donor cannot be deleted");
                }
                else
                {
                    _repo.RemoveFromAllEvents(donorId, ref trans);
                    _repo.Delete(donorId, ref trans);
                }
                trans.Commit();
            }
            catch (Exception ex)
            {
                trans.Rollback();
                val.AddError(string.Format("Unable to delete Donor: {0}", ex.Message));
            }
            finally
            {
                trans.Dispose();
            }

            return val;
        }
Esempio n. 18
0
 public void ShouldAddAddErrorFromNormalErrorToListItemError()
 {
     Validation validation = new Validation();
     validation.AddError("test", "Hello");
     Validation listValidation = new Validation();
     listValidation.AddErrorFrom(1, validation);
     Assert.AreEqual(1, listValidation.Errors.Count);
 }
Esempio n. 19
0
 public void RetrieveListErrorFromValidationWhichContainsNonListErrors()
 {
     Validation validation = new Validation();
     validation.AddError("a", "m");
     validation.AddError("a", "m", 0);
     validation.AddError("a", "m", 1);
     Assert.AreEqual(1, validation.ErrorOn(0).Count);
 }
Esempio n. 20
0
 public void ObjectIsRequiredShouldBeValid()
 {
     var data = new TestData {ANullableInt = 10};
     var validator = new Validation<TestData>(data);
     var result = validator.IsRequired(p => p.ANullableInt).ReadResults();
     Assert.IsTrue(result.IsValid);
     Assert.AreEqual(0, result.ValidationResults.Count);
 }
Esempio n. 21
0
 public void IsEqualToShouldValidateFor(string source, string compareTo)
 {
     var data = new TestData {AString = source};
     var validator = new Validation<TestData>(data);
     var result = validator.IsEqualTo(p => p.AString, compareTo).ReadResults();
     Assert.IsTrue(result.IsValid);
     Assert.AreEqual(0, result.ValidationResults.Count);
 }
 protected void AddServiceValidationToModelState(Validation serviceValidation)
 {
     if (!serviceValidation.IsValid())
     {
         foreach (KeyValuePair<string, List<string>> error in serviceValidation.Errors)
             foreach(string errorStr in error.Value)
                 ModelState.AddModelError(error.Key, errorStr);
     }
 }
Esempio n. 23
0
 public void CustomRuleShouldValidates()
 {
     var data = new TestData {AString = "any would do"};
     var validator = new Validation<TestData>(data);
     var result =
         validator.CustomRule(p => p.AString, p => p.Contains("would"), "Failed").ReadResults();
     Assert.IsTrue(result.IsValid);
     Assert.AreEqual(0, result.ValidationResults.Count);
 }
Esempio n. 24
0
 public void ErrorOnObject()
 {
     Validation validation = new Validation();
     validation.AddError("a", "m", DateTime.Today.Date);
     List<Error> errors = validation.ErrorOn(DateTime.Today.Date);
     Assert.AreEqual(1, errors.Count);
     errors = validation.ErrorOn(DateTime.Today.Date.AddDays(1));
     Assert.AreEqual(0, errors.Count);
 }
Esempio n. 25
0
 public frBusStation()
 {
     InitializeComponent();
     val = new Validation(this.Controls);
     skip = new List<Control> { tbSearch, cbLoadItem, lbIdValue };
     this.cbLoadItem.SelectedIndex = 0;
     this.Page = 0;
     LoadGrid(this.Page);
 }
Esempio n. 26
0
 public void ObjectIsRequiredShouldFailOnNull()
 {
     var data = new TestData {ANullableInt = null};
     var validator = new Validation<TestData>(data);
     var result = validator.IsRequired(p => p.ANullableInt).ReadResults();
     Assert.IsFalse(result.IsValid);
     Assert.AreEqual(1, result.ValidationResults.Count);
     Assert.AreEqual(result.ValidationResults[0].PropertyName, "ANullableInt");
     Assert.IsNotNull(result.ValidationResults[0].ErrorMessage);
 }
Esempio n. 27
0
 public frTicketType(Form frM)
 {
     InitializeComponent();
     this.frM = frM as frMain;
     val = new Validation(this.Controls);
     skip = new List<Control> { tbSearch, cbLoadItem, lbIdValue };
     this.cbLoadItem.SelectedIndex = 0;
     this.Page = 0;
     LoadGrid(Page);
 }
Esempio n. 28
0
        public Validation DeleteEvent(long eventId, bool deleteAll)
        {
            var val = new Validation();
            if (!deleteAll)
            {

            }
            //need to see if there are any other domain objects associated with event
            return val;
        }
 public void CheckValidationField(bool fName, bool lName, bool eMail, bool acCode, bool date)
 {
     JavaScriptExecutorHelper.ScrollElementAndClick(Validation);
     GenericHelper.WaitForLoadingMask();
     Validation val = new Validation(driver);
     val.CheckValidationField(fName, lName, eMail, acCode, date);
     JavaScriptExecutorHelper.ScrollElementAndClick(ValidationNext);
     Validation.Click();
     GenericHelper.WaitForLoadingMask();
 }
Esempio n. 30
0
 public frPricing(Form owner)
 {
     InitializeComponent();
     frM = owner as frMain;
     val = new Validation(this.Controls);
     skip = new List<Control> { tbSearch, cbLoadItem, lbIdValue };
     this.cbLoadItem.SelectedIndex = 0;
     this.Page = 0;
     LoadGrid(this.Page);
 }
Esempio n. 31
0
 public void ThenTheBrowserLogsHasTheValue(Validation validation)
 => Executor.Execute(() => WebDriver.BrowserLogs.Validate(validation));
Esempio n. 32
0
 private void BtnSave_Click(object sender, EventArgs e)
 {
     if (!this.txtNewPassword.Text.ToString().Equals(this.txtConfirmPassword.Text.ToString()) || this.txtNewPassword.Text.ToString().Length.Equals(0) || this.txtConfirmPassword.Text.ToString().Length.Equals(0) || this.txtCurrentPassword.Text.ToString().Length.Equals(0) || this.txtCurrentPassword.Text.ToString().Equals(this.txtNewPassword.Text.ToString()) || !this.employee.Password.Equals(this.txtCurrentPassword.Text.ToString()) || Validation.IsStringValid(this.txtCurrentPassword.Text.ToString()) == false || Validation.IsStringValid(this.txtNewPassword.Text.ToString()) == false || Validation.IsStringValid(this.txtConfirmPassword.Text.ToString()) == false)
     {
         MessageBox.Show("Invalid Info");
         txtCurrentPassword.Focus();
     }
     else
     {
         this.employee.Password = this.txtNewPassword.Text.ToString();
         UserRepo employeeRepo = new UserRepo();
         if (employeeRepo.SaveEmployeeInfo(this.employee, "change password") == true)
         {
             MessageBox.Show("Password Updated Successfully");
             this.txtNewPassword.Clear();
             this.txtConfirmPassword.Clear();
             this.txtCurrentPassword.Clear();
         }
         else
         {
             MessageBox.Show("Something happened bad,please try again");
             this.txtNewPassword.Clear();
             this.txtConfirmPassword.Clear();
             this.txtCurrentPassword.Clear();
         }
     }
 }
Esempio n. 33
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="validation"></param>
 public LikesController(Validation validation)
 {
     this._validation = validation;
 }
Esempio n. 34
0
 private void txtPassword_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validation.ValidateQuoteCharacter(txtPassword, e);
 }
Esempio n. 35
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Load += (s, e) => { Start(); };

            Tipo1.Click += (s, e) =>
            {
                Categorias.Enabled = true;
                Fornecedor.Enabled = true;
                imprimir.Visible   = false;
                label4.Text        = @"Despesa:";
                LoadCategorias("Despesas");
            };
            Tipo2.Click += (s, e) =>
            {
                Categorias.Enabled = true;
                Fornecedor.Enabled = false;
                imprimir.Visible   = true;
                label4.Text        = @"Despesa:";
                LoadCategorias("Despesas");
            };

            Tipo3.Click += (s, e) =>
            {
                Categorias.Enabled = false;
                Fornecedor.Enabled = false;
                imprimir.Visible   = false;
                label4.Text        = @"Receita:";
                LoadCategorias("Receitas");
            };

            btnAddCategoria.Click += (s, e) =>
            {
                string categoriasdeContas;
                if (Tipo1.Checked || Tipo2.Checked)
                {
                    categoriasdeContas = "Despesas";
                }
                else
                {
                    categoriasdeContas = "Receitas";
                }

                Home.CategoriaPage = categoriasdeContas;
                var f = new AddCategorias
                {
                    FormBorderStyle = FormBorderStyle.FixedSingle,
                    StartPosition   = FormStartPosition.CenterScreen
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    LoadCategorias(categoriasdeContas);
                }
            };

            btnAddFornecedor.Click += (s, e) =>
            {
                Home.pessoaPage = "Fornecedores";
                AddClientes.Id  = 0;
                var f = new AddClientes
                {
                    FormBorderStyle = FormBorderStyle.FixedSingle,
                    StartPosition   = FormStartPosition.CenterScreen
                };
                if (f.ShowDialog() == DialogResult.OK)
                {
                    LoadFornecedores();
                }
            };

            btnSalvar.Click += (s, e) =>
            {
                _modelCaixaMov.id_caixa     = idCaixa;
                _modelCaixaMov.id_formapgto = Dinheiro.Checked ? 1 : Cheque.Checked ? 2 : 1;

                _modelCaixaMov.id_categoria = Validation.ConvertToInt32(Categorias.SelectedValue);
                _modelCaixaMov.id_pessoa    = Validation.ConvertToInt32(Fornecedor.SelectedValue);

                _modelCaixaMov.Tipo = Tipo1.Checked ? 1 : Tipo2.Checked ? 2 : Tipo3.Checked ? 3 : 1;

                var tipo = "";
                if (Tipo1.Checked)
                {
                    tipo = "Saída - Lançamento de Despesa";
                }
                else if (Tipo2.Checked)
                {
                    tipo = "Saída - Sangria";
                }
                else if (Tipo3.Checked)
                {
                    tipo = "Entrada - Acréscimo";
                }

                var formaPgto = "";
                if (Dinheiro.Checked)
                {
                    formaPgto = "Dinheiro";
                }
                else if (Cheque.Checked)
                {
                    formaPgto = "Cheque";
                }

                _modelCaixaMov.Descricao = $"{formaPgto} - {tipo}";
                _modelCaixaMov.Valor     = Validation.ConvertToDouble(Valor.Text);
                _modelCaixaMov.Obs       = Obs.Text;
                if (_modelCaixaMov.Save(_modelCaixaMov))
                {
                    if (Tipo1.Checked)
                    {
                        if (_modelCaixaMov.Id != 0)
                        {
                            _modelTitulo = _modelTitulo.Query().Where("id_caixa_mov", _modelCaixaMov.Id)
                                           .Where("excluir", 0).FirstOrDefault <Titulo>();
                        }

                        _modelTitulo.Tipo               = "Pagar";
                        _modelTitulo.Emissao            = Validation.DateNowToSql();
                        _modelTitulo.Id_Categoria       = _modelCaixaMov.id_categoria;
                        _modelTitulo.Id_Pessoa          = _modelCaixaMov.id_pessoa;
                        _modelTitulo.Total              = _modelCaixaMov.Valor;
                        _modelTitulo.Id_FormaPgto       = _modelCaixaMov.id_formapgto;
                        _modelTitulo.Vencimento         = Validation.DateNowToSql();
                        _modelTitulo.Baixa_data         = Validation.DateNowToSql();
                        _modelTitulo.Baixa_id_formapgto = _modelCaixaMov.id_formapgto;
                        _modelTitulo.Baixa_total        = _modelCaixaMov.Valor;
                        _modelTitulo.Id_Caixa           = idCaixa;
                        _modelTitulo.Id_Caixa_Mov       = _modelCaixaMov.GetLastId();
                        _modelTitulo.Obs = $"Pagamento gerado a partir de um lançamento do caixa. {Obs.Text}";
                        _modelTitulo.Save(_modelTitulo, false);
                    }

                    DialogResult = DialogResult.OK;
                    Close();
                }
            };

            Valor.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            btnApagar.Click += (s, e) =>
            {
                if (_modelCaixaMov.Remove(idMov))
                {
                    var titulo = _modelTitulo.Query().Where("ID_CAIXA_MOV", idMov).FirstOrDefault();
                    if (titulo != null)
                    {
                        _modelTitulo.RemoveIdCaixaMov(idMov);
                    }

                    DialogResult = DialogResult.OK;
                    Close();
                }
            };

            imprimir.Click += (s, e) =>
            {
                _modelCaixa = _modelCaixa.FindById(idCaixa).FirstOrDefault <Model.Caixa>();

                var user     = _modelUsuarios.FindByUserId(_modelCaixa.Usuario).FirstOrDefault();
                var userName = "";
                if (user != null)
                {
                    userName = user.NOME;
                }

                var html   = Template.Parse(File.ReadAllText($@"{Program.PATH_BASE}\html\CupomAssinaturaCaixaMov.html"));
                var render = html.Render(Hash.FromAnonymousObject(new
                {
                    INCLUDE_PATH = Program.PATH_BASE,
                    URL_BASE     = Program.PATH_BASE,
                    Emissao      = DateTime.Now.ToString("dd/MM/yyyy HH:mm"),
                    nrTerminal   = _modelCaixa.Terminal,
                    nrCaixa      = _modelCaixa.Id.ToString(),
                    Responsavel  = userName,
                    Valor        = Valor.Text
                }));

                Browser.htmlRender = render;
                var f = new Browser();
                f.ShowDialog();
            };
        }
Esempio n. 36
0
 private void txtMobileNo_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validation.ValidateTextIsNumeric(txtMobileNo, e);
 }
Esempio n. 37
0
 private void txtLastName_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validation.ValidateQuoteCharacter(txtLastName, e);
 }
Esempio n. 38
0
 public ConnectionViewModel(Validation validation)
 {
     _validation = validation;
     ConnectionTemp.PropertyChanged += (s, e) => { RaisePropertyChanged("connectionStatus"); };
     DisplayName = "Bağlantı Ayarları";
 }
        private void saveRecordBtn_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Do you want to save?", "Confirmation", MessageBoxButton.OKCancel, MessageBoxImage.Information);
            if (result == MessageBoxResult.OK)
            {
                foreach (var element in form.Children)
                {
                    if (element is TextBox)
                    {
                        BindingExpression expression = ((TextBox)element).GetBindingExpression(TextBox.TextProperty);
                        if (expression != null)
                        {
                            if (((TextBox)element).IsEnabled)
                            {
                                expression.UpdateSource();
                                if (Validation.GetHasError((TextBox)element))
                                    validationError = true;
                            }
                        }
                    }
                    else if (element is Xceed.Wpf.Toolkit.DecimalUpDown)
                    {
                        BindingExpression expression = ((Xceed.Wpf.Toolkit.DecimalUpDown)element).GetBindingExpression(Xceed.Wpf.Toolkit.DecimalUpDown.TextProperty);
                        Validation.ClearInvalid(expression);
                        if (((Xceed.Wpf.Toolkit.DecimalUpDown)element).IsEnabled)
                        {
                            expression.UpdateSource();
                            if (Validation.GetHasError((Xceed.Wpf.Toolkit.DecimalUpDown)element))
                                validationError = true;
                        }
                    }
                    else if (element is ComboBox)
                    {
                        BindingExpression expression = ((ComboBox)element).GetBindingExpression(ComboBox.SelectedItemProperty);
                        if (expression != null)
                        {
                            expression.UpdateSource();
                            if (Validation.GetHasError((ComboBox)element))
                                validationError = true;
                        }

                    }
                }
                if (!validationError)
                {
                    saveDataToDb();
                    MainVM.isEdit = false;
                    MainVM.Provinces.Clear();
                    OnSaveCloseButtonClicked(e);
                }
                else
                {
                    MessageBox.Show("Resolve the error first");
                    validationError = false;
                }

            }
            else if (result == MessageBoxResult.Cancel)
            {
            }

        }
 public GreaterThanAttribute(Double minimum)
     : base(() => Validation.For("GreaterThan"))
 {
     Minimum = Convert.ToDecimal(minimum);
 }
Esempio n. 41
0
 public virtual Validation Put(Validation validation)
 {
     _validationCommands.ActiveUser = Models.ApiContext.ActiveUser;
     return(_validationCommands.Put(validation));
 }
Esempio n. 42
0
File: Bind.cs Progetto: jedahu/Jib
 public static Validation <X, A> Join <X, A>(this Validation <X, Validation <X, A> > validation)
 {
     return(validation.Bind(a => a));
 }
Esempio n. 43
0
File: Bind.cs Progetto: jedahu/Jib
 public static Validation <X, B> Bind <X, A, B>(this Validation <X, A> validation, Func <A, Validation <X, B> > f)
 {
     return(validation.Cata(Validation.Failure <X, B>, f));
 }
Esempio n. 44
0
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            DateTime startDate, endDate;

            if (lastDateTextBox.IsEnabled)
            {
                if (Validation.GetHasError(lastDateTextBox))
                {
                    MessageBox.Show("Girdiğiniz değer hatalı. Lütfen değiştirip tekrar deneyin.", "Uyarı",
                                    MessageBoxButton.OK);
                    return;
                }
                endDate = DateTime.Today;
                TimeSpan ts = new TimeSpan(SaleCntDate.LastDateCount, 0, 0, 0);
                startDate = endDate - ts;
            }
            else
            {
                if (Validation.GetHasError(intervalStartDatePicker) || Validation.GetHasError(intervalEndDatePicker))
                {
                    MessageBox.Show("Girdiğiniz değerlerden biri hatalı. Lütfen değiştirip tekrar deneyin.", "Uyarı",
                                    MessageBoxButton.OK);
                    return;
                }
                startDate = SaleCntDate.IntervalStartDate ?? DateTime.Today;
                endDate   = SaleCntDate.IntervalEndDate ?? DateTime.Today;
            }

            SaleCountItems.Clear();

            // Set endDate to one day after since linq to entity doesn't support comparing by .Date property
            endDate += new TimeSpan(24, 0, 0);

            // The following query results with a "must be reducible node" error.
            // It is most probably an EFCore error accorsing to Google.
            // Replacing with the one written below (it has ToList() somewhere to make the life easier for EFCore).

            //var query = from saleItem in ObjectCtx.Context.SaleItems.Include(si => si.ProductSale)
            //            where saleItem.ProductSale.SaleDate >= startDate && saleItem.ProductSale.SaleDate <= endDate
            //            group saleItem by saleItem.Product
            //            into saleItemProduct
            //            orderby saleItemProduct.Sum(s => s.NumSold) descending
            //            select new SaleCountItem
            //                   {
            //                       ProductName = saleItemProduct.Key.Name,
            //                       Brand = saleItemProduct.Key.Brand,
            //                       TotalNumSold = saleItemProduct.Sum(saleItem => saleItem.NumSold)
            //                   };
            //foreach (SaleCountItem saleCountItem in query)
            //{
            //    SaleCountItems.Add(saleCountItem);
            //}

            var productSaleItemGroup = ObjectCtx.Context.SaleItems.Include(si => si.ProductSale).
                                       Where(si => si.ProductSale.SaleDate >= startDate && si.ProductSale.SaleDate <= endDate).
                                       GroupBy(si => si.Product).ToList();
            List <SaleCountItem> sciList = new List <SaleCountItem>();

            foreach (var psiEntry in productSaleItemGroup)
            {
                SaleCountItem sci = new SaleCountItem
                {
                    ProductName  = psiEntry.Key.Name,
                    Brand        = psiEntry.Key.Brand,
                    TotalNumSold = psiEntry.Sum(si => si.NumSold)
                };
                sciList.Add(sci);
            }
            sciList.Sort((sci1, sci2) => sci2.TotalNumSold.CompareTo(sci1.TotalNumSold));
            foreach (var sci in sciList)
            {
                SaleCountItems.Add(sci);
            }
        }
Esempio n. 45
0
 private void Validar()
 {
     _validationResults = Validation.Validate(this.Vendedor);
 }
 public void Add(HttpCookie cookie)
 {
     Validation.EnsureNotNull(cookie, nameof(cookie), "The cookie to add must not be null.");
     this.cookies[cookie.Key] = cookie;
 }
        public async Task CachePurge(Request request, Response response)
        {
            var userSession = await CheckAuth.Check(request, response, AuthLevel.Administrator);

            if (userSession == null)
            {
                return;
            }

            var requestJson = request.Json <PurgeCacheRequest>();

            //判断请求是否有效
            if (!Validation.Valid(requestJson, out string reason))
            {
                await response.BadRequest(reason);

                return;
            }

            switch (requestJson.op_key)
            {
            case "anno":
            {
                var db = DbFactory.Get <Announcement>();
                await db.InvalidateCache();

                await response.OK();

                return;
            }

            case "invi":
            {
                var db = DbFactory.Get <Invite>();
                await db.InvalidateCache();

                await response.OK();

                return;
            }

            case "mess":
            {
                var db = DbFactory.Get <Message>();
                await db.InvalidateCache();

                await response.OK();

                return;
            }

            case "prog":
            {
                var db = DbFactory.Get <Progress>();
                await db.InvalidateCache();

                await response.OK();

                return;
            }

            case "puzz":
            {
                var db = DbFactory.Get <Puzzle>();
                await db.InvalidateCache();

                await response.OK();

                return;
            }

            case "puzg":
            {
                var db = DbFactory.Get <PuzzleGroup>();
                await db.InvalidateCache();

                await response.OK();

                return;
            }

            case "user":
            {
                var db = DbFactory.Get <User>();
                await db.InvalidateCache();

                await response.OK();

                return;
            }

            case "useg":
            {
                var db = DbFactory.Get <UserGroup>();
                await db.InvalidateCache();

                await response.OK();

                return;
            }

            case "usgb":
            {
                var db = DbFactory.Get <UserGroupBind>();
                await db.InvalidateCache();

                await response.OK();

                return;
            }

            case "uall":
            {
                var db1 = DbFactory.Get <User>();
                var db2 = DbFactory.Get <UserGroup>();
                var db3 = DbFactory.Get <UserGroupBind>();
                await db1.InvalidateCache();

                await db2.InvalidateCache();

                await db3.InvalidateCache();

                await response.OK();

                return;
            }

            case "pall":
            {
                var db1 = DbFactory.Get <Puzzle>();
                var db2 = DbFactory.Get <PuzzleGroup>();
                await db1.InvalidateCache();

                await db2.InvalidateCache();

                await response.OK();

                return;
            }

            case "aall":
            {
                var db1 = DbFactory.Get <Announcement>();
                var db2 = DbFactory.Get <Invite>();
                var db3 = DbFactory.Get <Message>();
                var db4 = DbFactory.Get <Progress>();
                var db5 = DbFactory.Get <Puzzle>();
                var db6 = DbFactory.Get <PuzzleGroup>();
                var db7 = DbFactory.Get <User>();
                var db8 = DbFactory.Get <UserGroup>();
                var db9 = DbFactory.Get <UserGroupBind>();
                await db1.InvalidateCache();

                await db2.InvalidateCache();

                await db3.InvalidateCache();

                await db4.InvalidateCache();

                await db5.InvalidateCache();

                await db6.InvalidateCache();

                await db7.InvalidateCache();

                await db8.InvalidateCache();

                await db9.InvalidateCache();

                await response.OK();

                return;
            }

            default:
                break;
            }

            await response.BadRequest("wrong op_key");
        }
        public bool ContainsKey(string key)
        {
            Validation.EnsureNotNullOrEmptyString(key, nameof(key));

            return(this.cookies.ContainsKey(key));
        }
Esempio n. 49
0
 private void txtQuarterNumber_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validation.ValidateTextIsNumeric(txtQuarterNumber, e);
 }
Esempio n. 50
0
 // Enable/disable Save button if we have valid input
 private void Save_CanExecute(object sender, CanExecuteRoutedEventArgs e)
 {
     e.CanExecute = !String.IsNullOrWhiteSpace(FirstName) && !String.IsNullOrWhiteSpace(LastName) &&
                    !Validation.GetHasError(DOBDateBox) && !Validation.GetHasError(SpareProp1Value) && !Validation.GetHasError(SSNBox) && !Validation.GetHasError(SpareProp2Value);
 }
Esempio n. 51
0
 public FileSizeAttribute(Double maximumMB)
     : base(() => Validation.For("FileSize"))
 {
     MaximumMB = Convert.ToDecimal(maximumMB);
 }
        /// <summary>
        /// Validates and saves a page's values. Returns true if the page is valid.
        /// </summary>
        /// <param name="page">The page ID to check.</param>
        /// <param name="currentPage">Whether this is the current page. If true, the values in the controls will be checked, otherwise the session will be checked.</param>
        /// <param name="saveOnly">If save only is true, the validation will be ignored and values will be saved so that they can be returned to. This is for use with the "Back" button.</param>
        protected bool ValidateAndSave(int page, bool currentPage, bool saveOnly)
        {
            bool retVal = true;

            switch (page)
            {
            case 1:

                #region Page 1
                string email = GetValue(txtEmail, currentPage, String.Empty);
                if (!Validation.RegExCheck(email, ValidationType.Email))
                {
                    mmTxtEmail.ErrorMessage = "Please enter a valid email address.";
                    return(false);
                }
                else if (currentPage)
                {
                    SaveValue <string>(txtEmail);
                }
                break;

                #endregion Page 1

            case 2:

                #region Page 2
                if (!saveOnly)
                {
                    bool accept  = GetValue(radAccept, currentPage, false);
                    bool decline = GetValue(radDecline, currentPage, false);
                    if (!accept && !decline)
                    {
                        mmAcceptGroup.ErrorMessage = "Please select one of the following options.";
                        return(false);
                    }
                }
                if (currentPage)
                {
                    SurveyTools.SaveRadioButtons(radAccept, radDecline);
                }
                break;

                #endregion Page 2

            case 3:

                #region Page 3
                if (!saveOnly)
                {
                    bool Q1notselected = !GetValue(Q1_1, currentPage, false) &&
                                         !GetValue(Q1_2to4, currentPage, false) &&
                                         !GetValue(Q1_5to9, currentPage, false) &&
                                         !GetValue(Q1_10, currentPage, false);
                    if (Q1notselected)
                    {
                        Q1Message.ErrorMessage = "Please select one of the following options.";
                        retVal = false;
                    }

                    bool Q2notselected = !GetValue(Q2_Yes, currentPage, false) &&
                                         !GetValue(Q2_No, currentPage, false);
                    if (Q2notselected)
                    {
                        Q2Message.ErrorMessage = "Please select one of the following options.";
                    }

                    bool Q3notselected = !GetValue(Q3_No, currentPage, false) &&
                                         !GetValue(Q3_Yes, currentPage, false);
                    if (Q3notselected)
                    {
                        Q3Message.ErrorMessage = "Please select one of the following options.";
                    }

                    bool Q4notselected = !GetValue(Q4_Yes, currentPage, false) &&
                                         !GetValue(Q4_No, currentPage, false);

                    if (Q4notselected)
                    {
                        Q4Message.ErrorMessage = "Please select Yes or No.";
                        retVal = false;
                    }
                }
                if (currentPage)
                {
                    SaveValue(Q1_1);
                    SaveValue(Q1_2to4);
                    SaveValue(Q1_5to9);
                    SaveValue(Q1_10);
                    SaveValue(Q2_No);
                    SaveValue(Q2_Yes);
                    SaveValue(Q3_No);
                    SaveValue(Q3_Yes);
                    SaveValue(Q4_Yes);
                    SaveValue(Q4_No);
                    SaveValue(Q4_EncoreNumber);
                }
                break;

                #endregion Page 3

            case 4:

                #region Page 4
                if (!saveOnly)
                {
                    bool Q5notselected = !GetValue(Q5_Tarmac, currentPage, false) &&
                                         !GetValue(Q5_BoxSeats, currentPage, false) &&
                                         !GetValue(Q5_GroupPatio, currentPage, false) &&
                                         !GetValue(Q5_MarqueeTent, currentPage, false) &&
                                         !GetValue(Q5_SilksBuffet, currentPage, false) &&
                                         !GetValue(Q5_DiamondClub, currentPage, false);
                    if (Q5notselected)
                    {
                        Q5Message.ErrorMessage = "Please select one of the following options.";
                        retVal = false;
                    }

                    bool Q6notselected = !GetValue(Q6_Excellent, currentPage, false) &&
                                         !GetValue(Q6_VeryGood, currentPage, false) &&
                                         !GetValue(Q6_Good, currentPage, false) &&
                                         !GetValue(Q6_Fair, currentPage, false) &&
                                         !GetValue(Q6_Poor, currentPage, false);
                    if (Q6notselected)
                    {
                        Q6Message.ErrorMessage = "Please select one of the following options.";
                        retVal = false;
                    }

                    bool Q7notselected = !GetValue(Q7_Excellent, currentPage, false) &&
                                         !GetValue(Q7_VeryGood, currentPage, false) &&
                                         !GetValue(Q7_Good, currentPage, false) &&
                                         !GetValue(Q7_Fair, currentPage, false) &&
                                         !GetValue(Q7_Poor, currentPage, false);
                    if (Q7notselected)
                    {
                        Q7Message.ErrorMessage = "Please select one of the following options.";
                        retVal = false;
                    }

                    bool Q8notselected = !GetValue(Q8_DefinitelyWould, currentPage, false) &&
                                         !GetValue(Q8_ProbablyWould, currentPage, false) &&
                                         !GetValue(Q8_MightMightNot, currentPage, false) &&
                                         !GetValue(Q8_ProbablyWouldNot, currentPage, false) &&
                                         !GetValue(Q8_DefinitelyWouldNot, currentPage, false);
                    if (Q8notselected)
                    {
                        Q8Message.ErrorMessage = "Please select one of the following options.";
                        retVal = false;
                    }
                }
                if (currentPage)
                {
                    SaveValue(Q5_Tarmac);
                    SaveValue(Q5_BoxSeats);
                    SaveValue(Q5_GroupPatio);
                    SaveValue(Q5_MarqueeTent);
                    SaveValue(Q5_SilksBuffet);
                    SaveValue(Q5_DiamondClub);
                    SaveValue(Q6_Excellent);
                    SaveValue(Q6_VeryGood);
                    SaveValue(Q6_Good);
                    SaveValue(Q6_Fair);
                    SaveValue(Q6_Poor);
                    SaveValue(Q7_Excellent);
                    SaveValue(Q7_VeryGood);
                    SaveValue(Q7_Good);
                    SaveValue(Q7_Fair);
                    SaveValue(Q7_Poor);
                    SaveValue(Q8_DefinitelyWould);
                    SaveValue(Q8_ProbablyWould);
                    SaveValue(Q8_MightMightNot);
                    SaveValue(Q8_ProbablyWouldNot);
                    SaveValue(Q8_DefinitelyWouldNot);
                }
                break;

                #endregion Page 4

            case 5:

                #region Page 5
                if (!saveOnly)
                {
                    bool Q9notselected = !GetValue(Q9_Male, currentPage, false) &&
                                         !GetValue(Q9_Female, currentPage, false);
                    if (Q9notselected)
                    {
                        Q9Message.ErrorMessage = "Please select one of the following options.";
                        retVal = false;
                    }

                    bool Q10notselected = !GetValue(Q10_19to24, currentPage, false) &&
                                          !GetValue(Q10_25to34, currentPage, false) &&
                                          !GetValue(Q10_35to44, currentPage, false) &&
                                          !GetValue(Q10_45to54, currentPage, false) &&
                                          !GetValue(Q10_55to64, currentPage, false) &&
                                          !GetValue(Q10_65orOlder, currentPage, false);
                    if (Q10notselected)
                    {
                        Q10Message.ErrorMessage = "Please select one of the following options.";
                        retVal = false;
                    }

                    bool Q11notselected = !GetValue(Q11_35000, currentPage, false) &&
                                          !GetValue(Q11_35000to59999, currentPage, false) &&
                                          !GetValue(Q11_60000to89999, currentPage, false) &&
                                          !GetValue(Q11_90000, currentPage, false) &&
                                          !GetValue(Q11_NoSay, currentPage, false);
                    if (Q11notselected)
                    {
                        Q10Message.ErrorMessage = "Please select one of the following options.";
                        retVal = false;
                    }

                    bool Q12check = !String.IsNullOrEmpty(GetValue(Q12_PostalCode, currentPage, String.Empty));

                    if (!Q12check)
                    {
                        Q12_PostalCode.MessageManager.ErrorMessage = "Please enter the first 3 digits of your Postal Code.";
                        retVal = false;
                    }

                    bool Q13FirstNameCheck = !String.IsNullOrEmpty(GetValue(Q13_FirstName, currentPage, String.Empty));

                    if (!Q13FirstNameCheck)
                    {
                        Q13_FirstName.MessageManager.ErrorMessage = "Please enter your First Name.";
                        retVal = false;
                    }

                    bool Q13LastNameCheck = !String.IsNullOrEmpty(GetValue(Q13_LastName, currentPage, String.Empty));

                    if (!Q13LastNameCheck)
                    {
                        Q13_LastName.MessageManager.ErrorMessage = "Please enter your Last Name.";
                        retVal = false;
                    }

                    bool Q13EmailCheck = !String.IsNullOrEmpty(GetValue(Q13_Email, currentPage, String.Empty));

                    if (!Q13EmailCheck)
                    {
                        Q13_Email.MessageManager.ErrorMessage = "Please enter your Email Address.";
                        retVal = false;
                    }
                }
                if (currentPage)
                {
                    SaveValue(Q9_Male);
                    SaveValue(Q9_Female);
                    SaveValue(Q10_19to24);
                    SaveValue(Q10_25to34);
                    SaveValue(Q10_35to44);
                    SaveValue(Q10_45to54);
                    SaveValue(Q10_55to64);
                    SaveValue(Q10_65orOlder);
                    SaveValue(Q11_35000);
                    SaveValue(Q11_35000to59999);
                    SaveValue(Q11_60000to89999);
                    SaveValue(Q11_90000);
                    SaveValue(Q11_NoSay);
                    SaveValue(Q12_PostalCode);
                    SaveValue(Q13_FirstName);
                    SaveValue(Q13_LastName);
                    SaveValue(Q13_Email);
                }
                break;

                #endregion Page 5
            }
            return(retVal);
        }
Esempio n. 53
0
        private void Start()
        {
            LoadCategorias("Despesas");
            LoadFornecedores();

            if (idMov > 0)
            {
                imprimir.Visible  = true;
                btnApagar.Visible = true;

                _modelCaixaMov = _modelCaixaMov.FindById(idMov).FirstOrDefault <CaixaMovimentacao>();
                idCaixa        = _modelCaixaMov.id_caixa;

                if (_modelCaixaMov.id_formapgto == 1)
                {
                    Dinheiro.Checked = true;
                }

                if (_modelCaixaMov.id_formapgto == 2)
                {
                    Cheque.Checked = true;
                }

                switch (_modelCaixaMov.Tipo)
                {
                case 1:
                    //Dinheiro.Enabled = false;
                    //Cheque.Enabled = false;
                    //Tipo1.Checked = true;
                    //Tipo2.Enabled = false;
                    //Tipo3.Enabled = false;
                    //Valor.Enabled = false;
                    //Categorias.Enabled = false;
                    //Fornecedor.Enabled = false;
                    //Obs.Enabled = false;
                    //btnSalvar.Enabled = false;

                    Categorias.Enabled = true;
                    Fornecedor.Enabled = true;
                    imprimir.Visible   = false;
                    label4.Text        = @"Despesa:";
                    break;

                case 2:
                    Tipo2.Checked      = true;
                    Categorias.Enabled = true;
                    Fornecedor.Enabled = false;
                    imprimir.Visible   = true;
                    label4.Text        = @"Despesa:";
                    break;

                case 3:
                    Tipo3.Checked      = true;
                    Categorias.Enabled = false;
                    Fornecedor.Enabled = false;
                    imprimir.Visible   = false;
                    label4.Text        = @"Receita:";
                    break;
                }

                Valor.Text = Validation.FormatPrice(_modelCaixaMov.Valor);
                Categorias.SelectedValue = _modelCaixaMov.id_categoria.ToString();
                Fornecedor.SelectedValue = _modelCaixaMov.id_pessoa.ToString();
                Obs.Text = _modelCaixaMov.Obs;
            }
        }
Esempio n. 54
0
        private void btnSaveCategory_Click(object sender, System.EventArgs e)
        {
            CategoryInfo category = SubsiteCatalogHelper.GetCategory(this.categoryId);

            if (category == null)
            {
                this.ShowMsg("编缉商品分类错误,未知", false);
                return;
            }
            //if (this.fileUpload.HasFile)
            //{
            //    try
            //    {
            //        ResourcesHelper.DeleteImage(category.Icon);
            //        category.Icon = SubsiteCatalogHelper.UploadCategoryIcon(this.fileUpload.PostedFile);
            //    }
            //    catch
            //    {
            //        this.ShowMsg("图片上传失败,您选择的不是图片类型的文件,或者网站的虚拟目录没有写入文件的权限", false);
            //        return;
            //    }
            //}
            category.AssociatedProductType = this.dropProductTypes.SelectedValue;
            category.Name            = this.txtCategoryName.Text;
            category.RewriteName     = this.txtRewriteName.Text;
            category.MetaTitle       = this.txtPageKeyTitle.Text;
            category.MetaKeywords    = this.txtPageKeyWords.Text;
            category.MetaDescription = this.txtPageDesc.Text;
            category.Notes1          = this.fckNotes1.Text;
            category.Notes2          = this.fckNotes2.Text;
            category.Notes3          = this.fckNotes3.Text;
            if (category.Depth > 1)
            {
                CategoryInfo category2 = SubsiteCatalogHelper.GetCategory(category.ParentCategoryId.Value);
                if (string.IsNullOrEmpty(category.Notes1))
                {
                    category.Notes1 = category2.Notes1;
                }
                if (string.IsNullOrEmpty(category.Notes2))
                {
                    category.Notes2 = category2.Notes2;
                }
                if (string.IsNullOrEmpty(category.Notes3))
                {
                    category.Notes3 = category2.Notes3;
                }
                if (string.IsNullOrEmpty(category.Notes4))
                {
                    category.Notes4 = category2.Notes4;
                }
                if (string.IsNullOrEmpty(category.Notes5))
                {
                    category.Notes5 = category2.Notes5;
                }
            }
            ValidationResults validationResults = Validation.Validate <CategoryInfo>(category, new string[]
            {
                "ValCategory"
            });
            string text = string.Empty;

            if (!validationResults.IsValid)
            {
                foreach (ValidationResult current in (System.Collections.Generic.IEnumerable <ValidationResult>)validationResults)
                {
                    text += Formatter.FormatErrorMessage(current.Message);
                }
                this.ShowMsg(text, false);
            }
            else
            {
                CategoryActionStatus categoryActionStatus = SubsiteCatalogHelper.UpdateCategory(category);
                if (categoryActionStatus == CategoryActionStatus.Success)
                {
                    this.ShowMsg("成功修改了当前商品分类", true);
                    this.BindCategoryInfo(category);
                    return;
                }
                if (categoryActionStatus == CategoryActionStatus.UpdateParentError)
                {
                    this.ShowMsg("不能自己成为自己的上级分类", false);
                    return;
                }
                this.ShowMsg("编缉商品分类错误,未知", false);
                return;
            }
        }
Esempio n. 55
0
        void RestartPendingDownloads()
        {
            using (var db = DatabaseManager.Open())
            {
                foreach (var map in DatabaseManager.PendingMapDownloads())
                {
                    SIM.LogWeb(SIM.Web.MapDownloadStart, map.Name);
                    Uri uri = new Uri(map.Url);
                    DownloadManager.AddDownloadToQueue(
                        uri,
                        map.LocalPath,
                        progress =>
                    {
                        Debug.Log($"Map Download at {progress}%");
                        NotificationManager.SendNotification("MapDownload", new { map.Id, progress }, map.Owner);
                    },
                        (success, ex) =>
                    {
                        var updatedModel      = db.Single <MapModel>(map.Id);
                        bool passesValidation = false;
                        if (success)
                        {
                            passesValidation = Validation.BeValidAssetBundle(map.LocalPath);
                            if (!passesValidation)
                            {
                                updatedModel.Error = "You must specify a valid AssetBundle";
                            }
                        }

                        updatedModel.Status = passesValidation ? "Valid" : "Invalid";

                        if (ex != null)
                        {
                            updatedModel.Error = ex.Message;
                        }

                        db.Update(updatedModel);
                        NotificationManager.SendNotification("MapDownloadComplete", updatedModel, map.Owner);

                        SIM.LogWeb(SIM.Web.MapDownloadFinish, map.Name);
                    }
                        );
                }

                var added    = new HashSet <Uri>();
                var vehicles = new VehicleService();

                foreach (var vehicle in DatabaseManager.PendingVehicleDownloads())
                {
                    Uri uri = new Uri(vehicle.Url);
                    if (added.Contains(uri))
                    {
                        continue;
                    }
                    added.Add(uri);

                    SIM.LogWeb(SIM.Web.VehicleDownloadStart, vehicle.Name);
                    DownloadManager.AddDownloadToQueue(
                        uri,
                        vehicle.LocalPath,
                        progress =>
                    {
                        Debug.Log($"Vehicle Download at {progress}%");
                        NotificationManager.SendNotification("VehicleDownload", new { vehicle.Id, progress }, vehicle.Owner);
                    },
                        (success, ex) =>
                    {
                        bool passesValidation = success && Validation.BeValidAssetBundle(vehicle.LocalPath);

                        string status = passesValidation ? "Valid" : "Invalid";
                        vehicles.SetStatusForPath(status, vehicle.LocalPath);
                        vehicles.GetAllMatchingUrl(vehicle.Url).ForEach(v =>
                        {
                            if (!passesValidation)
                            {
                                v.Error = "You must specify a valid AssetBundle";
                            }

                            if (ex != null)
                            {
                                v.Error = ex.Message;
                            }

                            NotificationManager.SendNotification("VehicleDownloadComplete", v, v.Owner);
                            SIM.LogWeb(SIM.Web.VehicleDownloadFinish, vehicle.Name);
                        });
                    }
                        );
                }
            }
        }
Esempio n. 56
0
 public ProjectInfo(string Name, string Directory)
 {
     name = Name;
     path = Directory;
     type = Validation.IsUnityDirectory(new DirectoryInfo(path)) ? ProjectType.Unity : ProjectType.Standalone;
 }
Esempio n. 57
0
 void ITaskDesc.Validate()
 {
     Validation.NotEmpty(EventType, nameof(EventType));
 }
Esempio n. 58
0
 public bool ValidarTelefone(string f)
 {
     return(Validation.validarTelefone(f));
 }
Esempio n. 59
0
 public bool validaEmail(string email)
 {
     return(Validation.validarEmail(email));
 }
Esempio n. 60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MethodGraphFieldTemplate" /> class.
 /// </summary>
 /// <param name="parent">The parent object template that owns this method.</param>
 /// <param name="methodInfo">The method information.</param>
 protected MethodGraphFieldTemplate(IGraphTypeTemplate parent, MethodInfo methodInfo)
     : base(parent, methodInfo)
 {
     this.Method = Validation.ThrowIfNullOrReturn(methodInfo, nameof(methodInfo));
     _arguments  = new List <GraphFieldArgumentTemplate>();
 }