示例#1
0
        public static ObservableListSource <ConfigVal> FetchList(int n_idemp)
        {
            ObservableListSource <ConfigVal> m_listentidad = new ObservableListSource <ConfigVal>();

            using (MySqlConnection connection
                       = new MySqlConnection(
                             ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.CommandText = "con_configval_listar";
                    command.Parameters.Add(new MySqlParameter("@n_idemp", n_idemp));
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ConfigVal m_entidad = SetObject(reader);
                            m_entidad.IsNew = false;
                            m_listentidad.Add(m_entidad);
                        }
                    }
                }
            }
            return(m_listentidad);
        }
示例#2
0
        public static ConfigVal Fetch(int id)
        {
            ConfigVal m_entidad = new ConfigVal();

            using (MySqlConnection connection
                       = new MySqlConnection(
                             ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.CommandText = "con_configval_traerregistro";
                    command.Parameters.Add(new MySqlParameter("@n_id", id));
                    connection.Open();
                    using (MySqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            m_entidad       = SetObject(reader);
                            m_entidad.IsNew = false;
                        }
                    }
                }
            }
            return(m_entidad);
        }
示例#3
0
        public static ObservableListSource <CostoProduccionCue> TraerListaPorConfiguracion(int n_idemp
                                                                                           , int n_anotra
                                                                                           , int n_mesini
                                                                                           , int n_mesfin
                                                                                           , int n_idconfigval)
        {
            // Se trae la lista de cuenta de la configuracion
            ConfigVal configVal = ConfigVal.Fetch(n_idconfigval);

            //Se trae el listado de cuentas del periodo
            DataTable DtResul = new DataTable();

            using (MySqlConnection connection
                       = new MySqlConnection(
                             ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                using (MySqlCommand command = new MySqlCommand())
                {
                    command.Connection  = connection;
                    command.CommandType = System.Data.CommandType.StoredProcedure;
                    command.CommandText = "con_diario_balancecomprobacion_v2";
                    command.Parameters.Add(new MySqlParameter("@n_idemp", n_idemp));
                    command.Parameters.Add(new MySqlParameter("@n_anotra", n_anotra));
                    command.Parameters.Add(new MySqlParameter("@n_mesini", n_mesini));
                    command.Parameters.Add(new MySqlParameter("@n_mesfin", n_mesfin));
                    command.Parameters.Add(new MySqlParameter("@n_idlib", 0));
                    connection.Open();

                    MySqlDataAdapter adp = new MySqlDataAdapter(command);
                    adp.Fill(DtResul);
                }
            }

            //Se agregan registros
            ObservableListSource <CostoProduccionCue> m_listentidad = new ObservableListSource <CostoProduccionCue>();

            foreach (var configValCue in configVal.ConfigValCues)
            {
                //Se busca el registro en la tabla
                DataRow row = DtResul.AsEnumerable()
                              .SingleOrDefault(r => r.Field <int>("n_idcue") == configValCue.n_idcue);

                if (row != null)
                {
                    CostoProduccionCue m_entidad = new CostoProduccionCue();
                    m_entidad.n_idcue = Convert.ToInt32(row["n_idcue"]);
                    //m_entidad.n_impt = Convert.ToDouble(row["n_movperhab"]);
                    m_entidad.n_impt   = Convert.ToDouble(row["n_movperdeb"]) / 7; //Se pone en duro debido a lo solicitado por Agrovado
                    m_entidad.c_descue = configValCue.c_descue;

                    m_listentidad.Add(m_entidad);
                }
            }
            return(m_listentidad);
        }