Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            var existe = catManager.Existe(comboBox1.Text);
            var resp   = MessageBox.Show("Esta seguro de Agregar esta Categoría?", "Agregar Categoria", MessageBoxButtons.YesNo);

            if (resp == DialogResult.Yes && comboBox1.Text != "" && existe == false)
            {
                catManager.InsertCategorias(new Categoria {
                    Activo = true, CategoriaDesc = comboBox1.Text.ToUpper(), Pesa = false, Idcategoria = 0
                });
            }
            comboUpdates();
        }
Exemplo n.º 2
0
        public void SeleccionoBarra()
        {
            this.textoBoxp2.Focus();
            if (comandBar1.Status == RecordAction.Search)
            {
                Carga_Busqueda();
            }
            if (comandBar1.Status == RecordAction.None)
            {
                this.panel1.Enabled = false;
            }
            if (comandBar1.Status == RecordAction.Insert || (comandBar1.Status == RecordAction.Update))
            {
                this.panel1.Enabled = true;
                this.panel1.Select();
                if (comandBar1.Status == RecordAction.Insert)
                {
                    initField();
                }
                textoBoxp2.Focus();
            }

            if (comandBar1.Status == RecordAction.Delete && comandBar1.confirma)
            {
                catManager.Delete(currentCat.Idcategoria);
                this.comandBar1.confirma = false;
                initField();
                panel1.Enabled = false;
                Utilities.Mensaje(errorBar1, "El registro fue Borrado", errorType.Error);
            }
            if (comandBar1.Status == RecordAction.Save)
            {
                var aux = validaforma();
                if (aux != "")
                {
                    errorBar1.Mensaje = aux;
                    errorBar1.Status  = errorType.Error;
                    this.comandBar1.Novalido();
                    return;
                }
                if (comandBar1.Status == RecordAction.Save && comandBar1.previo == RecordAction.Insert && aux == "")
                {
                    var Cat = new Categoria {
                        Pesa = checkBox2.Checked, Activo = checkBox1.Checked, CategoriaDesc = textoBoxp2.Text, Idcategoria = 0
                    };
                    var aux1 = validarRegistro(Cat);
                    if (aux1.Length > 0)
                    {
                        Utilities.Mensaje(errorBar1, aux1, errorType.Error);
                        return;
                    }
                    catManager.InsertCategorias(Cat);
                    this.comandBar1.previo = RecordAction.None;
                    Utilities.Controles(this, "Reset");
                    panel1.Enabled = false;
                }

                if (comandBar1.Status == RecordAction.Save && comandBar1.previo == RecordAction.Update && aux == "")
                {
                    var Cat = new Categoria {
                        Pesa = checkBox2.Checked, Activo = checkBox1.Checked, CategoriaDesc = textoBoxp2.Text, Idcategoria = Convert.ToInt16(labelindex.Text)
                    };
                    var Catdto = new CategoriaDTO {
                        pesa = checkBox2.Checked, activo = checkBox1.Checked, CategoriaDesc = textoBoxp2.Text, Idcategoria = Convert.ToInt16(labelindex.Text)
                    };
                    var aux1 = validarRegistro(Cat);
                    if (aux1.Length > 0)
                    {
                        Utilities.Mensaje(errorBar1, aux1, errorType.Error);
                        return;
                    }
                    catManager.Edit(Catdto);
                    this.comandBar1.previo = RecordAction.None;
                    Utilities.Controles(this, "Reset");
                    panel1.Enabled = false;
                }
            }
        }