Introduction

One of the popular options offered by ASP.NET Core is Razor Pages. Razor Pages in turn provides various options to create web-based applications. An example is to create a web-based application that uses an XML database. This project explores that option of creating a Web-base application that uses a database, namely a text-based database. In this case, we will use XML to create and manage the records of the application.

Practical LearningPractical Learning: Introducing the Application

  1. Start Microsoft Visual Studio
  2. In the Visual Studio 2022 dialog box, click Create a New Project
  3. In the Create a New Project dialog box, click ASP.NET Core Web App (Razor Pages)
  4. Change the project Name to StellarWaterPoint5.
    Accept or change the project Location
  5. Click Next
  6. In the Additional Information dialog box, in the Framework combo box, select the highest .NET version.
    Click Create
  7. In the Solution Explorer, click the name of the project -> New -> New Folder
  8. Type Models as the name of the new folder
  9. In the Solution Explorer, right-click wwwroot -> Add -> New Folder
  10. Type Images as the name of the new folder and press Enter
  11. Copy the follwing photos to the Images folder:
    Stellar Water Point - Water Bills Stellar Water Point - Customers Accounts
    Stellar Water Point - Water Meters Stellar Water Point - Community Services
    Stellar Water Point - Legal Affairs Stellar Water Point - Employees Portal
  12. In the Solution Explore, expand wwwroot, then expand css and double-click site.css
  13. Press Enter
  14. Add the following formats:
    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;
    }
    
    .bordered       { border: 1px solid black;     }
    .encloser       { margin: auto;
                      width:  400px;               }
    .encloser-large { margin: auto;
                      width:  600px;               }
    .enclosing      { margin: auto;
                      width:  500px;               }
    
    .mb-3           { margin-bottom:    5rem !important;
                      background-color: #800000 !important;
                      font-family:      Garamond, Georgia, Cambria, 'Times New Roman', Times, serif; }
    
    .text-light     { font-weight:      bold;      }
    .stellar        { font-weight:      bold;
                      text-decoration:  none;
                      color:            maroon;
                      font-family:      Garamond, Georgia, Cambria, 'Times New Roman', Times, serif; }
    a.stellar:focus { color:            red;       }
    a.stellar:hover { color:            navy;
                      text-decoration:  underline; }
    .navbar-light .navbar-brand {
                      font-weight:      bold;
                      color:            #FFD800;   }
    
    .navbar-light .navbar-brand:hover, .navbar-light .navbar-brand:focus {
                     font-weight:       bold;
                     color:             #FFFFFF;   }
    
    .nav-link .text-light:focus {
                     font-weight:       bold;
                     color:             #FFD800;   }
    
    .nav-link .text-light:hover {
                     font-weight:       bold;
                     color:             #FFFFFF;   }
    
    .common-font {
        font-family: Garamond, Georgia, Cambria, 'Times New Roman', Times, serif
    }

A Database for an Application

Our application will use a database. We will create that database in the application as a local database. When setting up the database, we will create tables for water meters, customers, and water bills.

Practical LearningPractical Learning: Preparing a Database

  1. To create a new database, on the main menu of Microsoft Visual Studio, click View and click Server Explorer
  2. In the Server Explorer, right-click Data Connections and click Create New SQL Server Database...
  3. In the Server Name combo box, select your server or type (local)
  4. Set the database name as StellarWaterPoint
  5. Click OK
  6. In the Server Explorer, right-click the StellarWaterPoint connection and click New Query
  7. Type the following code to create a table:
    CREATE TABLE WaterMeters
    (
    	WaterMeterId          INT IDENTITY(1, 1),
    	MeterNumber           NVARCHAR(10) NOT NULL,
    	Make                  NVARCHAR(25) NOT NULL,
    	Model                 NVARCHAR(15) NOT NULL,
    	MeterSize             NVARCHAR(15) NOT NULL,
    	CONSTRAINT   PK_WaterMeters PRIMARY KEY(WaterMeterId)
    );
    GO
    
    CREATE TABLE Customers
    (
    	CustomerId            INT IDENTITY(1, 1),
    	AccountNumber         NVARCHAR(15) NOT NULL,
    	MeterNumber           NVARCHAR(10),
    	FirstName             NVARCHAR(18),
    	LastName              NVARCHAR(18) NOT NULL,
    	[Address]             NVARCHAR(150),
    	City                  NVARCHAR(25),
    	County                NVARCHAR(35),
    	[State]               NVARCHAR(35) NOT NULL,
    	ZIPCode               NVARCHAR(12),
    	CONSTRAINT    PK_Customers PRIMARY KEY(CustomerId)
    );
    GO
    
    CREATE TABLE WaterBills
    (
    	WaterBillId           INT IDENTITY(1, 1),
    	AccountNumber         NVARCHAR(15) NOT NULL,
    	InvoiceNumber         INT          NOT NULL,
    	MeterReadingStartDate NVARCHAR(50) NOT NULL,
    	MeterReadingEndDate   NVARCHAR(50) NOT NULL,
    	BillingDays           INT          NOT NULL,
    	CounterReadingStart   NVARCHAR(15),
    	CounterReadingEnd     NVARCHAR(15),
    	Consumption           NVARCHAR(15),
    	TotalGallons          NVARCHAR(15),
    	FirstTierConsumption  NVARCHAR(15),
    	SecondTierConsumption NVARCHAR(15),
    	LastTierConsumption   NVARCHAR(15),
    	WaterCharges          NVARCHAR(15),
    	SewerCharges          NVARCHAR(15),
    	EnvironmentCharges    NVARCHAR(15),
    	TotalCharges          NVARCHAR(15),
    	LocalTaxes            NVARCHAR(15),
    	StateTaxes            NVARCHAR(15),
    	PaymentDueDate        NVARCHAR(50),
    	AmountDue             NVARCHAR(15),
    	LatePaymentDueDate    NVARCHAR(50),
    	LateAmountDue         NVARCHAR(15),
    	CONSTRAINT            PK_WaterBills PRIMARY KEY(WaterBillId)
    );
    GO
  8. Right-click inside the document and click Execute
  9. Close the Query window
  10. When asked whether you want to save, click Don't Save
  11. In the Solution Explorer, right-click the name of the project and click Manage NuGet Packages...
  12. In the NuGet tab, click Browse
  13. In the combo box, type System.Data.SqlClient
  14. In the list, click System.Data.SqlClient
  15. In the right list, click Install
  16. In the Preview Changes dialog box, click Apply
  17. In the License Acceptance dialog box, click I Accept

Water Meters

A water meter is an electro-mechanical device that is installed at a cusomer's location to measure how much water a constume is consuming. For our application, we will use one form in a webpage to create water meter records, another webpage to allow a user to review the record of a water meter, another webpage to allow the use to make one or more changes about the information of a water recor, and one wepage to allow a user to delete the record of a water meter.

Practical LearningPractical Learning: Creating Water Meter Records

  1. In the Solution Explorer, right-click Models -> Add -> Class...
  2. Type WaterMeter as the name of the class
  3. Click Add
  4. Change the document as follows:
    using System.ComponentModel.DataAnnotations;
    
    namespace StellarWaterPoint51.Models
    {
        public class WaterMeter
        {
            [Display(Name = "Water Meter Id")]
            public int WaterMeterId    { get; set; }
            [Display(Name = "Meter #")]
            public string? MeterNumber { get; set; }
            public string? Make        { get; set; }
            public string? Model       { get; set; }
    
            [Display(Name = "Meter Size")]
            public string? MeterSize   { get; set; }
    
            public string Description
            {
                get
                {
                    return Make + " " + Model +
                           " (Model #: " + MeterNumber + ", " +
                           MeterSize + ")";
                }
            }
        }
    }
  5. In the Solution Explorer, right-click Pages -> Add -> New Folder
  6. Type WaterMeters and press Enter
  7. >In the Solution Explorer, expand Pages, right-click WaterMeters -> Add -> Razor Page...
  8. In the middle section of the Add New Scaffolder Item dialog box, make sure Razor Page - Empty is selected

    Add New Scaffolded Item

  9. Click Add
  10. In the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Create
  11. Click Add
  12. In the Solution Explorer, below WaterMeters, and below Create.cshtml, double-click Create.cshtml.cs to open the file
  13. Change the document as follows:
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    using StellarWaterPoint51.Models;
    using System.Data.SqlClient;
    
    namespace StellarWaterPoint51.Pages.WaterMeters
    {
        public class CreateModel : PageModel
        {
            [BindProperty]
            public WaterMeter? WaterMeter { get; set; } = new WaterMeter();
    
            public void OnGet()
            {
            }
    
            public async Task<IActionResult> OnPostAsync()
            {
                using (SqlConnection scWaterDistribution = new SqlConnection("Data Source='DESKTOP-PD7NQLM';" +
                                                                             "Initial Catalog='StellarWaterPoint10';" +
                                                                             "Integrated Security=True;"))
                {
                    SqlCommand cmdWaterMeters = new SqlCommand("INSERT INTO WaterMeters(MeterNumber, Make, Model, MeterSize) " +
                                                               "VALUES(N'" + WaterMeter!.MeterNumber + "', N'" + 
                                                                             WaterMeter.Make + "', N'" + 
                                                                             WaterMeter.Model + "', N'" + 
                                                                             WaterMeter.MeterSize + "');",
                                                               scWaterDistribution);
    
                    scWaterDistribution.Open();
                    cmdWaterMeters.ExecuteNonQuery();
                }
    
                await Task.CompletedTask;
    
                return RedirectToPage("Index");
            }
        }
    }
  14. In the Solution Explorer, under Pages and under WaterMeters, double-click Create.cshtml
  15. Change the document as follows:
    @page
    @model StellarWaterPoint51.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.WaterMeter!.MeterNumber" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.WaterMeter!.MeterNumber" class="form-control" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.WaterMeter!.Make" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.WaterMeter!.Make" class="form-control" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.WaterMeter!.Model" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.WaterMeter!.Model" class="form-control" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.WaterMeter!.MeterSize" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.WaterMeter!.MeterSize" class="form-control" />
            </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="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>
  16. In the Solution Explorer, under Pages, right-click WaterMeters -> Add -> Razor Page...
  17. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected and click Add
  18. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Details
  19. Click Add
  20. In the Solution Explorer, under WaterMeters, double-click Details.cshtml and change the document as follows:
  21. In the Solution Explorer, under Pages, right-click WaterMeters -> Add -> Razor Page...
  22. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  23. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is slected.
    Change the file Name to Edit
  24. Click Add
  25. In the Solution Explorer, under WaterMeters and under Edit, double-click Edit.cshtml.cs
  26. Change the document as follows:
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    using System.ComponentModel.DataAnnotations;
    
    namespace StellarWaterPoint4.Pages.WaterMeters
    {
        public class EditModel : PageModel
        {
            [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()
            {
                MeterNumber = string.Empty;
                Make        = string.Empty;
                Model       = string.Empty;
                MeterSize   = string.Empty;
            }
        }
    }
  27. In the Solution Explorer, under Pages and under WaterMeters, click Edit.cshtml
  28. Change the webpage as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.WaterMeters.EditModel
    @{
        bool    meterFound     = false;
        string? message        = string.Empty;
        string? strMake        = string.Empty;
        string? strModel       = 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     = @"C:\Stellar Water Point\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;
                            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 = @"C:\Stellar Water Point\WaterMeters.xml";
    
                FileInfo fiWaterMeters     = new FileInfo(strWaterMeters);
    
                if (fiWaterMeters.Exists == true)
                {
                    xdWaterMeters.Load(strWaterMeters);
    
                    XmlNodeList xnlWaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
    
                    foreach (XmlNode xnWaterMeter in xnlWaterMeters!)
                    {
                        if (xnWaterMeter.InnerText.Equals(strMeterNumber))
                        {
                            xnWaterMeter.ParentNode!.InnerXml = "<meter-number>" + @strMeterNumber  + "</meter-number>" +
                                                                "<make>"         + @Model.Make      + "</make>"         +
                                                                "<model>"        + @Model.Model     + "</model>"        +
                                                                "<meter-size>"   + @Model.MeterSize + "</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-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-primary" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.Make" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.Make" class="form-control" value="@strMake" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.Model" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.Model" class="form-control" value="@strModel" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.MeterSize" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.MeterSize" 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="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>
  29. In the Solution Explorer, under Pages, right-click WaterMeters -> Add -> Razor Page...
  30. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  31. In the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Delete
  32. Click Add
  33. In the Solution Explorer, under WaterMeters and under Delete.cshtml, double-click Delete.cshtml.cs
  34. Change the document as follows:
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    using System.ComponentModel.DataAnnotations;
    
    namespace StellarWaterPoint4.Pages.WaterMeters
    {
        public class DeleteModel : PageModel
        {
            [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()
            {
                MeterNumber = string.Empty;
                Make        = string.Empty;
                Model       = string.Empty;
                MeterSize   = string.Empty;
            }
        }
    }
  35. In the Solution Explorer, under WaterMeters, double-click Delete.cshtml
  36. Change the document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.WaterMeters.DeleteModel
    @{
        bool    meterFound     = false;
        string? message        = string.Empty;
        string? strMake        = string.Empty;
        string? strModel       = 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 = @"C:\Stellar Water Point\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;
                            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 = @"C:\Stellar Water Point\WaterMeters.xml";
    
                FileInfo fiWaterMeters     = new FileInfo(strWaterMeters);
    
                if (fiWaterMeters.Exists == true)
                {
                    xdWaterMeters.Load(strWaterMeters);
    
                    XmlNodeList xnlWaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
    
                    foreach (XmlNode xnWaterMeter in xnlWaterMeters!)
                    {
                        if (xnWaterMeter.InnerText.Equals(strMeterNumber))
                        {
    
                            xnWaterMeter.ParentNode!.RemoveChild(xnWaterMeter);
    
                            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-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-primary" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.Make" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.Make" class="form-control" value="@strMake" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.Model" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.Model" class="form-control" value="@strModel" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.MeterSize" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.MeterSize" 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>
  37. In the Solution Explorer, under Pages, right-click WaterMeters -> Add -> Razor Page...
  38. In the middle list of the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  39. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Accept the file name as Index.cshtml
    Click Add
  40. In the Solution Explorer, under WaterMeters and under Index.cshtml, double-click Index.cshtml.cs
  41. Change the document as follows:
    using Microsoft.AspNetCore.Mvc.RazorPages;
    using System.Xml;
    
    namespace StellarWaterPoint4.Pages.WaterMeters
    {
        public class IndexModel : PageModel
        {
            public XmlNodeList? WaterMeters { get; set; } = null;
    
            public void OnGet()
            {
                XmlDocument xdWaterMeters  = new XmlDocument();
                string      strWaterMeters = @"C:\Stellar Water Point\WaterMeters.xml";
                    
                FileInfo fiWaterMeters     = new FileInfo(strWaterMeters);
    
                if (fiWaterMeters.Exists)
                {
                    xdWaterMeters.Load(fiWaterMeters.FullName);
    
                    WaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
                }
            }
        }
    }
  42. In the Solution Explorer, under WaterMeters, double-click Index.cshtml
  43. Change the document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.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>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>@xnWaterMeter.InnerText</td>
                    <td>@xnWaterMeter.NextSibling!.InnerText</td>
                    <td>@xnWaterMeter.NextSibling!.NextSibling!.InnerText</td>
                    <td>@xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText</td>
                </tr>
            }
        }
    </table>
    
    <hr />
    
    <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>

Customers

A customer is an entity (person, business, organization, etc) that consumes the services of a company, such as a water distribution company. In our application, we will create the types of webpages we created for water meters.

Practical LearningPractical Learning: Creating Customers Records

  1. In the Solution Explorer, right-click Pages -> Add -> New Folder
  2. Type Customers and press Enter
  3. In the Solution Explorer, under Pages, right-click Customers -> Add -> Razor Page...
  4. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  5. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Create
  6. Press Enter
  7. In the Solution Explorer, under Pages and under Customers, double-click Create.cshtml.cs
  8. Change the document as follows:
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    using System.ComponentModel.DataAnnotations;
    
    namespace StellarWaterPoint4.Pages.Customers
    {
        public class CreateModel : PageModel
        {
            [BindProperty]
            [Display(Name = "Account #")]
            public string? AccountNumber { get; set; }
            [BindProperty]
            [Display(Name = "Meter #")]
            public string? MeterNumber { get; set; } = string.Empty;
            [BindProperty]
            [Display(Name = "First Name")]
            public string? FirstName { get; set; } = string.Empty;
            [BindProperty]
            [Display(Name = "Last Name")]
            public string? LastName { get; set; }
            [BindProperty]
            public string? Address { get; set; } = string.Empty;
            [BindProperty]
            public string? City { get; set; } = string.Empty;
            [BindProperty]
            public string? County { get; set; } = string.Empty;
            [BindProperty]
            public string? State { get; set; }
            [BindProperty]
            [Display(Name = "ZIP-Code")]
            public string? ZIPCode { get; set; } = string.Empty;
    
            public void OnGet()
            {
            }
        }
    }
  9. In the Solution Explorer, under Customers, double-click Create.cshtml
  10. Change the document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.Customers.CreateModel
    @{
        bool meterFound = false;
        string? message = string.Empty;
        string? strMeterNumber = string.Empty;
        string? strMeterDetails = string.Empty;
    
        if (Request.HasFormContentType)
        {
            strMeterNumber = Request.Form["txtMeterNumber"];
    
            if (Request.Form["btnFindWaterMeter"] == "Find Water Meter")
            {
                XmlDocument xdWaterMeters = new XmlDocument();
                string strWaterMeters = @"C:\Stellar Water Point\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;
                            strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                              xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                              xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                            break;
                        }
                    }
                }
                
                if(meterFound == false)
                {
                    message = "There is no water meter with that number in our system.";
                }
            }
    
            if (Request.Form["btnSaveCustomer"] == "Save Customer Account")
            {
                XmlDocument xdCustomers = new XmlDocument();
                string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                FileInfo fiCustomers = new FileInfo(strCustomers);
    
                if (fiCustomers.Exists == false)
                {
                    xdCustomers.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                        "<customers></customers>");
    
                    xdCustomers.Save(fiCustomers.FullName);
                }
    
                xdCustomers.Load(strCustomers);
    
                XmlElement xeCustomer = xdCustomers.CreateElement("customer");
    
                xeCustomer.InnerXml = "<account-number>" + @Model.AccountNumber + "</account-number>" +
                                      "<meter-number>"   + @strMeterNumber      + "</meter-number>"   +
                                      "<first-name>"     + @Model.FirstName     + "</first-name>"     +
                                      "<last-name>"      + @Model.LastName      + "</last-name>"      +
                                      "<address>"        + @Model.Address       + "</address>"        +
                                      "<city>"           + @Model.City          + "</city>"           +
                                      "<county>"         + @Model.County        + "</county>"         +
                                      "<state>"          + @Model.State         + "</state>"          +
                                      "<zip-code>"       + @Model.ZIPCode       + "</zip-code>";
    
                xdCustomers.DocumentElement!.AppendChild(xeCustomer);
    
                xdCustomers.Save(fiCustomers.FullName);
                            
                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 asp-for="@Model.AccountNumber" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.AccountNumber" class="form-control" />
            </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-primary" />
            </div>
        </div>
        <div class="row mb-2">
            <label for="MeterDetails" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input name="MeterDetails" class="form-control" value="@strMeterDetails" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.FirstName" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.FirstName" class="form-control" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.LastName" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.LastName" class="form-control" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.Address" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.Address" class="form-control" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.City" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.City" class="form-control" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.County" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.County" class="form-control" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.State" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.State" class="form-control" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.ZIPCode" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.ZIPCode" class="form-control" />
            </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-primary" />
            </div>
        </div>
    </form>
    
    <hr />
    
    <p class="text-center">
        <a asp-page="./Details" class="stellar">Review a Customer&#039;s Account</a> ::
        <a asp-page="./Edit"    class="stellar">Edit/Update a Customer&#039;s Account</a> ::
        <a asp-page="./Delete"  class="stellar">Delete a Customer&#039;s Account</a>
    </p>
  11. In the Solution Explorer, under Pages, right-click Customers -> Add -> Razor Page...
  12. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  13. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Details
  14. Press Enter
  15. Change the Details.cshtml document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.Customers.DetailsModel
    @{
        bool    accountFound = false;
        string? message = string.Empty;
        string? strCity = string.Empty;
        string? strState = string.Empty;
        string? strCounty = string.Empty;
        string? strZIPCode = string.Empty;
        string? strAddress = 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)
        {
            strAccountNumber = Request.Form["txtAccountNumber"];
    
            if(string.IsNullOrEmpty(strMeterNumber))
            {
                XmlDocument xdCustomers = new XmlDocument();
                string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                FileInfo fiCustomers = new FileInfo(strCustomers);
    
                if (fiCustomers.Exists)
                {
                    xdCustomers.Load(strCustomers);
    
                    XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                    foreach (XmlNode xnCustomer in xnlCustomers!)
                    {
                        if (xnCustomer.InnerText.Equals(strAccountNumber))
                        {
                            accountFound   = true;
                            strMeterNumber = xnCustomer.NextSibling!.InnerText;
                            strFirstName   = xnCustomer.NextSibling!.NextSibling!.InnerText;
                            strLastName    = xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strAddress     = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strCity        = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strCounty      = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strState       = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strZIPCode     = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            break;
                        }
                    }
    
                    XmlDocument xdWaterMeters = new XmlDocument();
                    string strWaterMeters = @"C:\Stellar Water Point\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))
                            {
                                strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                                break;
                            }
                        }
                    }
                }
    
                if (accountFound == false)
                {
                    message = "There is no customer with that account number in our system.";
                }
            }
        }
    }
    
    <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 for="txtAccountNumber" class="col-form-label col-md-3 fw-bold">Account #</label>
            <div class="col-md-4">
                <input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
            </div>
            <div class="col-md-4">
                <input type="submit" name="btnFindCustomer" value="Find Customer" class="btn btn-primary" />
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">Meter #</label>
            <div class="col-md-9">
                <label name="lblMeterNumber" class="form-control">@strMeterNumber</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">Meter Details</label>
            <div class="col-md-9">
                <label name="lblMeterDetails" class="form-control">@strMeterDetails</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">First Name</label>
            <div class="col-md-9">
                <label name="lblFirstName" class="form-control">@strFirstName</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">Last Name</label>
            <div class="col-md-9">
                <label name="lblLastName" class="form-control">@strLastName</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">Address</label>
            <div class="col-md-9">
                <label name="lblAddress" class="form-control">@strAddress</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">City</label>
            <div class="col-md-9">
                <label name="lblCity" class="form-control">@strCity</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">County</label>
            <div class="col-md-9">
                <label name="lblCounty" class="form-control">@strCounty</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">State</label>
            <div class="col-md-9">
                <label name="lblState" class="form-control">@strState</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">ZIP Code</label>
            <div class="col-md-9">
                <label name="lblZIPCode" class="form-control">@strZIPCode</label>
            </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">
                <span>@message</span>
            </div>
        </div>
    </form>
    
    <hr />
    
    <p class="text-center">
        <a asp-page="./Create" class="stellar">Create a Customer&#039;s Account</a> ::
        <a asp-page="./Edit"   class="stellar">Edit/Update a Customer&#039;s Account</a> ::
        <a asp-page="./Delete" class="stellar">Delete a Customer&#039;s Account</a>
    </p>
  16. In the Solution Explorer, under Pages, right-click Customers -> Add -> Razor Page...
  17. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  18. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Edit
  19. Click Add
  20. In the Solution Explorer, under Customers and under Edit.cshtml, double-click Edit.cshtml.cs
  21. Change the code as follows:
    using Microsoft.AspNetCore.Mvc;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    using System.ComponentModel.DataAnnotations;
    
    namespace StellarWaterPoint4.Pages.Customers
    {
        public class EditModel : PageModel
        {
            [BindProperty]
            [Display(Name = "Account #")]
            public string? AccountNumber { get; set; }
            [BindProperty]
            [Display(Name = "Meter #")]
            public string? MeterNumber { get; set; } = string.Empty;
            [BindProperty]
            [Display(Name = "Meter Details")]
            public string? MeterDetails { get; set; } = string.Empty;
            [BindProperty]
            [Display(Name = "First Name")]
            public string? FirstName { get; set; } = string.Empty;
            [BindProperty]
            [Display(Name = "Last Name")]
            public string? LastName { get; set; }
            [BindProperty]
            public string? Address { get; set; } = string.Empty;
            [BindProperty]
            public string? City { get; set; } = string.Empty;
            [BindProperty]
            public string? County { get; set; } = string.Empty;
            [BindProperty]
            public string? State { get; set; }
            [BindProperty]
            [Display(Name = "ZIP-Code")]
            public string? ZIPCode { get; set; } = string.Empty;
    
            public void OnGet()
            {
            }
        }
    }
  22. In the Solution Explorer, under Customers, double-click Edit.cshtml
  23. Change the document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.Customers.EditModel
    @{
        bool meterFound = false;
        bool accountFound = false;
        string? message = string.Empty;
        string? strCity = string.Empty;
        string? strState = string.Empty;
        string? strCounty = string.Empty;
        string? strZIPCode = string.Empty;
        string? strAddress = 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)
        {
            strAccountNumber = Request.Form["txtAccountNumber"];
    
            if (Request.Form["btnFindCustomer"] == "Find Customer")
            {
                if (!string.IsNullOrEmpty(strAccountNumber))
                {
                    XmlDocument xdCustomers = new XmlDocument();
                    string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                    FileInfo fiCustomers = new FileInfo(strCustomers);
    
                    if (fiCustomers.Exists)
                    {
                        xdCustomers.Load(fiCustomers.FullName);
    
                        XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                        foreach (XmlNode xnCustomer in xnlCustomers!)
                        {
                            if (xnCustomer.InnerText.Equals(strAccountNumber))
                            {
                                accountFound = true;
                                strMeterNumber = xnCustomer.NextSibling!.InnerText;
                                strFirstName = xnCustomer.NextSibling!.NextSibling!.InnerText;
                                strLastName = xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAddress = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCity = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounty = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strState = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strZIPCode = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdWaterMeters = new XmlDocument();
                    string strWaterMeters = @"C:\Stellar Water Point\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))
                            {
                                strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                                break;
                            }
                        }
                    }
                }
    
                if (accountFound == false)
                {
                    message = "There is no customer with that account number in our system.";
                }
            }
    
            if (Request.Form["btnFindWaterMeter"] == "Find Water Meter")
            {
                XmlDocument xdWaterMeters = new XmlDocument();
                string strWaterMeters = @"C:\Stellar Water Point\WaterMeters.xml";
    
                FileInfo fiWaterMeters = new FileInfo(strWaterMeters);
    
                if (fiWaterMeters.Exists)
                {
                    xdWaterMeters.Load(fiWaterMeters.FullName);
    
                    XmlNodeList xnlWaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
    
                    strMeterNumber = Request.Form["txtMeterNumber"];
    
                    foreach (XmlNode xnWaterMeter in xnlWaterMeters!)
                    {
                        if (xnWaterMeter.InnerText.Equals(strMeterNumber))
                        {
                            meterFound = true;
                            strMeterNumber = xnWaterMeter.InnerText;
                            strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                              xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                              xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                            break;
                        }
                    }
                }
    
                XmlDocument xdCustomers = new XmlDocument();
                string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                FileInfo fiCustomers = new FileInfo(strCustomers);
    
                if (fiCustomers.Exists)
                {
                    xdCustomers.Load(fiCustomers.FullName);
    
                    XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                    foreach (XmlNode xnCustomer in xnlCustomers!)
                    {
                        if (xnCustomer.InnerText.Equals(strAccountNumber))
                        {
                            accountFound = true;
                            strFirstName = xnCustomer.NextSibling!.NextSibling!.InnerText;
                            strLastName = xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strAddress = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strCity = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strCounty = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strState = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strZIPCode = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            break;
                        }
                    }
                }
    
                if (meterFound == false)
                {
                    message = "There is no water meter with that number in our system.";
                }
            }
    
            if (Request.Form["btnUpdateCustomer"] == "Update Customer Account")
            {
                XmlDocument xdCustomers = new XmlDocument();
                string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                FileInfo fiCustomers = new FileInfo(strCustomers);
    
                if (fiCustomers.Exists)
                {
                    xdCustomers.Load(fiCustomers.FullName);
    
                    XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                    foreach (XmlNode xnCustomer in xnlCustomers!)
                    {
                        if (xnCustomer.InnerText.Equals(strAccountNumber))
                        {
                            xnCustomer.ParentNode!.InnerXml = "<account-number>" + strAccountNumber + "</account-number>" +
                                                              "<meter-number>" + Request.Form["txtMeterNumber"] + "</meter-number>" +
                                                              "<first-name>" + @Model.FirstName + "</first-name>" +
                                                              "<last-name>" + @Model.LastName + "</last-name>" +
                                                              "<address>" + @Model.Address + "</address>" +
                                                              "<city>" + @Model.City + "</city>" +
                                                              "<county>" + @Model.County + "</county>" +
                                                              "<state>" + @Model.State + "</state>" +
                                                              "<zip-code>" + @Model.ZIPCode + "</zip-code>";
    
                            xdCustomers.Save(fiCustomers.FullName);
                            break;
                        }
                    }
                }
    
                Response.Redirect("Index");
            }
        }
    }
    
    <h1 class="common-font fw-bold text-center">Edit/Update Customer Account</h1>
    
    <hr />
    
    <form method="post" class="common-font enclosing">
        <div class="row mb-2">
            <label for="txtAccountNumber" class="col-form-label col-md-3 fw-bold">Account #</label>
            <div class="col-md-4">
                <input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
            </div>
            <div class="col-md-4">
                <input type="submit" name="btnFindCustomer" value="Find Customer" class="btn btn-primary" />
            </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-primary" />
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">Meter Details</label>
            <div class="col-md-9">
                <input asp-for="@Model.MeterDetails" class="form-control" value="@strMeterDetails" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.FirstName" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.FirstName" class="form-control" value="@strFirstName" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.LastName" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.LastName" class="form-control" value="@strLastName" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.Address" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.Address" class="form-control" value="@strAddress" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.City" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.City" class="form-control" value="@strCity" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.County" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.County" class="form-control" value="@strCounty" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.State" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.State" class="form-control" value="@strState" />
            </div>
        </div>
        <div class="row mb-2">
            <label asp-for="@Model.ZIPCode" class="col-form-label col-md-3 fw-bold"></label>
            <div class="col-md-9">
                <input asp-for="@Model.ZIPCode" 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="btnUpdateCustomer"
                       value="Update Customer Account" class="btn btn-primary" />
            </div>
        </div>
    </form>
    
    <hr />
    
    <p class="text-center">
        <a asp-page="./Create"  class="stellar">Create a New Customer&#039;s Account</a> ::
        <a asp-page="./Details" class="stellar">Review a Customer&#039;s Account</a> ::
        <a asp-page="./Delete"  class="stellar">Delete a Customer&#039;s Account</a>
    </p>
  24. In the Solution Explorer, under Pages, right-click Customers -> Add -> Razor Page...
  25. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  26. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Delete
  27. Press Enter
  28. In the Solution Explorer, under Pages and under Customers, double-click Delete.cshtml
  29. Change the document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.Customers.DeleteModel
    @{
        bool meterFound = false;
        bool accountFound = false;
        string? message = string.Empty;
        string? strCity = string.Empty;
        string? strState = string.Empty;
        string? strCounty = string.Empty;
        string? strZIPCode = string.Empty;
        string? strAddress = 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)
        {
            strAccountNumber = Request.Form["txtAccountNumber"];
    
            if (Request.Form["btnFindCustomer"] == "Find Customer")
            {
                if (!string.IsNullOrEmpty(strAccountNumber))
                {
                    XmlDocument xdCustomers = new XmlDocument();
                    string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                    FileInfo fiCustomers = new FileInfo(strCustomers);
    
                    if (fiCustomers.Exists)
                    {
                        xdCustomers.Load(fiCustomers.FullName);
    
                        XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                        foreach (XmlNode xnCustomer in xnlCustomers!)
                        {
                            if (xnCustomer.InnerText.Equals(strAccountNumber))
                            {
                                accountFound = true;
                                strMeterNumber = xnCustomer.NextSibling!.InnerText;
                                strFirstName = xnCustomer.NextSibling!.NextSibling!.InnerText;
                                strLastName = xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAddress = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCity = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounty = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strState = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strZIPCode = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdWaterMeters = new XmlDocument();
                    string strWaterMeters = @"C:\Stellar Water Point\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))
                            {
                                strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                                break;
                            }
                        }
                    }
                }
    
                if (accountFound == false)
                {
                    message = "There is no customer with that account number in our system.";
                }
            }
    
            if (Request.Form["btnFindWaterMeter"] == "Find Water Meter")
            {
                XmlDocument xdWaterMeters = new XmlDocument();
                string strWaterMeters = @"C:\Stellar Water Point\WaterMeters.xml";
    
                FileInfo fiWaterMeters = new FileInfo(strWaterMeters);
    
                if (fiWaterMeters.Exists)
                {
                    xdWaterMeters.Load(fiWaterMeters.FullName);
    
                    XmlNodeList xnlWaterMeters = xdWaterMeters.GetElementsByTagName("meter-number");
    
                    strMeterNumber = Request.Form["txtMeterNumber"];
    
                    foreach (XmlNode xnWaterMeter in xnlWaterMeters!)
                    {
                        if (xnWaterMeter.InnerText.Equals(strMeterNumber))
                        {
                            meterFound = true;
                            strMeterNumber = xnWaterMeter.InnerText;
                            strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                              xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                              xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                            break;
                        }
                    }
                }
    
                XmlDocument xdCustomers = new XmlDocument();
                string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                FileInfo fiCustomers = new FileInfo(strCustomers);
    
                if (fiCustomers.Exists)
                {
                    xdCustomers.Load(fiCustomers.FullName);
    
                    XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                    foreach (XmlNode xnCustomer in xnlCustomers!)
                    {
                        if (xnCustomer.InnerText.Equals(strAccountNumber))
                        {
                            accountFound = true;
                            strFirstName = xnCustomer.NextSibling!.NextSibling!.InnerText;
                            strLastName = xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strAddress = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strCity = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strCounty = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strState = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            strZIPCode = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                            break;
                        }
                    }
                }
    
                if (meterFound == false)
                {
                    message = "There is no water meter with that number in our system.";
                }
            }
    
            if (Request.Form["btnDeleteCustomer"] == "Delete Customer Account")
            {
                XmlDocument xdCustomers = new XmlDocument();
                string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                FileInfo fiCustomers = new FileInfo(strCustomers);
    
                if (fiCustomers.Exists)
                {
                    xdCustomers.Load(fiCustomers.FullName);
    
                    XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                    foreach (XmlNode xnCustomer in xnlCustomers!)
                    {
                        if (xnCustomer.InnerText.Equals(strAccountNumber))
                        {
                            xdCustomers.DocumentElement!.RemoveChild(xnCustomer.ParentNode!);
                            break;
                        }
                    }
    
                    xdCustomers.Save(strCustomers);
                }
    
                Response.Redirect("Index");
            }
        }
    }
    
    <h1 class="common-font fw-bold text-center">Customer Account Deletion</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">
                <input name="txtAccountNumber" class="form-control" value="@strAccountNumber" />
            </div>
            <div class="col-md-4">
                <input type="submit" name="btnFindCustomer" value="Find Customer" class="btn btn-primary" />
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">Meter #</label>
            <div class="col-md-9">
                <label name="lblMeterNumber" class="form-control">@strMeterNumber</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">Meter Details</label>
            <div class="col-md-9">
                <label name="lblMeterDetails" class="form-control">@strMeterDetails</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">First Name</label>
            <div class="col-md-9">
                <label name="lblFirstName" class="form-control">@strFirstName</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">Last Name</label>
            <div class="col-md-9">
                <label name="lblLastName" class="form-control">@strLastName</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">Address</label>
            <div class="col-md-9">
                <label name="lblAddress" class="form-control">@strAddress</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">City</label>
            <div class="col-md-9">
                <label name="lblCity" class="form-control">@strCity</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">County</label>
            <div class="col-md-9">
                <label name="lblCounty" class="form-control">@strCounty</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">State</label>
            <div class="col-md-9">
                <label name="lblState" class="form-control">@strState</label>
            </div>
        </div>
        <div class="row mb-2">
            <label class="col-form-label col-md-3 fw-bold">ZIP Code</label>
            <div class="col-md-9">
                <label name="lblZIPCode" class="form-control">@strZIPCode</label>
            </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="btnDeleteCustomer"
                       value="Delete Customer Account" class="btn btn-primary" />
            </div>
        </div>
    </form>
    
    <hr />
    
    <p class="text-center">
        <a asp-page="./Create"  class="stellar">Create a Customer&#039;s Account</a> ::
        <a asp-page="./Details" class="stellar">View a Customer&#039;s Account</a> ::
        <a asp-page="./Edit"    class="stellar">Edit/Update a Customer&#039;s Account</a>
    </p>
  30. In the Solution Explorer, under Pages, right-click Customers -> Add -> Razor Page...
  31. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  32. In the middle list of the Add New Item dialog box, make sure Raor Page - Empty is selected.
    Accept the file Name as Index.cshtml.
    Click Add
  33. In the Solution Explorer, under Pages, under Customers, and under Index.cshtml, double-click Index.cshtml.cs
  34. Change the document as follows:
    using System.Xml;
    using Microsoft.AspNetCore.Mvc.RazorPages;
    
    namespace StellarWaterPoint4.Pages.Customers
    {
        public class IndexModel : PageModel
        {
            public XmlNodeList? Customers { get; set; } = null;
    
            public void OnGet()
            {
                XmlDocument xdCustomers = new XmlDocument();
                string strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                FileInfo fiCustomers = new FileInfo(strCustomers);
    
                if (fiCustomers.Exists)
                {
                    xdCustomers.Load(fiCustomers.FullName);
    
                    Customers = xdCustomers.GetElementsByTagName("account-number");
                }
            }
        }
    }
  35. In the Solution Explorer, under Pages and under Customers, double-click Index.cshtml
  36. Change the document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.Customers.IndexModel
    @{
    }
    
    <h1 class="common-font fw-bold text-center">Customers</h1>
    
    <hr />
    
    <table class="table common-font">
        <tr class="fw-bold">
            <td>Account #</td>
            <td>Meter #</td>
            <td>First Name</td>
            <td>Last Name</td>
            <td>Address</td>
            <td>City</td>
            <td>County</td>
            <td>State</td>
            <td>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>
    
    <hr />
    
    <p class="text-center">
        <a asp-page="./Create"  class="stellar">Create a Customer&#039;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&#039;s Account</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 LearningPractical Learning: Creating Water Bills

  1. In the Solution Explorer, right-click Pages -> Add -> New Folder
  2. Type WaterBills as the name of the new folder, and press Enter
  3. In the Solution Explorer, under Pages, right-click WaterBills -> Add -> Razor Page...
  4. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  5. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Create
  6. Click Add
  7. Change the Create.cshtml document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.WaterBills.CreateModel
    @{
        bool accountFound = false;
        string? message = 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)
        {
            strBillNumber = Request.Form["txtBillNumber"];
            strAccountNumber = Request.Form["txtAccountNumber"];
    
            if (Request.Form["btnFindCustomerAccount"] == "Find Customer Account")
            {
                if (!string.IsNullOrEmpty(strAccountNumber))
                {
                    XmlDocument xdCustomers = new XmlDocument();
                    string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                    FileInfo fiCustomers = new FileInfo(strCustomers);
    
                    if (fiCustomers.Exists)
                    {
                        xdCustomers.Load(fiCustomers.FullName);
    
                        XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                        foreach (XmlNode xnCustomer in xnlCustomers!)
                        {
                            if (xnCustomer.InnerText.Equals(strAccountNumber))
                            {
                                accountFound = true;
                                strMeterNumber = xnCustomer.NextSibling!.InnerText;
                                strCustomerName = xnCustomer.NextSibling!.NextSibling!.InnerText + " " +
                                                  xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAddress = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCity = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounty = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strState = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strZIPCode = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdWaterMeters = new XmlDocument();
                    string strWaterMeters = @"C:\Stellar Water Point\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))
                            {
                                strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                                break;
                            }
                        }
                    }
    
                    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"];
    
                    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"];
                    strAmountDue = Request.Form["txtAmountDue"];
                    strPaymentDueDate = Request.Form["txtPaymentDueDate"];
                    strLateAmountDue = Request.Form["txtLateAmountDue"];
                    strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
                }
    
                if (accountFound == false)
                {
                    message = "There is no customer with that account number in our system.";
                }
            }
    
            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")
            {
                XmlDocument xdWaterBills = new XmlDocument();
                string? strWaterBills = @"C:\Stellar Water Point\WaterBills.xml";
    
                FileInfo fiWaterBills = new FileInfo(strWaterBills);
    
                if (fiWaterBills.Exists == false)
                {
                    xdWaterBills.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                                         "<water-bills></water-bills>");
    
                    xdWaterBills.Save(fiWaterBills.FullName);
                }
    
                xdWaterBills.Load(fiWaterBills.FullName);
    
                XmlElement xeWaterBill = xdWaterBills.CreateElement("water-bill");
    
                xeWaterBill.InnerXml = "<bill-number>" + Request.Form["txtBillNumber"] + "</bill-number>" +
                                           "<account-number>" + Request.Form["txtAccountNumber"] + "</account-number>" +
                                           "<meter-reading-start-date>" + Request.Form["txtMeterReadingStartDate"] + "</meter-reading-start-date>" +
                                           "<meter-reading-end-date>" + Request.Form["txtMeterReadingEndDate"] + "</meter-reading-end-date>" +
                                           "<counter-reading-start>" + Request.Form["txtCounterReadingStart"] + "</counter-reading-start>" +
                                           "<counter-reading-end>" + Request.Form["txtCounterReadingEnd"] + "</counter-reading-end>" +
                                           "<billing-days>" + Request.Form["txtBillingDays"] + "</billing-days>" +
                                           "<total-gallons>" + Request.Form["txtTotalGallons"] + "</total-gallons>" +
                                           "<total-ccf>" + Request.Form["txtTotalCCF"] + "</total-ccf>" +
                                           "<first-tier-consumption>" + Request.Form["txtFirstTierConsumption"] + "</first-tier-consumption>" +
                                           "<second-tier-consumption>" + Request.Form["txtSecondTierConsumption"] + "</second-tier-consumption>" +
                                           "<last-tier-consumption>" + Request.Form["txtLastTierConsumption"] + "</last-tier-consumption>" +
                                           "<water-charges>" + Request.Form["txtWaterCharges"] + "</water-charges>" +
                                           "<sewer-charges>" + Request.Form["txtSewerCharges"] + "</sewer-charges>" +
                                           "<environment-charges>" + Request.Form["txtEnvironmentCharges"] + "</environment-charges>" +
                                           "<total-charges>" + Request.Form["txtTotalCharges"] + "</total-charges>" +
                                           "<local-taxes>" + Request.Form["txtLocalTaxes"] + "</local-taxes>" +
                                           "<state-taxes>" + Request.Form["txtStateTaxes"] + "</state-taxes>" +
                                           "<amount-due>" + Request.Form["txtAmountDue"] + "</amount-due>" +
                                           "<payment-due-date>" + Request.Form["txtPaymentDueDate"] + "</payment-due-date>" +
                                           "<late-amount-due>" + Request.Form["txtLateAmountDue"] + "</late-amount-due>" +
                                           "<late-payment-due-date>" + Request.Form["txtLatePaymentDueDate"] + "</late-payment-due-date>";
    
                xdWaterBills.DocumentElement!.AppendChild(xeWaterBill);
    
                xdWaterBills.Save(fiWaterBills.FullName);
    
                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-primary" />
                </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-primary" />
                </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" type="number" 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" type="number" 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-primary" />
                </div>
            </div>
        </div>
    
        <p>@message</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>
  8. In the Solution Explorer, under Pages, right-click WaterBills -> Add -> Razor Page...
  9. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  10. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Details
  11. Click Add
  12. Change the document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.WaterBills.DetailsModel
    @{
        bool billFound = false;
        string? message = 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)
        {
            strBillNumber = Request.Form["txtBillNumber"];
    
            if (Request.Form["btnFindWaterBill"] == "Find Water Bill")
            {
                if (!string.IsNullOrEmpty(strBillNumber))
                {
                    XmlDocument xdWaterBils = new XmlDocument();
                    string? strWaterBils = @"C:\Stellar Water Point\WaterBills.xml";
    
                    FileInfo fiWaterBils = new FileInfo(strWaterBils);
    
                    if (fiWaterBils.Exists)
                    {
                        xdWaterBils.Load(fiWaterBils.FullName);
    
                        XmlNodeList xnlWaterBils = xdWaterBils.GetElementsByTagName("bill-number");
    
                        foreach (XmlNode xnWaterBil in xnlWaterBils!)
                        {
                            if (xnWaterBil.InnerText.Equals(strBillNumber))
                            {
                                billFound = true;
                                strAccountNumber         = xnWaterBil.NextSibling!.InnerText;
                                strMeterReadingStartDate = xnWaterBil.NextSibling!.NextSibling!.InnerText;
                                strMeterReadingEndDate   = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounterReadingStart   = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounterReadingEnd     = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strBillingDays           = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strTotalGallons          = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strTotalCCF              = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strFirstTierConsumption  = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strSecondTierConsumption = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLastTierConsumption   = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strWaterCharges          = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strSewerCharges          = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strEnvironmentCharges    = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strTotalCharges          = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLocalTaxes            = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strStateTaxes            = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strPaymentDueDate        = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAmountDue             = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLatePaymentDueDate    = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLateAmountDue         = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdCustomers = new XmlDocument();
                    string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                    FileInfo fiCustomers = new FileInfo(strCustomers);
    
                    if (fiCustomers.Exists)
                    {
                        xdCustomers.Load(fiCustomers.FullName);
    
                        XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                        foreach (XmlNode xnCustomer in xnlCustomers!)
                        {
                            if (xnCustomer.InnerText.Equals(strAccountNumber))
                            {                            
                                strMeterNumber = xnCustomer.NextSibling!.InnerText;
                                strCustomerName = xnCustomer.NextSibling!.NextSibling!.InnerText + " " +
                                                  xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAddress = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCity = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounty = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strState = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strZIPCode = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdWaterMeters = new XmlDocument();
                    string strWaterMeters = @"C:\Stellar Water Point\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))
                            {
                                strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                                break;
                            }
                        }
                    }
                }
    
                if (billFound == false)
                {
                    message = "There is no water bill with that number in our system.";
                }
            }
    
            if (Request.Form["btnReturnHome"] == "Return to Stellar Water Point Home")
            {
                Response.Redirect("/WaterBills/Index");
            }
        }
    }
    
    <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-primary" />
                </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="text" 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="text" 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" type="number" 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" type="number" 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="btnReturnHome"
                           value="Return to Stellar Water Point Home" class="btn btn-primary" />
                </div>
            </div>
        </div>
    
        <p>@message</p>
    </form>
    
    <hr />
    
    <p class="text-center">
        <a asp-page="./Create" class="stellar">Water Bill Processing</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>
  13. In the Solution Explorer, under Pages, right-click WaterBills -> Add -> Razor Page...
  14. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  15. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Edit
  16. Click Add
  17. Change the document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.WaterBills.EditModel
    @{
        bool billFound = false;
        bool accountFound = false;
        string? message = 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)
        {
            strBillNumber = Request.Form["txtBillNumber"];
    
            if (Request.Form["btnFindWaterBill"] == "Find Water Bill")
            {
                if (!string.IsNullOrEmpty(strBillNumber))
                {
                    XmlDocument xdWaterBils = new XmlDocument();
                    string? strWaterBils = @"C:\Stellar Water Point\WaterBills.xml";
    
                    FileInfo fiWaterBils = new FileInfo(strWaterBils);
    
                    if (fiWaterBils.Exists)
                    {
                        xdWaterBils.Load(fiWaterBils.FullName);
    
                        XmlNodeList xnlWaterBils = xdWaterBils.GetElementsByTagName("bill-number");
    
                        foreach (XmlNode xnWaterBil in xnlWaterBils!)
                        {
                            if (xnWaterBil.InnerText.Equals(strBillNumber))
                            {
                                billFound = true;
                                strAccountNumber         = xnWaterBil.NextSibling!.InnerText;
                                strMeterReadingStartDate = xnWaterBil.NextSibling!.NextSibling!.InnerText;
                                strMeterReadingEndDate   = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounterReadingStart   = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounterReadingEnd     = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strBillingDays           = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strTotalGallons = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strTotalCCF = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strFirstTierConsumption = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strSecondTierConsumption = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLastTierConsumption = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strWaterCharges = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strSewerCharges = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strEnvironmentCharges = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strTotalCharges = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLocalTaxes = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strStateTaxes = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strPaymentDueDate = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAmountDue = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLatePaymentDueDate = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLateAmountDue = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdCustomers = new XmlDocument();
                    string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                    FileInfo fiCustomers = new FileInfo(strCustomers);
    
                    if (fiCustomers.Exists)
                    {
                        xdCustomers.Load(fiCustomers.FullName);
    
                        XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                        foreach (XmlNode xnCustomer in xnlCustomers!)
                        {
                            if (xnCustomer.InnerText.Equals(strAccountNumber))
                            {
                                strMeterNumber = xnCustomer.NextSibling!.InnerText;
                                strCustomerName = xnCustomer.NextSibling!.NextSibling!.InnerText + " " +
                                                  xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAddress = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCity = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounty = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strState = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strZIPCode = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdWaterMeters = new XmlDocument();
                    string strWaterMeters = @"C:\Stellar Water Point\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))
                            {
                                strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                                break;
                            }
                        }
                    }
                }
    
                if (billFound == false)
                {
                    message = "There is no customer with that account number in our system.";
                }
            }
            else if (Request.Form["btnFindCustomerAccount"] == "Find Customer Account")
            {
                strBillNumber = Request.Form["txtBillNumber"];
                strAccountNumber = Request.Form["txtAccountNumber"];
                
                if(!string.IsNullOrEmpty(strAccountNumber))
                {
                    XmlDocument xdCustomers = new XmlDocument();
                    string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                    FileInfo fiCustomers = new FileInfo(strCustomers);
    
                    if (fiCustomers.Exists)
                    {
                        xdCustomers.Load(fiCustomers.FullName);
    
                        XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                        foreach (XmlNode xnCustomer in xnlCustomers!)
                        {
                            if (xnCustomer.InnerText.Equals(strAccountNumber))
                            {
                                accountFound = true;
                                strAccountNumber = Request.Form["txtAccountNumber"];
                                strMeterNumber  = xnCustomer.NextSibling!.InnerText;
                                strCustomerName = xnCustomer.NextSibling!.NextSibling!.InnerText + " " + 
                                                  xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAddress = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCity = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounty = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strState = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strZIPCode = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdWaterMeters = new XmlDocument();
                    string strWaterMeters = @"C:\Stellar Water Point\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))
                            {
                                strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                                break;
                            }
                        }
                    }
    
                    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"];
    
                    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"];
                    strAmountDue = Request.Form["txtAmountDue"];
                    strPaymentDueDate = Request.Form["txtPaymentDueDate"];
                    strLateAmountDue = Request.Form["txtLateAmountDue"];
                    strLatePaymentDueDate = Request.Form["txtLatePaymentDueDate"];
                }
    
                if (accountFound == false)
                {
                    message = "There is no customer with that account number in our system.";
                }
            }
            else if (Request.Form["btnEvaluateWaterBill"] == "Evaluate Water Bill")
            {
                strBillNumber = Request.Form["txtBillNumber"];
                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"];
                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();
            }
            else 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();
            }
    
            else if (Request.Form["btnUpdateWaterBill"] == "Update Water Bill")
            {
                FileStream? fsWaterBills = null;
                XmlDocument xdWaterBills = new XmlDocument();
                string strWaterBills = @"C:\Stellar Water Point\WaterBills.xml";
    
                FileInfo? fiWaterBills = new FileInfo(strWaterBills);
    
                if (fiWaterBills.Exists)
                {
                    strBillNumber = Request.Form["txtBillNumber"];
    
                    using (fsWaterBills = new FileStream(fiWaterBills.FullName, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        xdWaterBills.Load(fsWaterBills);
                        XmlNodeList xnlWaterBills = xdWaterBills.DocumentElement!.SelectNodes("//bill-number[.='" + strBillNumber + "']")!;
    
                        foreach (XmlNode xnWaterBill in xnlWaterBills)
                        {
                            xnWaterBill.ParentNode!.InnerXml = "<bill-number>" + Request.Form["txtBillNumber"] + "</bill-number>" +
                                           "<account-number>" + Request.Form["txtAccountNumber"] + "</account-number>" +
                                           "<meter-reading-start-date>" + Request.Form["txtMeterReadingStartDate"] + "</meter-reading-start-date>" +
                                           "<meter-reading-end-date>" + Request.Form["txtMeterReadingEndDate"] + "</meter-reading-end-date>" +
                                           "<counter-reading-start>" + Request.Form["txtCounterReadingStart"] + "</counter-reading-start>" +
                                           "<counter-reading-end>" + Request.Form["txtCounterReadingEnd"] + "</counter-reading-end>" +
                                           "<billing-days>" + Request.Form["txtBillingDays"] + "</billing-days>" +
                                           "<total-gallons>" + Request.Form["txtTotalGallons"] + "</total-gallons>" +
                                           "<total-ccf>" + Request.Form["txtTotalCCF"] + "</total-ccf>" +
                                           "<first-tier-consumption>" + Request.Form["txtFirstTierConsumption"] + "</first-tier-consumption>" +
                                           "<second-tier-consumption>" + Request.Form["txtSecondTierConsumption"] + "</second-tier-consumption>" +
                                           "<last-tier-consumption>" + Request.Form["txtLastTierConsumption"] + "</last-tier-consumption>" +
                                           "<water-charges>" + Request.Form["txtWaterCharges"] + "</water-charges>" +
                                           "<sewer-charges>" + Request.Form["txtSewerCharges"] + "</sewer-charges>" +
                                           "<environment-charges>" + Request.Form["txtEnvironmentCharges"] + "</environment-charges>" +
                                           "<total-charges>" + Request.Form["txtTotalCharges"] + "</total-charges>" +
                                           "<local-taxes>" + Request.Form["txtLocalTaxes"] + "</local-taxes>" +
                                           "<state-taxes>" + Request.Form["txtStateTaxes"] + "</state-taxes>" +
                                           "<amount-due>" + Request.Form["txtAmountDue"] + "</amount-due>" +
                                           "<payment-due-date>" + Request.Form["txtPaymentDueDate"] + "</payment-due-date>" +
                                           "<late-amount-due>" + Request.Form["txtLateAmountDue"] + "</late-amount-due>" +
                                           "<late-payment-due-date>" + Request.Form["txtLatePaymentDueDate"] + "</late-payment-due-date>";
    
                        }
                    }
    
                    using (fsWaterBills = new FileStream(fiWaterBills.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                    {
                        xdWaterBills.Save(fsWaterBills);
                    }
                }
    
                Response.Redirect("../Index");
            }
        }
    }
    
    <h1 class="common-font fw-bold text-center">Water Bill Update</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-primary" />
                </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-primary" />
                </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="text" 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="text" 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-primary" />
                </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" type="number" 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" type="number" 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-primary" />
                </div>
            </div>
        </div>
    
        <p>@message</p>
    </form>
    
    <hr />
    
    <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="./Delete"  class="stellar">Delete a Water Bill</a>
    </p>
  18. In the Solution Explorer, under Pages, right-click WaterBills -> Add -> Razor Page...
  19. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  20. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Change the file Name to Delete
  21. Click Add
  22. Change the document as follows:
    @page
    @using System.Xml
    @model StellarWaterPoint4.Pages.WaterBills.DeleteModel
    @{
        bool billFound = false;
        string? message = 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)
        {
            strBillNumber = Request.Form["txtBillNumber"];
    
            if (Request.Form["btnFindWaterBill"] == "Find Water Bill")
            {
                if (!string.IsNullOrEmpty(strBillNumber))
                {
                    XmlDocument xdWaterBils = new XmlDocument();
                    string? strWaterBils = @"C:\Stellar Water Point\WaterBills.xml";
    
                    FileInfo fiWaterBils = new FileInfo(strWaterBils);
    
                    if (fiWaterBils.Exists)
                    {
                        xdWaterBils.Load(fiWaterBils.FullName);
    
                        XmlNodeList xnlWaterBils = xdWaterBils.GetElementsByTagName("bill-number");
    
                        foreach (XmlNode xnWaterBil in xnlWaterBils!)
                        {
                            if (xnWaterBil.InnerText.Equals(strBillNumber))
                            {
                                billFound = true;
                                strAccountNumber = xnWaterBil.NextSibling!.InnerText;
                                strMeterReadingStartDate = xnWaterBil.NextSibling!.NextSibling!.InnerText;
                                strMeterReadingEndDate = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounterReadingStart = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounterReadingEnd = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strBillingDays = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strTotalGallons = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strTotalCCF = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strFirstTierConsumption = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strSecondTierConsumption = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLastTierConsumption = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strWaterCharges = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strSewerCharges = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strEnvironmentCharges = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strTotalCharges = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLocalTaxes = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strStateTaxes = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strPaymentDueDate = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAmountDue = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLatePaymentDueDate = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strLateAmountDue = xnWaterBil.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdCustomers = new XmlDocument();
                    string? strCustomers = @"C:\Stellar Water Point\Customers.xml";
    
                    FileInfo fiCustomers = new FileInfo(strCustomers);
    
                    if (fiCustomers.Exists)
                    {
                        xdCustomers.Load(fiCustomers.FullName);
    
                        XmlNodeList xnlCustomers = xdCustomers.GetElementsByTagName("account-number");
    
                        foreach (XmlNode xnCustomer in xnlCustomers!)
                        {
                            if (xnCustomer.InnerText.Equals(strAccountNumber))
                            {
                                strMeterNumber = xnCustomer.NextSibling!.InnerText;
                                strCustomerName = xnCustomer.NextSibling!.NextSibling!.InnerText + " " +
                                                  xnCustomer.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strAddress = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCity = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strCounty = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strState = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                strZIPCode = xnCustomer.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.NextSibling!.InnerText;
                                break;
                            }
                        }
                    }
    
                    XmlDocument xdWaterMeters = new XmlDocument();
                    string strWaterMeters = @"C:\Stellar Water Point\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))
                            {
                                strMeterDetails = xnWaterMeter.NextSibling!.InnerText + " " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.InnerText + " (Meter Size: " +
                                                  xnWaterMeter.NextSibling!.NextSibling!.NextSibling!.InnerText + ")";
                                break;
                            }
                        }
                    }
                }
    
                if (billFound == false)
                {
                    message = "There is no water bill with that number in our system.";
                }
            }
    
    
            if (Request.Form["btnDeleteWaterBill"] == "Delete this Water Bill")
            {
                XmlDocument xdWaterBills = new XmlDocument();
                string? strWaterBills = @"C:\Stellar Water Point\WaterBills.xml";
    
                FileInfo fiWaterBills = new FileInfo(strWaterBills);
    
                if (fiWaterBills.Exists)
                {
                    xdWaterBills.Load(fiWaterBills.FullName);
    
                    XmlNodeList xnlWaterBillrs = xdWaterBills.GetElementsByTagName("bill-number");
    
                    foreach (XmlNode xnWaterBill in xnlWaterBillrs!)
                    {
                        if (xnWaterBill.InnerText.Equals(strBillNumber))
                        {
                            xdWaterBills.DocumentElement!.RemoveChild(xnWaterBill.ParentNode!);
                            break;
                        }
                    }
    
                    xdWaterBills.Save(strWaterBills);
                }
    
                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-primary" />
                </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="text" 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="text" 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" type="number" 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" type="number" 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 this Water Bill" class="btn btn-primary" />
                </div>
            </div>
        </div>
    
        <p>@message</p>
    </form>
    
    <hr />
    
    <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"    class="stellar">Edit/Update a Water Bill</a>
    </p>
  23. In the Solution Explorer, under Pages, right-click WaterBills -> Add -> Razor Page...
  24. In the Add New Scaffolded Item dialog box, make sure Razor Page - Empty is selected.
    Click Add
  25. In the middle list of the Add New Item dialog box, make sure Razor Page - Empty is selected.
    Accept the suggested file Name as Index.cshtml .
    Click Add
  26. Change the document follows:
    @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>

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 LearningPractical Learning: Finalizing and Testing the Application

  1. In the Solution Explorer, expand Pages and expand Shared
  2. In the Solution Explorer, under Pages and under Shared, click _Layout.cshtml to access it
  3. Change the document as follows:
    <!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>
        <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="~/StellarWaterPoint30.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="/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">&copy; 2025 - Stellar Water Point - <a asp-area="" asp-page="/Privacy">Privacy</a></p>
            </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>
  4. In the Solution Explorer, scroll down completly and double-click the last Index.cshtml
  5. Change the document as follows:
    @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>
  6. To execute, on the main menu, click Debug and click Start Without Debugging:

  7. In the top bar, click the Water Meters link

    Water Meters

  8. Click the Create Water Meter link

    Water Meters

  9. Create each of the following records, and save after each record:
     
    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
  10. Click the Customers link
  11. Click the Create Customer Account link

    Water Meters

  12. Create the following records:
    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
  13. Click the Water Bills link
  14. Click Water Bill Processing:

    Water Bill Processiing

    Water Bill Processiing

    Water Bill Processiing

  15. Create and save some records as follows:
    Water Bill # Account # Meter Reading Start Date Meter Reading End Date Counter Reading Start Counter Reading End
    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
  16. Close the browser and return to your programming environment
  17. Close your programming environment

Home Copyright © 2017-2024, FunctionX Tuesday 21 August 2024, 11:14 Home