public static string AskCloseBox()
        {
            // Table to store the query results
            DataTable table = new DataTable();

            // Class to store the table
            BoxTable boxTable;

            // Creates a SQL connection
            string strConnString = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            using (var connection = new SqlConnection(strConnString))
            {
                connection.Open();

                // Creates a SQL command
                using (var command = new SqlCommand("SELECT * FROM View_AskBox", connection))
                {
                    // Loads the query results into the table
                    table.Load(command.ExecuteReader());
                }

                boxTable = new BoxTable(table);
                connection.Close();
            }

            string json = JsonConvert.SerializeObject(boxTable);

            return(json);
        }
Esempio n. 2
0
        public static string GetBox(string date)
        {
            // Table to store the query results
            DataTable table    = new DataTable();
            DateTime  dateTime = Convert.ToDateTime(date);

            // Class to store the table
            BoxTable boxTable;

            // Creates a SQL connection
            string strConnString = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;

            using (var connection = new SqlConnection(strConnString))
            {
                connection.Open();

                // Creates a SQL command
                using (var command = new SqlCommand("SELECT * FROM View_FullBox WHERE fecha_cierre_caja = @CloseBoxDate", connection))
                {
                    // Loads the query results into the table
                    command.Parameters.AddWithValue("@CloseBoxDate", dateTime);
                    table.Load(command.ExecuteReader());
                }

                boxTable = new BoxTable(table);
                connection.Close();
            }

            string json = JsonConvert.SerializeObject(boxTable);

            return(json);
        }