Esempio n. 1
0
        public void TestGetWeightTicketReport()
        {
            WeightTicketsBL weightTicketBL       = new WeightTicketsBL(connectionString);
            WeightTicketReportFilterModel filter = new WeightTicketReportFilterModel();

            filter.CicleId          = 1;
            filter.WeightTicketType = 1;
            ReportData data = weightTicketBL.GetWeightTicketsReport(filter);
        }
Esempio n. 2
0
 public WeightTicketsReport()
 {
     InitializeComponent();
     presenter                    = new WeightTicketReportPresenter(this);
     CurrentFilters               = new WeightTicketReportFilterModel();
     CurrentFilters.EndDateTime   = DateTime.Now;
     CurrentFilters.StartDateTime = DateTime.Now;
     GridFilters.DataContext      = CurrentFilters;
     InitializeColumnsDictionary();
 }
Esempio n. 3
0
        public IHttpActionResult  GetWeightTicketsReport([FromUri] WeightTicketReportFilterModel filters)
        {
            GetReportDataResponse response = new GetReportDataResponse();

            try
            {
                response.ReportData = weightTicketsBL.GetWeightTicketsReport(filters);
                response.Success    = true;
            }
            catch (Exception ex)
            {
                response.ErrorMessage = "Error. " + ex.Message;
                response.Success      = false;
            }
            return(Ok(response));
        }
Esempio n. 4
0
        public ReportData GetWeightTicketsReport(WeightTicketReportFilterModel filters)
        {
            ReportData reportData = new ReportData();
            DataTable  data       = weightTicketsDL.GetWeightTicketsReport(filters);

            foreach (DataColumn column in data.Columns)
            {
                ReportDataColumn reportColumn = new ReportDataColumn();
                reportColumn.Type = column.DataType;
                reportColumn.Name = column.ColumnName;
                reportData.Columns.Add(reportColumn);
            }
            foreach (DataRow row in data.Rows)
            {
                ReportDataRow reportRow = new ReportDataRow();
                reportRow.Items = new List <object>(row.ItemArray);
                reportData.Rows.Add(reportRow);
            }
            return(reportData);
        }
Esempio n. 5
0
        public void TestGetWeightTicketReport()
        {
            //Test this one in prod
            baseUrl = @"http://lasmargaritas.azurewebsites.net/";
            Token      token  = TokenHelper.GetToken(baseUrl, "Melvin3", "MelvinPass3");
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(baseUrl);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.access_token);
            WeightTicketReportFilterModel filter = new WeightTicketReportFilterModel();

            filter.CicleId          = 1;
            filter.WeightTicketType = (int)WeightTicketType.Producer;
            HttpResponseMessage response = client.GetAsync(string.Format("{0}?{1}", getReportAction, filter.GetUrlQuery())).Result;

            response.EnsureSuccessStatusCode();
            GetReportDataResponse getReportDataResponse = response.Content.ReadAsAsync <GetReportDataResponse>().Result;

            Assert.IsTrue(getReportDataResponse.Success);
            Assert.IsTrue(getReportDataResponse.ReportData != null);
            // Assert.IsTrue(getReportDataResponse.ReportData.Count > 0);
        }
Esempio n. 6
0
        public DataTable GetWeightTicketsReport(WeightTicketReportFilterModel filters)
        {
            DataTable dataTable = new DataTable();

            using (SqlCommand command = new SqlCommand())
            {
                using (SqlConnection connection = new SqlConnection())
                {
                    connection.ConnectionString = ConnectionString;
                    command.Connection          = connection;
                    command.CommandText         = "spGetWeightTicketReport";
                    foreach (PropertyInfo prop in (from x in filters.GetType().GetProperties() select x).ToArray())
                    {
                        if (prop.PropertyType == typeof(DateTime))
                        {
                            command.Parameters.AddWithValue("@" + prop.Name, ((DateTime)prop.GetValue(filters)).ToUniversalTime());
                        }
                        else if (prop.PropertyType == typeof(DateTime?) && ((DateTime?)prop.GetValue(filters)).HasValue)
                        {
                            command.Parameters.AddWithValue("@" + prop.Name, ((DateTime)prop.GetValue(filters)).ToUniversalTime());
                        }
                        else
                        {
                            command.Parameters.AddWithValue("@" + prop.Name, prop.GetValue(filters));
                        }
                    }
                    command.CommandType = CommandType.StoredProcedure;
                    connection.Open();
                    using (SqlDataAdapter adapter = new SqlDataAdapter())
                    {
                        adapter.SelectCommand = command;
                        adapter.Fill(dataTable);
                    }
                }
                return(dataTable);
            }
        }