Exemplo n.º 1
0
     // Type report between specific dates using store procedure//
        public virtual List<TypeReports> GetReportByTypeName(DateTime fromDate, DateTime toDate)
        {

            SqlConnection connection = new SqlConnection(Connection);
            string query = "sp_GetReportByType";

            connection.Open();

            SqlCommand command = new SqlCommand(query, connection);
            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@FromDate", fromDate);
            command.Parameters.AddWithValue("@ToDate", toDate);
            SqlDataReader reader = command.ExecuteReader();
            List<TypeReports> TestReportList = new List<TypeReports>();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    string typeName = reader["typeName"].ToString();
                    int totalTest = (int)reader["totalTest"];
                    decimal totalAmount = (decimal)reader["totalAmount"];

                    TypeReports TestReport = new TypeReports(typeName, totalTest, totalAmount);
                    TestReportList.Add(TestReport);
                }
                reader.Close();

            }

            connection.Close();
            return TestReportList;

        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("IdType,Type")] TypeReports typeReports)
        {
            if (id != typeReports.IdType)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(typeReports);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeReportsExists(typeReports.IdType))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeReports));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("IdType,Type")] TypeReports typeReports)
        {
            if (ModelState.IsValid)
            {
                _context.Add(typeReports);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeReports));
        }
 private static void SeedRepportType(DataContext dataContext)
 {
     if (dataContext.TypeReports.Where(r => r.Type == "PFE").FirstOrDefault() == null)
     {
         TypeReports typeReports = new TypeReports();
         typeReports.Type = "PFE";
         dataContext.TypeReports.Add(typeReports);
         dataContext.SaveChanges();
     }
     if (dataContext.TypeReports.Where(r => r.Type == "STAGE").FirstOrDefault() == null)
     {
         TypeReports typeReports = new TypeReports();
         typeReports.Type = "STAGE";
         dataContext.TypeReports.Add(typeReports);
         dataContext.SaveChanges();
     }
     if (dataContext.TypeReports.Where(r => r.Type == "PFA").FirstOrDefault() == null)
     {
         TypeReports typeReports = new TypeReports();
         typeReports.Type = "PFA";
         dataContext.TypeReports.Add(typeReports);
         dataContext.SaveChanges();
     }
 }