Ejemplo n.º 1
0
 private void Cargar_cmbCategoria()
 {
     var BE = new tb_pt_categoria();
     var BL = new tb_pt_categoriaBL();
     var dt = new DataTable();
     dt = BL.GetAll(EmpresaID, BE).Tables[0];
     if (dt.Rows.Count > 0)
     {
         cmb_categoriaid.DataSource = dt;
         cmb_categoriaid.ValueMember = "categoriaid";
         cmb_categoriaid.DisplayMember = "categorianame";
     }
 }
        private void Update()
        {
            try
            {
                if (categoriaid.Text.Trim().Length != 2)
                {
                    MessageBox.Show("Falta Codigo Categoria !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (categorianame.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Ingrese Nombre de Categoria", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    tb_pt_categoriaBL BL = new tb_pt_categoriaBL();
                    tb_pt_categoria BE = new tb_pt_categoria();

                    BE.categoriaid = categoriaid.Text.Trim().PadLeft(2, '0');
                    BE.categorianame = categorianame.Text.ToUpper();
                    BE.es_saldo = chkessaldo.Checked;
                    BE.usuar = VariablesPublicas.Usuar.Trim();

                    if (BL.Update(EmpresaID, BE))
                    {
                        SEGURIDAD_LOG("M");
                        MessageBox.Show("Datos Modificado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        procesado = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Insert()
        {
            try
            {
                if (categorianame.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Ingrese Nombre de categoria", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    tb_pt_categoriaBL BL = new tb_pt_categoriaBL();
                    tb_pt_categoria BE = new tb_pt_categoria();

                    BE.categoriaid = categoriaid.Text.Trim().PadLeft(2, '0');
                    BE.categorianame = categorianame.Text.ToUpper();
                    BE.es_saldo = chkessaldo.Checked;
                    BE.usuar = VariablesPublicas.Usuar.Trim();

                    if (BL.Insert(EmpresaID, BE))
                    {
                        MessageBox.Show("Datos grabados correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        procesado = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void form_cargar_datos(String posicion)
        {
            try
            {
                tb_pt_categoriaBL BL = new tb_pt_categoriaBL();
                tb_pt_categoria BE = new tb_pt_categoria();
                DataTable dt = new DataTable();

                if (categoriaid.Text.Trim().Length > 0)
                {
                    BE.categoriaid = categoriaid.Text.Trim().PadLeft(2, '0');
                }
                BE.posicion = posicion.Trim();

                dt = BL.GetAll_paginacion(EmpresaID, BE).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    limpiar_documento();
                    ssModo = "EDIT";

                    categoriaid.Text = dt.Rows[0]["categoriaid"].ToString().Trim();
                    categorianame.Text = dt.Rows[0]["categorianame"].ToString().Trim();
                    chkessaldo.Checked = Convert.ToBoolean(dt.Rows[0]["es_saldo"].ToString());

                    btn_editar.Enabled = true;
                    btn_eliminar.Enabled = true;
                    btn_imprimir.Enabled = true;

                    btn_primero.Enabled = true;
                    btn_anterior.Enabled = true;
                    btn_siguiente.Enabled = true;
                    btn_ultimo.Enabled = true;

                    btn_buscar.Enabled = true;
                    btn_salir.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Delete()
        {
            try
            {
                if (categoriaid.Text.Trim().Length != 2)
                {
                    MessageBox.Show("Falta Codigo Categoria !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    tb_pt_categoriaBL BL = new tb_pt_categoriaBL();
                    tb_pt_categoria BE = new tb_pt_categoria();

                    BE.categoriaid = categoriaid.Text.Trim().PadLeft(2, '0');
                    //BE.categorianame = categorianame.Text.ToUpper();
                    //BE.usuar = VariablesPublicas.Usuar.Trim();

                    if (BL.Delete(EmpresaID, BE))
                    {
                        SEGURIDAD_LOG("E");
                        MessageBox.Show("Datos Eliminados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        NIVEL_FORMS();
                        limpiar_documento();
                        data_Tablacategoria();
                        form_bloqueado(false);
                        btn_nuevo.Enabled = true;

                        btn_primero.Enabled = true;
                        btn_anterior.Enabled = true;
                        btn_siguiente.Enabled = true;
                        btn_ultimo.Enabled = true;

                        btn_buscar.Enabled = true;
                        btn_salir.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void data_Tablacategoria()
        {
            try
            {
                if (Tablacategoria.Rows.Count > 0)
                    Tablacategoria.Rows.Clear();
                tb_pt_categoriaBL BL = new tb_pt_categoriaBL();
                tb_pt_categoria BE = new tb_pt_categoria();

                BE.categorianame = txt_criterio.Text.Trim().ToUpper();

                Tablacategoria = BL.GetAll(EmpresaID, BE).Tables[0];
                if (Tablacategoria.Rows.Count > 0)
                {
                    btn_imprimir.Enabled = true;
                    gridcategoria.DataSource = Tablacategoria;
                    gridcategoria.Rows[0].Selected = false;
                    gridcategoria.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }