Critical Code Fragments

This page holds descriptions of the crticial pieces of code that will be included, essential to running the project and maintaining order and modularity of procedures.

Code
/// /// A class for managing the DataConnection of various pages /// public class DataConnection {    public static SqlConnection Connect {        SqlConnection conn = new SqlConnection("Data Source=" + System.Environment.MachineName + ";Initial Catalog=CVC;Integrated Security=True"); conn.Open; return conn; } }

File
DataConnection.cs

Purpose
The class opens a connection to the database server and returns the connection to the requesting method.

Functional Description

 * Line 1 - A connection variable is declared and set to the result of a connection to the server database
 * Line 2 - The connection is opened
 * Line 3 - The connection info is returned

Code
Response.Clear; Response.ContentType = "text/plain"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + tankName + ".tnk"); Response.TransmitFile(Server.MapPath("./TankFileGeneration/" + tankName + ".tnk")); Response.End;

File
Gallery.aspx.cs & Search.aspx.cs

Purpose
This section is an sets up a Response to the client's browser is prepared and sent, in order to send files.

Functional Description

 * Line 1 - Any existing Response is cleared.
 * Line 2 - The content type is defined as plain text.
 * Line 3 - The file's name is defined.
 * Line 4 - The location of the file is given, in order to transmit the file.
 * Line 5 - End transmission.