예제 #1
0
        public ObservableCollection <TotalAccionesDensocial> GetSociedadesDosSocios()
        {
            ObservableCollection <TotalAccionesDensocial> sociedades = new ObservableCollection <TotalAccionesDensocial>();

            string sqlCadena = "select count(dsdensocial),crfme,dsdensocial from sociosacciones where (acciones is not null and total is not null) and (acciones <> '' and total <> '')  group by crfme,dsdensocial having count(dsdensocial) = 2 ";

            SqlConnection connection = new SqlConnection(connectionString);
            SqlCommand    cmd        = null;
            SqlDataReader reader     = null;

            int queRegistro = 0;

            try
            {
                connection.Open();

                cmd    = new SqlCommand(sqlCadena, connection);
                reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        TotalAccionesDensocial sociedad = new TotalAccionesDensocial();
                        sociedad.Folio     = reader["CRFME"].ToString();
                        sociedad.DenSocial = reader["DSDENSOCIAL"].ToString();

                        sociedades.Add(sociedad);
                    }
                }
                cmd.Dispose();
                reader.Close();
            }
            catch (SqlException ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                ErrorUtilities.SetNewErrorMessage(ex, methodName + queRegistro + " Exception,totalAccionesDenSocialModel", "DGNMTools");
            }
            catch (Exception ex)
            {
                string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                ErrorUtilities.SetNewErrorMessage(ex, methodName + queRegistro + " Exception,totalAccionesDenSocialModel", "DGNMTools");
            }
            finally
            {
                connection.Close();
            }

            this.GetSocios(sociedades);

            foreach (TotalAccionesDensocial sociedad in sociedades)
            {
                this.SetSocForAnalisis(sociedad);
            }

            return(sociedades);
        }
예제 #2
0
        public bool SetSocForAnalisisNLCD(TotalAccionesDensocial sociedad)
        {
            SqlConnection connection = new SqlConnection(connectionString);

            bool insertCompleted = false;

            try
            {
                connection.Open();

                string sqlQuery = "INSERT INTO AnalisisPorcentajesNLCD(Crfme,dsdensocial,totalacciones,totalvalor,porcentajeacciones,porcentajevalor)" +
                                  "VALUES (@Crfme,@dsdensocial,@totalacciones,@totalvalor,@porcentajeacciones,@porcentajevalor)";

                SqlCommand cmd = new SqlCommand(sqlQuery, connection);
                cmd.Parameters.AddWithValue("@Crfme", sociedad.Folio);
                cmd.Parameters.AddWithValue("@dsdensocial", sociedad.DenSocial);
                cmd.Parameters.AddWithValue("@totalacciones", sociedad.TotalAcciones);
                cmd.Parameters.AddWithValue("@totalvalor", sociedad.TotalValor);
                cmd.Parameters.AddWithValue("@porcentajeacciones", sociedad.PorcentajeAcciones);
                cmd.Parameters.AddWithValue("@porcentajevalor", sociedad.Porcentajevalor);
                cmd.ExecuteNonQuery();

                cmd.Dispose();
                insertCompleted = true;
            }
            catch (SqlException ex)
            {
                Console.WriteLine("Error");
                //string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                //ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,ObraModel", "PadronApi");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error");
                //string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                //ErrorUtilities.SetNewErrorMessage(ex, methodName + " Exception,ObraModel", "PadronApi");
            }
            finally
            {
                connection.Close();
            }

            return(insertCompleted);
        }