Пример #1
0
 void data_cbo_estructuraid()
 {
     tb_ta_estructuraBL BL = new tb_ta_estructuraBL();
     tb_ta_estructura BE = new tb_ta_estructura();
     try
     {
         estructuraid.DataSource = BL.GetAll(EmpresaID, BE).Tables[0];
         estructuraid.ValueMember = "estructuraid";
         estructuraid.DisplayMember = "estructuraname";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void Update()
        {
            try
            {
                if (estructuraid.Text.Trim().Length != 1)
                {
                    MessageBox.Show("Falta Codigo Estructura !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (estructuraname.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Ingrese Nombre de Estructura", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        var BL = new tb_ta_estructuraBL();
                        var BE = new tb_ta_estructura();

                        BE.estructuraid = estructuraid.Text.Trim().PadLeft(1, '0');
                        BE.estructuraname = estructuraname.Text.ToUpper();
                        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 form_cargar_datos(String posicion)
        {
            try
            {
                var BL = new tb_ta_estructuraBL();
                var BE = new tb_ta_estructura();
                var dt = new DataTable();

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

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

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

                    estructuraid.Text = dt.Rows[0]["estructuraid"].ToString().Trim();
                    estructuraname.Text = dt.Rows[0]["estructuraname"].ToString().Trim();

                    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 (estructuraid.Text.Trim().Length != 1)
                {
                    MessageBox.Show("Falta Codigo Estructura !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new tb_ta_estructuraBL();
                    var BE = new tb_ta_estructura();

                    BE.estructuraid = estructuraid.Text.Trim().PadLeft(1, '0');
                    BE.estructuraname = estructuraname.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_Tablaestructura();
                        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_Tablaestructura()
        {
            try
            {
                if (Tablaestructura.Rows.Count > 0)
                {
                    Tablaestructura.Rows.Clear();
                }
                var BL = new tb_ta_estructuraBL();
                var BE = new tb_ta_estructura();

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

                Tablaestructura = BL.GetAll(EmpresaID, BE).Tables[0];
                if (Tablaestructura.Rows.Count > 0)
                {
                    btn_imprimir.Enabled = true;
                    gridestructura.DataSource = Tablaestructura;
                    gridestructura.Rows[0].Selected = false;
                    gridestructura.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Insert()
        {
            try
            {
                if (estructuraid.Text.Trim().Length != 3)
                {
                    MessageBox.Show("Falta Codigo estructura !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else if (estructuraname.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Ingrese nombre de estructura", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    tb_ta_estructuraBL BL = new tb_ta_estructuraBL();
                    tb_ta_estructura BE = new tb_ta_estructura();

                    BE.estructuraid = estructuraid.Text.Trim().PadLeft(1, '0');
                    BE.estructuraname = estructuraname.Text.ToUpper();
                    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);
            }
        }