示例#1
0
        private void AddReplaceEvent(object sender, EventArgs e)
        {
            var name = this.txtName.Text;

            if (ValidatorManager.IsValid(TypeValidation.WORD, name))
            {
                DialogResult result = MessageBox.Show("¿Estás seguro que deseas " + btnGuardar.Text + " la marca " + name + "?", "", MessageBoxButtons.OKCancel);
                if (result.Equals(DialogResult.OK))
                {
                    MessageModel message = null;
                    if (btnGuardar.Text.ToLower().Equals("guardar"))
                    {
                        message = _brand.SetItem(new BrandModel()
                        {
                            Name = name
                        });
                    }
                    else
                    {
                        message = _brand.UpdateItem(new BrandModel()
                        {
                            Name = name, Id = idSelected
                        });

                        message = _brand.UpdateStateItem(new BrandModel()
                        {
                            State = (this.rdoActive.Checked)?0:1, Id = idSelected
                        });
                    }
                    if (message.Code == 200)
                    {
                        this.dgvCatalog.DataSource = _brand.GetBrands();
                        this.ClearProperties();
                    }
                    else
                    {
                        MessageBox.Show(message.Message);
                    }
                }
            }
            else
            {
                MessageBox.Show("Debes completar todos los parametros antes de realizar el proceso");
            }
        }