예제 #1
0
        public static eDocumento GetItem(int IdDocumento)
        {
            SqlCommand cmd = new SqlCommand("pAdm_Documento_select");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@IdDocumento", SqlDbType.Int).Value = IdDocumento;

            SqlDataReader reader     = ExecuteReader(cmd);
            eDocumento    oDocumento = null;

            if (reader.Read())
            {
                oDocumento                   = new eDocumento();
                oDocumento.IdDocumento       = reader.GetInt32(0);
                oDocumento.Descripcion       = reader.GetString(1);
                oDocumento.Documento         = reader.GetString(2);
                oDocumento.Version           = reader.GetString(3);
                oDocumento.IdEstado          = reader.GetByte(4);
                oDocumento.FechaPublicacion  = reader.GetDateTime(5);
                oDocumento.DescripcionEstado = EstadoDescripcion(oDocumento.IdEstado);
            }
            reader.Close();

            return(oDocumento);
        }
예제 #2
0
        public static List <eDocumento> GetList()
        {
            SqlCommand cmd = new SqlCommand("pAdm_Documento_list");

            cmd.CommandType = CommandType.StoredProcedure;

            SqlDataReader     reader = ExecuteReader(cmd);
            List <eDocumento> lista  = new List <eDocumento>();

            while (reader.Read())
            {
                eDocumento oDocumento = new eDocumento();
                oDocumento.IdDocumento       = reader.GetInt32(0);
                oDocumento.Descripcion       = reader.GetString(1);
                oDocumento.Documento         = reader.GetString(2);
                oDocumento.Version           = reader.GetString(3);
                oDocumento.IdEstado          = reader.GetByte(4);
                oDocumento.FechaPublicacion  = reader.GetDateTime(5);
                oDocumento.DescripcionEstado = EstadoDescripcion(oDocumento.IdEstado);

                lista.Add(oDocumento);
            }
            reader.Close();

            return(lista);
        }
        public bool Documento_edit(eDocumento oDocumento)
        {
            bool isEdit = false;

            IdException = cDocumento.Update(oDocumento);
            if (IdException == 0)
            {
                isEdit = true;
            }
            return(isEdit);
        }
        public int Documento_add(eDocumento oDocumento)
        {
            int addNew = 0;

            IdException = cDocumento.Insert(oDocumento);
            if (IdException == 0)
            {
                addNew = cDocumento.getLastID;
            }
            return(addNew);
        }
예제 #5
0
        private void FillDetalle(int DocumentoID)
        {
            ClearFormDetalle();
            eDocumento _oDocumento = cAdministrador.Documento_item(DocumentoID);

            if (_oDocumento != null)
            {
                txtDescripcion.Text     = _oDocumento.Descripcion;
                txtDocumento.Text       = _oDocumento.Documento;
                txtVersion.Text         = _oDocumento.Version;
                drpEstado.SelectedValue = _oDocumento.IdEstado.ToString();
            }
        }
예제 #6
0
        public static int Insert(eDocumento oDocumento)
        {
            SqlCommand cmd = new SqlCommand("pAdm_Documento_insert");

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@Descripcion", SqlDbType.VarChar, 255).Value  = oDocumento.Descripcion;
            cmd.Parameters.Add("@Documento", SqlDbType.VarChar, 255).Value    = oDocumento.Documento;
            cmd.Parameters.Add("@Version", SqlDbType.VarChar, 20).Value       = oDocumento.Version;
            cmd.Parameters.Add("@IdEstado", SqlDbType.TinyInt).Value          = oDocumento.IdEstado;
            cmd.Parameters.Add("@FechaPublicacion", SqlDbType.DateTime).Value = oDocumento.FechaPublicacion;

            return(InsertCommand(cmd, true));
        }
        public int Update(eDocumento oDocumento)
        {
            SqlCommand cmd = new SqlCommand("pAdm_Documento_update");

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@IdDocumento", SqlDbType.BigInt).Value        = oDocumento.IdDocumento;
            cmd.Parameters.Add("@Descripcion", SqlDbType.VarChar, 255).Value  = oDocumento.Descripcion;
            cmd.Parameters.Add("@Documento", SqlDbType.VarChar, 255).Value    = oDocumento.Documento;
            cmd.Parameters.Add("@Version", SqlDbType.VarChar, 20).Value       = oDocumento.Version;
            cmd.Parameters.Add("@IdEstado", SqlDbType.TinyInt).Value          = oDocumento.IdEstado;
            cmd.Parameters.Add("@FechaPublicacion", SqlDbType.DateTime).Value = oDocumento.FechaPublicacion;

            return(UpdateCommand(cmd));
        }
예제 #8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!validateUserAction(IdModulo, CMD_Administrar))
            {
                return;
            }

            eDocumento _oDocumento = new eDocumento();
            bool       success     = false;


            _oDocumento.Descripcion      = this.txtDescripcion.Text;
            _oDocumento.Documento        = this.txtDocumento.Text;
            _oDocumento.Version          = this.txtVersion.Text;
            _oDocumento.IdEstado         = Convert.ToByte(this.drpEstado.SelectedValue);
            _oDocumento.FechaPublicacion = DateTime.Now;

            if (grvListado.SelectedIndex >= 0)
            {
                _oDocumento.IdDocumento = Convert.ToInt32(grvListado.SelectedDataKey.Value);
                success = cAdministrador.Documento_edit(_oDocumento);
                RegistrarLog(IdModulo, CMD_Administrar, "Se ha actualizado el Documento: " + _oDocumento.IdDocumento.ToString());
            }
            else
            {
                _oDocumento.IdDocumento = cAdministrador.Documento_add(_oDocumento);
                success = (_oDocumento.IdDocumento > 0);
                RegistrarLog(IdModulo, CMD_Administrar, "Se ha insertado un Nuevo Documento: " + _oDocumento.IdDocumento.ToString());
            }

            if (success)
            {
                modDetalle.Hide();
                BindListado();
            }
            else
            {
                lblFormError.Text = cAdministrador.getErrorMessage();
            }
        }