Esempio n. 1
0
        public SingleBono(Bono reg)
        {
            InitializeComponent();
            bono = reg;
            this.DataContext = bono;

            btnActualizar.Visibility = Visibility.Visible;
            btnGuardar.Visibility = Visibility.Collapsed;
        }
Esempio n. 2
0
        public string Create(Bono obj)
        {

            CreateDAC objDAC = new CreateDAC();
            if (objDAC.CreateRecord(obj) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }
Esempio n. 3
0
        public bool UpdateRecord(Bono obj, int idBono)
        {
            SqlConnection con = new SqlConnection(Info.sqlSet());
            SqlCommand cmd = new SqlCommand("SP_Bono_Update", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@IdBono", idBono);
            cmd.Parameters.AddWithValue("@Descripcion", obj.Descripcion);
            cmd.Parameters.AddWithValue("@Clave", obj.Clave);
            cmd.Parameters.AddWithValue("@Monto", obj.Monto);
            con.Open();

            if (cmd.ExecuteNonQuery() > 0)
            {
                con.Close();
                return true;
            }
            else
            {
                con.Close();
                return false;
            }
        }
Esempio n. 4
0
        public List<Bono> readBono()
        {
            List<Bono> bonoList = new List<Bono>();

            using (SqlConnection con = new SqlConnection(Info.sqlSet()))
            {
                SqlCommand cmd = new SqlCommand("SP_Bono_SelectAll", con);
                cmd.CommandType = CommandType.StoredProcedure;

                con.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    // Loop through each record.
                    while (reader.Read())
                    {
                        Bono tmp = new Bono();

                        tmp.IdBono = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdBono;
                        tmp.Descripcion = (reader.GetValue(1) != DBNull.Value) ? Convert.ToString(reader.GetValue(1)) : tmp.Descripcion;
                        tmp.Clave = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Clave;
                        tmp.Monto = (reader.GetValue(3) != DBNull.Value) ? Convert.ToSingle(reader.GetValue(3)) : tmp.Monto;

                        bonoList.Add(tmp);
                    }
                }

                con.Close();
            }

            return bonoList;
        }
Esempio n. 5
0
        public Bono readOneBono(int idBono)
        {
            Bono bono = new Bono();

            using (SqlConnection con = new SqlConnection(Info.sqlSet()))
            {
                SqlCommand cmd = new SqlCommand("SP_Bono_SelectRow", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@IdBono", idBono);

                con.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    // Loop through each record.
                    while (reader.Read())
                    {
                        Bono tmp = new Bono();

                        tmp.IdBono = (reader.GetValue(0) != DBNull.Value) ? Convert.ToInt32(reader.GetValue(0)) : tmp.IdBono;
                        tmp.Descripcion = (reader.GetValue(1) != DBNull.Value) ? Convert.ToString(reader.GetValue(1)) : tmp.Descripcion;
                        tmp.Clave = (reader.GetValue(2) != DBNull.Value) ? Convert.ToString(reader.GetValue(2)) : tmp.Clave;
                        tmp.Monto = (reader.GetValue(3) != DBNull.Value) ? Convert.ToSingle(reader.GetValue(3)) : tmp.Monto;

                        bono = tmp;
                    }
                }

                con.Close();
            }

            return bono;
        }
Esempio n. 6
0
        public string Update(Bono obj, int idBono)
        {

            UpdateDAC objDAC = new UpdateDAC();
            if (objDAC.UpdateRecord(obj, idBono) == true)
                return "Registro almacenado con éxito.";
            else
                return "No se pudo almacenar el regitro.";
        }