Razor Pages - XML Application: Stellar Water Point
Razor Pages - XML Application: Stellar Water Point
Introduction
ASP.NET is a widely used concept of creating web-based applications. ASP.NET includes many approaches to Web development. ASP.NET Core Razor Pages, or simply Razor Pages, is one of those techniques. This exercise is one of our introduction to web-based applications using Razor Pages in ASP.NET Core using Razor Pages.
In this exercise, we will create a web-based application for a fictional company that provides water as a utility for various communities. This version will use a text-based database where records of an application are saved and managed in XML format.
Practical Learning: Introducing the Application
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Stellar Water Point</title>
<script type="importmap"></script>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/StellarWaterPoint1.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-page="/Index">Stellar Water Point</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-light" asp-area="" asp-page="/WaterBills/Index">Water Bills</a>
</li>
<li class="nav-item">
<a class="nav-link text-light" asp-area="" asp-page="/Customers/Index">Customers</a>
</li>
<li class="nav-item">
<a class="nav-link text-light" asp-area="" asp-page="/WaterMeters/Index">Water Meters</a>
</li>
<li class="nav-item">
<a class="nav-link text-light" asp-area="" asp-page="/AccountsTypes/Index">Accounts Types</a>
</li>
<li class="nav-item">
<a class="nav-link text-light" asp-area="" asp-page="/Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
<p class="common-font text-center">© 2001-@DateTime.Today.Year - Stellar Water Point - <a asp-area="" asp-page="/Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<main class="common-font">
<div class="text-center">
<h1 class="display-4 fw-bold">Stellar Water Point</h1>
<p class="lead text-muted">Stellar Water Point is a community-based company that commercially distributes water to customers in need. Our water process is socially responsible and community oriented.</p>
</div>
<div class="py-5 bg-light">
<div class="container">
<div class="row">
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img class="bordered" src="../Images/WaterBills.png" alt="Water Bills">
<div class="card-body">
<h5><a class="nav-link text-dark fw-bold" href="/WaterBills/Index">Water Bills</a></h5>
<hr />
<p class="card-text">Water bills are processed in a timely and responsible manner, applying only the strictest, regular, and lawful rules.</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img class="bordered card-img-top" src="../Images/Customers.png" alt="Customers Accounts">
<div class="card-body">
<h5><a class="nav-link text-dark fw-bold" href="/Customers/Index">Customers Accounts</a></h5>
<hr />
<p class="card-text">Water bills are sent in a trimester-base to each of our customers who holds an account with us, all for good service.</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4 box-shadow">
<img class="bordered card-img-top" src="../Images/WaterMeter.png" alt="Water Meters">
<div class="card-body">
<h5><a class="nav-link text-dark fw-bold" href="/WaterMeters/Index">Water Meters</a></h5>
<hr />
<p class="card-text">We use industry standard water meters that are regularly government inspected for their accuracy and precision.</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4">
<img class="card-img-top bordered" src="../Images/Community.png" alt="Community Services">
<div class="card-body">
<h5><a class="nav-link text-dark fw-bold" href="/StellarWaterPoint">Community Services</a></h5>
<hr />
<p class="card-text">Stellar Water Point is a community-oriented company that works withn various local activities and authorities.</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4">
<img class="card-img-top bordered" src="../Images/LegalAffairs.png" alt="Legal Affairs">
<div class="card-body">
<h5><a class="nav-link text-dark fw-bold" href="/StellarWaterPoint">Legal Affairs</a></h5>
<hr />
<p class="card-text">Issues of regulations and government affairs are addressed here. This is available for employees, contractors, etc.</p>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card mb-4">
<img class="card-img-top bordered" src="../Images/Employees.png" alt="Employees Portal">
<div class="card-body">
<h5><a class="nav-link text-dark fw-bold" href="/StellarWaterPoint">Employees Portal</a></h5>
<hr />
<p class="card-text">This is a central area form employees to access the company resources such as time sheets, payroll, benefits, etc.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</main>Water Meters
Introduction
In this classic water distribution application, the company uses water meters that installed in people's houses to monitor water consumption. For our application, we will create a section that manages that water consumption.
Practical Learning: Introducing Water Meters
Displaying Water Meters
Our application will allow a user to see a list of water meters that the company uses. In this section, we create a form that can display some (limited) information about the water meters of our application.
Practical Learning: Displaying Water Meters
using System.Xml; using Microsoft.AspNetCore.Mvc.RazorPages; namespace StellarWaterPoint1.Pages.WaterMeters { public class IndexModel : PageModel { public XmlNodeList? WaterMeters { get; set; } = null; public void OnGet() { XmlDocument xdWaterMeters = new XmlDocument(); string strWaterMeters = @"E:\Stellar Water Point4\WaterMeters.xml"; FileInfo fiWaterMeters = new FileInfo(strWaterMeters); if (fiWaterMeters.Exists) { xdWaterMeters.Load(fiWaterMeters.FullName); WaterMeters = xdWaterMeters.GetElementsByTagName("water-meter-id"); } } } }
@page
@using System.Xml
@model StellarWaterPoint1.Pages.WaterMeters.IndexModel
@{
}
<h1 class="common-font fw-bold text-center">Water Meters</h1>
<hr />
<table class="table common-font">
<tr class="fw-bold">
<td class="text-center">Water Meter Id</td>
<td class="text-center">Meter #</td>
<td>Make</td>
<td>Model</td>
<td>Meter Size</td>
</tr>
@if (Model.WaterMeters is not null)
{
@foreach (XmlNode xnWaterMeter in Model.WaterMeters!)
{
<tr>
<td class="text-center">@xnWaterMeter.InnerText</td>
<td class="text-center">@xnWaterMeter.NextSibling!.InnerText</td>
<td>@xnWaterMeter.NextSibling!.NextSibling!.InnerText</td>
<td>@xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText</td>
<td>@xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText</td>
</tr>
}
}
</table>
<p class="text-center">
<a asp-page="./Create" class="stellar">Create Water Meter</a> ::
<a asp-page="./Details" class="stellar">Water Meter Details</a> ::
<a asp-page="./Edit" class="stellar">Edit/Update a Water Meter</a> ::
<a asp-page="./Delete" class="stellar">Delete a Water Meter</a>
</p>
A Water Meter Record
To make sure a customer can benefit from the services of this application, a water meter must be installed to the customer's residence. The application should have a repository of the water meters records. For that residence, we will create a form that allows an employee of the company to create a record for each water meter.
Practical Learning: Creating a Water Meter Record

using System.Xml;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.ComponentModel.DataAnnotations;
namespace StellarWaterPoint1.Pages.WaterMeters
{
public class CreateModel : PageModel
{
[BindProperty]
[Display(Name = "Water Meter Id")]
public int WaterMeterId { get; set; }
[BindProperty]
[Display(Name = "Meter #")]
public string? MeterNumber { get; set; }
[BindProperty]
public string? Make { get; set; }
[BindProperty]
public string? Model { get; set; }
[BindProperty]
[Display(Name = "Meter Size")]
public string? MeterSize { get; set; }
public void OnGet()
{
WaterMeterId = 0;
MeterNumber = string.Empty;
Make = string.Empty;
Model = string.Empty;
MeterSize = string.Empty;
}
public async Task<IActionResult> OnPostAsync()
{
XmlDocument xdWaterMeters = new XmlDocument();
string strWaterMeters = @"E:\Stellar Water Point4\WaterMeters.xml";
FileInfo fiWaterMeters = new FileInfo(strWaterMeters);
if (fiWaterMeters.Exists == false)
{
xdWaterMeters.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<water-meters></water-meters>");
xdWaterMeters.Save(fiWaterMeters.FullName);
}
xdWaterMeters.Load(strWaterMeters);
XmlElement xeWaterMeter = xdWaterMeters.CreateElement("water-meter");
xeWaterMeter.InnerXml = "<water-meter-id>" + WaterMeterId + "</water-meter-id>" +
"<meter-number>" + MeterNumber + "</meter-number>" +
"<make>" + Make + "</make>" +
"<model>" + Model + "</model>" +
"<meter-size>" + MeterSize + "</meter-size>";
xdWaterMeters.DocumentElement!.AppendChild(xeWaterMeter);
xdWaterMeters.Save(fiWaterMeters.FullName);
await Task.CompletedTask;
return RedirectToPage("Index");
}
}
}@page
@model StellarWaterPoint1.Pages.WaterMeters.CreateModel
@{
}
<h1 class="common-font fw-bold text-center">Water Meter Setup</h1>
<hr />
<form method="post" class="common-font encloser">
<div class="row mb-2">
<label asp-for="@Model.WaterMeterId" class="col-form-label col-md-4 fw-bold"></label>
<div class="col-md-8">
<input asp-for="@Model.WaterMeterId" class="form-control" />
</div>
</div>
<div class="row mb-2">
<label asp-for="@Model.MeterNumber" class="col-form-label col-md-4 fw-bold"></label>
<div class="col-md-8">
<input asp-for="@Model.MeterNumber" class="form-control" />
</div>
</div>
<div class="row mb-2">
<label asp-for="@Model.Make" class="col-form-label col-md-4 fw-bold"></label>
<div class="col-md-8">
<input asp-for="@Model.Make" class="form-control" />
</div>
</div>
<div class="row mb-2">
<label asp-for="@Model.Model" class="col-form-label col-md-4 fw-bold"></label>
<div class="col-md-8">
<input asp-for="@Model.Model" class="form-control" />
</div>
</div>
<div class="row mb-2">
<label asp-for="@Model.MeterSize" class="col-form-label col-md-4 fw-bold"></label>
<div class="col-md-8">
<input asp-for="@Model.MeterSize" class="form-control" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index" class="stellar">Water Meters</a>
</div>
<div class="col-md-7">
<input type="submit" name="btnSaveWaterMeter" value="Save Water Meter" class="btn btn-primary" />
</div>
</div>
</form>
<hr />
<p class="text-center">
<a asp-page="./Details" class="stellar">View a Water Meter Details</a> ::
<a asp-page="./Edit" class="stellar">Edit a Water Meter</a> ::
<a asp-page="./Delete" class="stellar">Delete a Water Meter</a>
</p>

| Water Meter Id | Meter # | Make | Model | Meter Size |
| 1 | 392-494-572 | Constance Technologies | TG-4822 | 5/8 Inches |
| 2 | 938-705-869 | Stan Wood | 66-G | 1 Inch |
| 3 | 588-279-663 | Estellano | NCF-226 | 3/4 Inches |
Water Meter Details
For any reason necessary, some time to time, an employee may want to see a record of a particular water meter. To make this possible, we will create a form.
Practical Learning: Viewing a Water Meter Details
@page
@using System.Xml;
@model StellarWaterPoint1.Pages.WaterMeters.DetailsModel
@{
bool meterFound = false;
string? message = string.Empty;
string? strMake = string.Empty;
string? strModel = string.Empty;
string? strMeterSize = string.Empty;
string? strWaterMeterId = string.Empty;
string? strMeterNumber = string.Empty;
if (Request.HasFormContentType)
{
XmlDocument xdWaterMeters = new XmlDocument();
string strWaterMeters = @"E:\Stellar Water Point5\WaterMeters.xml";
FileInfo fiWaterMeters = new FileInfo(strWaterMeters);
strMeterNumber = Request.Form["txtMeterNumber"];
if (fiWaterMeters.Exists)
{
xdWaterMeters.Load(fiWaterMeters.FullName);
XmlNodeList xnlWaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
foreach (XmlNode xnWaterMeter in xnlWaterMeters!)
{
if (xnWaterMeter.InnerText.Equals(strMeterNumber))
{
meterFound = true;
strWaterMeterId = xnWaterMeter.PreviousSibling!.InnerText;
strMake = xnWaterMeter.NextSibling!.InnerText;
strModel = xnWaterMeter.NextSibling!.NextSibling!.InnerText;
strMeterSize = xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText;
break;
}
}
}
if (meterFound == false)
{
message = "There is no water meter with that number in our system.";
}
}
}
<h1 class="common-font fw-bold text-center">Water Meter Details</h1>
<hr />
<form method="post" class="common-font encloser">
<div class="row mb-2">
<label for="txtMeterNumber" class="col-form-label col-md-4 fw-bold">Meter #</label>
<div class="col-md-4">
<input name="txtMeterNumber" class="form-control" value="@strMeterNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindWaterMeter" value="Find Water Meter" class="btn btn-primary" />
</div>
</div>
<div class="row mb-2">
<label for="txtWaterMeterId" class="col-form-label col-md-4 fw-bold">Water Meter Id</label>
<div class="col-md-8">
<input name="txtWaterMeterId" class="form-control" value="@strWaterMeterId" />
</div>
</div>
<div class="row mb-2">
<label for="txtMake" class="col-form-label col-md-4 fw-bold">Make</label>
<div class="col-md-8">
<input name="txtMake" class="form-control" value="@strMake" />
</div>
</div>
<div class="row mb-2">
<label for="txtModel" class="col-form-label col-md-4 fw-bold">Model</label>
<div class="col-md-8">
<input name="txtModel" class="form-control" value="@strModel" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterSize" class="col-form-label col-md-4 fw-bold">Meter Size</label>
<div class="col-md-8">
<input name="txtMeterSize" class="form-control" value="@strMeterSize" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index" class="stellar">Water Meters</a>
</div>
<div class="col-md-7">
<p>@message</p>
</div>
</div>
</form>
<hr />
<p class="text-center">
<a asp-page="./Create" class="stellar">Create Water Meter</a> ::
<a asp-page="./Edit" class="stellar">Edit a Water Meter</a> ::
<a asp-page="./Delete" class="stellar">Delete a Water Meter</a>
</p>


Updating a Water Meter Details
One of the routine operations performed on a database is to change the details of a record. To support this operation for a water meter, we will create a form that can be used to update the information of a water meter.
Practical Learning: Updating a Water Meter
@page
@using System.Xml;
@model StellarWaterPoint1.Pages.WaterMeters.EditModel
@{
bool meterFound = false;
string? message = string.Empty;
string? strMake = string.Empty;
string? strModel = string.Empty;
string? strMeterSize = string.Empty;
string? strWaterMeterId = string.Empty;
string? strMeterNumber = string.Empty;
if (Request.HasFormContentType)
{
strMeterNumber = Request.Form["txtMeterNumber"];
if (Request.Form["btnFindWaterMeter"] == "Find Water Meter")
{
XmlDocument xdWaterMeters = new XmlDocument();
string strWaterMeters = @"E:\Stellar Water Point5\WaterMeters.xml";
FileInfo fiWaterMeters = new FileInfo(strWaterMeters);
if (fiWaterMeters.Exists)
{
xdWaterMeters.Load(fiWaterMeters.FullName);
XmlNodeList xnlWaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
foreach (XmlNode xnWaterMeter in xnlWaterMeters!)
{
if (xnWaterMeter.InnerText.Equals(strMeterNumber))
{
meterFound = true;
strWaterMeterId = xnWaterMeter.PreviousSibling!.InnerText;
strMake = xnWaterMeter.NextSibling!.InnerText;
strModel = xnWaterMeter.NextSibling!.NextSibling!.InnerText;
strMeterSize = xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText;
break;
}
}
}
if (meterFound == false)
{
message = "There is no water meter with that number in our system.";
}
}
if (Request.Form["btnUpdateWaterMeter"] == "Update Water Meter")
{
XmlDocument xdWaterMeters = new XmlDocument();
string strWaterMeters = @"E:\Stellar Water Point5\WaterMeters.xml";
FileInfo fiWaterMeters = new FileInfo(strWaterMeters);
if (fiWaterMeters.Exists == true)
{
xdWaterMeters.Load(strWaterMeters);
XmlNodeList xnlWaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
// XmlNodeList xnlWaterMeters = xdWaterMeters.DocumentElement!.SelectNodes("//meter-number[.='" + strMeterNumber + "']")!;
foreach (XmlNode xnWaterMeter in xnlWaterMeters!)
{
if (xnWaterMeter.InnerText.Equals(strMeterNumber))
{
xnWaterMeter.ParentNode!.InnerXml = "<water-meter-id>" + Request.Form["txtWaterMeterId"] + "</water-meter-id>" +
"<meter-number>" + Request.Form["txtMeterNumber"] + "</meter-number>" +
"<make>" + Request.Form["txtMake"] + "</make>" +
"<model>" + Request.Form["txtModel"] + "</model>" +
"<meter-size>" + Request.Form["txtMeterSize"] + "</meter-size>";
xdWaterMeters.Save(fiWaterMeters.FullName);
break;
}
}
}
Response.Redirect("Index");
}
}
}
<h1 class="common-font fw-bold text-center">Edit/Update Water Meter</h1>
<hr />
<form method="post" class="common-font encloser">
<div class="row mb-2">
<label for="txtMeterNumber" class="col-form-label col-md-4 fw-bold">Meter #</label>
<div class="col-md-4">
<input name="txtMeterNumber" class="form-control" value="@strMeterNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindWaterMeter" value="Find Water Meter" class="btn btn-primary" />
</div>
</div>
<div class="row mb-2">
<label for="txtWaterMeterId" class="col-form-label col-md-4 fw-bold">Water Meter Id</label>
<div class="col-md-8">
<input name="txtWaterMeterId" class="form-control" value="@strWaterMeterId" />
</div>
</div>
<div class="row mb-2">
<label for="txtMake" class="col-form-label col-md-4 fw-bold">Make</label>
<div class="col-md-8">
<input name="txtMake" class="form-control" value="@strMake" />
</div>
</div>
<div class="row mb-2">
<label for="txtModel" class="col-form-label col-md-4 fw-bold">Model</label>
<div class="col-md-8">
<input name="txtModel" class="form-control" value="@strModel" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterSize" class="col-form-label col-md-4 fw-bold">Meter Size</label>
<div class="col-md-8">
<input name="txtMeterSize" class="form-control" value="@strMeterSize" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index" class="stellar">Water Meters</a>
</div>
<div class="col-md-7">
<input type="submit" name="btnUpdateWaterMeter" value="Update Water Meter" class="btn btn-primary" />
</div>
</div>
</form>
<hr />
<p class="text-center">
<a asp-page="./Create" class="stellar">Create Water Meter</a> ::
<a asp-page="./Details" class="stellar">View a Water Meter Details</a> ::
<a asp-page="./Delete" class="stellar">Delete a Water Meter</a>
</p>


| Make: | Stanford Trend | Model: | 266G |
| Meter Size: | 1 1/2 Inches |


Removing a Water Meter from the Database
If a water meter has become useless and you want to make sure it is no more available for customer use, you can delete its record. To assist the user, we will create a form for that operation.
Practical Learning: Deleting a Water Meter Record
@page
@using System.Xml
@model StellarWaterPoint1.Pages.WaterMeters.DeleteModel
@{
bool meterFound = false;
string? message = string.Empty;
string? strMake = string.Empty;
string? strModel = string.Empty;
string? strWaterMeterId = string.Empty;
string? strMeterSize = string.Empty;
string? strMeterNumber = string.Empty;
if (Request.HasFormContentType)
{
strMeterNumber = Request.Form["txtMeterNumber"];
if (Request.Form["btnFindWaterMeter"] == "Find Water Meter")
{
XmlDocument xdWaterMeters = new XmlDocument();
string strWaterMeters = @"E:\Stellar Water Point5\WaterMeters.xml";
FileInfo fiWaterMeters = new FileInfo(strWaterMeters);
if (fiWaterMeters.Exists)
{
xdWaterMeters.Load(fiWaterMeters.FullName);
XmlNodeList xnlWaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
foreach (XmlNode xnWaterMeter in xnlWaterMeters!)
{
if (xnWaterMeter.InnerText.Equals(strMeterNumber))
{
meterFound = true;
strWaterMeterId = xnWaterMeter.PreviousSibling!.InnerText;
strMake = xnWaterMeter.NextSibling!.InnerText;
strModel = xnWaterMeter.NextSibling!.NextSibling!.InnerText;
strMeterSize = xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText;
break;
}
}
}
if (meterFound == false)
{
message = "There is no water meter with that number in our system.";
}
}
if (Request.Form["btnDeleteWaterMeter"] == "Delete Water Meter")
{
XmlDocument xdWaterMeters = new XmlDocument();
string strWaterMeters = @"E:\Stellar Water Point5\WaterMeters.xml";
FileInfo fiWaterMeters = new FileInfo(strWaterMeters);
if (fiWaterMeters.Exists == true)
{
xdWaterMeters.Load(strWaterMeters);
// XmlNodeList xnlWaterMeters = xdWaterMeters.DocumentElement!.SelectNodes("//meter-number[.='" + strMeterNumber + "']")!;
XmlNodeList xnlWaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
foreach (XmlNode xnWaterMeter in xnlWaterMeters!)
{
if (xnWaterMeter.InnerText.Equals(strMeterNumber))
{
xdWaterMeters.DocumentElement!.RemoveChild(xnWaterMeter.ParentNode!);
xdWaterMeters.Save(fiWaterMeters.FullName);
break;
}
}
Response.Redirect("Index");
}
}
}
}
<h1 class="common-font fw-bold text-center">Delete Water Meter</h1>
<hr />
<form method="post" class="common-font encloser">
<div class="row mb-2">
<label for="txtMeterNumber" class="col-form-label col-md-4 fw-bold">Meter #</label>
<div class="col-md-4">
<input name="txtMeterNumber" class="form-control" value="@strMeterNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindWaterMeter" value="Find Water Meter" class="btn btn-primary" />
</div>
</div>
<div class="row mb-2">
<label for="txtWaterMeterId" class="col-form-label col-md-4 fw-bold">Water Meter Id</label>
<div class="col-md-8">
<input name="txtWaterMeterId" class="form-control" value="@strWaterMeterId" />
</div>
</div>
<div class="row mb-2">
<label for="txtMake" class="col-form-label col-md-4 fw-bold">Make</label>
<div class="col-md-8">
<input name="txtMake" class="form-control" value="@strMake" />
</div>
</div>
<div class="row mb-2">
<label for="txtModel" class="col-form-label col-md-4 fw-bold">Model</label>
<div class="col-md-8">
<input name="txtModel" class="form-control" value="@strModel" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterSize" class="col-form-label col-md-4 fw-bold">Meter Size</label>
<div class="col-md-8">
<input name="txtMeterSize" class="form-control" value="@strMeterSize" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index">Water Meters</a>
</div>
<div class="col-md-7">
<input type="submit" name="btnDeleteWaterMeter" value="Delete Water Meter" class="btn btn-primary" />
</div>
</div>
</form>
<hr />
<p class="text-center">
<a asp-page="./Create" class="stellar">Create Water Meter</a> ::
<a asp-page="./Edit" class="stellar">Edit a Water Meter</a> ::
<a asp-page="./Details" class="stellar">View a Water Meter Details</a>
</p>




<?xml version="1.0" encoding="utf-8"?> <water-meters> <water-meter> <meter-number>392-494-572</meter-number> <make>Constance Technologies</make> <model>TG-4822</model> <meter-size>5/8 Inches</meter-size> </water-meter> <water-meter> <meter-number>938-725-869</meter-number> <make>Stanford Trend</make> <model>266G</model> <meter-size>1 1/2 Inches</meter-size> </water-meter> <water-meter> <meter-number>588-279-663</meter-number> <make>Estellano</make> <model>NCF-226</model> <meter-size>4 Inches</meter-size> </water-meter> <water-meter> <meter-number>186-962-805</meter-number> <make>Lansome</make> <model>2800</model> <meter-size>1 1/2 Inches</meter-size> </water-meter> <water-meter> <meter-number>379-386-979</meter-number> <make>Planetra</make> <model>P-2020</model> <meter-size>4 Inches</meter-size> </water-meter> <water-meter> <meter-number>580-742-825</meter-number> <make>Kensa Sons</make> <model>KS2000A</model> <meter-size>1 3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>849-351-444</meter-number> <make>Raynes Energica</make> <model>a1088</model> <meter-size>2 Inches</meter-size> </water-meter> <water-meter> <meter-number>208-428-308</meter-number> <make>Constance Technologies</make> <model>808D</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>738-588-249</meter-number> <make>Warrington</make> <model>W4242</model> <meter-size>5/8 Inches</meter-size> </water-meter> <water-meter> <meter-number>496-813-794</meter-number> <make>Estellano</make> <model>NCF-226</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>862-715-006</meter-number> <make>Warrington</make> <model>W-4040</model> <meter-size>1/2 Inch</meter-size> </water-meter> <water-meter> <meter-number>649-358-184</meter-number> <make>Raynes Energica</make> <model>b1700</model> <meter-size>1 1/2 Inches</meter-size> </water-meter> <water-meter> <meter-number>928-317-924</meter-number> <make>Gongola</make> <model>GN1000</model> <meter-size>2 Inch</meter-size> </water-meter> <water-meter> <meter-number>595-753-147</meter-number> <make>Grass Grill</make> <model>CRC-1000</model> <meter-size>1 Inch</meter-size> </water-meter> <water-meter> <meter-number>799-528-461</meter-number> <make>Kensa Sons</make> <model>K-584-L</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>386-468-057</meter-number> <make>Estellano</make> <model>NCF-226</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>938-275-294</meter-number> <make>Constance Technologies</make> <model>TT-8822</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>288-427-585</meter-number> <make>Planetra</make> <model>P-2020</model> <meter-size>1/2 Inch</meter-size> </water-meter> <water-meter> <meter-number>394-835-297</meter-number> <make>Raynes Energica</make> <model>i2022</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>847-252-246</meter-number> <make>Master Stream</make> <model>2000-MS</model> <meter-size>1 1/2 Inches</meter-size> </water-meter> <water-meter> <meter-number>349-725-848</meter-number> <make>Planetra</make> <model>P-8000</model> <meter-size>1 Inch</meter-size> </water-meter> <water-meter> <meter-number>713-942-058</meter-number> <make>Master Stream</make> <model>3366-MS</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>747-581-379</meter-number> <make>Warrington</make> <model>W4242</model> <meter-size>5/8 Inches</meter-size> </water-meter> <water-meter> <meter-number>582-755-263</meter-number> <make>Kensa Sons</make> <model>KS2000A</model> <meter-size>1 Inch</meter-size> </water-meter> <water-meter> <meter-number>827-260-758</meter-number> <make>Raynes Energica</make> <model>a1088</model> <meter-size>1-1/4 Inch</meter-size> </water-meter> <water-meter> <meter-number>837-806-836</meter-number> <make>Lansome</make> <model>7400</model> <meter-size>5/8 Inches</meter-size> </water-meter> <water-meter> <meter-number>207-964-835</meter-number> <make>Constance Technologies</make> <model>TG-6220</model> <meter-size>5/8 Inches</meter-size> </water-meter> <water-meter> <meter-number>296-837-495</meter-number> <make>Raynes Energica</make> <model>QG505</model> <meter-size>4 Inches</meter-size> </water-meter> <water-meter> <meter-number>468-359-486</meter-number> <make>Grass Grill</make> <model>KLP-8822</model> <meter-size>1-1/4 Inch</meter-size> </water-meter> <water-meter> <meter-number>931-486-003</meter-number> <make>Planetra</make> <model>P-2020</model> <meter-size>1/2 Inch</meter-size> </water-meter> <water-meter> <meter-number>483-770-648</meter-number> <make>Warren</make> <model>WWW</model> <meter-size>0.1 Inches</meter-size> </water-meter> <water-meter> <meter-number>592-824-957</meter-number> <make>Kensa Sons</make> <model>D-497-H</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>293-835-704</meter-number> <make>Gongola</make> <model>GOL1000</model> <meter-size>1/2 Inch</meter-size> </water-meter> <water-meter> <meter-number>739-777-749</meter-number> <make>Warrington</make> <model>W2200W</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>374-886-284</meter-number> <make>Raynes Energica</make> <model>i2022</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>186-959-757</meter-number> <make>Kensa Sons</make> <model>M-686-G</model> <meter-size>1 1/2 Inches</meter-size> </water-meter> <water-meter> <meter-number>594-827-359</meter-number> <make>Planetra</make> <model>P-8000</model> <meter-size>1 Inch</meter-size> </water-meter> <water-meter> <meter-number>394-739-242</meter-number> <make>Master Stream</make> <model>9393-TT</model> <meter-size>5/8 Inches</meter-size> </water-meter> <water-meter> <meter-number>529-283-752</meter-number> <make>Constance Technologies</make> <model>404T</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>295-770-695</meter-number> <make>Warrington</make> <model>W-2286</model> <meter-size>1-1/4 Inch</meter-size> </water-meter> <water-meter> <meter-number>739-749-737</meter-number> <make>Kensa Sons</make> <model>KS2000A</model> <meter-size>1 Inch</meter-size> </water-meter> <water-meter> <meter-number>947-528-317</meter-number> <make>Gondola</make> <model>GDL-5000</model> <meter-size>1 Inch</meter-size> </water-meter> <water-meter> <meter-number>630-207-055</meter-number> <make>Lansome</make> <model>2800</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>827-508-248</meter-number> <make>Standard Trend</make> <model>428T</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>293-924-869</meter-number> <make>Grass Grill</make> <model>CRC-2020</model> <meter-size>1/2 Inch</meter-size> </water-meter> <water-meter> <meter-number>928-247-580</meter-number> <make>Gondola</make> <model>GOL2000</model> <meter-size>0.34 Inch</meter-size> </water-meter> <water-meter> <meter-number>682-537-380</meter-number> <make>Planetra</make> <model>P-2020</model> <meter-size>1-1/4 Inch</meter-size> </water-meter> <water-meter> <meter-number>470-628-850</meter-number> <make>Estellano</make> <model>WRT-482</model> <meter-size>3/4 Inches</meter-size> </water-meter> <water-meter> <meter-number>649-373-505</meter-number> <make>Constance Technologies</make> <model>BD-7000</model> <meter-size>5/8 Inches</meter-size> </water-meter> <water-meter> <meter-number>306-842-497</meter-number> <make>Lansome</make> <model>9000</model> <meter-size>3/4 Inches</meter-size> </water-meter> </water-meters>
Customers
Introduction
Practical Learning: Introducing Customers
Customers Accounts
Practical Learning: Displaying Customers Accounts
using System.Xml;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace StellarWaterPoint1.Pages.Customers
{
public class IndexModel : PageModel
{
public XmlNodeList? Customers { get; set; } = null;
public void OnGet()
{
XmlDocument xdCustomers = new XmlDocument();
string strCustomers = @"E:\Stellar Water Point5\Customers.xml";
FileInfo fiCustomers = new FileInfo(strCustomers);
if (fiCustomers.Exists)
{
xdCustomers.Load(fiCustomers.FullName);
Customers = xdCustomers.GetElementsByTagName("customer-id");
}
}
}
}@page
@using System.Xml
@model StellarWaterPoint1.Pages.Customers.IndexModel
@{
}
<h1 class="common-font fw-bold text-center">Customers</h1>
<hr />
<table class="table common-font">
<tr class="fw-bold">
<td class="text-center">Customer Id</td>
<td class="text-center">Account #</td>
<td>Account Name</td>
<td>Account Type</td>
<td>Water Meter</td>
<td>Address</td>
<td>City</td>
<td>County</td>
<td class="text-center">State</td>
<td class="text-center">ZIP-Code</td>
</tr>
@if (Model.Customers is not null)
{
foreach (XmlNode xnCustomer in Model.Customers!)
{
<tr>
<td>@xnCustomer.InnerText</td>
<td>@xnCustomer.NextSibling!.InnerText</td>
<td>@xnCustomer.NextSibling!.NextSibling!.InnerText</td>
<td>@xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText</td>
<td>@xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText</td>
<td>@xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText</td>
<td>@xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText</td>
<td>@xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText</td>
<td>@xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText</td>
</tr>
}
}
</table>
<p class="text-center">
<a asp-page="./Create" class="stellar">Create a Customer's Account</a> ::
<a asp-page="./Details" class="stellar">Customer Account Details</a> ::
<a asp-page="./Edit" class="stellar">Edit/Update a Customer Account</a> ::
<a asp-page="./Delete" class="stellar">Delete a Customer's Account</a>
</p>
A Customer Account
Practical Learning: Creating a Water Meter Record
@page
@using System.Data;
@using Microsoft.Data.SqlClient;
@model StellarWaterPoint1.Pages.Customers.CreateModel
@{
ViewData["Title"] = "Customer";
bool bMeterFound = false;
string? strCity = string.Empty;
string? strState = string.Empty;
string? strCounty = string.Empty;
string? strAddress = string.Empty;
string? strZIPCode = string.Empty;
string? strMessage = string.Empty;
string? strAccountName = string.Empty;
string? strMeterNumber = string.Empty;
string? strAccountType = string.Empty;
string? strMeterDetails = string.Empty;
string? strAccountNumber = string.Empty;
if (Request.HasFormContentType)
{
DataSet dsWaterMeters = new("WaterMetersSet");
strMeterNumber = Request.Form["txtMeterNumber"];
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strFirstName = Request.Form["txtFirstName"];
strLastName = Request.Form["txtLastName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
if (Request.Form["btnFindWaterMeter"] == "Find Water Meter")
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
bMeterFound = true;
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
if (bMeterFound == false)
{
strMessage = "There is no water meter with that number in our system.";
}
}
if (Request.Form["btnSaveCustomer"] == "Save Customer Account")
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strFirstName = Request.Form["txtFirstName"];
strLastName = Request.Form["txtLastName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
SqlCommand cmdWaterMeters = new SqlCommand("INSERT INTO Customers(AccountNumber, MeterNumber, " +
" FirstName, LastName, Address, " +
" City, County, State, ZIPCode) " +
"VALUES(N'" + strAccountNumber + "', N'" +
strMeterNumber + "', N'" +
strFirstName + "', N'" +
strLastName + "', N'" +
strAddress + "', N'" +
strCity + "', N'" +
strCounty + "', N'" +
strState + "', N'" +
strZIPCode + "');",
scWaterDistribution);
scWaterDistribution.Open();
cmdWaterMeters.ExecuteNonQuery();
}
Response.Redirect("Index");
}
}
}
<h1 class="common-font fw-bold text-center">Create Customer Account</h1>
<hr />
<form method="post" class="common-font encloser">
<div class="row mb-2">
<label for="txtAccountNumber" class="col-form-label col-md-3 fw-bold">Account #</label>
<div class="col-md-9">
<input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterNumber" class="col-form-label col-md-3 fw-bold">Meter #</label>
<div class="col-md-4">
<input name="txtMeterNumber" class="form-control" value="@strMeterNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindWaterMeter" value="Find Water Meter" class="btn btn-maroon" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterDetails" class="col-form-label col-md-3 fw-bold">Meter Details</label>
<div class="col-md-9">
<input name="txtMeterDetails" class="form-control" value="@strMeterDetails" />
</div>
</div>
<div class="row mb-2">
<label for="txtFirstName" class="col-form-label col-md-3 fw-bold">First Name</label>
<div class="col-md-9">
<input name="txtFirstName" class="form-control" value="@strFirstName" />
</div>
</div>
<div class="row mb-2">
<label for="txtLastName" class="col-form-label col-md-3 fw-bold">Last Name</label>
<div class="col-md-9">
<input name="txtLastName" class="form-control" value="@strLastName" />
</div>
</div>
<div class="row mb-2">
<label for="txtAddress" class="col-form-label col-md-3 fw-bold">Address</label>
<div class="col-md-9">
<input name="txtAddress" class="form-control" value="@strAddress" />
</div>
</div>
<div class="row mb-2">
<label for="txtCity" class="col-form-label col-md-3 fw-bold">City</label>
<div class="col-md-9">
<input name="txtCity" class="form-control" value="@strCity" />
</div>
</div>
<div class="row mb-2">
<label for="txtCounty" class="col-form-label col-md-3 fw-bold">County</label>
<div class="col-md-9">
<input name="txtCounty" class="form-control" value="@strCounty" />
</div>
</div>
<div class="row mb-2">
<label for="txtState" class="col-form-label col-md-3 fw-bold">State</label>
<div class="col-md-9">
<input name="txtState" class="form-control" value="@strState" />
</div>
</div>
<div class="row mb-2">
<label for="txtZIPCode" class="col-form-label col-md-3 fw-bold">ZIP-Code</label>
<div class="col-md-9">
<input name="txtZIPCode" class="form-control" value="@strZIPCode" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index">Customers Accounts</a>
</div>
<div class="col-md-7">
<input type="submit" name="btnSaveCustomer"
value="Save Customer Account" class="btn btn-maroon" />
</div>
</div>
</form>
<hr />
<p class="text-center">
<a asp-page="./Details" class="stellar">Review a Customer's Account</a> ::
<a asp-page="./Edit" class="stellar">Edit/Update a Customer's Account</a> ::
<a asp-page="./Delete" class="stellar">Delete a Customer's Account</a>
</p>Account #: 9279-570-8394 Account Name: Thomas Stones Meter #: 799-528-461 Account Type: RES - Residential Household Address: 10252 Broward Ave #D4 City: Frederick County: Frederick State: MD ZIP-Code: 21703-4422
| Account # | Account Name | Meter # | Account Type | Address | City | County | State | ZIP-Code |
| 4086-938-4783 | Hernola Dough | 594-827-359 | UUO - Unidentified or Unclassified Type of Organization | 10 10 Hexagonal Drv | Winston | Yoke | Penn | 11402-4411 |
| 7080-583-5947 | Sunny Yard | 827-508-248 | WAT - Water Intensive Business(Laudromat, Hair Salon, Restaurant, etc | 663 Sherry Wood East Street | Shimpstown | Franklin | PA | 17236-2626 |
A Review of a Customer's Account
Practical Learning: Reviewing a Water Meter Record
@page
@using System.Data;
@using Microsoft.Data.SqlClient;
@model StellarWaterPoint1.Pages.Customers.DetailsModel
@{
ViewData["Title"] = "Customer";
bool bCustomerFound = false;
string? strCity = string.Empty;
string? strState = string.Empty;
string? strCounty = string.Empty;
string? strAddress = string.Empty;
string? strZIPCode = string.Empty;
string? strMessage = string.Empty;
string? strLastName = string.Empty;
string? strFirstName = string.Empty;
string? strCustomerId = string.Empty;
string? strMeterNumber = string.Empty;
string? strMeterDetails = string.Empty;
string? strAccountNumber = string.Empty;
if (Request.HasFormContentType)
{
DataSet dsWaterMeters = new("WaterMetersSet");
DataSet dsCustomers = new("CustomersSet");
strAccountNumber = Request.Form["txtAccountNumber"];
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
SqlCommand cmdCustomers = new SqlCommand("SELECT CustomerId, " +
" MeterNumber, " +
" FirstName, " +
" LastName, " +
" Address, " +
" City, " +
" County, " +
" State, " +
" ZIPCode " +
"FROM Customers " +
"WHERE AccountNumber = N'" + strAccountNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaCustomers = new SqlDataAdapter(cmdCustomers);
sdaCustomers.Fill(dsCustomers);
foreach (DataRow drCustomer in dsCustomers.Tables[0].Rows!)
{
bCustomerFound = true;
strCustomerId = drCustomer[0].ToString();
strMeterNumber = drCustomer[1].ToString();
strFirstName = drCustomer[2].ToString();
strLastName = drCustomer[3].ToString();
strAddress = drCustomer[4].ToString();
strCity = drCustomer[5].ToString();
strCounty = drCustomer[6].ToString();
strState = drCustomer[7].ToString();
strZIPCode = drCustomer[8].ToString();
break;
}
}
if (bCustomerFound == false)
{
strMessage = "There is no customer account with that number in our system.";
}
else
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
bCustomerFound = true;
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
}
}
}
<h1 class="common-font fw-bold text-center">View Customer Account</h1>
<hr />
<form method="post" class="common-font encloser">
<div class="row mb-2">
<label for="txtAccountNumber" class="col-form-label col-md-3 fw-bold">Account #</label>
<div class="col-md-4 text-center">
<input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindCustomerAccount" value="Find Customer Account" class="btn btn-maroon" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterDetails" class="col-form-label col-md-3 fw-bold">Meter Details</label>
<div class="col-md-9">
<input name="txtMeterDetails" class="form-control" value="@strMeterDetails" />
</div>
</div>
<div class="row mb-2">
<label for="txtFirstName" class="col-form-label col-md-3 fw-bold">First Name</label>
<div class="col-md-9">
<input name="txtFirstName" class="form-control" value="@strFirstName" />
</div>
</div>
<div class="row mb-2">
<label for="txtLastName" class="col-form-label col-md-3 fw-bold">Last Name</label>
<div class="col-md-9">
<input name="txtLastName" class="form-control" value="@strLastName" />
</div>
</div>
<div class="row mb-2">
<label for="txtAddress" class="col-form-label col-md-3 fw-bold">Address</label>
<div class="col-md-9">
<input name="txtAddress" class="form-control" value="@strAddress" />
</div>
</div>
<div class="row mb-2">
<label for="txtCity" class="col-form-label col-md-3 fw-bold">City</label>
<div class="col-md-9">
<input name="txtCity" class="form-control" value="@strCity" />
</div>
</div>
<div class="row mb-2">
<label for="txtCounty" class="col-form-label col-md-3 fw-bold">County</label>
<div class="col-md-9">
<input name="txtCounty" class="form-control" value="@strCounty" />
</div>
</div>
<div class="row mb-2">
<label for="txtState" class="col-form-label col-md-3 fw-bold">State</label>
<div class="col-md-9">
<input name="txtState" class="form-control" value="@strState" />
</div>
</div>
<div class="row mb-2">
<label for="txtZIPCode" class="col-form-label col-md-3 fw-bold">ZIP-Code</label>
<div class="col-md-9">
<input name="txtZIPCode" class="form-control" value="@strZIPCode" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
</div>
<div class="col-md-7">
<a asp-page="Index">Customers Accounts</a>
</div>
</div>
</form>
<hr />
<p class="text-center">
<a asp-page="./Create" class="stellar">Create a New Customer's Account</a> ::
<a asp-page="./Edit" class="stellar">Edit/Update a Customer's Account</a> ::
<a asp-page="./Delete" class="stellar">Delete a Customer's Account</a>
</p>

Updating a Customer's Account
Some time to time, a piece of information changes about a customer's account. When that happens, a user must update such an account. To assist the users in performing such an operation, we will create a form.
Practical Learning: Updating a Water Meter
@page
@using System.Data;
@using Microsoft.Data.SqlClient;
@model StellarWaterPoint1.Pages.Customers.EditModel
@{
ViewData["Title"] = "Update Customer Account";
bool bMeterFound = false;
bool bCustomerFound = false;
string? strCity = string.Empty;
string? strState = string.Empty;
string? strCounty = string.Empty;
string? strAddress = string.Empty;
string? strZIPCode = string.Empty;
string? strMessage = string.Empty;
string? strLastName = string.Empty;
string? strFirstName = string.Empty;
string? strMeterNumber = string.Empty;
string? strMeterDetails = string.Empty;
string? strAccountNumber = string.Empty;
if (Request.HasFormContentType)
{
DataSet dsCustomers = new("CustomersSet");
DataSet dsWaterMeters = new("WaterMetersSet");
strMeterNumber = Request.Form["txtMeterNumber"];
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strFirstName = Request.Form["txtFirstName"];
strLastName = Request.Form["txtLastName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
strAccountNumber = Request.Form["txtAccountNumber"];
if (Request.Form["btnFindCustomerAccount"] == "Find Customer Account")
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
SqlCommand cmdCustomers = new SqlCommand("SELECT MeterNumber, " +
" FirstName, " +
" LastName, " +
" Address, " +
" City, " +
" County, " +
" State, " +
" ZIPCode " +
"FROM Customers " +
"WHERE AccountNumber = N'" + strAccountNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaCustomers = new SqlDataAdapter(cmdCustomers);
sdaCustomers.Fill(dsCustomers);
foreach (DataRow drCustomer in dsCustomers.Tables[0].Rows!)
{
bCustomerFound = true;
strMeterNumber = drCustomer[0].ToString();
strFirstName = drCustomer[1].ToString();
strLastName = drCustomer[2].ToString();
strAddress = drCustomer[3].ToString();
strCity = drCustomer[4].ToString();
strCounty = drCustomer[5].ToString();
strState = drCustomer[6].ToString();
strZIPCode = drCustomer[7].ToString();
break;
}
}
if(bCustomerFound == false)
{
strMessage = "There is no customer account with that number in our system.";
}
else
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
bCustomerFound = true;
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
}
}
if (Request.Form["btnFindWaterMeter"] == "Find Water Meter")
{
strMeterNumber = Request.Form["txtMeterNumber"];
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
bMeterFound = true;
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
if (bMeterFound == false)
{
strMessage = "There is no water meter with that number in our system.";
}
}
if (Request.Form["btnUpdateCustomerAccount"] == "Update Customer Account")
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strFirstName = Request.Form["txtFirstName"];
strLastName = Request.Form["txtLastName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
SqlCommand cmdWaterMeters = new SqlCommand("UPDATE Customers SET AccountName = N'" + txtAccountName.Text + "' WHERE AccountNumber = N'" + mtbAccountNumber.Text + "';" +
"UPDATE Customers SET MeterNumber = N'" + mtbMeterNumber.Text + "' WHERE AccountNumber = N'" + mtbAccountNumber.Text + "';" +
"UPDATE Customers SET AccountType = N'" + strAccountType + "' WHERE AccountNumber = N'" + mtbAccountNumber.Text + "';" +
"UPDATE Customers SET [Address] = N'" + txtAddress.Text + "' WHERE AccountNumber = N'" + mtbAccountNumber.Text + "';" +
"UPDATE Customers SET City = N'" + txtCity.Text + "' WHERE AccountNumber = N'" + mtbAccountNumber.Text + "';" +
"UPDATE Customers SET County = N'" + txtCounty.Text + "' WHERE AccountNumber = N'" + mtbAccountNumber.Text + "';" +
"UPDATE Customers SET [State] = N'" + txtState.Text + "' WHERE AccountNumber = N'" + mtbAccountNumber.Text + "';" +
"UPDATE Customers SET ZIPCode = N'" + mtbZIPCode.Text + "' WHERE AccountNumber = N'" + mtbAccountNumber.Text + "';",
scStellarWaterPoint);
scWaterDistribution.Open();
cmdWaterMeters.ExecuteNonQuery();
}
Response.Redirect("Index");
}
}
}
<h1 class="common-font fw-bold text-center">Edit/Update Customer Account</h1>
<hr />
<form method="post" class="common-font encloser">
<div class="row mb-2">
<label for="txtAccountNumber" class="col-form-label col-md-3 fw-bold">Account #</label>
<div class="col-md-4 text-center">
<input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindCustomerAccount" value="Find Customer Account" class="btn btn-maroon" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterNumber" class="col-form-label col-md-3 fw-bold">Meter #</label>
<div class="col-md-4">
<input name="txtMeterNumber" class="form-control" value="@strMeterNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindWaterMeter" value="Find Water Meter" class="btn btn-maroon" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterDetails" class="col-form-label col-md-3 fw-bold">Meter Details</label>
<div class="col-md-9">
<input name="txtMeterDetails" class="form-control" value="@strMeterDetails" />
</div>
</div>
<div class="row mb-2">
<label for="txtFirstName" class="col-form-label col-md-3 fw-bold">First Name</label>
<div class="col-md-9">
<input name="txtFirstName" class="form-control" value="@strFirstName" />
</div>
</div>
<div class="row mb-2">
<label for="txtLastName" class="col-form-label col-md-3 fw-bold">Last Name</label>
<div class="col-md-9">
<input name="txtLastName" class="form-control" value="@strLastName" />
</div>
</div>
<div class="row mb-2">
<label for="txtAddress" class="col-form-label col-md-3 fw-bold">Address</label>
<div class="col-md-9">
<input name="txtAddress" class="form-control" value="@strAddress" />
</div>
</div>
<div class="row mb-2">
<label for="txtCity" class="col-form-label col-md-3 fw-bold">City</label>
<div class="col-md-9">
<input name="txtCity" class="form-control" value="@strCity" />
</div>
</div>
<div class="row mb-2">
<label for="txtCounty" class="col-form-label col-md-3 fw-bold">County</label>
<div class="col-md-9">
<input name="txtCounty" class="form-control" value="@strCounty" />
</div>
</div>
<div class="row mb-2">
<label for="txtState" class="col-form-label col-md-3 fw-bold">State</label>
<div class="col-md-9">
<input name="txtState" class="form-control" value="@strState" />
</div>
</div>
<div class="row mb-2">
<label for="txtZIPCode" class="col-form-label col-md-3 fw-bold">ZIP-Code</label>
<div class="col-md-9">
<input name="txtZIPCode" class="form-control" value="@strZIPCode" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index">Customers Accounts</a>
</div>
<div class="col-md-7">
<input type="submit" name="btnUpdateCustomerAccount"
value="Update Customer Account" class="btn btn-maroon" />
</div>
</div>
</form>
<hr />
<p class="text-center">
<a asp-page="./Details" class="stellar">Review a Customer's Account</a> ::
<a asp-page="./Edit" class="stellar">Edit/Update a Customer's Account</a> ::
<a asp-page="./Delete" class="stellar">Delete a Customer's Account</a>
</p>

Account Name: Bernotte Doughnuts Meter #: 580-742-825 and click Find Water Meter Account Type: BUS - General Business Address: 10103 Hexagon Drive City: Winterstown County: York State: PA ZIP-Code: 17402-8828


Deleting a Customer's Account
If a customer's account is not necessary anymore, the user can remove that account. To assist the user with this operation, we will create a form with necessary buttons.
Practical Learning: Deleting a Customer Account
@page
@using System.Data;
@using Microsoft.Data.SqlClient;
@model StellarWaterPoint1.Pages.Customers.DeleteModel
@{
ViewData["Title"] = "Customer Deletion";
bool bCustomerFound = false;
string? strCity = string.Empty;
string? strState = string.Empty;
string? strCounty = string.Empty;
string? strAddress = string.Empty;
string? strZIPCode = string.Empty;
string? strMessage = string.Empty;
string? strLastName = string.Empty;
string? strFirstName = string.Empty;
string? strMeterNumber = string.Empty;
string? strMeterDetails = string.Empty;
string? strAccountNumber = string.Empty;
if (Request.HasFormContentType)
{
DataSet dsWaterMeters = new("WaterMetersSet");
DataSet dsCustomers = new("CustomersSet");
strMeterNumber = Request.Form["txtMeterNumber"];
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strFirstName = Request.Form["txtFirstName"];
strLastName = Request.Form["txtLastName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
strAccountNumber = Request.Form["txtAccountNumber"];
if (Request.Form["btnFindCustomerAccount"] == "Find Customer Account")
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
SqlCommand cmdCustomers = new SqlCommand("SELECT MeterNumber, " +
" FirstName, " +
" LastName, " +
" Address, " +
" City, " +
" County, " +
" State, " +
" ZIPCode " +
"FROM Customers " +
"WHERE AccountNumber = N'" + strAccountNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaCustomers = new SqlDataAdapter(cmdCustomers);
sdaCustomers.Fill(dsCustomers);
foreach (DataRow drCustomer in dsCustomers.Tables[0].Rows!)
{
bCustomerFound = true;
strMeterNumber = drCustomer[0].ToString();
strFirstName = drCustomer[1].ToString();
strLastName = drCustomer[2].ToString();
strAddress = drCustomer[3].ToString();
strCity = drCustomer[4].ToString();
strCounty = drCustomer[5].ToString();
strState = drCustomer[6].ToString();
strZIPCode = drCustomer[7].ToString();
break;
}
}
if (bCustomerFound == false)
{
strMessage = "There is no customer account with that number in our system.";
}
else
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
bCustomerFound = true;
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
}
}
if (Request.Form["btnDeleteCustomerAccount"] == "Delete Customer Account")
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;" +
"TrustServerCertificate=True;"))
{
/* strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strFirstName = Request.Form["txtFirstName"];
strLastName = Request.Form["txtLastName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"]; */
SqlCommand cmdWaterMeters = new SqlCommand("DELETE Customers WHERE AccountNumber = N'" + strAccountNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
cmdWaterMeters.ExecuteNonQuery();
}
Response.Redirect("Index");
}
}
}
<h1 class="common-font fw-bold text-center">Delete Customer Account</h1>
<hr />
<form method="post" class="common-font encloser">
<div class="row mb-2">
<label for="txtAccountNumber" class="col-form-label col-md-3 fw-bold">Account #</label>
<div class="col-md-4 text-center">
<input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindCustomerAccount" value="Find Customer Account" class="btn btn-maroon" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterDetails" class="col-form-label col-md-3 fw-bold">Meter Details</label>
<div class="col-md-9">
<input name="txtMeterDetails" class="form-control" value="@strMeterDetails" />
</div>
</div>
<div class="row mb-2">
<label for="txtFirstName" class="col-form-label col-md-3 fw-bold">First Name</label>
<div class="col-md-9">
<input name="txtFirstName" class="form-control" value="@strFirstName" />
</div>
</div>
<div class="row mb-2">
<label for="txtLastName" class="col-form-label col-md-3 fw-bold">Last Name</label>
<div class="col-md-9">
<input name="txtLastName" class="form-control" value="@strLastName" />
</div>
</div>
<div class="row mb-2">
<label for="txtAddress" class="col-form-label col-md-3 fw-bold">Address</label>
<div class="col-md-9">
<input name="txtAddress" class="form-control" value="@strAddress" />
</div>
</div>
<div class="row mb-2">
<label for="txtCity" class="col-form-label col-md-3 fw-bold">City</label>
<div class="col-md-9">
<input name="txtCity" class="form-control" value="@strCity" />
</div>
</div>
<div class="row mb-2">
<label for="txtCounty" class="col-form-label col-md-3 fw-bold">County</label>
<div class="col-md-9">
<input name="txtCounty" class="form-control" value="@strCounty" />
</div>
</div>
<div class="row mb-2">
<label for="txtState" class="col-form-label col-md-3 fw-bold">State</label>
<div class="col-md-9">
<input name="txtState" class="form-control" value="@strState" />
</div>
</div>
<div class="row mb-2">
<label for="txtZIPCode" class="col-form-label col-md-3 fw-bold">ZIP-Code</label>
<div class="col-md-9">
<input name="txtZIPCode" class="form-control" value="@strZIPCode" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index">Customers Accounts</a>
</div>
<div class="col-md-7">
<input type="submit" name="btnDeleteCustomerAccount"
value="Delete Customer Account" class="btn btn-maroon" />
</div>
</div>
</form>
<hr />
<p class="text-center">
<a asp-page="./Details" class="stellar">Review a Customer's Account</a> ::
<a asp-page="./Edit" class="stellar">Edit/Update a Customer's Account</a> ::
<a asp-page="./Delete" class="stellar">Delete a Customer's Account</a>
</p>




Water Bills
Introduction
.
Practical Learning: Preparing Bills
A List of Water Bills
Practical Learning: Viewing Water Bills
@page
@model StellarWaterPoint4.Pages.WaterBills.IndexModel
@{
}
<p class="text-center">
<a asp-page="./Create" class="stellar">Water Bill Processing</a> ::
<a asp-page="./Details" class="stellar">Review a Water Bill</a> ::
<a asp-page="./Edit">Edit/Update a Water Bill</a> ::
<a asp-page="./Delete" class="stellar">Delete a Water Bill</a>
</p>Water Bills
A water bill is a summery of the amount of water a customer has consumed, the amount to pay for that consumption, and the dates related to that bill. For our application, we will create a webpage that contains a form to create a water bill. We will create a webpage that contains a form that allows an employee to review a water bill. We will create a webpage that contains a form that allows an employee to review and edit or update a water bill. We will create a webpage that contains a form that allows an employee to delete a water bill.
Practical Learning: Creating Water Bills
@page
@using System.Data;
@using Microsoft.Data.SqlClient;
@model StellarWaterPoint61.Pages.WaterBills.CreateModel
@{
ViewData["Title"] = "Water Bill Processing";
bool bCustomerFound = false;
string? strMessage = string.Empty;
string? strMeterNumber = string.Empty;
string? strMeterDetails = string.Empty;
string? strCity = string.Empty;
string? strState = string.Empty;
string? strCounty = string.Empty;
string? strZIPCode = string.Empty;
string? strAddress = string.Empty;
string? strBillNumber = string.Empty;
string? strBillingDays = string.Empty;
string? strCustomerName = string.Empty;
string? strAccountNumber = string.Empty;
string? strCounterReadingEnd = string.Empty;
string? strCounterReadingStart = string.Empty;
string? strMeterReadingEndDate = string.Empty;
string? strMeterReadingStartDate = string.Empty;
string? strTotalCCF = string.Empty;
string? strTotalGallons = string.Empty;
string? strFirstTierConsumption = string.Empty;
string? strSecondTierConsumption = string.Empty;
string? strLastTierConsumption = string.Empty;
string? strWaterCharges = string.Empty;
string? strSewerCharges = string.Empty;
string? strEnvironmentCharges = string.Empty;
string? strTotalCharges = string.Empty;
string? strLocalTaxes = string.Empty;
string? strStateTaxes = string.Empty;
string? strPaymentDueDate = string.Empty;
string? strAmountDue = string.Empty;
string? strLatePaymentDueDate = string.Empty;
string? strLateAmountDue = string.Empty;
if (Request.HasFormContentType)
{
DataSet dsCustomers = new("CustomersSet");
DataSet dsWaterBills = new("WaterBillsSet");
DataSet dsWaterMeters = new("WaterMetersSet");
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strCustomerName = Request.Form["txtCustomerName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
strMeterReadingStartDate = Request.Form["txtMeterReadingStartDate"];
strMeterReadingEndDate = Request.Form["txtMeterReadingEndDate"];
strCounterReadingStart = Request.Form["txtCounterReadingStart"];
strCounterReadingEnd = Request.Form["txtCounterReadingEnd"];
strBillingDays = Request.Form["txtBillingDays"];
strTotalCCF = Request.Form["txtTotalCCF"];
strTotalGallons = Request.Form["txtTotalGallons"];
strFirstTierConsumption = Request.Form["txtFirstTierConsumption"];
strSecondTierConsumption = Request.Form["txtSecondTierConsumption"];
strLastTierConsumption = Request.Form["txtLastTierConsumption"];
strWaterCharges = Request.Form["txtWaterCharges"];
strSewerCharges = Request.Form["txtSewerCharges"];
strEnvironmentCharges = Request.Form["txtEnvironmentCharges"];
strTotalCharges = Request.Form["txtTotalCharges"];
strLocalTaxes = Request.Form["txtLocalTaxes"];
strStateTaxes = Request.Form["txtStateTaxes"];
strPaymentDueDate = Request.Form["txtPaymentDueDate"];
strAmountDue = Request.Form["txtAmountDue"];
strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
strLateAmountDue = Request.Form["txtLateAmountDue"];
if (Request.Form["btnFindCustomerAccount"] == "Find Customer Account")
{
strBillNumber = Request.Form["txtBillNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strMeterDetails = Request.Form["txtMeterDetails"];
strPaymentDueDate = Request.Form["txtPaymentDueDate"];
strAmountDue = Request.Form["txtAmountDue"];
strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
strLateAmountDue = Request.Form["txtLateAmountDue"];
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdCustomers = new SqlCommand("SELECT MeterNumber, " +
" FirstName, " +
" LastName, " +
" Address, " +
" City, " +
" County, " +
" State, " +
" ZIPCode " +
"FROM Customers " +
"WHERE AccountNumber = N'" + strAccountNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaCustomers = new SqlDataAdapter(cmdCustomers);
sdaCustomers.Fill(dsCustomers);
foreach (DataRow drCustomer in dsCustomers.Tables[0].Rows!)
{
bCustomerFound = true;
strMeterNumber = drCustomer[0].ToString();
strCustomerName = drCustomer[1].ToString() + " " + drCustomer[2].ToString();
strAddress = drCustomer[3].ToString();
strCity = drCustomer[4].ToString();
strCounty = drCustomer[5].ToString();
strState = drCustomer[6].ToString();
strZIPCode = drCustomer[7].ToString();
break;
}
}
if (bCustomerFound == false)
{
strMessage = "There is no customer account with that number in our system.";
}
else
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
}
if (Request.Form["btnFindWaterMeter"] == "Find Water Meter")
{
strMeterNumber = Request.Form["txtMeterNumber"];
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
}
}
if (Request.Form["btnEvaluateWaterBill"] == "Evaluate Water Bill")
{
strBillNumber = Request.Form["txtBillNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strCustomerName = Request.Form["txtCustomerName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
strMeterDetails = Request.Form["txtMeterDetails"];
strMeterReadingStartDate = Request.Form["txtMeterReadingStartDate"];
strMeterReadingEndDate = Request.Form["txtMeterReadingEndDate"];
strCounterReadingStart = Request.Form["txtCounterReadingStart"];
strCounterReadingEnd = Request.Form["txtCounterReadingEnd"];
strPaymentDueDate = Request.Form["txtPaymentDueDate"];
strAmountDue = Request.Form["txtAmountDue"];
strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
strLateAmountDue = Request.Form["txtLateAmountDue"];
TimeSpan tsDays = DateTime.Parse(strMeterReadingEndDate!) - DateTime.Parse(strMeterReadingStartDate!);
strBillingDays = tsDays.Days.ToString();
string strCounterStart = Request.Form["txtCounterReadingStart"]!;
string strCounterEnd = Request.Form["txtCounterReadingEnd"]!;
double counterStart = double.Parse(strCounterStart);
double counterEnd = double.Parse(strCounterEnd);
double consumption = counterEnd - counterStart;
double gallons = consumption * 748.05;
double firstTier = gallons * (48.00 / 10000.00);
double secondTier = gallons * (32.00 / 10000.00);
double lastTier = gallons * (20.00 / 10000.00);
double waterCharges = firstTier + secondTier + lastTier;
double sewerCharges = waterCharges * 28.65 / 100;
double envCharges = waterCharges * 0.22184;
double totalCharges = waterCharges + sewerCharges + envCharges;
double localTaxes = totalCharges * 0.06148;
double stateTaxes = totalCharges * 0.01374;
double amtDue = totalCharges + localTaxes + stateTaxes;
TimeSpan tsPaymentDueDate = new TimeSpan(15, 0, 0, 0);
strMeterReadingStartDate = Request.Form["txtMeterReadingStartDate"];
strMeterReadingEndDate = Request.Form["txtMeterReadingEndDate"];
DateTime dtPmtDueDate = DateTime.Parse(strMeterReadingEndDate!) + tsPaymentDueDate;
TimeSpan tsLatePaymentDueDate = new TimeSpan(30, 0, 0, 0);
DateTime dtLatePmtDueDate = DateTime.Parse(strMeterReadingEndDate!) + tsLatePaymentDueDate;
strTotalCCF = consumption.ToString();
strTotalGallons = gallons.ToString("F");
strFirstTierConsumption = firstTier.ToString("F");
strSecondTierConsumption = secondTier.ToString("F");
strLastTierConsumption = lastTier.ToString("F");
strWaterCharges = waterCharges.ToString("F");
strSewerCharges = sewerCharges.ToString("F");
strEnvironmentCharges = envCharges.ToString("F");
strTotalCharges = totalCharges.ToString("F");
strLocalTaxes = localTaxes.ToString("F");
strStateTaxes = stateTaxes.ToString("F");
strAmountDue = amtDue.ToString("F");
strPaymentDueDate = dtPmtDueDate.ToLongDateString();
strLateAmountDue = (amtDue + 8.95).ToString("F");
strLatePaymentDueDate = dtLatePmtDueDate.ToLongDateString();
}
if (Request.Form["btnSaveWaterBill"] == "Save Water Bill")
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
strAccountNumber = Request.Form["txtAccountNumber"];
strBillNumber = Request.Form["txtBillNumber"];
strMeterReadingStartDate = Request.Form["txtMeterReadingStartDate"];
strMeterReadingEndDate = Request.Form["txtMeterReadingEndDate"];
strBillingDays = Request.Form["txtBillingDays"];
strCounterReadingStart = Request.Form["txtCounterReadingStart"];
strCounterReadingEnd = Request.Form["txtCounterReadingEnd"];
strTotalCCF = Request.Form["txtTotalCCF"];
strTotalGallons = Request.Form["txtTotalGallons"];
strFirstTierConsumption = Request.Form["txtFirstTierConsumption"];
strSecondTierConsumption = Request.Form["txtSecondTierConsumption"];
strLastTierConsumption = Request.Form["txtLastTierConsumption"];
strWaterCharges = Request.Form["txtWaterCharges"];
strSewerCharges = Request.Form["txtSewerCharges"];
strEnvironmentCharges = Request.Form["txtEnvironmentCharges"];
strTotalCharges = Request.Form["txtTotalCharges"];
strLocalTaxes = Request.Form["txtLocalTaxes"];
strStateTaxes = Request.Form["txtStateTaxes"];
strPaymentDueDate = Request.Form["txtPaymentDueDate"];
strAmountDue = Request.Form["txtAmountDue"];
strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
strLateAmountDue = Request.Form["txtLateAmountDue"];
SqlCommand cmdWaterMeters = new SqlCommand("INSERT INTO WaterBills(AccountNumber, " +
" BillNumber, " +
" MeterReadingStartDate, " +
" MeterReadingEndDate, " +
" BillingDays, " +
" CounterReadingStart, " +
" CounterReadingEnd, " +
" Consumption, " +
" TotalGallons, " +
" FirstTierConsumption, " +
" SecondTierConsumption, " +
" LastTierConsumption, " +
" WaterCharges, " +
" SewerCharges, " +
" EnvironmentCharges, " +
" TotalCharges, " +
" LocalTaxes, " +
" StateTaxes, " +
" PaymentDueDate, " +
" AmountDue, " +
" LatePaymentDueDate, " +
" LateAmountDue) " +
" VALUES(N'" + strAccountNumber + "'," +
" N'" + strBillNumber + "'," +
" N'" + strMeterReadingStartDate + "'," +
" N'" + strMeterReadingEndDate + "'," +
" N'" + strBillingDays + "'," +
" N'" + strCounterReadingStart + "'," +
" N'" + strCounterReadingEnd + "'," +
" N'" + strTotalCCF + "'," +
" N'" + strTotalGallons + "'," +
" N'" + strFirstTierConsumption + "'," +
" N'" + strSecondTierConsumption + "'," +
" N'" + strLastTierConsumption + "'," +
" N'" + strWaterCharges + "'," +
" N'" + strSewerCharges + "'," +
" N'" + strEnvironmentCharges + "'," +
" N'" + strTotalCharges + "'," +
" N'" + strLocalTaxes + "'," +
" N'" + strStateTaxes + "'," +
" N'" + strPaymentDueDate + "'," +
" N'" + strAmountDue + "'," +
" N'" + strLatePaymentDueDate + "'," +
" N'" + strLateAmountDue + "');",
scWaterDistribution);
scWaterDistribution.Open();
cmdWaterMeters.ExecuteNonQuery();
}
Response.Redirect("Index");
}
}
}
<h1 class="common-font fw-bold text-center">Water Bill Processing</h1>
<hr />
<form method="post" class="common-font">
<div class="encloser-large">
<div class="row mb-2">
<label for="txtBillNumber" class="col-form-label col-md-4 fw-bold">Bill Number</label>
<div class="col-md-3">
<input name="txtBillNumber" class="form-control" value="@strBillNumber" />
</div>
</div>
<hr />
<h3 class="fw-bold">Customer Information</h3>
<hr />
<div class="row mb-2">
<label for="txtAccountNumber" class="col-form-label col-md-4 fw-bold">Account #</label>
<div class="col-md-3">
<input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindCustomerAccount" value="Find Customer Account" class="btn btn-maroon" />
</div>
</div>
<div class="row mb-2">
<label for="txtCustomerName" class="col-form-label col-md-4 fw-bold">Customer Name</label>
<div class="col-md-8">
<input name="txtCustomerName" class="form-control" value="@strCustomerName" />
</div>
</div>
<div class="row mb-2">
<label for="txtAddress" class="col-form-label col-md-4 fw-bold">Address</label>
<div class="col-md-8">
<input name="txtAddress" class="form-control" value="@strAddress" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtCity" class="col-form-label col-md-4 fw-bold"></label>
<div class="col-md-2">
<input name="txtCity" class="form-control" value="@strCity" />
</div>
<div class="col-md-2">
<input name="txtCounty" class="form-control" value="@strCounty" />
</div>
<div class="col-md-2">
<input name="txtState" class="form-control" value="@strState" />
</div>
<div class="col-md-2">
<input name="txtZIPCode" class="form-control" value="@strZIPCode" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtMeterDetails" class="col-form-label col-md-4 fw-bold">Meter Details</label>
<div class="col-md-8">
<input name="txtMeterDetails" class="form-control" value="@strMeterDetails" />
</div>
</div>
<hr />
<h3 class="fw-bold">Meter/Counter Reading</h3>
<hr />
<div class="row mb-2">
<label for="txtMeterReadingStartDate" class="col-form-label col-md-4 fw-bold">Meter Reading Start Date</label>
<div class="col-md-6">
<input name="txtMeterReadingStartDate" class="form-control" type="date" value="@strMeterReadingStartDate" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterReadingEndDate" class="col-form-label col-md-4 fw-bold">Meter Reading End Date</label>
<div class="col-md-6">
<input name="txtMeterReadingEndDate" class="form-control" type="date" value="@strMeterReadingEndDate" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtCounterReadingStart" class="col-form-label col-md-4 fw-bold">Counter Reading Start</label>
<div class="col-md-4">
<input name="txtCounterReadingStart" class="form-control" type="number" value="@strCounterReadingStart" />
</div>
</div>
<div class="row mb-2">
<label for="txtCounterReadingEnd" class="col-form-label col-md-4 fw-bold">Counter Reading End</label>
<div class="col-md-4">
<input name="txtCounterReadingEnd" class="form-control" type="number" value="@strCounterReadingEnd" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-4 col-form-label">
</div>
<div class="col-md-7">
<input type="submit" name="btnEvaluateWaterBill"
value="Evaluate Water Bill" class="btn btn-maroon" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtBillingDays" class="col-form-label col-md-4 fw-bold">Billing Days</label>
<div class="col-md-4">
<input name="txtBillingDays" class="form-control" value="@strBillingDays" />
</div>
</div>
<div class="row mb-2">
<label for="txtTotalGallons" class="col-form-label col-md-4 fw-bold">Total Gallons</label>
<div class="col-md-4">
<input name="txtTotalGallons" class="form-control" value="@strTotalGallons" />
</div>
</div>
<hr />
<h3 class="fw-bold">Consumption</h3>
<hr />
<div class="row mb-2">
<label for="txtTotalCCF" class="col-form-label col-md-4 fw-bold">Total CCF</label>
<div class="col-md-4">
<input name="txtTotalCCF" class="form-control" value="@strTotalCCF" />
</div>
</div>
<div class="row mb-2">
<label for="txtFirstTierConsumption" class="col-form-label col-md-4 fw-bold">First Tier Consumption</label>
<div class="col-md-4">
<input name="txtFirstTierConsumption" class="form-control" value="@strFirstTierConsumption" />
</div>
</div>
<div class="row mb-2">
<label for="txtSecondTierConsumption" class="col-form-label col-md-4 fw-bold">Second Tier Consumption</label>
<div class="col-md-4">
<input name="txtSecondTierConsumption" class="form-control" value="@strSecondTierConsumption" />
</div>
</div>
<div class="row mb-2">
<label for="txtLastTierConsumption" class="col-form-label col-md-4 fw-bold">Last Tier Consumption</label>
<div class="col-md-4">
<input name="txtLastTierConsumption" class="form-control" value="@strLastTierConsumption" />
</div>
</div>
<hr />
<h3 class="fw-bold">Bill Charges</h3>
<hr />
<div class="row mb-2">
<label for="txtWaterCharges" class="col-form-label col-md-4 fw-bold">Water Charges</label>
<div class="col-md-4">
<input name="txtWaterCharges" class="form-control" value="@strWaterCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtSewerCharges" class="col-form-label col-md-4 fw-bold">Sewer Charges</label>
<div class="col-md-4">
<input name="txtSewerCharges" class="form-control" value="@strSewerCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtEnvironmentCharges" class="col-form-label col-md-4 fw-bold">Environment Charges</label>
<div class="col-md-4">
<input name="txtEnvironmentCharges" class="form-control" value="@strEnvironmentCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtTotalCharges" class="col-form-label col-md-4 fw-bold">Total Charges</label>
<div class="col-md-4">
<input name="txtTotalCharges" class="form-control" value="@strTotalCharges" />
</div>
</div>
<hr />
<h3 class="fw-bold">Taxes</h3>
<hr />
<div class="row mb-2">
<label for="txtLocalTaxes" class="col-form-label col-md-4 fw-bold">Local Taxes</label>
<div class="col-md-4">
<input name="txtLocalTaxes" class="form-control" value="@strLocalTaxes" />
</div>
</div>
<div class="row mb-2">
<label for="txtStateTaxes" class="col-form-label col-md-4 fw-bold">State Taxes</label>
<div class="col-md-4">
<input name="txtStateTaxes" class="form-control" value="@strStateTaxes" />
</div>
</div>
<hr />
<h3 class="fw-bold">Payment Details</h3>
<hr />
<div class="row mb-2">
<label for="txtAmountDue" class="col-form-label col-md-4 fw-bold">Amount Due</label>
<div class="col-md-4">
<input name="txtAmountDue" class="form-control" value="@strAmountDue" />
</div>
</div>
<div class="row mb-2">
<label for="txtPaymentDueDate" class="col-form-label col-md-4 fw-bold">Payment Due Date</label>
<div class="col-md-6">
<input name="txtPaymentDueDate" class="form-control" value="@strPaymentDueDate" />
</div>
</div>
<div class="row mb-2">
<label for="txtLateAmountDue" class="col-form-label col-md-4 fw-bold">Late Amount Due</label>
<div class="col-md-4">
<input name="txtLateAmountDue" class="form-control" value="@strLateAmountDue" />
</div>
</div>
<div class="row mb-2">
<label for="txtLatePaymentDueDate" class="col-form-label col-md-4 fw-bold">Late Payment Due Date</label>
<div class="col-md-6">
<input name="txtLatePaymentDueDate" class="form-control" value="@strLatePaymentDueDate" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index">Stellar Water Point Home</a>
</div>
<div class="col-md-7">
<input type="submit" name="btnSaveWaterBill"
value="Save Water Bill" class="btn btn-maroon" />
</div>
</div>
</div>
<p>@strMessage</p>
</form>
<hr />
<p class="text-center">
<a asp-page="./Details" class="stellar">Review a Water Bill</a> ::
<a asp-page="./Edit" class="stellar">Edit/Update a Water Bill</a> ::
<a asp-page="./Delete" class="stellar">Delete a Water Bill</a>
</p>@page
@using System.Data;
@using Microsoft.Data.SqlClient;
@model StellarWaterPoint61.Pages.WaterBills.DetailsModel
@{
ViewData["Title"] = "Water Bill Details";
bool bWaterBillFound = false;
string? strMessage = string.Empty;
string? strMeterNumber = string.Empty;
string? strMeterDetails = string.Empty;
string? strCity = string.Empty;
string? strState = string.Empty;
string? strCounty = string.Empty;
string? strZIPCode = string.Empty;
string? strAddress = string.Empty;
string? strWaterBillId = string.Empty;
string? strBillNumber = string.Empty;
string? strBillingDays = string.Empty;
string? strCustomerName = string.Empty;
string? strAccountNumber = string.Empty;
string? strCounterReadingEnd = string.Empty;
string? strCounterReadingStart = string.Empty;
string? strMeterReadingEndDate = string.Empty;
string? strMeterReadingStartDate = string.Empty;
string? strTotalCCF = string.Empty;
string? strTotalGallons = string.Empty;
string? strFirstTierConsumption = string.Empty;
string? strSecondTierConsumption = string.Empty;
string? strLastTierConsumption = string.Empty;
string? strWaterCharges = string.Empty;
string? strSewerCharges = string.Empty;
string? strEnvironmentCharges = string.Empty;
string? strTotalCharges = string.Empty;
string? strLocalTaxes = string.Empty;
string? strStateTaxes = string.Empty;
string? strPaymentDueDate = string.Empty;
string? strAmountDue = string.Empty;
string? strLatePaymentDueDate = string.Empty;
string? strLateAmountDue = string.Empty;
if (Request.HasFormContentType)
{
DataSet dsCustomers = new("CustomersSet");
DataSet dsWaterBills = new("WaterBillsSet");
DataSet dsWaterMeters = new("WaterMetersSet");
strBillNumber = Request.Form["txtBillNumber"];
if (Request.Form["btnFindWaterBill"] == "Find Water Bill")
{
if (!string.IsNullOrEmpty(strBillNumber))
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterBills = new SqlCommand("SELECT AccountNumber, " +
" MeterReadingStartDate, " +
" MeterReadingEndDate, " +
" BillingDays, " +
" CounterReadingStart, " +
" CounterReadingEnd, " +
" Consumption, " +
" TotalGallons, " +
" FirstTierConsumption, " +
" SecondTierConsumption, " +
" LastTierConsumption, " +
" WaterCharges, " +
" SewerCharges, " +
" EnvironmentCharges, " +
" TotalCharges, " +
" LocalTaxes, " +
" StateTaxes, " +
" PaymentDueDate, " +
" AmountDue, " +
" LatePaymentDueDate, " +
" LateAmountDue " +
"FROM WaterBills " +
"WHERE BillNumber = N'" + strBillNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterBills = new SqlDataAdapter(cmdWaterBills);
sdaWaterBills.Fill(dsWaterBills);
foreach (DataRow drWaterBill in dsWaterBills.Tables[0].Rows!)
{
bWaterBillFound = true;
strAccountNumber = drWaterBill[ 0].ToString();
strMeterReadingStartDate = drWaterBill[ 1].ToString();
strMeterReadingEndDate = drWaterBill[ 2].ToString();
strBillingDays = drWaterBill[ 3].ToString();
strCounterReadingStart = drWaterBill[ 4].ToString();
strCounterReadingEnd = drWaterBill[ 5].ToString();
strTotalCCF = drWaterBill[ 6].ToString();
strTotalGallons = drWaterBill[ 7].ToString();
strFirstTierConsumption = drWaterBill[ 8].ToString();
strSecondTierConsumption = drWaterBill[ 9].ToString();
strLastTierConsumption = drWaterBill[10].ToString();
strWaterCharges = drWaterBill[11].ToString();
strSewerCharges = drWaterBill[12].ToString();
strEnvironmentCharges = drWaterBill[13].ToString();
strTotalCharges = drWaterBill[14].ToString();
strLocalTaxes = drWaterBill[15].ToString();
strStateTaxes = drWaterBill[16].ToString();
strPaymentDueDate = drWaterBill[17].ToString();
strAmountDue = drWaterBill[18].ToString();
strLatePaymentDueDate = drWaterBill[19].ToString();
strLateAmountDue = drWaterBill[20].ToString();
break;
}
}
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdCustomers = new SqlCommand("SELECT MeterNumber, " +
" FirstName, " +
" LastName, " +
" Address, " +
" City, " +
" County, " +
" State, " +
" ZIPCode " +
"FROM Customers " +
"WHERE AccountNumber = N'" + strAccountNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaCustomers = new SqlDataAdapter(cmdCustomers);
sdaCustomers.Fill(dsCustomers);
foreach (DataRow drCustomer in dsCustomers.Tables[0].Rows!)
{
strMeterNumber = drCustomer[0].ToString();
strCustomerName = drCustomer[1].ToString() + " " + drCustomer[2].ToString();
strAddress = drCustomer[3].ToString();
strCity = drCustomer[4].ToString();
strCounty = drCustomer[5].ToString();
strState = drCustomer[6].ToString();
strZIPCode = drCustomer[7].ToString();
break;
}
}
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
}
if (bWaterBillFound == false)
{
strMessage = "There is no water bill with that number in our system.";
}
}
}
}
<h1 class="common-font fw-bold text-center">Water Bill Details</h1>
<hr />
<form method="post" class="common-font">
<div class="encloser-large">
<div class="row mb-2">
<label for="txtBillNumber" class="col-form-label col-md-4 fw-bold">Bill Number</label>
<div class="col-md-3">
<input name="txtBillNumber" class="form-control" value="@strBillNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindWaterBill" value="Find Water Bill" class="btn btn-maroon" />
</div>
</div>
<hr />
<h3 class="fw-bold">Customer Information</h3>
<hr />
<div class="row mb-2">
<label for="txtAccountNumber" class="col-form-label col-md-4 fw-bold">Account #</label>
<div class="col-md-3">
<input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
</div>
</div>
<div class="row mb-2">
<label for="txtCustomerName" class="col-form-label col-md-4 fw-bold">Customer Name</label>
<div class="col-md-8">
<input name="txtCustomerName" class="form-control" value="@strCustomerName" />
</div>
</div>
<div class="row mb-2">
<label for="txtAddress" class="col-form-label col-md-4 fw-bold">Address</label>
<div class="col-md-8">
<input name="txtAddress" class="form-control" value="@strAddress" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtCity" class="col-form-label col-md-4 fw-bold"></label>
<div class="col-md-2">
<input name="txtCity" class="form-control" value="@strCity" />
</div>
<div class="col-md-2">
<input name="txtCounty" class="form-control" value="@strCounty" />
</div>
<div class="col-md-2">
<input name="txtState" class="form-control" value="@strState" />
</div>
<div class="col-md-2">
<input name="txtZIPCode" class="form-control" value="@strZIPCode" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtMeterDetails" class="col-form-label col-md-4 fw-bold">Meter Details</label>
<div class="col-md-8">
<input name="txtMeterDetails" class="form-control" value="@strMeterDetails" />
</div>
</div>
<hr />
<h3 class="fw-bold">Meter/Counter Reading</h3>
<hr />
<div class="row mb-2">
<label for="txtMeterReadingStartDate" class="col-form-label col-md-4 fw-bold">Meter Reading Start Date</label>
<div class="col-md-6">
<input name="txtMeterReadingStartDate" class="form-control" type="date" value="@strMeterReadingStartDate" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterReadingEndDate" class="col-form-label col-md-4 fw-bold">Meter Reading End Date</label>
<div class="col-md-6">
<input name="txtMeterReadingEndDate" class="form-control" type="date" value="@strMeterReadingEndDate" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtCounterReadingStart" class="col-form-label col-md-4 fw-bold">Counter Reading Start</label>
<div class="col-md-4">
<input name="txtCounterReadingStart" class="form-control" type="number" value="@strCounterReadingStart" />
</div>
</div>
<div class="row mb-2">
<label for="txtCounterReadingEnd" class="col-form-label col-md-4 fw-bold">Counter Reading End</label>
<div class="col-md-4">
<input name="txtCounterReadingEnd" class="form-control" type="number" value="@strCounterReadingEnd" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-4 col-form-label">
</div>
<div class="col-md-7">
<input type="submit" name="btnEvaluateWaterBill"
value="Evaluate Water Bill" class="btn btn-maroon" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtBillingDays" class="col-form-label col-md-4 fw-bold">Billing Days</label>
<div class="col-md-4">
<input name="txtBillingDays" class="form-control" value="@strBillingDays" />
</div>
</div>
<div class="row mb-2">
<label for="txtTotalGallons" class="col-form-label col-md-4 fw-bold">Total Gallons</label>
<div class="col-md-4">
<input name="txtTotalGallons" class="form-control" value="@strTotalGallons" />
</div>
</div>
<hr />
<h3 class="fw-bold">Consumption</h3>
<hr />
<div class="row mb-2">
<label for="txtTotalCCF" class="col-form-label col-md-4 fw-bold">Total CCF</label>
<div class="col-md-4">
<input name="txtTotalCCF" class="form-control" value="@strTotalCCF" />
</div>
</div>
<div class="row mb-2">
<label for="txtFirstTierConsumption" class="col-form-label col-md-4 fw-bold">First Tier Consumption</label>
<div class="col-md-4">
<input name="txtFirstTierConsumption" class="form-control" value="@strFirstTierConsumption" />
</div>
</div>
<div class="row mb-2">
<label for="txtSecondTierConsumption" class="col-form-label col-md-4 fw-bold">Second Tier Consumption</label>
<div class="col-md-4">
<input name="txtSecondTierConsumption" class="form-control" value="@strSecondTierConsumption" />
</div>
</div>
<div class="row mb-2">
<label for="txtLastTierConsumption" class="col-form-label col-md-4 fw-bold">Last Tier Consumption</label>
<div class="col-md-4">
<input name="txtLastTierConsumption" class="form-control" value="@strLastTierConsumption" />
</div>
</div>
<hr />
<h3 class="fw-bold">Bill Charges</h3>
<hr />
<div class="row mb-2">
<label for="txtWaterCharges" class="col-form-label col-md-4 fw-bold">Water Charges</label>
<div class="col-md-4">
<input name="txtWaterCharges" class="form-control" value="@strWaterCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtSewerCharges" class="col-form-label col-md-4 fw-bold">Sewer Charges</label>
<div class="col-md-4">
<input name="txtSewerCharges" class="form-control" value="@strSewerCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtEnvironmentCharges" class="col-form-label col-md-4 fw-bold">Environment Charges</label>
<div class="col-md-4">
<input name="txtEnvironmentCharges" class="form-control" value="@strEnvironmentCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtTotalCharges" class="col-form-label col-md-4 fw-bold">Total Charges</label>
<div class="col-md-4">
<input name="txtTotalCharges" class="form-control" value="@strTotalCharges" />
</div>
</div>
<hr />
<h3 class="fw-bold">Taxes</h3>
<hr />
<div class="row mb-2">
<label for="txtLocalTaxes" class="col-form-label col-md-4 fw-bold">Local Taxes</label>
<div class="col-md-4">
<input name="txtLocalTaxes" class="form-control" value="@strLocalTaxes" />
</div>
</div>
<div class="row mb-2">
<label for="txtStateTaxes" class="col-form-label col-md-4 fw-bold">State Taxes</label>
<div class="col-md-4">
<input name="txtStateTaxes" class="form-control" value="@strStateTaxes" />
</div>
</div>
<hr />
<h3 class="fw-bold">Payment Details</h3>
<hr />
<div class="row mb-2">
<label for="txtAmountDue" class="col-form-label col-md-4 fw-bold">Amount Due</label>
<div class="col-md-4">
<input name="txtAmountDue" class="form-control" value="@strAmountDue" />
</div>
</div>
<div class="row mb-2">
<label for="txtPaymentDueDate" class="col-form-label col-md-4 fw-bold">Payment Due Date</label>
<div class="col-md-6">
<input name="txtPaymentDueDate" class="form-control" value="@strPaymentDueDate" />
</div>
</div>
<div class="row mb-2">
<label for="txtLateAmountDue" class="col-form-label col-md-4 fw-bold">Late Amount Due</label>
<div class="col-md-4">
<input name="txtLateAmountDue" class="form-control" value="@strLateAmountDue" />
</div>
</div>
<div class="row mb-2">
<label for="txtLatePaymentDueDate" class="col-form-label col-md-4 fw-bold">Late Payment Due Date</label>
<div class="col-md-6">
<input name="txtLatePaymentDueDate" class="form-control" value="@strLatePaymentDueDate" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
</div>
<div class="col-md-7">
<a asp-page="Index">Water Bills</a>
</div>
</div>
</div>
<p>@strMessage</p>
</form>
<hr />
<p class="text-center">
<a asp-page="./Create" class="stellar">Prepare a Water Bill</a> ::
<a asp-page="./Edit" class="stellar">Edit/Update a Water Bill</a> ::
<a asp-page="./Delete" class="stellar">Delete a Water Bill</a>
</p>@page
@using System.Data;
@using Microsoft.Data.SqlClient;
@model StellarWaterPoint61.Pages.WaterBills.EditModel
@{
ViewData["Title"] = "Water Bill Processing";
bool bCustomerFound = false;
bool bWaterBillFound = false;
string? strMessage = string.Empty;
string? strBillNumber = string.Empty;
string? strCity = string.Empty;
string? strState = string.Empty;
string? strCounty = string.Empty;
string? strZIPCode = string.Empty;
string? strAddress = string.Empty;
string? strCustomerName = string.Empty;
string? strAccountNumber = string.Empty;
string? strMeterNumber = string.Empty;
string? strMeterDetails = string.Empty;
string? strTotalCCF = string.Empty;
string? strAmountDue = string.Empty;
string? strLocalTaxes = string.Empty;
string? strStateTaxes = string.Empty;
string? strBillingDays = string.Empty;
string? strSewerCharges = string.Empty;
string? strWaterCharges = string.Empty;
string? strTotalGallons = string.Empty;
string? strTotalCharges = string.Empty;
string? strLateAmountDue = string.Empty;
string? strPaymentDueDate = string.Empty;
string? strCounterReadingEnd = string.Empty;
string? strEnvironmentCharges = string.Empty;
string? strLatePaymentDueDate = string.Empty;
string? strLastTierConsumption = string.Empty;
string? strCounterReadingStart = string.Empty;
string? strMeterReadingEndDate = string.Empty;
string? strFirstTierConsumption = string.Empty;
string? strMeterReadingStartDate = string.Empty;
string? strSecondTierConsumption = string.Empty;
if(Request.HasFormContentType)
{
DataSet dsCustomers = new("CustomersSet");
DataSet dsWaterBills = new("WaterBillsSet");
DataSet dsWaterMeters = new("WaterMetersSet");
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strCustomerName = Request.Form["txtCustomerName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
strMeterReadingStartDate = Request.Form["txtMeterReadingStartDate"];
strMeterReadingEndDate = Request.Form["txtMeterReadingEndDate"];
strCounterReadingStart = Request.Form["txtCounterReadingStart"];
strCounterReadingEnd = Request.Form["txtCounterReadingEnd"];
strBillingDays = Request.Form["txtBillingDays"];
strTotalCCF = Request.Form["txtTotalCCF"];
strTotalGallons = Request.Form["txtTotalGallons"];
strFirstTierConsumption = Request.Form["txtFirstTierConsumption"];
strSecondTierConsumption = Request.Form["txtSecondTierConsumption"];
strLastTierConsumption = Request.Form["txtLastTierConsumption"];
strWaterCharges = Request.Form["txtWaterCharges"];
strSewerCharges = Request.Form["txtSewerCharges"];
strEnvironmentCharges = Request.Form["txtEnvironmentCharges"];
strTotalCharges = Request.Form["txtTotalCharges"];
strLocalTaxes = Request.Form["txtLocalTaxes"];
strStateTaxes = Request.Form["txtStateTaxes"];
strPaymentDueDate = Request.Form["txtPaymentDueDate"];
strAmountDue = Request.Form["txtAmountDue"];
strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
strLateAmountDue = Request.Form["txtLateAmountDue"];
strBillNumber = Request.Form["txtBillNumber"];
if (Request.Form["btnFindWaterBill"] == "Find Water Bill")
{
if (!string.IsNullOrEmpty(strBillNumber))
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterBills = new SqlCommand("SELECT AccountNumber, " +
" MeterReadingStartDate, " +
" MeterReadingEndDate, " +
" BillingDays, " +
" CounterReadingStart, " +
" CounterReadingEnd, " +
" Consumption, " +
" TotalGallons, " +
" FirstTierConsumption, " +
" SecondTierConsumption, " +
" LastTierConsumption, " +
" WaterCharges, " +
" SewerCharges, " +
" EnvironmentCharges, " +
" TotalCharges, " +
" LocalTaxes, " +
" StateTaxes, " +
" PaymentDueDate, " +
" AmountDue, " +
" LatePaymentDueDate, " +
" LateAmountDue " +
"FROM WaterBills " +
"WHERE BillNumber = N'" + strBillNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterBills = new SqlDataAdapter(cmdWaterBills);
sdaWaterBills.Fill(dsWaterBills);
if (dsWaterBills.Tables[0].Rows.Count > 0)
{
bWaterBillFound = true;
}
foreach (DataRow drWaterBill in dsWaterBills.Tables[0].Rows!)
{
strAccountNumber = drWaterBill[0].ToString();
strMeterReadingStartDate = drWaterBill[1].ToString();
strMeterReadingEndDate = drWaterBill[2].ToString();
strBillingDays = drWaterBill[3].ToString();
strCounterReadingStart = drWaterBill[4].ToString();
strCounterReadingEnd = drWaterBill[5].ToString();
strTotalCCF = drWaterBill[6].ToString();
strTotalGallons = drWaterBill[7].ToString();
strFirstTierConsumption = drWaterBill[8].ToString();
strSecondTierConsumption = drWaterBill[9].ToString();
strLastTierConsumption = drWaterBill[10].ToString();
strWaterCharges = drWaterBill[11].ToString();
strSewerCharges = drWaterBill[12].ToString();
strEnvironmentCharges = drWaterBill[13].ToString();
strTotalCharges = drWaterBill[14].ToString();
strLocalTaxes = drWaterBill[15].ToString();
strStateTaxes = drWaterBill[16].ToString();
strPaymentDueDate = drWaterBill[17].ToString();
strAmountDue = drWaterBill[18].ToString();
strLatePaymentDueDate = drWaterBill[19].ToString();
strLateAmountDue = drWaterBill[20].ToString();
break;
}
}
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdCustomers = new SqlCommand("SELECT MeterNumber, " +
" FirstName, " +
" LastName, " +
" Address, " +
" City, " +
" County, " +
" State, " +
" ZIPCode " +
"FROM Customers " +
"WHERE AccountNumber = N'" + strAccountNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaCustomers = new SqlDataAdapter(cmdCustomers);
sdaCustomers.Fill(dsCustomers);
foreach (DataRow drCustomer in dsCustomers.Tables[0].Rows!)
{
bCustomerFound = true;
strMeterNumber = drCustomer[0].ToString();
strCustomerName = drCustomer[1].ToString() + " " + drCustomer[2].ToString();
strAddress = drCustomer[3].ToString();
strCity = drCustomer[4].ToString();
strCounty = drCustomer[5].ToString();
strState = drCustomer[6].ToString();
strZIPCode = drCustomer[7].ToString();
break;
}
}
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
}
}
if (Request.Form["btnFindCustomerAccount"] == "Find Customer Account")
{
strBillNumber = Request.Form["txtBillNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strMeterDetails = Request.Form["txtMeterDetails"];
strPaymentDueDate = Request.Form["txtPaymentDueDate"];
strAmountDue = Request.Form["txtAmountDue"];
strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
strLateAmountDue = Request.Form["txtLateAmountDue"];
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdCustomers = new SqlCommand("SELECT MeterNumber, " +
" FirstName, " +
" LastName, " +
" Address, " +
" City, " +
" County, " +
" State, " +
" ZIPCode " +
"FROM Customers " +
"WHERE AccountNumber = N'" + strAccountNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaCustomers = new SqlDataAdapter(cmdCustomers);
sdaCustomers.Fill(dsCustomers);
foreach (DataRow drCustomer in dsCustomers.Tables[0].Rows!)
{
bCustomerFound = true;
strMeterNumber = drCustomer[0].ToString();
strCustomerName = drCustomer[1].ToString() + " " + drCustomer[2].ToString();
strAddress = drCustomer[3].ToString();
strCity = drCustomer[4].ToString();
strCounty = drCustomer[5].ToString();
strState = drCustomer[6].ToString();
strZIPCode = drCustomer[7].ToString();
break;
}
}
if (bCustomerFound == false)
{
strMessage = "There is no customer account with that number in our system.";
}
else
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
}
}
if (Request.Form["btnEvaluateWaterBill"] == "Evaluate Water Bill")
{
strBillNumber = Request.Form["txtBillNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strMeterDetails = Request.Form["txtMeterDetails"];
strCustomerName = Request.Form["txtCustomerName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
strMeterReadingStartDate = Request.Form["txtMeterReadingStartDate"];
strMeterReadingEndDate = Request.Form["txtMeterReadingEndDate"];
strCounterReadingStart = Request.Form["txtCounterReadingStart"];
strCounterReadingEnd = Request.Form["txtCounterReadingEnd"];
strPaymentDueDate = Request.Form["txtPaymentDueDate"];
strAmountDue = Request.Form["txtAmountDue"];
strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
strLateAmountDue = Request.Form["txtLateAmountDue"];
TimeSpan tsDays = DateTime.Parse(strMeterReadingEndDate!) - DateTime.Parse(strMeterReadingStartDate!);
strBillingDays = tsDays.Days.ToString();
string strCounterStart = Request.Form["txtCounterReadingStart"]!;
string strCounterEnd = Request.Form["txtCounterReadingEnd"]!;
double counterStart = double.Parse(strCounterStart);
double counterEnd = double.Parse(strCounterEnd);
double consumption = counterEnd - counterStart;
double gallons = consumption * 748.05;
double firstTier = gallons * (48.00 / 10000.00);
double secondTier = gallons * (32.00 / 10000.00);
double lastTier = gallons * (20.00 / 10000.00);
double waterCharges = firstTier + secondTier + lastTier;
double sewerCharges = waterCharges * 28.65 / 100;
double envCharges = waterCharges * 0.22184;
double totalCharges = waterCharges + sewerCharges + envCharges;
double localTaxes = totalCharges * 0.06148;
double stateTaxes = totalCharges * 0.01374;
double amtDue = totalCharges + localTaxes + stateTaxes;
TimeSpan tsPaymentDueDate = new TimeSpan(15, 0, 0, 0);
strMeterReadingStartDate = Request.Form["txtMeterReadingStartDate"];
strMeterReadingEndDate = Request.Form["txtMeterReadingEndDate"];
DateTime dtPmtDueDate = DateTime.Parse(strMeterReadingEndDate!) + tsPaymentDueDate;
TimeSpan tsLatePaymentDueDate = new TimeSpan(30, 0, 0, 0);
DateTime dtLatePmtDueDate = DateTime.Parse(strMeterReadingEndDate!) + tsLatePaymentDueDate;
strTotalCCF = consumption.ToString();
strTotalGallons = gallons.ToString("F");
strFirstTierConsumption = firstTier.ToString("F");
strSecondTierConsumption = secondTier.ToString("F");
strLastTierConsumption = lastTier.ToString("F");
strWaterCharges = waterCharges.ToString("F");
strSewerCharges = sewerCharges.ToString("F");
strEnvironmentCharges = envCharges.ToString("F");
strTotalCharges = totalCharges.ToString("F");
strLocalTaxes = localTaxes.ToString("F");
strStateTaxes = stateTaxes.ToString("F");
strAmountDue = amtDue.ToString("F");
strPaymentDueDate = dtPmtDueDate.ToLongDateString();
strLateAmountDue = (amtDue + 8.95).ToString("F");
strLatePaymentDueDate = dtLatePmtDueDate.ToLongDateString();
}
if (Request.Form["btnUpdateWaterBill"] == "Update Water Bill")
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
strAccountNumber = Request.Form["txtAccountNumber"];
strBillNumber = Request.Form["txtBillNumber"];
strMeterReadingStartDate = Request.Form["txtMeterReadingStartDate"];
strMeterReadingEndDate = Request.Form["txtMeterReadingEndDate"];
strBillingDays = Request.Form["txtBillingDays"];
strCounterReadingStart = Request.Form["txtCounterReadingStart"];
strCounterReadingEnd = Request.Form["txtCounterReadingEnd"];
strTotalCCF = Request.Form["txtTotalCCF"];
strTotalGallons = Request.Form["txtTotalGallons"];
strFirstTierConsumption = Request.Form["txtFirstTierConsumption"];
strSecondTierConsumption = Request.Form["txtSecondTierConsumption"];
strLastTierConsumption = Request.Form["txtLastTierConsumption"];
strWaterCharges = Request.Form["txtWaterCharges"];
strSewerCharges = Request.Form["txtSewerCharges"];
strEnvironmentCharges = Request.Form["txtEnvironmentCharges"];
strTotalCharges = Request.Form["txtTotalCharges"];
strLocalTaxes = Request.Form["txtLocalTaxes"];
strStateTaxes = Request.Form["txtStateTaxes"];
strPaymentDueDate = Request.Form["txtPaymentDueDate"];
strAmountDue = Request.Form["txtAmountDue"];
strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
strLateAmountDue = Request.Form["txtLateAmountDue"];
SqlCommand cmdWaterMeters = new SqlCommand("UPDATE WaterBills SET AccountNumber = N'" + strAccountNumber + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET MeterReadingStartDate = N'" + strMeterReadingStartDate + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET MeterReadingEndDate = N'" + strMeterReadingEndDate + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET BillingDays = N'" + strBillingDays + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET CounterReadingStart = N'" + strCounterReadingStart + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET CounterReadingEnd = N'" + strCounterReadingEnd + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET Consumption = N'" + strTotalCCF + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET TotalGallons = N'" + strTotalGallons + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET FirstTierConsumption = N'" + strFirstTierConsumption + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET SecondTierConsumption = N'" + strSecondTierConsumption + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET LastTierConsumption = N'" + strLastTierConsumption + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET WaterCharges = N'" + strWaterCharges + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET SewerCharges = N'" + strSewerCharges + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET EnvironmentCharges = N'" + strEnvironmentCharges + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET TotalCharges = N'" + strTotalCharges + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET LocalTaxes = N'" + strLocalTaxes + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET StateTaxes = N'" + strStateTaxes + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET PaymentDueDate = N'" + strPaymentDueDate + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET AmountDue = N'" + strAmountDue + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET LatePaymentDueDate = N'" + strLatePaymentDueDate + "' WHERE BillNumber = N'" + strBillNumber + "';" +
"UPDATE WaterBills SET LateAmountDue = N'" + strLateAmountDue + "' WHERE BillNumber = N'" + strBillNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
cmdWaterMeters.ExecuteNonQuery();
}
Response.Redirect("Index");
}
}
}
<h1 class="common-font fw-bold text-center">Edit/Update a Water Bill</h1>
<hr />
<form method="post" class="common-font">
<div class="encloser-large">
<div class="row mb-2">
<label for="txtBillNumber" class="col-form-label col-md-4 fw-bold">Bill Number</label>
<div class="col-md-3">
<input name="txtBillNumber" class="form-control" value="@strBillNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindWaterBill" value="Find Water Bill" class="btn btn-maroon" />
</div>
</div>
<hr />
<h3 class="fw-bold">Customer Information</h3>
<hr />
<div class="row mb-2">
<label for="txtAccountNumber" class="col-form-label col-md-4 fw-bold">Account #</label>
<div class="col-md-3">
<input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindCustomerAccount" value="Find Customer Account" class="btn btn-maroon" />
</div>
</div>
<div class="row mb-2">
<label for="txtCustomerName" class="col-form-label col-md-4 fw-bold">Customer Name</label>
<div class="col-md-8">
<input name="txtCustomerName" class="form-control" value="@strCustomerName" />
</div>
</div>
<div class="row mb-2">
<label for="txtAddress" class="col-form-label col-md-4 fw-bold">Address</label>
<div class="col-md-8">
<input name="txtAddress" class="form-control" value="@strAddress" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtCity" class="col-form-label col-md-4 fw-bold"></label>
<div class="col-md-2">
<input name="txtCity" class="form-control" value="@strCity" />
</div>
<div class="col-md-2">
<input name="txtCounty" class="form-control" value="@strCounty" />
</div>
<div class="col-md-2">
<input name="txtState" class="form-control" value="@strState" />
</div>
<div class="col-md-2">
<input name="txtZIPCode" class="form-control" value="@strZIPCode" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtMeterDetails" class="col-form-label col-md-4 fw-bold">Meter Details</label>
<div class="col-md-8">
<input name="txtMeterDetails" class="form-control" value="@strMeterDetails" />
</div>
</div>
<hr />
<h3 class="fw-bold">Meter/Counter Reading</h3>
<hr />
<div class="row mb-2">
<label for="txtMeterReadingStartDate" class="col-form-label col-md-4 fw-bold">Meter Reading Start Date</label>
<div class="col-md-6">
<input name="txtMeterReadingStartDate" class="form-control" type="date" value="@strMeterReadingStartDate" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterReadingEndDate" class="col-form-label col-md-4 fw-bold">Meter Reading End Date</label>
<div class="col-md-6">
<input name="txtMeterReadingEndDate" class="form-control" type="date" value="@strMeterReadingEndDate" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtCounterReadingStart" class="col-form-label col-md-4 fw-bold">Counter Reading Start</label>
<div class="col-md-4">
<input name="txtCounterReadingStart" class="form-control" type="number" value="@strCounterReadingStart" />
</div>
</div>
<div class="row mb-2">
<label for="txtCounterReadingEnd" class="col-form-label col-md-4 fw-bold">Counter Reading End</label>
<div class="col-md-4">
<input name="txtCounterReadingEnd" class="form-control" type="number" value="@strCounterReadingEnd" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-4 col-form-label">
</div>
<div class="col-md-7">
<input type="submit" name="btnEvaluateWaterBill"
value="Evaluate Water Bill" class="btn btn-maroon" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtBillingDays" class="col-form-label col-md-4 fw-bold">Billing Days</label>
<div class="col-md-4">
<input name="txtBillingDays" class="form-control" value="@strBillingDays" />
</div>
</div>
<div class="row mb-2">
<label for="txtTotalGallons" class="col-form-label col-md-4 fw-bold">Total Gallons</label>
<div class="col-md-4">
<input name="txtTotalGallons" class="form-control" value="@strTotalGallons" />
</div>
</div>
<hr />
<h3 class="fw-bold">Consumption</h3>
<hr />
<div class="row mb-2">
<label for="txtTotalCCF" class="col-form-label col-md-4 fw-bold">Total CCF</label>
<div class="col-md-4">
<input name="txtTotalCCF" class="form-control" value="@strTotalCCF" />
</div>
</div>
<div class="row mb-2">
<label for="txtFirstTierConsumption" class="col-form-label col-md-4 fw-bold">First Tier Consumption</label>
<div class="col-md-4">
<input name="txtFirstTierConsumption" class="form-control" value="@strFirstTierConsumption" />
</div>
</div>
<div class="row mb-2">
<label for="txtSecondTierConsumption" class="col-form-label col-md-4 fw-bold">Second Tier Consumption</label>
<div class="col-md-4">
<input name="txtSecondTierConsumption" class="form-control" value="@strSecondTierConsumption" />
</div>
</div>
<div class="row mb-2">
<label for="txtLastTierConsumption" class="col-form-label col-md-4 fw-bold">Last Tier Consumption</label>
<div class="col-md-4">
<input name="txtLastTierConsumption" class="form-control" value="@strLastTierConsumption" />
</div>
</div>
<hr />
<h3 class="fw-bold">Bill Charges</h3>
<hr />
<div class="row mb-2">
<label for="txtWaterCharges" class="col-form-label col-md-4 fw-bold">Water Charges</label>
<div class="col-md-4">
<input name="txtWaterCharges" class="form-control" value="@strWaterCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtSewerCharges" class="col-form-label col-md-4 fw-bold">Sewer Charges</label>
<div class="col-md-4">
<input name="txtSewerCharges" class="form-control" value="@strSewerCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtEnvironmentCharges" class="col-form-label col-md-4 fw-bold">Environment Charges</label>
<div class="col-md-4">
<input name="txtEnvironmentCharges" class="form-control" value="@strEnvironmentCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtTotalCharges" class="col-form-label col-md-4 fw-bold">Total Charges</label>
<div class="col-md-4">
<input name="txtTotalCharges" class="form-control" value="@strTotalCharges" />
</div>
</div>
<hr />
<h3 class="fw-bold">Taxes</h3>
<hr />
<div class="row mb-2">
<label for="txtLocalTaxes" class="col-form-label col-md-4 fw-bold">Local Taxes</label>
<div class="col-md-4">
<input name="txtLocalTaxes" class="form-control" value="@strLocalTaxes" />
</div>
</div>
<div class="row mb-2">
<label for="txtStateTaxes" class="col-form-label col-md-4 fw-bold">State Taxes</label>
<div class="col-md-4">
<input name="txtStateTaxes" class="form-control" value="@strStateTaxes" />
</div>
</div>
<hr />
<h3 class="fw-bold">Payment Details</h3>
<hr />
<div class="row mb-2">
<label for="txtAmountDue" class="col-form-label col-md-4 fw-bold">Amount Due</label>
<div class="col-md-4">
<input name="txtAmountDue" class="form-control" value="@strAmountDue" />
</div>
</div>
<div class="row mb-2">
<label for="txtPaymentDueDate" class="col-form-label col-md-4 fw-bold">Payment Due Date</label>
<div class="col-md-6">
<input name="txtPaymentDueDate" class="form-control" value="@strPaymentDueDate" />
</div>
</div>
<div class="row mb-2">
<label for="txtLateAmountDue" class="col-form-label col-md-4 fw-bold">Late Amount Due</label>
<div class="col-md-4">
<input name="txtLateAmountDue" class="form-control" value="@strLateAmountDue" />
</div>
</div>
<div class="row mb-2">
<label for="txtLatePaymentDueDate" class="col-form-label col-md-4 fw-bold">Late Payment Due Date</label>
<div class="col-md-6">
<input name="txtLatePaymentDueDate" class="form-control" value="@strLatePaymentDueDate" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index">Stellar Water Point Home</a>
</div>
<div class="col-md-7">
<input type="submit" name="btnUpdateWaterBill"
value="Update Water Bill" class="btn btn-maroon" />
</div>
</div>
</div>
<p>@strMessage</p>
</form>
<hr />
<p class="text-center">
<a asp-page="./Create" class="stellar">Prepare a New Water Bill</a> ::
<a asp-page="./Details" class="stellar">Review an Existing Water Bill</a> ::
<a asp-page="./Delete" class="stellar">Delete an Existing Water Bill</a>
</p>@page
@using System.Data;
@using Microsoft.Data.SqlClient;
@model StellarWaterPoint61.Pages.WaterBills.DeleteModel
@{
ViewData["Title"] = "Water Bill Deletion";
bool bWaterBillFound = false;
string? strMessage = string.Empty;
string? strMeterNumber = string.Empty;
string? strMeterDetails = string.Empty;
string? strCity = string.Empty;
string? strState = string.Empty;
string? strCounty = string.Empty;
string? strZIPCode = string.Empty;
string? strAddress = string.Empty;
string? strBillNumber = string.Empty;
string? strBillingDays = string.Empty;
string? strCustomerName = string.Empty;
string? strAccountNumber = string.Empty;
string? strCounterReadingEnd = string.Empty;
string? strCounterReadingStart = string.Empty;
string? strMeterReadingEndDate = string.Empty;
string? strMeterReadingStartDate = string.Empty;
string? strTotalCCF = string.Empty;
string? strTotalGallons = string.Empty;
string? strFirstTierConsumption = string.Empty;
string? strSecondTierConsumption = string.Empty;
string? strLastTierConsumption = string.Empty;
string? strWaterCharges = string.Empty;
string? strSewerCharges = string.Empty;
string? strEnvironmentCharges = string.Empty;
string? strTotalCharges = string.Empty;
string? strLocalTaxes = string.Empty;
string? strStateTaxes = string.Empty;
string? strPaymentDueDate = string.Empty;
string? strAmountDue = string.Empty;
string? strLatePaymentDueDate = string.Empty;
string? strLateAmountDue = string.Empty;
if (Request.HasFormContentType)
{
DataSet dsCustomers = new("CustomersSet");
DataSet dsWaterBills = new("WaterBillsSet");
DataSet dsWaterMeters = new("WaterMetersSet");
/* strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strAccountNumber = Request.Form["txtAccountNumber"];
strMeterNumber = Request.Form["txtMeterNumber"];
strCustomerName = Request.Form["txtCustomerName"];
strAddress = Request.Form["txtAddress"];
strCity = Request.Form["txtCity"];
strCounty = Request.Form["txtCounty"];
strState = Request.Form["txtState"];
strZIPCode = Request.Form["txtZIPCode"];
strMeterReadingStartDate = Request.Form["txtMeterReadingStartDate"];
strMeterReadingEndDate = Request.Form["txtMeterReadingEndDate"];
strCounterReadingStart = Request.Form["txtCounterReadingStart"];
strCounterReadingEnd = Request.Form["txtCounterReadingEnd"];
strBillingDays = Request.Form["txtBillingDays"];
strTotalCCF = Request.Form["txtTotalCCF"];
strTotalGallons = Request.Form["txtTotalGallons"];
strFirstTierConsumption = Request.Form["txtFirstTierConsumption"];
strSecondTierConsumption = Request.Form["txtSecondTierConsumption"];
strLastTierConsumption = Request.Form["txtLastTierConsumption"];
strWaterCharges = Request.Form["txtWaterCharges"];
strSewerCharges = Request.Form["txtSewerCharges"];
strEnvironmentCharges = Request.Form["txtEnvironmentCharges"];
strTotalCharges = Request.Form["txtTotalCharges"];
strLocalTaxes = Request.Form["txtLocalTaxes"];
strStateTaxes = Request.Form["txtStateTaxes"];
strPaymentDueDate = Request.Form["txtPaymentDueDate"];
strAmountDue = Request.Form["txtAmountDue"];
strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
strLateAmountDue = Request.Form["txtLateAmountDue"]; */
strBillNumber = Request.Form["txtBillNumber"];
if (Request.Form["btnFindWaterBill"] == "Find Water Bill")
{
if (!string.IsNullOrEmpty(strBillNumber))
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterBills = new SqlCommand("SELECT AccountNumber, " +
" MeterReadingStartDate, " +
" MeterReadingEndDate, " +
" BillingDays, " +
" CounterReadingStart, " +
" CounterReadingEnd, " +
" Consumption, " +
" TotalGallons, " +
" FirstTierConsumption, " +
" SecondTierConsumption, " +
" LastTierConsumption, " +
" WaterCharges, " +
" SewerCharges, " +
" EnvironmentCharges, " +
" TotalCharges, " +
" LocalTaxes, " +
" StateTaxes, " +
" PaymentDueDate, " +
" AmountDue, " +
" LatePaymentDueDate, " +
" LateAmountDue " +
"FROM WaterBills " +
"WHERE BillNumber = N'" + strBillNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterBills = new SqlDataAdapter(cmdWaterBills);
sdaWaterBills.Fill(dsWaterBills);
if (dsWaterBills.Tables[0].Rows.Count > 0)
{
bWaterBillFound = true;
}
foreach (DataRow drWaterBill in dsWaterBills.Tables[0].Rows!)
{
strAccountNumber = drWaterBill[0].ToString();
strMeterReadingStartDate = drWaterBill[1].ToString();
strMeterReadingEndDate = drWaterBill[2].ToString();
strBillingDays = drWaterBill[3].ToString();
strCounterReadingStart = drWaterBill[4].ToString();
strCounterReadingEnd = drWaterBill[5].ToString();
strTotalCCF = drWaterBill[6].ToString();
strTotalGallons = drWaterBill[7].ToString();
strFirstTierConsumption = drWaterBill[8].ToString();
strSecondTierConsumption = drWaterBill[9].ToString();
strLastTierConsumption = drWaterBill[10].ToString();
strWaterCharges = drWaterBill[11].ToString();
strSewerCharges = drWaterBill[12].ToString();
strEnvironmentCharges = drWaterBill[13].ToString();
strTotalCharges = drWaterBill[14].ToString();
strLocalTaxes = drWaterBill[15].ToString();
strStateTaxes = drWaterBill[16].ToString();
strPaymentDueDate = drWaterBill[17].ToString();
strAmountDue = drWaterBill[18].ToString();
strLatePaymentDueDate = drWaterBill[19].ToString();
strLateAmountDue = drWaterBill[20].ToString();
break;
}
}
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdCustomers = new SqlCommand("SELECT MeterNumber, " +
" FirstName, " +
" LastName, " +
" Address, " +
" City, " +
" County, " +
" State, " +
" ZIPCode " +
"FROM Customers " +
"WHERE AccountNumber = N'" + strAccountNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaCustomers = new SqlDataAdapter(cmdCustomers);
sdaCustomers.Fill(dsCustomers);
foreach (DataRow drCustomer in dsCustomers.Tables[0].Rows!)
{
strMeterNumber = drCustomer[0].ToString();
strCustomerName = drCustomer[1].ToString() + " " + drCustomer[2].ToString();
strAddress = drCustomer[3].ToString();
strCity = drCustomer[4].ToString();
strCounty = drCustomer[5].ToString();
strState = drCustomer[6].ToString();
strZIPCode = drCustomer[7].ToString();
break;
}
}
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("SELECT Make, Model, MeterSize " +
"FROM WaterMeters " +
"WHERE MeterNumber = N'" + strMeterNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
SqlDataAdapter sdaWaterMeters = new SqlDataAdapter(cmdWaterMeters);
sdaWaterMeters.Fill(dsWaterMeters);
foreach (DataRow drWaterMeter in dsWaterMeters.Tables[0].Rows!)
{
strMeterDetails = drWaterMeter[0].ToString() + " " +
drWaterMeter[1].ToString() +
" (Meter Size: " + drWaterMeter[2].ToString() + ")";
break;
}
}
}
}
if (Request.Form["btnDeleteWaterBill"] == "Delete Water Bill")
{
using (SqlConnection scWaterDistribution = new SqlConnection("Data Source=(local);" +
"Initial Catalog='StellarWaterPoint1';" +
"Integrated Security=True;"))
{
SqlCommand cmdWaterMeters = new SqlCommand("DELETE WaterBills WHERE BillNumber = N'" + strBillNumber + "';",
scWaterDistribution);
scWaterDistribution.Open();
cmdWaterMeters.ExecuteNonQuery();
}
Response.Redirect("Index");
}
}
}
<h1 class="common-font fw-bold text-center">Water Bill Deletion</h1>
<hr />
<form method="post" class="common-font">
<div class="encloser-large">
<div class="row mb-2">
<label for="txtBillNumber" class="col-form-label col-md-4 fw-bold">Bill Number</label>
<div class="col-md-3">
<input name="txtBillNumber" class="form-control" value="@strBillNumber" />
</div>
<div class="col-md-4">
<input type="submit" name="btnFindWaterBill" value="Find Water Bill" class="btn btn-maroon" />
</div>
</div>
<hr />
<h3 class="fw-bold">Customer Information</h3>
<hr />
<div class="row mb-2">
<label for="txtAccountNumber" class="col-form-label col-md-4 fw-bold">Account #</label>
<div class="col-md-3">
<input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
</div>
</div>
<div class="row mb-2">
<label for="txtCustomerName" class="col-form-label col-md-4 fw-bold">Customer Name</label>
<div class="col-md-8">
<input name="txtCustomerName" class="form-control" value="@strCustomerName" />
</div>
</div>
<div class="row mb-2">
<label for="txtAddress" class="col-form-label col-md-4 fw-bold">Address</label>
<div class="col-md-8">
<input name="txtAddress" class="form-control" value="@strAddress" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtCity" class="col-form-label col-md-4 fw-bold"></label>
<div class="col-md-2">
<input name="txtCity" class="form-control" value="@strCity" />
</div>
<div class="col-md-2">
<input name="txtCounty" class="form-control" value="@strCounty" />
</div>
<div class="col-md-2">
<input name="txtState" class="form-control" value="@strState" />
</div>
<div class="col-md-2">
<input name="txtZIPCode" class="form-control" value="@strZIPCode" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtMeterDetails" class="col-form-label col-md-4 fw-bold">Meter Details</label>
<div class="col-md-8">
<input name="txtMeterDetails" class="form-control" value="@strMeterDetails" />
</div>
</div>
<hr />
<h3 class="fw-bold">Meter/Counter Reading</h3>
<hr />
<div class="row mb-2">
<label for="txtMeterReadingStartDate" class="col-form-label col-md-4 fw-bold">Meter Reading Start Date</label>
<div class="col-md-6">
<input name="txtMeterReadingStartDate" class="form-control" type="date" value="@strMeterReadingStartDate" />
</div>
</div>
<div class="row mb-2">
<label for="txtMeterReadingEndDate" class="col-form-label col-md-4 fw-bold">Meter Reading End Date</label>
<div class="col-md-6">
<input name="txtMeterReadingEndDate" class="form-control" type="date" value="@strMeterReadingEndDate" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtCounterReadingStart" class="col-form-label col-md-4 fw-bold">Counter Reading Start</label>
<div class="col-md-4">
<input name="txtCounterReadingStart" class="form-control" type="number" value="@strCounterReadingStart" />
</div>
</div>
<div class="row mb-2">
<label for="txtCounterReadingEnd" class="col-form-label col-md-4 fw-bold">Counter Reading End</label>
<div class="col-md-4">
<input name="txtCounterReadingEnd" class="form-control" type="number" value="@strCounterReadingEnd" />
</div>
</div>
<hr />
<div class="row mb-2">
<label for="txtBillingDays" class="col-form-label col-md-4 fw-bold">Billing Days</label>
<div class="col-md-4">
<input name="txtBillingDays" class="form-control" value="@strBillingDays" />
</div>
</div>
<div class="row mb-2">
<label for="txtTotalGallons" class="col-form-label col-md-4 fw-bold">Total Gallons</label>
<div class="col-md-4">
<input name="txtTotalGallons" class="form-control" value="@strTotalGallons" />
</div>
</div>
<hr />
<h3 class="fw-bold">Consumption</h3>
<hr />
<div class="row mb-2">
<label for="txtTotalCCF" class="col-form-label col-md-4 fw-bold">Total CCF</label>
<div class="col-md-4">
<input name="txtTotalCCF" class="form-control" value="@strTotalCCF" />
</div>
</div>
<div class="row mb-2">
<label for="txtFirstTierConsumption" class="col-form-label col-md-4 fw-bold">First Tier Consumption</label>
<div class="col-md-4">
<input name="txtFirstTierConsumption" class="form-control" value="@strFirstTierConsumption" />
</div>
</div>
<div class="row mb-2">
<label for="txtSecondTierConsumption" class="col-form-label col-md-4 fw-bold">Second Tier Consumption</label>
<div class="col-md-4">
<input name="txtSecondTierConsumption" class="form-control" value="@strSecondTierConsumption" />
</div>
</div>
<div class="row mb-2">
<label for="txtLastTierConsumption" class="col-form-label col-md-4 fw-bold">Last Tier Consumption</label>
<div class="col-md-4">
<input name="txtLastTierConsumption" class="form-control" value="@strLastTierConsumption" />
</div>
</div>
<hr />
<h3 class="fw-bold">Bill Charges</h3>
<hr />
<div class="row mb-2">
<label for="txtWaterCharges" class="col-form-label col-md-4 fw-bold">Water Charges</label>
<div class="col-md-4">
<input name="txtWaterCharges" class="form-control" value="@strWaterCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtSewerCharges" class="col-form-label col-md-4 fw-bold">Sewer Charges</label>
<div class="col-md-4">
<input name="txtSewerCharges" class="form-control" value="@strSewerCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtEnvironmentCharges" class="col-form-label col-md-4 fw-bold">Environment Charges</label>
<div class="col-md-4">
<input name="txtEnvironmentCharges" class="form-control" value="@strEnvironmentCharges" />
</div>
</div>
<div class="row mb-2">
<label for="txtTotalCharges" class="col-form-label col-md-4 fw-bold">Total Charges</label>
<div class="col-md-4">
<input name="txtTotalCharges" class="form-control" value="@strTotalCharges" />
</div>
</div>
<hr />
<h3 class="fw-bold">Taxes</h3>
<hr />
<div class="row mb-2">
<label for="txtLocalTaxes" class="col-form-label col-md-4 fw-bold">Local Taxes</label>
<div class="col-md-4">
<input name="txtLocalTaxes" class="form-control" value="@strLocalTaxes" />
</div>
</div>
<div class="row mb-2">
<label for="txtStateTaxes" class="col-form-label col-md-4 fw-bold">State Taxes</label>
<div class="col-md-4">
<input name="txtStateTaxes" class="form-control" value="@strStateTaxes" />
</div>
</div>
<hr />
<h3 class="fw-bold">Payment Details</h3>
<hr />
<div class="row mb-2">
<label for="txtAmountDue" class="col-form-label col-md-4 fw-bold">Amount Due</label>
<div class="col-md-4">
<input name="txtAmountDue" class="form-control" value="@strAmountDue" />
</div>
</div>
<div class="row mb-2">
<label for="txtPaymentDueDate" class="col-form-label col-md-4 fw-bold">Payment Due Date</label>
<div class="col-md-6">
<input name="txtPaymentDueDate" class="form-control" value="@strPaymentDueDate" />
</div>
</div>
<div class="row mb-2">
<label for="txtLateAmountDue" class="col-form-label col-md-4 fw-bold">Late Amount Due</label>
<div class="col-md-4">
<input name="txtLateAmountDue" class="form-control" value="@strLateAmountDue" />
</div>
</div>
<div class="row mb-2">
<label for="txtLatePaymentDueDate" class="col-form-label col-md-4 fw-bold">Late Payment Due Date</label>
<div class="col-md-6">
<input name="txtLatePaymentDueDate" class="form-control" value="@strLatePaymentDueDate" />
</div>
</div>
<hr />
<div class="row mb-2">
<div class="col-md-5 col-form-label">
<a asp-page="Index">Stellar Water Point Home</a>
</div>
<div class="col-md-7">
<input type="submit" name="btnDeleteWaterBill"
value="Delete Water Bill" class="btn btn-maroon" />
</div>
</div>
</div>
<p>@strMessage</p>
</form>
<hr />
<p class="text-center">
<a asp-page="./Create" class="stellar">Prepare a New Water Bill</a> ::
<a asp-page="./Details" class="stellar">Review an Existing Water Bill</a> ::
<a asp-page="./Edit" class="stellar">Edit/Update an Existing Water Bill</a>
</p>Finalizing and Testing the Application
After creating the webpages and webforms that are necessary for the application, we can put the final touches and test it with some values.
Practical Learning: Finalizing and Testing the Application


| Meter # | Make | Model | Meter Size |
| 392-44-572 | Constance Technologies | TG-4822 | 5/8 Inches |
| 938-75-869 | Stanford Trend | 266G | 1 1/2 Inches |
| 588-29-663 | Estellano | NCF-226 | 3/4 Inches |
| 186-92-805 | Lansome | 2800 | 1 1/2 Inches |
| 799-28-461 | Kensa Sons | K-584-L | 3/4 Inches |
| 386-48-057 | Estellano | NCF-226 | 3/4 Inches |
| 837-06-836 | Lansome | 7400 | 5/8 Inches |
| 207-94-835 | Constance Technologies | TG-6220 | 5/8 Inches |
| 592-84-957 | Kensa Sons | D-497-H | 3/4 Inches |
| 374-06-284 | Raynes Energica | i2022 | 3/4 Inches |
| 186-99-757 | Kensa Sons | M-686-G | 1 1/2 Inches |
| 630-07-055 | Lansome | 2800 | 3/4 Inches |
| 827-50-248 | Standard Trend | 428T | 3/4 Inches |
| 470-68-850 | Estellano | WRT-482 | 3/4 Inches |
| 649-33-505 | Constance Technologies | BD-7000 | 5/8 Inches |
| 306-82-497 | Lansome | 9000 | 3/4 Inches |

| Account # | Meter # | First Name | Last Name | Address | City | County | State | ZIP-Code |
| 9279-570-8394 | 799-28-461 | Thomas | Stones | 10252 Broward Ave #D4 | Frederick | Frederick | MD | 21703-6628 |
| 2068-258-9486 | 186-92-805 | Ericka | Dellaney | 4819 East Munk Street | Whitehall | Fulton | PA | 17340-2277 |
| 4820-375-2842 | 392-44-572 | Akhil | Koumari | 748 Red Hills Rd | Roanoke | VA | 24012-9726 | |
| 6003-386-3955 | 374-06-284 | Mandiakandara | Marmoudi | 539 Avalon Court | Greenwood | Sussex | DE | 19950-2288 |
| 9249-379-6848 | 588-29-663 | Richard | Eghert | 8280 Sligo North Way | Albright | Preston | WV | 26519-4626 |
| 7518-302-6895 | 207-94-835 | Grace | Brenner | 4299 Peachtree Court | Rockville | Montgomery | MD | 20853-1512 |
| 3028-502-9418 | 186-99-757 | Spencer | Kershaw | 338C Grayson Street | Gatchellville | York | PA | 17352-3808 |
| 5293-957-3395 | 386-48-057 | Kelly | Davids | 10484 Greenway Avenue | Mt Storm | Grant | WV | 26739-6242 |
| 2038-413-9680 | 938-75-869 | Amidou | Gomah | 2075 Rose Hills Avenue | Washington | DC | 20004-1818 | |
| 7028-405-9381 | 306-82-497 | Jonathan | Simmings | 613 Meadowhill Road | Alonzaville | Shenandoah | VA | 22664-2662 |
| 5938-074-5293 | 592-84-957 | Marie | Rath | 582G Dunhill Avenue | Lanham | Prince Georges | MD | 20706-4422 |
| 1827-395-0203 | 470-68-850 | Sathyavanthara | Khooni | 10331 Chryswell Road | Washington | DC | 20008-5050 | |
| 8027-304-6829 | 837-06-836 | Anthony | Clarcksons | 904 Augusta Drive | Blackbird | New Castle | DE | 19734-2606 |
| 6699-396-2905 | 649-33-505 | Spencer | Reuter | 2850 Burnsweak Avenue | Silver Spring | Montgomery | MD | 20910-7272 |
| 7080-583-5947 | 827-50-248 | Sandra | Moffat | 663 Sherry Wood East Street | Shimpstown | Franklin | PA | 17236-1116 |



| Water Bill # | Account # | Meter Reading Start Date | Meter Reading End Date | Counter Reading Start | Counter Reading End |
| 847384 | 3028-502-9418 | 10/03/2024 | 01/06/2025 | 16 | 21 |
| 330820 | 7028-405-9381 | 10/03/2024 | 01/03/2025 | 9749 | 9906 |
| 468550 | 7518-302-6895 | 10/05/2024 | 01/09/2025 | 96 | 114 |
| 148274 | 9249-379-6848 | 10/05/2024 | 01/10/2025 | 260504 | 260555 |
| 326384 | 2068-258-9486 | 10/08/2024 | 01/10/2025 | 104837 | 104851 |
| 936497 | 5293-957-3395 | 10/11/2024 | 01/10/2025 | 350 | 356 |
| 682416 | 4820-375-2842 | 10/18/2024 | 01/20/2025 | 109992 | 109998 |
| 203804 | 8027-304-6829 | 10/22/2024 | 1/23/2025 | 9953 | 9979 |
| 149739 | 6003-386-3955 | 10/22/2024 | 1/18/2025 | 98 | 99 |
|
|
|||
| Home | Copyright © 2017-2025, FunctionX | Saturday 09 November 2024, 11:19 | Home |
|
|
|||