Beispiel #1
0
        public static bool InsertPlan(PlanesSociales _planes)
        {
            int  idUltimoPlanInsertado = 0;
            bool exito = false;

            connection.Close();
            connection.Open();
            string       proceso = "AltaPlan";
            MySqlCommand cmd     = new MySqlCommand(proceso, connection);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("Nombre_in", _planes.Nombre);
            cmd.Parameters.AddWithValue("FechaDeAlta_in", _planes.FechaDeAlta);
            cmd.Parameters.AddWithValue("idUsuario_in", _planes.idUsuario);
            cmd.Parameters.AddWithValue("Estado_in", _planes.Estado);
            MySqlDataReader r = cmd.ExecuteReader();

            while (r.Read())
            {
                idUltimoPlanInsertado = Convert.ToInt32(r["ID"].ToString());
            }
            if (idUltimoPlanInsertado > 0)
            {
                exito = InsertHistorialValorPlan(_planes, idUltimoPlanInsertado);
            }
            exito = true;
            connection.Close();
            return(exito);
        }
Beispiel #2
0
        public static List <PlanesSociales> ConsultarPlan(PlanesSociales _listaPlanes)
        {
            connection.Close();
            connection.Open();
            List <PlanesSociales> listaPlanes = new List <PlanesSociales>();
            MySqlCommand          cmd         = new MySqlCommand();

            cmd.Connection = connection;
            DataTable Tabla = new DataTable();

            MySqlParameter[] oParam  = { new MySqlParameter("Estado_in", _listaPlanes.Estado) };
            string           proceso = "ConsultarPlanes";
            MySqlDataAdapter dt      = new MySqlDataAdapter(proceso, connection);

            dt.SelectCommand.CommandType = CommandType.StoredProcedure;
            dt.SelectCommand.Parameters.AddRange(oParam);
            dt.Fill(Tabla);
            if (Tabla.Rows.Count > 0)
            {
                foreach (DataRow item in Tabla.Rows)
                {
                    Entidades.PlanesSociales listaPlanes2 = new Entidades.PlanesSociales();
                    listaPlanes2.idPlan      = Convert.ToInt32(item["idPlan"].ToString());
                    listaPlanes2.Nombre      = item["Nombre"].ToString();
                    listaPlanes2.FechaDeAlta = Convert.ToDateTime(item["FechaAlta"].ToString());
                    listaPlanes2.Valor       = Convert.ToDecimal(item["Valor"].ToString());
                    listaPlanes.Add(listaPlanes2);
                }
            }
            connection.Close();
            return(listaPlanes);
        }
        public static bool GurdarPlan(PlanesSociales _planes)
        {
            bool exito = false;

            try
            {
                ValidarDatosPlanes(_planes);
                bool PlanExistente = ValidarPlanExistente(_planes);
                if (PlanExistente == true)
                {
                    const string message = "Ya existe un plan registrado con el nokbre ingresado.";
                    const string caption = "Error";
                    var          result  = MessageBox.Show(message, caption,
                                                           MessageBoxButtons.OK,
                                                           MessageBoxIcon.Exclamation);
                    throw new Exception();
                }
                else
                {
                    exito = PlanesDao.InsertPlan(_planes);
                }
            }
            catch (Exception ex)
            {
            }
            return(exito);
        }
 private static void ValidarDatosPlanes(PlanesSociales _planes)
 {
     if (String.IsNullOrEmpty(_planes.Nombre))
     {
         const string message = "El campo dni es obligatorio.";
         const string caption = "Error";
         var          result  = MessageBox.Show(message, caption,
                                                MessageBoxButtons.OK,
                                                MessageBoxIcon.Exclamation);
         throw new Exception();
     }
 }
        public static List <PlanesSociales> ConsultarPlan(PlanesSociales _planes)
        {
            List <PlanesSociales> _listaPlanes = new List <PlanesSociales>();

            try
            {
                _listaPlanes = PlanesDao.ConsultarPlan(_planes);
            }
            catch (Exception ex)
            {
            }
            return(_listaPlanes);
        }
        public static bool EliminarPlan(PlanesSociales _planes)
        {
            bool exito = false;

            try
            {
                exito = PlanesDao.BajaPlan(_planes);
            }
            catch (Exception ex)
            {
            }
            return(exito);
        }
        public static bool GuardarNuevoValor(PlanesSociales _planes)
        {
            bool exito = false;

            try
            {
                exito = PlanesDao.InsertNuevoValor(_planes);
            }
            catch (Exception ex)
            {
            }
            return(exito);
        }
Beispiel #8
0
        public static bool BajaPlan(PlanesSociales _planes)
        {
            bool exito = false;

            connection.Close();
            connection.Open();
            string       Actualizar = "BajaPlan";
            MySqlCommand cmd        = new MySqlCommand(Actualizar, connection);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("Estado_in", _planes.Estado);
            cmd.Parameters.AddWithValue("idPlan_in", _planes.idPlan);
            cmd.ExecuteNonQuery();
            exito = true;
            connection.Close();
            return(exito);
        }
Beispiel #9
0
        private void btnBajarPlan_Click(object sender, EventArgs e)
        {
            PlanesSociales _planes = new PlanesSociales();

            _planes.idPlan    = 1;
            _planes.idUsuario = 1;
            _planes.Estado    = "No_Vigente";
            bool Exito = PlanesSocietariosNeg.EliminarPlan(_planes);

            if (Exito == true)
            {
                const string message2 = "El plan se dio de baja exitosamente.";
                const string caption2 = "Éxito";
                var          result2  = MessageBox.Show(message2, caption2,
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Asterisk);
            }
        }
Beispiel #10
0
        public static bool InsertHistorialValorPlan(PlanesSociales _planes, int idUltimoPlanInsertado)
        {
            bool exito = false;

            connection.Close();
            connection.Open();
            string       proceso = "AltaHistorialValorPlan";
            MySqlCommand cmd     = new MySqlCommand(proceso, connection);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("Valor_in", _planes.Valor);
            cmd.Parameters.AddWithValue("FechaDeAlta_in", _planes.FechaDeAlta);
            cmd.Parameters.AddWithValue("idUsuario_in", _planes.idUsuario);
            cmd.Parameters.AddWithValue("idPlan_in", idUltimoPlanInsertado);
            cmd.ExecuteNonQuery();
            exito = true;
            connection.Close();
            return(exito);
        }
Beispiel #11
0
        private void btnNuevoValor_Click(object sender, EventArgs e)
        {
            PlanesSociales _planes = new PlanesSociales();

            _planes.idPlan      = 1;
            _planes.FechaDeAlta = DateTime.Now;
            _planes.idUsuario   = 1;
            _planes.Valor       = Convert.ToDecimal("300,00");
            bool Exito = PlanesSocietariosNeg.GuardarNuevoValor(_planes);

            if (Exito == true)
            {
                const string message2 = "Se registro el nuevo valor para el plan exitosamente.";
                const string caption2 = "Éxito";
                var          result2  = MessageBox.Show(message2, caption2,
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Asterisk);
            }
        }
Beispiel #12
0
        private void btnConsultarPlan_Click(object sender, EventArgs e)
        {
            PlanesSociales _planes = new PlanesSociales();

            _planes.Estado = "Vigente";
            List <PlanesSociales> Lista = PlanesSocietariosNeg.ConsultarPlan(_planes);

            if (Lista.Count > 0)
            {
                const string message2 = "Exito.";
                const string caption2 = "Éxito";
                var          result2  = MessageBox.Show(message2, caption2,
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Asterisk);
            }
            if (Lista.Count == 0)
            {
                const string message2 = "Exito sin dato.";
                const string caption2 = "Éxito";
                var          result2  = MessageBox.Show(message2, caption2,
                                                        MessageBoxButtons.OK,
                                                        MessageBoxIcon.Asterisk);
            }
        }
        private static bool ValidarPlanExistente(PlanesSociales _planes)
        {
            bool existe = PlanesDao.ValidarPlanExistente(_planes.Nombre);

            return(existe);
        }