コード例 #1
0
ファイル: Familia.cs プロジェクト: nahuel19/SistemaGestionPP
        /// <summary>
        /// selecciona una familia
        /// </summary>
        /// <param name="IdFamiliaElement">string</param>
        /// <returns>data set</returns>
        public static DataSet Select(System.String IdFamiliaElement)
        {
            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand("Familia_Select @IdFamiliaElement", conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@IdFamiliaElement", IdFamiliaElement);

                        conn.Open();

                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        DataSet        ds = new DataSet();
                        da.Fill(ds);
                        da.Dispose();

                        return(ds);
                    }
                }

                //Database myDatabase = DatabaseFactory.CreateDatabase();
                //DbCommand myCommand = myDatabase.GetStoredProcCommand("Familia_Select");
                //myDatabase.AddInParameter(myCommand, "@IdFamilia", DbType.String, IdFamiliaElement);

                //return myDatabase.ExecuteDataSet(myCommand);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
ファイル: Familia.cs プロジェクト: nahuel19/SistemaGestionPP
        /// <summary>
        /// elimina una familia
        /// </summary>
        /// <param name="_object">familia</param>
        public static void Delete(Entities.UFP.Familia _object)
        {
            if (_object.Accesos != null)
            {
                DeleteAccesos(_object);
            }

            using (SqlConnection conn = ConnectionBD.Instance().Conect())
            {
                using (SqlCommand cmd = new SqlCommand("Familia_Delete @IdFamiliaElement", conn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@IdFamiliaElement", _object.IdFamiliaElement);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
            }

            //Database myDatabase = DatabaseFactory.CreateDatabase();
            //DbCommand myCommand = myDatabase.GetStoredProcCommand("Familia_Delete");
            //myDatabase.AddInParameter(myCommand, "@IdFamilia", DbType.String, _object.IdFamiliaElement);

            //myDatabase.ExecuteNonQuery(myCommand);
        }
コード例 #3
0
ファイル: Familia.cs プロジェクト: nahuel19/SistemaGestionPP
        /// <summary>
        /// selecciona las faimilias
        /// </summary>
        /// <returns>data set</returns>
        public static DataSet SelectAll()
        {
            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand("Familia_SelectAll", conn))
                    {
                        cmd.CommandType = CommandType.Text;

                        conn.Open();

                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        DataSet        ds = new DataSet();
                        da.Fill(ds);
                        da.Dispose();

                        return(ds);
                    }
                }
                //Database myDatabase = DatabaseFactory.CreateDatabase();
                //DbCommand myCommand = myDatabase.GetStoredProcCommand("Familia_SelectAll");
                //return myDatabase.ExecuteDataSet(myCommand);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
ファイル: Familia.cs プロジェクト: nahuel19/SistemaGestionPP
        /// <summary>
        /// selecciona los accesos de una familia
        /// </summary>
        /// <param name="IdFamiliaElement">strin</param>
        /// <returns>datatable</returns>
        public static DataTable GetAccesos(System.String IdFamiliaElement)
        {
            using (SqlConnection conn = ConnectionBD.Instance().Conect())
            {
                using (SqlCommand cmd = new SqlCommand("Familia_Familia_SelectParticular @IdFamilia", conn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@IdFamilia", IdFamiliaElement);

                    conn.Open();

                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    da.Dispose();

                    return(dt);
                }
            }
            //Database myDatabase = DatabaseFactory.CreateDatabase();
            //DbCommand myCommand = myDatabase.GetStoredProcCommand("Familia_Familia_SelectParticular");
            //myDatabase.AddInParameter(myCommand, "@IdFamilia", DbType.String, IdFamiliaElement);

            //return myDatabase.ExecuteDataSet(myCommand).Tables[0];
        }
コード例 #5
0
ファイル: Usuario.cs プロジェクト: nahuel19/SistemaGestionPP
        /// <summary>
        /// elimina las patentes de un usuario
        /// </summary>
        /// <param name="_object"></param>
        public static void DeletePatentes(Entities.UFP.Usuario _object)
        {
            using (SqlConnection conn = ConnectionBD.Instance().Conect())
            {
                using (SqlCommand cmd = new SqlCommand("Usuario_Patente_DeleteParticular @IdUsuario", conn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@IdUsuario", _object.IdUsuario);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
            }
            //Database myDatabase = DatabaseFactory.CreateDatabase();
            //DbCommand myCommand = myDatabase.GetStoredProcCommand("Usuario_Patente_DeleteParticular");
            //myDatabase.AddInParameter(myCommand, "@IdUsuario", DbType.String, _object.IdUsuario);

            //myDatabase.ExecuteNonQuery(myCommand);
        }
コード例 #6
0
        /// <summary>
        /// inserta una patente
        /// </summary>
        /// <param name="_object">patente</param>
        public static void Insert(Entities.UFP.Patente _object)
        {
            using (SqlConnection conn = ConnectionBD.Instance().Conect())
            {
                using (SqlCommand cmd = new SqlCommand("Patente_Insert @IdPatente, @Nombre", conn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@IdPatente", _object.IdFamiliaElement);
                    cmd.Parameters.AddWithValue("@Nombre", _object.Nombre);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
            }
            //Database myDatabase = DatabaseFactory.CreateDatabase();
            //DbCommand myCommand = myDatabase.GetStoredProcCommand("Patente_Insert");
            //myDatabase.AddInParameter(myCommand, "@IdPatente", DbType.String, _object.IdFamiliaElement);
            //myDatabase.AddInParameter(myCommand, "@Nombre", DbType.String, _object.Nombre);
            //myDatabase.ExecuteNonQuery(myCommand);
        }
コード例 #7
0
        /// <summary>
        /// Update de tabla DVV (contiene info de digítos verificadores verticales)
        /// </summary>
        /// <param name="entity"></param>
        public void UpdateDVV(DVV entity)
        {
            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("sp_insert_updateDVV @tabla, @columna, @DV", conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@tabla", entity.tabla);
                        cmd.Parameters.AddWithValue("@columna", entity.columna);
                        cmd.Parameters.AddWithValue("@DV", entity.DV);

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #8
0
ファイル: Usuario.cs プロジェクト: nahuel19/SistemaGestionPP
        //=================================================================
        /// <summary>
        /// valida si un usuario puede loggearse
        /// </summary>
        /// <param name="entity">usuario</param>
        /// <returns>bool, string (idusuario)</returns>
        public static (bool, string) Login(Entities.UFP.Usuario entity)
        {
            string idUser = null;

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    using (SqlCommand cmd = new SqlCommand("sp_login @nombre, @pass", conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@nombre", entity.Nombre);
                        cmd.Parameters.AddWithValue("@pass", entity.Pass);
                        conn.Open();

                        SqlDataReader reader = cmd.ExecuteReader();

                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                idUser = reader.GetString(0);
                            }
                            return(true, idUser);
                        }
                        else
                        {
                            return(false, idUser);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #9
0
        /// <summary>
        /// Update genérico para ejecutar stores de de DVH
        /// </summary>
        /// <param name="entity">IEntityDV</param>
        /// <param name="tabla">string</param>
        public void Update(IEntityDV entity, string tabla)
        {
            string sp = "sp_updateDVH_" + tabla + " @DVH, @id";

            try
            {
                using (SqlConnection conn = ConnectionBD.Instance().Conect())
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand(sp, conn))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Parameters.AddWithValue("@id", entity.id);
                        cmd.Parameters.AddWithValue("@DVH", entity.DVH);

                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #10
0
ファイル: Familia.cs プロジェクト: nahuel19/SistemaGestionPP
        /// <summary>
        /// inserta una familia
        /// </summary>
        /// <param name="_object">familia</param>
        public static void Insert(Entities.UFP.Familia _object)
        {
            using (SqlConnection conn = ConnectionBD.Instance().Conect())
            {
                using (SqlCommand cmd = new SqlCommand("Familia_Insert @IdFamilia, @Nombre", conn))
                {
                    cmd.CommandType = CommandType.Text;
                    cmd.Parameters.AddWithValue("@IdFamilia", _object.IdFamiliaElement);
                    cmd.Parameters.AddWithValue("@Nombre", _object.Nombre);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
            }
            //Database myDatabase = DatabaseFactory.CreateDatabase();
            //DbCommand myCommand = myDatabase.GetStoredProcCommand("Familia_Insert");
            //myDatabase.AddInParameter(myCommand, "@IdFamilia", DbType.String, _object.IdFamiliaElement);
            //myDatabase.AddInParameter(myCommand, "@Nombre", DbType.String, _object.Nombre);
            //myDatabase.ExecuteNonQuery(myCommand);

            if (_object.Accesos != null)
            {
                DeleteAccesos(_object);
                Familia_Patente.DeleteAccesos(_object);
                foreach (Entities.UFP.FamiliaElement _tipo in _object.Accesos)
                {
                    if (_tipo.GetType().Name == "Familia")
                    {
                        using (SqlConnection conn = ConnectionBD.Instance().Conect())
                        {
                            using (SqlCommand cmd = new SqlCommand("Familia_Familia_Insert @IdFamilia, @IdFamiliaHijo", conn))
                            {
                                cmd.CommandType = CommandType.Text;
                                cmd.Parameters.AddWithValue("@IdFamilia", _object.IdFamiliaElement);
                                cmd.Parameters.AddWithValue("@IdFamiliaHijo", _tipo.IdFamiliaElement);

                                conn.Open();
                                cmd.ExecuteNonQuery();
                            }
                        }

                        //DbCommand myCommandAccesos = myDatabase.GetStoredProcCommand("Familia_Familia_Insert");
                        //myDatabase.AddInParameter(myCommandAccesos, "@IdFamilia", DbType.String, _object.IdFamiliaElement);
                        //myDatabase.AddInParameter(myCommandAccesos, "@IdFamiliaHijo", DbType.String, _tipo.IdFamiliaElement);
                        //myDatabase.ExecuteNonQuery(myCommandAccesos);
                    }
                    else
                    {
                        using (SqlConnection conn = ConnectionBD.Instance().Conect())
                        {
                            using (SqlCommand cmd = new SqlCommand("Familia_Patente_Insert @IdFamilia, @IdPatente", conn))
                            {
                                cmd.CommandType = CommandType.Text;
                                cmd.Parameters.AddWithValue("@IdFamilia", _object.IdFamiliaElement);
                                cmd.Parameters.AddWithValue("@IdPatente", _tipo.IdFamiliaElement);

                                conn.Open();
                                cmd.ExecuteNonQuery();
                            }
                        }
                        //DbCommand myCommandAccesos = myDatabase.GetStoredProcCommand("Familia_Patente_Insert");
                        //myDatabase.AddInParameter(myCommandAccesos, "@IdFamilia", DbType.String, _object.IdFamiliaElement);
                        //myDatabase.AddInParameter(myCommandAccesos, "@IdPatente", DbType.String, _tipo.IdFamiliaElement);
                        //myDatabase.ExecuteNonQuery(myCommandAccesos);
                    }
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Client
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            #region Abstract Factory
            Console.WriteLine("Abstract Factory initialize");

            //Step 1
            SqlCommand   cmd = new SqlCommand();
            SqlConection cnn = new SqlConection();
            cmd.Execute();

            //Apply Abstract Factory pattern
            DbFactory db  = new OracleFactory();
            var       con = db.createConnection();
            con.Open();
            var command = db.createCommand();
            command.Execute();

            Console.WriteLine("Abstract Factory finalize" + Environment.NewLine);
            #endregion

            #region Builder
            Console.WriteLine("Builder initialize");

            //Step 1
            var car = new Auto("Car");
            car["gear"]  = "127c";
            car["doors"] = "4";
            car["tires"] = "4";
            car.Show();
            Console.ReadLine();

            var bike = new Auto("bike");
            bike["gear"]  = "50c";
            bike["doors"] = "0";
            bike["tires"] = "2";
            bike.Show();
            Console.ReadLine();

            //Apply Builder pattern
            AutoBuilder builder;
            var         director = new Director();

            builder = new CarBuilder();
            director.Construct(builder);
            builder.Auto.Show();

            builder = new BikeBuilder();
            director.Construct(builder);
            builder.Auto.Show();

            Console.WriteLine("Builder finalize" + Environment.NewLine);
            #endregion

            #region Factory
            Console.WriteLine("Factory Method Initialize");

            //Step 1
            var login = new AuthGoogle();
            login.Authorize();
            Console.ReadLine();

            //Apply Factory
            Creator[] creators = new Creator[2];
            creators[0] = new FacebookCreator();
            creators[1] = new GoogleCreator();

            foreach (Creator c in creators)
            {
                Auth aut = c.CreateInstance(); //Factory Method
                aut.Authorize();
            }
            Console.ReadLine();

            Console.WriteLine("Factory Finalize" + Environment.NewLine);
            #endregion

            #region Prototype
            Console.WriteLine("Prototype initialize");
            Book p1 = new Book(1, "Design Patterns - Book", 20.00);
            Book c1 = (Book)p1.Clone();
            Console.WriteLine(c1.Description);

            DVD p2 = new DVD(2, "Design Patterns - DVD", 25.00);
            DVD c2 = (DVD)p2.Clone();
            Console.WriteLine(c2.Description);
            Console.WriteLine("Prototype Finalize" + Environment.NewLine);
            Console.ReadKey();
            #endregion

            #region Singleton
            Console.WriteLine("Singleton Initialize");
            var con1 = ConnectionBD.Instance();
            con1.stringConexao = "SQLServer";
            con1.Open();
            var con2 = ConnectionBD.Instance();
            con2.stringConexao = "Oracle";
            con2.Open();

            if (con1.Equals(con2))
            {
                Console.WriteLine("Equals Instances");
            }

            Console.WriteLine("Singleton Finalize" + Environment.NewLine);
            Console.ReadKey();
            #endregion
        }