Esempio n. 1
0
        private void CargarCategorias()
        {
            NCategoria categorias = new NCategoria();

            dlCategorias.DataSource = Helper.ToCategoriaPuntuacion(categorias.ToList()).OrderBy(v => v.PromedioPuntuacion);
            dlCategorias.DataBind();
        }
 //Mostar no data Grid
 private void Mostar()
 {
     this.dataLista.DataSource = NCategoria.Mostrar();
     this.OcultarColunas();
     lblTotal.Text = dataLista.Rows.Count.ToString();
     lblTotal.Text = "Quantidade de registros: " + Convert.ToString(dataLista.Rows.Count);
 }
 private void BuscarDescripcion()
 {
     dtgvListado.DataSource       = NCategoria.Buscar_Descripcion_Categoria(mtxtbuscar.Text);
     dtgvListado.Columns[2].Width = 300;
     dtgvListado.Columns[1].Width = 250;
     lblTotal.Text = "Total de Registros: " + Convert.ToString(dtgvListado.RowCount);
 }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.txtCategoryName.Text == string.Empty || this.txtDescription.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados");
                    errorIcono.SetError(txtCategoryName, "Ingrese un Valor");
                    errorIcono.SetError(txtDescription, "Ingrese un Valor");
                }
                else
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    this.pxImagen.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    byte[] imagen = ms.GetBuffer();

                    if (this.IsNuevo)
                    {
                        rpta = NCategoria.Insertar(this.txtCategoryName.Text, this.txtDescription.Text.Trim(),
                                                   //Helpers.ImageHelper.ImageToByteArray(pxImagen.Image)
                                                   imagen

                                                   );
                    }
                    else
                    {
                        //rpta = NArticulo.Editar(this.txtCategoryName.Text, this.txtDescription.Text.Trim(),
                        //    this.txtDescripcion.Text.Trim(), imagen, Convert.ToInt32(this.txtIdcategoria.Text),
                        //    Convert.ToInt32(this.cbIdpresentacion.SelectedValue));
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se Insertó de forma correcta el registro");
                        }
                        else
                        {
                            this.MensajeOk("Se Actualizó de forma correcta el registro");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
        //Buscar pelo Nome
        private void BuscarNome()
        {
            this.dataLista.DataSource = NCategoria.BuscarNome(this.txtBuscar.Text);

            this.ocultarColunas();
            lblTotal.Text = "Total de Registros: " + Convert.ToString(dataLista.Rows.Count);
        }
        private void btnDeletar_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult Opcao;
                Opcao = MessageBox.Show("Realmente deseja apagar os Registros", "Sistema Comércio", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (Opcao == DialogResult.OK)
                {
                    string Codigo;
                    string Resp = "";

                    foreach (DataGridViewRow row in dataLista.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            Codigo = row.Cells[1].Value.ToString(); //caso erro trocar
                            Resp   = NCategoria.Excluir(Convert.ToInt32(Codigo));
                            if (Resp.Equals("OK"))
                            {
                                this.MensagemOK("Registro excluido com sucesso");
                            }
                            else
                            {
                                this.MensagemErro(Resp);
                            }
                        }
                    }
                    this.Mostar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 7
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult Opcion;
                Opcion = MessageBox.Show("Realmente Desea Eliminar los Registros", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (Opcion == DialogResult.OK)
                {
                    string Codigo;
                    string Rpta = "";
                    foreach (DataGridViewRow row in dataListado.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            Codigo = Convert.ToString(row.Cells[1].Value);
                            Rpta   = NCategoria.Eliminar(Convert.ToInt32(Codigo));

                            if (Rpta.Equals("OK"))
                            {
                                this.MensajeOK("Se Eliminó Correctamente el registro");
                            }
                            else
                            {
                                this.MensajeError(Rpta);
                            }
                        }
                    }
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 8
0
        private void Guardar()
        {
            ECategoria be = new ECategoria
            {
                ID     = Convert.ToInt32(lblIdentificador.Text),
                Nombre = TxtNombre.Text
            };
            NCategoria bo = new NCategoria();

            if (modificar == 0)
            {
                if (bo.Agregar(be))
                {
                    TxtNombre.Text = "";
                    Listar();
                    Frm_Principal.Main.ChangeMessage("Categoria agregado correctamente", "Success");
                }
                else
                {
                    Frm_Principal.Main.ChangeMessage("Algo salio mal, Intente de nuevo", "Failed");
                }
            }
            else if (modificar == 1)
            {
                if (bo.Modificar(be))
                {
                    Listar();
                    Frm_Principal.Main.ChangeMessage("Categoria modificado correctamente", "Success");
                }
                else
                {
                    Frm_Principal.Main.ChangeMessage("Algo salio mal, Intente de nuevo", "Failed");
                }
            }
        }
Esempio n. 9
0
 private void BtnEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult opcion;
         opcion = MessageBox.Show("¿Desea Eliminar los registros", "Supermercado", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
         if (opcion == DialogResult.OK)
         {
             string codigo;
             //string repuesta = "";
             foreach (DataGridViewRow row in DgvListado.Rows)
             {
                 if (Convert.ToBoolean(row.Cells[0].Value))
                 {
                     codigo = row.Cells[1].Value.ToString();
                     NCategoria.Eliminar(Convert.ToInt32(codigo));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
     this.mostrar();
 }
Esempio n. 10
0
 //metodo Buscar pelo Nome
 private void BuscarNome()
 {
     this.dataGridView_Lista.DataSource = NCategoria.BuscarNome(this.txt_Buscar.Text);
     //MessageBox.Show("teste");
     this.OcultarColunas();
     lb_TotalResgistro.Text = "Total de Registro encontrado: " + Convert.ToString(dataGridView_Lista.Rows.Count);
 }
Esempio n. 11
0
 //metodo mosrar
 private void Mostrar()
 {
     this.dataListado.DataSource = NCategoria.Mostrar();
     this.OcultarColumnas();
     lblTotal.Text = "Total de Registros: " + Convert.ToString(dataListado.Rows.Count);
     //Metodo BuscarNombre
 }
Esempio n. 12
0
 private void DgCategorias_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == DgCategorias.Columns["Eliminar"].Index)
     {
         DataGridViewCheckBoxCell ChkEliminar = (DataGridViewCheckBoxCell)DgCategorias.Rows[e.RowIndex].Cells["Eliminar"];
         ChkEliminar.Value = !Convert.ToBoolean(ChkEliminar.Value);
     }
     else if (e.ColumnIndex == DgCategorias.Columns[4].Index)
     {
         string respuesta;
         string check = Convert.ToString(DgCategorias.Rows[e.RowIndex].Cells[4].Value);
         DataGridViewCheckBoxCell ChkEliminar = (DataGridViewCheckBoxCell)DgCategorias.Rows[e.RowIndex].Cells[4];
         if (check.Equals("True"))
         {
             respuesta         = NCategoria.Desactivar(Convert.ToInt32(DgCategorias.Rows[e.RowIndex].Cells[1].Value));
             ChkEliminar.Value = !Convert.ToBoolean(ChkEliminar.Value);
             this.Alert("Categoría: " + Convert.ToString(DgCategorias.Rows[e.RowIndex].Cells[2].Value) + " desactivada", FrmAlert.alertTypeEnum.Info);
         }
         else
         {
             respuesta         = NCategoria.Activar(Convert.ToInt32(DgCategorias.Rows[e.RowIndex].Cells[1].Value));
             ChkEliminar.Value = !Convert.ToBoolean(ChkEliminar.Value);
             this.Alert("Categoría: " + Convert.ToString(DgCategorias.Rows[e.RowIndex].Cells[2].Value) + " activada", FrmAlert.alertTypeEnum.Info);
         }
     }
 }
Esempio n. 13
0
 private void cargarCategoria()
 {
     cbProducto.DataSource    = NCategoria.Mostrar();
     cbProducto.ValueMember   = "Codigo";
     cbProducto.DisplayMember = "Categoria";
     cbProducto.SelectedIndex = -1;
 }
Esempio n. 14
0
 private void BuscarNombre()
 {
     dtgvCategorias.DataSource       = NCategoria.Buscar_Nombre_Categoria(mtxtbuscar.Text);
     dtgvCategorias.Columns[3].Width = 300;
     dtgvCategorias.Columns[2].Width = 250;
     lblTotal.Text = "Total de Registros: " + Convert.ToString(dtgvCategorias.RowCount);
 }
Esempio n. 15
0
 private void ConsultarPorNome()
 {
     this.dataLista.DataSource = NCategoria.ConsultarPorNome(this.txtBuscar.Text);
     // para não mostrar as duas primeiras colunas
     this.OcultarColunas();
     // label para mostrar o total de registros
     lblTotal.Text = "Total de Registros: " + dataLista.Rows.Count.ToString(); // ou convert.tostring(datalista.rows.count);
 }
        //Metodo Buscar por Nombre

        private void BuscarNombre()
        {
            this.dataListado.DataSource = NCategoria.BuscarTexto(txtBuscar.Text);
            //LLammo al mostrar de la capa de negocio y me devuelve la tabla llena de datos
            OcultarColumnas();
            //Cuando muestro la informacion oculto la columna de eliminar
            lblTotal.Text = "Total de Registros: " + Convert.ToString(this.dataListado.RowCount);
        }
Esempio n. 17
0
 //Método mostrar
 private void Mostrar()
 {
     this.dataListado.DataSource           = NArticulo.Mostrar();
     this.dataListadoCategorias.DataSource = NCategoria.Mostrar();
     this.dataListadoFruver.DataSource     = NFruver.Mostrar();
     this.OcultarColumnas();
     lblTotal.Text = "Total de registros: " + Convert.ToString(dataListado.Rows.Count);
 }
Esempio n. 18
0
 private void cargarCategoria()
 {
     cbCategoria.DataSource    = NCategoria.Mostrar();
     cbCategoria.ValueMember   = "Codigo";
     cbCategoria.DisplayMember = "Categoria";
     cbCategoria.SelectedIndex = -1;
     //lblPrueba.Text = cbCategoria.SelectedValue.ToString();
 }
Esempio n. 19
0
        //guardar datos
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            string rutaimagen = "";


            //insertar datos
            try
            {
                string rpta = "";
                if (this.txtNombre.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algunos datos, serán remarcados.");
                    errorIcono.SetError(this.txtNombre, "Ingrese un nombre");
                }
                else
                {
                    if (this.EsNuevo)
                    {
                        //nombre,descripcion,imagen,activa
                        rpta = NCategoria.Insertar(this.txtNombre.Text.Trim().ToUpper(),
                                                   this.txtDescripcion.Text.Trim(), rutaimagen, Convert.ToInt32(this.CategoriaActiva(chkActiva)));
                    }
                    else
                    {
                        //id,nombre,descripcion,imagen,activa
                        rpta = NCategoria.Editar(Convert.ToInt32(this.txtCodigo.Text),
                                                 this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim(), rutaimagen, Convert.ToInt32(this.CategoriaActiva(chkActiva)));
                    }

                    if (rpta.Equals("OK"))
                    {
                        if (this.EsNuevo)
                        {
                            this.MensajeOK("Se inserto de forma correcta el registro.");
                        }
                        else
                        {
                            this.MensajeOK("Se modificó de forma correcta el registro.");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    //preparamos para nuevos datos
                    this.EsNuevo  = false;
                    this.EsEditar = false;
                    this.Botones();
                    this.LimpiarControles();
                    this.MostrarDatos();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 20
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                ErrorIcono.Clear();

                string msgRespuesta = "";
                if (txtNombre.Text == "" || txtDescripcion.Text == "")
                {
                    MsgError("Debe ingresar los datos correctamente para continuar: ");
                }
                if (txtNombre.Text == string.Empty)
                {
                    ErrorIcono.SetError(txtNombre, "Debe ingresar un nombre");
                }
                if (txtDescripcion.Text == string.Empty)
                {
                    ErrorIcono.SetError(txtDescripcion, "Debe Ingresar una Descripcion");
                }
                else
                {
                    if (N == true)
                    {
                        msgRespuesta = NCategoria.IngresarCategoria(txtNombre.Text.Trim(), txtDescripcion.Text.Trim());
                    }
                    else
                    {
                        msgRespuesta = NCategoria.ModificarCategoria(Convert.ToInt32(txtCodigo.Text), txtNombre.Text.Trim(), txtDescripcion.Text.Trim());
                    }
                    if (msgRespuesta.Equals("Ok"))
                    {
                        if (N)
                        {
                            MsgConfirmacion("Se han guardado los datos correctamente");
                        }
                        else
                        {
                            MsgConfirmacion("Se han editado los datos correctamente");
                        }
                        N = false;
                        E = false;
                        HoB_btn();
                        limpiar();
                        MostrarDatos();
                        ErrorIcono.Clear();
                    }
                    else
                    {
                        MsgError(msgRespuesta);
                    }
                }
            }

            catch (Exception ex)
            {
                MsgError(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 21
0
 private void llenar_comboBox()
 {
     CmbCategoria.DataSource       = NCategoria.mostrar();
     CmbCategoria.ValueMember      = "idcategoria";
     CmbCategoria.DisplayMember    = "nombre";
     CmbPresentacion.DataSource    = Npresentacion.mostrar();
     CmbPresentacion.ValueMember   = "idpresentacion";
     CmbPresentacion.DisplayMember = "nombre";
 }
Esempio n. 22
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult Opcion;

                Opcion = MessageBox.Show("¿Realmente desea eliminar los registros?", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                if (Opcion == DialogResult.OK)
                {
                    string Rpta = "";
                    string codigo;
                    int    cont_eliminados = 0;
                    foreach (DataGridViewRow row in dataListado.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells[0].Value))
                        {
                            codigo = Convert.ToString(row.Cells[1].Value);
                            Rpta   = NCategoria.Eliminar(Convert.ToInt32(codigo));

                            if (Rpta.Equals("OK"))
                            {
                                cont_eliminados++;
                            }

                            else
                            {
                                this.MensajeError(Rpta);
                            }
                        }
                    }

                    // show messages deletes
                    if (cont_eliminados > 0)
                    {
                        if (cont_eliminados == 1)
                        {
                            this.MensajeOk("Se elimino un registro");
                        }
                        else
                        {
                            this.MensajeOk("Se eliminaron " + cont_eliminados + " registros");
                        }
                    }

                    this.chkeliminar.Checked = false;

                    this.Mostrar();

                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Esempio n. 23
0
 /****************************
  * Creado Por: Sergio Garcia
  * Fecha Creacion: 08/Octubre/2019
  * Método: Mostrar
  * Descripción: Muestra los registros de las categorias en el datatable dt_Listado
  *****************************/
 private void Mostrar()
 {
     this.dt_Listado.DataSource            = NCategoria.Mostrar();
     this.dt_Listado.Columns[0].HeaderText = "Codigo";
     this.dt_Listado.Columns[1].HeaderText = "Nombre";
     this.dt_Listado.Columns[2].HeaderText = "Descripción";
     this.OcultarColumnas();
     this.lbl_Total.Text = "Total Registros: " + dt_Listado.Rows.Count;
 }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string Rpta = "";
                if (this.txtNombre.Text == string.Empty)
                {
                    MensajeError("Falta Ingresar algunos valores");
                    errorIcono.SetError(txtNombre, "Ingrese Nombre");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        //insertar un producto
                        Rpta = NCategoria.Insertar(this.txtNombre.Text.Trim().ToUpper(),
                                                   this.txtDescripcion.Text.Trim());
                    }
                    else
                    {
                        //modificar un producto
                        Rpta = NCategoria.Editar(Convert.ToInt32(this.txtIdCategoria.Text),
                                                 this.txtNombre.Text.Trim().ToUpper(),
                                                 this.txtDescripcion.Text.Trim());
                    }

                    if (Rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Insercion corecta");
                        }
                        else
                        {
                            this.MensajeOk("Actualizacion carecta");
                        }
                    }
                    else
                    {
                        //Mostramos el mensaje de error
                        this.MensajeError(Rpta);
                    }
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostar();
                    this.txtIdCategoria.Text = "";
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (Editar == true)
     {
         if (Comprobar_Campos() == string.Empty)
         {
             if (Obtener_Id(AuxiliarNombre) == 0)
             {
                 MessageBox.Show("Error: id no encontrado!");
             }
             else
             {
                 if (AuxiliarNombre == tbNombre.Text)
                 {
                     MessageBox.Show(NCategoria.Editar(Obtener_Id(tbNombre.Text), tbNombre.Text, tbDescripcion.Text));
                     Limpiar_Campos();
                     Editar = false;
                 }
                 else if (NombreExistente(tbNombre.Text))
                 {
                     MessageBox.Show(string.Format("Error: el nombre '{0}' ya se encuentra en uso!", tbNombre.Text));
                 }
                 else
                 {
                     MessageBox.Show(NCategoria.Editar(Obtener_Id(AuxiliarNombre), tbNombre.Text, tbDescripcion.Text));
                     Limpiar_Campos();
                     Editar = false;
                 }
             }
         }
         else
         {
             MessageBox.Show(Comprobar_Campos());
         }
     }
     else
     {
         if (Comprobar_Campos() == string.Empty)
         {
             if (NombreExistente(tbNombre.Text))
             {
                 MessageBox.Show(string.Format("Error: el nombre '{0}' ya se encuentra en uso!", tbNombre.Text));
             }
             else
             {
                 MessageBox.Show(NCategoria.Insertar(tbNombre.Text, tbDescripcion.Text));
                 Limpiar_Campos();
             }
         }
         else
         {
             MessageBox.Show(Comprobar_Campos());
         }
     }
     Mostrar();
 }
Esempio n. 26
0
 private void Listar()
 {
     try
     {
         dgvListado.DataSource = NCategoria.Listar();
     }catch (Exception ex)
     {
         MessageBox.Show(ex.Message + ex.StackTrace);
     }
 }
Esempio n. 27
0
 public MainCasosNegocio()
 {
     Categoria     = new NCategoria();
     Empresa       = new NEmpresa();
     Local         = new NLocal();
     Oferta        = new NOferta();
     OpinionOferta = new NOpinionOferta();
     Producto      = new NProducto();
     Usuario       = new NUsuario();
 }
Esempio n. 28
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";

                if (this.txtNombre.Text == string.Empty)
                {
                    MensajeError("Falta Ingresar algunos datos, serán remarcados");
                    errorIcono.SetError(txtNombre, "Ingrese un Nombre");
                }
                else
                {
                    if (this.IsNuevo)
                    {
                        rpta = NCategoria.Insertar(this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim().ToUpper());
                    }

                    if (this.IsEditar)
                    {
                        rpta = NCategoria.Editar(Convert.ToInt32(this.txtIdcategoria.Text.Trim()), this.txtNombre.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim().ToUpper());
                    }

                    // validar si se inserto correctamente el registro

                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            MensajeOk("Se insertó de forma correcta el registro");
                        }
                        else
                        {
                            MensajeOk("Se actualizó de forma correcta el registro");
                        }
                    }
                    // si es error
                    else
                    {
                        this.MensajeError(rpta);
                    }

                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
        private void CargarCategoria()
        {
            NCategoria bo = new NCategoria();

            if (bo.CuadroCombinado().Count > 0)
            {
                CbxCategoria.DataSource    = new BindingSource(bo.CuadroCombinado(), null);
                CbxCategoria.ValueMember   = "Key";
                CbxCategoria.DisplayMember = "Value";
            }
        }
Esempio n. 30
0
        private void cargarComboCategoria()
        {
            this.txtCategoria.DropDownList.Columns.Clear();
            this.txtCategoria.DropDownList.Columns.Add("nombre").Width = 200;
            this.txtCategoria.DropDownList.Columns["nombre"].Caption   = "";
            this.txtCategoria.ValueMember   = "nombre";
            this.txtCategoria.DisplayMember = "nombre";

            this.txtCategoria.DataSource = NCategoria.BuscarNombre(this.txtCategoria.Text.Trim());
            this.txtCategoria.Refresh();
        }