Пример #1
0
 protected void btnGuardar_OnClick(object sender, EventArgs e)
 {
     try
     {
         if (txtDescripcionCatalogo.Text.Trim() == string.Empty)
         {
             throw new Exception("Debe especificar una descripción");
         }
         if (EsAlta)
         {
             _servicioCatalogo.CrearCatalogo(txtDescripcionCatalogo.Text.Trim(), true);
         }
         LimpiarCampos();
         if (OnAceptarModal != null)
         {
             OnAceptarModal();
         }
     }
     catch (Exception ex)
     {
         if (_lstError == null)
         {
             _lstError = new List <string>();
         }
         _lstError.Add(ex.Message);
         Alerta = _lstError;
     }
 }
Пример #2
0
        protected void btnGuardar_OnClick(object sender, EventArgs e)
        {
            try
            {
                if (txtDescripcionCatalogo.Text.Trim() == string.Empty)
                {
                    throw new Exception("Debe especificar una descripción");
                }
                Catalogos cat = new Catalogos();
                cat.Descripcion      = txtDescripcionCatalogo.Text;
                cat.DescripcionLarga = txtDescripcionCatalogo.Text;
                cat.IdUsuarioAlta    = ((Usuario)Session["UserData"]).Id;

                if (EsAlta)
                {
                    _servicioCatalogo.CrearCatalogo(cat, true, (List <CatalogoGenerico>)Session["registrosCatalogos"]);
                }
                LimpiarCampos();
                if (OnAceptarModal != null)
                {
                    OnAceptarModal();
                }
            }
            catch (Exception ex)
            {
                if (_lstError == null)
                {
                    _lstError = new List <string>();
                }
                _lstError.Add(ex.Message);
                Alerta = _lstError;
            }
        }
Пример #3
0
        protected void btnGuardar_OnClick(object sender, EventArgs e)
        {
            try
            {
                if (txtNombreCatalogo.Text.Trim() == string.Empty)
                {
                    throw new Exception("Debe especificar un nombre.");
                }
                if (!rbtnManual.Checked && !rbtnArchivo.Checked)
                {
                    throw new Exception("Debe seleccionar tipo de carga.");
                }
                Catalogos cat = new Catalogos
                {
                    Descripcion      = txtNombreCatalogo.Text,
                    DescripcionLarga = txtDescripcionCatalogo.Text,
                    IdUsuarioAlta    = ((Usuario)Session["UserData"]).Id
                };
                if (rbtnArchivo.Checked)
                {
                    if (Session["ArchivoCarga"].ToString() != String.Empty)
                    {
                        if (rbtnHojas.SelectedItem.Value.Trim() == string.Empty)
                        {
                            throw new Exception("Seleccione una horja del archivo.");
                        }
                        if (EsAlta)
                        {
                            _servicioCatalogo.CrearCatalogoExcel(cat, true, hfFileName.Value, rbtnHojas.SelectedValue);
                        }
                        else
                        {
                            cat.Id = IdCatalogo;
                            cat.IdUsuarioModifico = ((Usuario)Session["UserData"]).Id;
                            _servicioCatalogo.ActualizarCatalogoExcel(cat, true, hfFileName.Value, rbtnHojas.SelectedValue);
                        }

                        BusinessFile.LimpiarRepositorioTemporal(new List <string> {
                            hfFileName.Value
                        });
                        LimpiarCampos();
                    }
                }
                else
                {
                    if (EsAlta)
                    {
                        _servicioCatalogo.CrearCatalogo(cat, true, ((List <CatalogoGenerico>)Session["registrosCatalogos"]));
                    }
                    else
                    {
                        cat.Id = IdCatalogo;
                        cat.IdUsuarioModifico = ((Usuario)Session["UserData"]).Id;
                        _servicioCatalogo.ActualizarCatalogo(cat, true, ((List <CatalogoGenerico>)Session["registrosCatalogos"]));
                    }
                }
                LimpiarCampos();
                if (OnAceptarModal != null)
                {
                    OnAceptarModal();
                }
            }
            catch (Exception ex)
            {
                if (_lstError == null)
                {
                    _lstError = new List <string>();
                }
                _lstError.Add(ex.Message);
                Alerta = _lstError;
            }
        }