コード例 #1
0
    private void Guardar()
    {
        tools _tools = new tools();

        Byte[]  archivo               = null;
        Int32   archivo_tamaño        = 0;
        decimal id_clausula           = 0;
        String  archivo_extension     = null;
        String  archivo_tipo          = null;
        bool    aplicarTodosLosCargos = false;
        decimal id_ocupacion          = 0;

        try
        {
            if (FileUpload_archivo.HasFile == true)
            {
                using (BinaryReader reader = new BinaryReader(FileUpload_archivo.PostedFile.InputStream))
                {
                    archivo           = reader.ReadBytes(FileUpload_archivo.PostedFile.ContentLength);
                    archivo_tamaño    = FileUpload_archivo.PostedFile.ContentLength;
                    archivo_tipo      = FileUpload_archivo.PostedFile.ContentType;
                    archivo_extension = _tools.obtenerExtensionArchivo(FileUpload_archivo.PostedFile.FileName);
                }

                if (DropDownList_ID_OCUPACION.Text.Equals(string.Empty))
                {
                    id_ocupacion = 0;
                }
                else if (DropDownList_ID_OCUPACION.Text.Equals("0"))
                {
                    aplicarTodosLosCargos = true;
                }
                else
                {
                    id_ocupacion = Convert.ToDecimal(DropDownList_ID_OCUPACION.SelectedValue);
                }

                Clausula clausula = new Clausula(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString());
                id_clausula = clausula.Adicionar(DropDownList_ID_TIPO_CLAUSULA.SelectedValue, DropDownList_ID_ESTADO.SelectedValue, TextBox_DESCRIPCION.Text,
                                                 Convert.ToDecimal(HiddenField_ID_EMPRESA.Value), id_ocupacion, archivo, archivo_tamaño, archivo_extension, archivo_tipo, aplicarTodosLosCargos);

                if (id_clausula > 0)
                {
                    Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "La Clausula fue registrada correctamente.", Proceso.Correcto);
                    this.HiddenField_id_clausula.Value = id_clausula.ToString();
                    Bloquear();
                    Ocultar();
                    Mostrar(Acciones.Editar);
                    DataRow dataRow = clausula.ObtenerPorId(id_clausula);
                    Cargar(dataRow);
                }
                else
                {
                    Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, "Error al registrar la Clausula", Proceso.Error);
                }
            }
        }
        catch (Exception e)
        {
            Informar(Panel_FONDO_MENSAJE, Image_MENSAJE_POPUP, Panel_MENSAJES, Label_MENSAJE, e.Message, Proceso.Error);
        }
    }