SlideShare a Scribd company logo
1 of 30
Download to read offline
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Population_Database
{
static class Program
{
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Population_Database
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void cityBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.cityBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.cityDataSet);
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'cityDataSet.City' table. You can move,
or remove it, as needed.
this.cityTableAdapter.Fill(this.cityDataSet.City);
}
private void btnAscPopulation_Click(object sender, EventArgs e)
{
// Sort the table by population in ascending order
this.cityTableAdapter.FillByAscPopulation(this.cityDataSet.City);
}
private void btnDescPopulation_Click(object sender, EventArgs e)
{
// Sort the table by population in descending order
this.cityTableAdapter.FillByDescPopulation(this.cityDataSet.City);
}
private void btnName_Click(object sender, EventArgs e)
{
this.cityTableAdapter.FillByCity(this.cityDataSet.City);
}
private void btnTotal_Click(object sender, EventArgs e)
{
// Declare variable to hold total population.
double totalPopulation;
// Get the total population.
totalPopulation = (double)this.cityTableAdapter.TotalPopulation();
// Display the total population.
MessageBox.Show("Total Population: " + totalPopulation.ToString("n0"));
}
private void btnAverage_Click(object sender, EventArgs e)
{
// Declare variable to hold average population.
double averagePopulation;
// Get the average population.
averagePopulation = (double)this.cityTableAdapter.AveragePopulation();
// Display the average population.
MessageBox.Show("Average Population: " + averagePopulation.ToString("n0"));
}
private void btnMaxPopulation_Click(object sender, EventArgs e)
{
// Declare variable to hold highest population.
double maxPopulation;
// Get the highest population.
maxPopulation = (double)this.cityTableAdapter.MaxPopulation();
// Display the highest population.
MessageBox.Show("Highest Population: " + maxPopulation.ToString("n0"));
}
private void btnMinPopulation_Click(object sender, EventArgs e)
{
// Declare variable to hold lowest population.
double minPopulation;
// Get the lowest population.
minPopulation = (double)this.cityTableAdapter.MinPopulation();
// Display the lowest population.
MessageBox.Show("Lowest Population: " + minPopulation.ToString("n0"));
}
private void btnExit_Click(object sender, EventArgs e)
{
// Close the form.
this.Close();
}
}
}
Form1.Designer.cs
namespace Population_Database
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new
System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.cityBindingNavigator = new
System.Windows.Forms.BindingNavigator(this.components);
this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton();
this.cityBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.cityDataSet = new Population_Database.CityDataSet();
this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel();
this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorMovePreviousItem = new
System.Windows.Forms.ToolStripButton();
this.bindingNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator();
this.bindingNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox();
this.bindingNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.bindingNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.cityBindingNavigatorSaveItem = new System.Windows.Forms.ToolStripButton();
this.cityDataGridView = new System.Windows.Forms.DataGridView();
this.dataGridViewTextBoxColumn1 = new
System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn2 = new
System.Windows.Forms.DataGridViewTextBoxColumn();
this.grpSort = new System.Windows.Forms.GroupBox();
this.btnName = new System.Windows.Forms.Button();
this.btnDescPopulation = new System.Windows.Forms.Button();
this.btnAscPopulation = new System.Windows.Forms.Button();
this.grpDisplay = new System.Windows.Forms.GroupBox();
this.btnMinPopulation = new System.Windows.Forms.Button();
this.btnMaxPopulation = new System.Windows.Forms.Button();
this.btnAverage = new System.Windows.Forms.Button();
this.btnTotal = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.cityTableAdapter = new
Population_Database.CityDataSetTableAdapters.CityTableAdapter();
this.tableAdapterManager = new
Population_Database.CityDataSetTableAdapters.TableAdapterManager();
((System.ComponentModel.ISupportInitialize)(this.cityBindingNavigator)).BeginInit();
this.cityBindingNavigator.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.cityBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cityDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cityDataGridView)).BeginInit();
this.grpSort.SuspendLayout();
this.grpDisplay.SuspendLayout();
this.SuspendLayout();
//
// cityBindingNavigator
//
this.cityBindingNavigator.AddNewItem = this.bindingNavigatorAddNewItem;
this.cityBindingNavigator.BindingSource = this.cityBindingSource;
this.cityBindingNavigator.CountItem = this.bindingNavigatorCountItem;
this.cityBindingNavigator.DeleteItem = this.bindingNavigatorDeleteItem;
this.cityBindingNavigator.Items.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.bindingNavigatorMoveFirstItem,
this.bindingNavigatorMovePreviousItem,
this.bindingNavigatorSeparator,
this.bindingNavigatorPositionItem,
this.bindingNavigatorCountItem,
this.bindingNavigatorSeparator1,
this.bindingNavigatorMoveNextItem,
this.bindingNavigatorMoveLastItem,
this.bindingNavigatorSeparator2,
this.bindingNavigatorAddNewItem,
this.bindingNavigatorDeleteItem,
this.cityBindingNavigatorSaveItem});
this.cityBindingNavigator.Location = new System.Drawing.Point(0, 0);
this.cityBindingNavigator.MoveFirstItem = this.bindingNavigatorMoveFirstItem;
this.cityBindingNavigator.MoveLastItem = this.bindingNavigatorMoveLastItem;
this.cityBindingNavigator.MoveNextItem = this.bindingNavigatorMoveNextItem;
this.cityBindingNavigator.MovePreviousItem =
this.bindingNavigatorMovePreviousItem;
this.cityBindingNavigator.Name = "cityBindingNavigator";
this.cityBindingNavigator.PositionItem = this.bindingNavigatorPositionItem;
this.cityBindingNavigator.Size = new System.Drawing.Size(560, 25);
this.cityBindingNavigator.TabIndex = 3;
this.cityBindingNavigator.Text = "bindingNavigator1";
//
// bindingNavigatorAddNewItem
//
this.bindingNavigatorAddNewItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorAddNewItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image")));
this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem";
this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorAddNewItem.Text = "Add new";
//
// cityBindingSource
//
this.cityBindingSource.DataMember = "City";
this.cityBindingSource.DataSource = this.cityDataSet;
//
// cityDataSet
//
this.cityDataSet.DataSetName = "CityDataSet";
this.cityDataSet.SchemaSerializationMode =
System.Data.SchemaSerializationMode.IncludeSchema;
//
// bindingNavigatorCountItem
//
this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";
this.bindingNavigatorCountItem.Size = new System.Drawing.Size(35, 22);
this.bindingNavigatorCountItem.Text = "of {0}";
this.bindingNavigatorCountItem.ToolTipText = "Total number of items";
//
// bindingNavigatorDeleteItem
//
this.bindingNavigatorDeleteItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorDeleteItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image")));
this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem";
this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorDeleteItem.Text = "Delete";
//
// bindingNavigatorMoveFirstItem
//
this.bindingNavigatorMoveFirstItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMoveFirstItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image")));
this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem";
this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMoveFirstItem.Text = "Move first";
//
// bindingNavigatorMovePreviousItem
//
this.bindingNavigatorMovePreviousItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMovePreviousItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image"))
);
this.bindingNavigatorMovePreviousItem.Name =
"bindingNavigatorMovePreviousItem";
this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMovePreviousItem.Text = "Move previous";
//
// bindingNavigatorSeparator
//
this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator";
this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25);
//
// bindingNavigatorPositionItem
//
this.bindingNavigatorPositionItem.AccessibleName = "Position";
this.bindingNavigatorPositionItem.AutoSize = false;
this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem";
this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 23);
this.bindingNavigatorPositionItem.Text = "0";
this.bindingNavigatorPositionItem.ToolTipText = "Current position";
//
// bindingNavigatorSeparator1
//
this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator1";
this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 25);
//
// bindingNavigatorMoveNextItem
//
this.bindingNavigatorMoveNextItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMoveNextItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image")));
this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem";
this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMoveNextItem.Text = "Move next";
//
// bindingNavigatorMoveLastItem
//
this.bindingNavigatorMoveLastItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMoveLastItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image")));
this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem";
this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMoveLastItem.Text = "Move last";
//
// bindingNavigatorSeparator2
//
this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator2";
this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25);
//
// cityBindingNavigatorSaveItem
//
this.cityBindingNavigatorSaveItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.cityBindingNavigatorSaveItem.Image =
((System.Drawing.Image)(resources.GetObject("cityBindingNavigatorSaveItem.Image")));
this.cityBindingNavigatorSaveItem.Name = "cityBindingNavigatorSaveItem";
this.cityBindingNavigatorSaveItem.Size = new System.Drawing.Size(23, 22);
this.cityBindingNavigatorSaveItem.Text = "Save Data";
this.cityBindingNavigatorSaveItem.Click += new
System.EventHandler(this.cityBindingNavigatorSaveItem_Click);
//
// cityDataGridView
//
this.cityDataGridView.AutoGenerateColumns = false;
this.cityDataGridView.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.cityDataGridView.Columns.AddRange(new
System.Windows.Forms.DataGridViewColumn[] {
this.dataGridViewTextBoxColumn1,
this.dataGridViewTextBoxColumn2});
this.cityDataGridView.DataSource = this.cityBindingSource;
this.cityDataGridView.Location = new System.Drawing.Point(12, 28);
this.cityDataGridView.Name = "cityDataGridView";
this.cityDataGridView.Size = new System.Drawing.Size(259, 296);
this.cityDataGridView.TabIndex = 4;
//
// dataGridViewTextBoxColumn1
//
this.dataGridViewTextBoxColumn1.DataPropertyName = "City";
this.dataGridViewTextBoxColumn1.HeaderText = "City";
this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
//
// dataGridViewTextBoxColumn2
//
this.dataGridViewTextBoxColumn2.DataPropertyName = "Population";
this.dataGridViewTextBoxColumn2.HeaderText = "Population";
this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
//
// grpSort
//
this.grpSort.Controls.Add(this.btnName);
this.grpSort.Controls.Add(this.btnDescPopulation);
this.grpSort.Controls.Add(this.btnAscPopulation);
this.grpSort.Location = new System.Drawing.Point(294, 28);
this.grpSort.Name = "grpSort";
this.grpSort.Size = new System.Drawing.Size(243, 121);
this.grpSort.TabIndex = 0;
this.grpSort.TabStop = false;
this.grpSort.Text = "Sort By";
//
// btnName
//
this.btnName.Location = new System.Drawing.Point(65, 68);
this.btnName.Name = "btnName";
this.btnName.Size = new System.Drawing.Size(110, 41);
this.btnName.TabIndex = 2;
this.btnName.Text = "City Name";
this.btnName.UseVisualStyleBackColor = true;
this.btnName.Click += new System.EventHandler(this.btnName_Click);
//
// btnDescPopulation
//
this.btnDescPopulation.Location = new System.Drawing.Point(124, 21);
this.btnDescPopulation.Name = "btnDescPopulation";
this.btnDescPopulation.Size = new System.Drawing.Size(110, 41);
this.btnDescPopulation.TabIndex = 1;
this.btnDescPopulation.Text = "Population in Descending Order";
this.btnDescPopulation.UseVisualStyleBackColor = true;
this.btnDescPopulation.Click += new
System.EventHandler(this.btnDescPopulation_Click);
//
// btnAscPopulation
//
this.btnAscPopulation.Location = new System.Drawing.Point(8, 21);
this.btnAscPopulation.Name = "btnAscPopulation";
this.btnAscPopulation.Size = new System.Drawing.Size(110, 41);
this.btnAscPopulation.TabIndex = 0;
this.btnAscPopulation.Text = "Population in Ascending Order";
this.btnAscPopulation.UseVisualStyleBackColor = true;
this.btnAscPopulation.Click += new
System.EventHandler(this.btnAscPopulation_Click);
//
// grpDisplay
//
this.grpDisplay.Controls.Add(this.btnMinPopulation);
this.grpDisplay.Controls.Add(this.btnMaxPopulation);
this.grpDisplay.Controls.Add(this.btnAverage);
this.grpDisplay.Controls.Add(this.btnTotal);
this.grpDisplay.Location = new System.Drawing.Point(294, 155);
this.grpDisplay.Name = "grpDisplay";
this.grpDisplay.Size = new System.Drawing.Size(243, 121);
this.grpDisplay.TabIndex = 1;
this.grpDisplay.TabStop = false;
this.grpDisplay.Text = "Display";
//
// btnMinPopulation
//
this.btnMinPopulation.Location = new System.Drawing.Point(124, 68);
this.btnMinPopulation.Name = "btnMinPopulation";
this.btnMinPopulation.Size = new System.Drawing.Size(110, 41);
this.btnMinPopulation.TabIndex = 4;
this.btnMinPopulation.Text = "Lowest Population";
this.btnMinPopulation.UseVisualStyleBackColor = true;
this.btnMinPopulation.Click += new
System.EventHandler(this.btnMinPopulation_Click);
//
// btnMaxPopulation
//
this.btnMaxPopulation.Location = new System.Drawing.Point(8, 68);
this.btnMaxPopulation.Name = "btnMaxPopulation";
this.btnMaxPopulation.Size = new System.Drawing.Size(110, 41);
this.btnMaxPopulation.TabIndex = 3;
this.btnMaxPopulation.Text = "Highest Population";
this.btnMaxPopulation.UseVisualStyleBackColor = true;
this.btnMaxPopulation.Click += new
System.EventHandler(this.btnMaxPopulation_Click);
//
// btnAverage
//
this.btnAverage.Location = new System.Drawing.Point(124, 21);
this.btnAverage.Name = "btnAverage";
this.btnAverage.Size = new System.Drawing.Size(110, 41);
this.btnAverage.TabIndex = 2;
this.btnAverage.Text = "Average Population";
this.btnAverage.UseVisualStyleBackColor = true;
this.btnAverage.Click += new System.EventHandler(this.btnAverage_Click);
//
// btnTotal
//
this.btnTotal.Location = new System.Drawing.Point(8, 21);
this.btnTotal.Name = "btnTotal";
this.btnTotal.Size = new System.Drawing.Size(110, 41);
this.btnTotal.TabIndex = 1;
this.btnTotal.Text = "Total Population";
this.btnTotal.UseVisualStyleBackColor = true;
this.btnTotal.Click += new System.EventHandler(this.btnTotal_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(359, 283);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(110, 41);
this.btnExit.TabIndex = 2;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// cityTableAdapter
//
this.cityTableAdapter.ClearBeforeFill = true;
//
// tableAdapterManager
//
this.tableAdapterManager.BackupDataSetBeforeUpdate = false;
this.tableAdapterManager.CityTableAdapter = this.cityTableAdapter;
this.tableAdapterManager.UpdateOrder =
Population_Database.CityDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.Inse
rtUpdateDelete;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnExit;
this.ClientSize = new System.Drawing.Size(560, 336);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.grpDisplay);
this.Controls.Add(this.grpSort);
this.Controls.Add(this.cityDataGridView);
this.Controls.Add(this.cityBindingNavigator);
this.Name = "Form1";
this.Text = "Population Database";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.cityBindingNavigator)).EndInit();
this.cityBindingNavigator.ResumeLayout(false);
this.cityBindingNavigator.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.cityBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cityDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cityDataGridView)).EndInit();
this.grpSort.ResumeLayout(false);
this.grpDisplay.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private CityDataSet cityDataSet;
private System.Windows.Forms.BindingSource cityBindingSource;
private CityDataSetTableAdapters.CityTableAdapter cityTableAdapter;
private CityDataSetTableAdapters.TableAdapterManager tableAdapterManager;
private System.Windows.Forms.BindingNavigator cityBindingNavigator;
private System.Windows.Forms.ToolStripButton bindingNavigatorAddNewItem;
private System.Windows.Forms.ToolStripLabel bindingNavigatorCountItem;
private System.Windows.Forms.ToolStripButton bindingNavigatorDeleteItem;
private System.Windows.Forms.ToolStripButton bindingNavigatorMoveFirstItem;
private System.Windows.Forms.ToolStripButton bindingNavigatorMovePreviousItem;
private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator;
private System.Windows.Forms.ToolStripTextBox bindingNavigatorPositionItem;
private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator1;
private System.Windows.Forms.ToolStripButton bindingNavigatorMoveNextItem;
private System.Windows.Forms.ToolStripButton bindingNavigatorMoveLastItem;
private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator2;
private System.Windows.Forms.ToolStripButton cityBindingNavigatorSaveItem;
private System.Windows.Forms.DataGridView cityDataGridView;
private System.Windows.Forms.DataGridViewTextBoxColumn
dataGridViewTextBoxColumn1;
private System.Windows.Forms.DataGridViewTextBoxColumn
dataGridViewTextBoxColumn2;
private System.Windows.Forms.GroupBox grpSort;
private System.Windows.Forms.GroupBox grpDisplay;
private System.Windows.Forms.Button btnDescPopulation;
private System.Windows.Forms.Button btnAscPopulation;
private System.Windows.Forms.Button btnName;
private System.Windows.Forms.Button btnMinPopulation;
private System.Windows.Forms.Button btnMaxPopulation;
private System.Windows.Forms.Button btnAverage;
private System.Windows.Forms.Button btnTotal;
private System.Windows.Forms.Button btnExit;
}
}
Solution
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Population_Database
{
static class Program
{
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Population_Database
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void cityBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.cityBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.cityDataSet);
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'cityDataSet.City' table. You can move,
or remove it, as needed.
this.cityTableAdapter.Fill(this.cityDataSet.City);
}
private void btnAscPopulation_Click(object sender, EventArgs e)
{
// Sort the table by population in ascending order
this.cityTableAdapter.FillByAscPopulation(this.cityDataSet.City);
}
private void btnDescPopulation_Click(object sender, EventArgs e)
{
// Sort the table by population in descending order
this.cityTableAdapter.FillByDescPopulation(this.cityDataSet.City);
}
private void btnName_Click(object sender, EventArgs e)
{
this.cityTableAdapter.FillByCity(this.cityDataSet.City);
}
private void btnTotal_Click(object sender, EventArgs e)
{
// Declare variable to hold total population.
double totalPopulation;
// Get the total population.
totalPopulation = (double)this.cityTableAdapter.TotalPopulation();
// Display the total population.
MessageBox.Show("Total Population: " + totalPopulation.ToString("n0"));
}
private void btnAverage_Click(object sender, EventArgs e)
{
// Declare variable to hold average population.
double averagePopulation;
// Get the average population.
averagePopulation = (double)this.cityTableAdapter.AveragePopulation();
// Display the average population.
MessageBox.Show("Average Population: " + averagePopulation.ToString("n0"));
}
private void btnMaxPopulation_Click(object sender, EventArgs e)
{
// Declare variable to hold highest population.
double maxPopulation;
// Get the highest population.
maxPopulation = (double)this.cityTableAdapter.MaxPopulation();
// Display the highest population.
MessageBox.Show("Highest Population: " + maxPopulation.ToString("n0"));
}
private void btnMinPopulation_Click(object sender, EventArgs e)
{
// Declare variable to hold lowest population.
double minPopulation;
// Get the lowest population.
minPopulation = (double)this.cityTableAdapter.MinPopulation();
// Display the lowest population.
MessageBox.Show("Lowest Population: " + minPopulation.ToString("n0"));
}
private void btnExit_Click(object sender, EventArgs e)
{
// Close the form.
this.Close();
}
}
}
Form1.Designer.cs
namespace Population_Database
{
partial class Form1
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new
System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.cityBindingNavigator = new
System.Windows.Forms.BindingNavigator(this.components);
this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton();
this.cityBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.cityDataSet = new Population_Database.CityDataSet();
this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel();
this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorMovePreviousItem = new
System.Windows.Forms.ToolStripButton();
this.bindingNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator();
this.bindingNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox();
this.bindingNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.bindingNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton();
this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.cityBindingNavigatorSaveItem = new System.Windows.Forms.ToolStripButton();
this.cityDataGridView = new System.Windows.Forms.DataGridView();
this.dataGridViewTextBoxColumn1 = new
System.Windows.Forms.DataGridViewTextBoxColumn();
this.dataGridViewTextBoxColumn2 = new
System.Windows.Forms.DataGridViewTextBoxColumn();
this.grpSort = new System.Windows.Forms.GroupBox();
this.btnName = new System.Windows.Forms.Button();
this.btnDescPopulation = new System.Windows.Forms.Button();
this.btnAscPopulation = new System.Windows.Forms.Button();
this.grpDisplay = new System.Windows.Forms.GroupBox();
this.btnMinPopulation = new System.Windows.Forms.Button();
this.btnMaxPopulation = new System.Windows.Forms.Button();
this.btnAverage = new System.Windows.Forms.Button();
this.btnTotal = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.cityTableAdapter = new
Population_Database.CityDataSetTableAdapters.CityTableAdapter();
this.tableAdapterManager = new
Population_Database.CityDataSetTableAdapters.TableAdapterManager();
((System.ComponentModel.ISupportInitialize)(this.cityBindingNavigator)).BeginInit();
this.cityBindingNavigator.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.cityBindingSource)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cityDataSet)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cityDataGridView)).BeginInit();
this.grpSort.SuspendLayout();
this.grpDisplay.SuspendLayout();
this.SuspendLayout();
//
// cityBindingNavigator
//
this.cityBindingNavigator.AddNewItem = this.bindingNavigatorAddNewItem;
this.cityBindingNavigator.BindingSource = this.cityBindingSource;
this.cityBindingNavigator.CountItem = this.bindingNavigatorCountItem;
this.cityBindingNavigator.DeleteItem = this.bindingNavigatorDeleteItem;
this.cityBindingNavigator.Items.AddRange(new
System.Windows.Forms.ToolStripItem[] {
this.bindingNavigatorMoveFirstItem,
this.bindingNavigatorMovePreviousItem,
this.bindingNavigatorSeparator,
this.bindingNavigatorPositionItem,
this.bindingNavigatorCountItem,
this.bindingNavigatorSeparator1,
this.bindingNavigatorMoveNextItem,
this.bindingNavigatorMoveLastItem,
this.bindingNavigatorSeparator2,
this.bindingNavigatorAddNewItem,
this.bindingNavigatorDeleteItem,
this.cityBindingNavigatorSaveItem});
this.cityBindingNavigator.Location = new System.Drawing.Point(0, 0);
this.cityBindingNavigator.MoveFirstItem = this.bindingNavigatorMoveFirstItem;
this.cityBindingNavigator.MoveLastItem = this.bindingNavigatorMoveLastItem;
this.cityBindingNavigator.MoveNextItem = this.bindingNavigatorMoveNextItem;
this.cityBindingNavigator.MovePreviousItem =
this.bindingNavigatorMovePreviousItem;
this.cityBindingNavigator.Name = "cityBindingNavigator";
this.cityBindingNavigator.PositionItem = this.bindingNavigatorPositionItem;
this.cityBindingNavigator.Size = new System.Drawing.Size(560, 25);
this.cityBindingNavigator.TabIndex = 3;
this.cityBindingNavigator.Text = "bindingNavigator1";
//
// bindingNavigatorAddNewItem
//
this.bindingNavigatorAddNewItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorAddNewItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image")));
this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem";
this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorAddNewItem.Text = "Add new";
//
// cityBindingSource
//
this.cityBindingSource.DataMember = "City";
this.cityBindingSource.DataSource = this.cityDataSet;
//
// cityDataSet
//
this.cityDataSet.DataSetName = "CityDataSet";
this.cityDataSet.SchemaSerializationMode =
System.Data.SchemaSerializationMode.IncludeSchema;
//
// bindingNavigatorCountItem
//
this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem";
this.bindingNavigatorCountItem.Size = new System.Drawing.Size(35, 22);
this.bindingNavigatorCountItem.Text = "of {0}";
this.bindingNavigatorCountItem.ToolTipText = "Total number of items";
//
// bindingNavigatorDeleteItem
//
this.bindingNavigatorDeleteItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorDeleteItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image")));
this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem";
this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorDeleteItem.Text = "Delete";
//
// bindingNavigatorMoveFirstItem
//
this.bindingNavigatorMoveFirstItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMoveFirstItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image")));
this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem";
this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMoveFirstItem.Text = "Move first";
//
// bindingNavigatorMovePreviousItem
//
this.bindingNavigatorMovePreviousItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMovePreviousItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image"))
);
this.bindingNavigatorMovePreviousItem.Name =
"bindingNavigatorMovePreviousItem";
this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMovePreviousItem.Text = "Move previous";
//
// bindingNavigatorSeparator
//
this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator";
this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25);
//
// bindingNavigatorPositionItem
//
this.bindingNavigatorPositionItem.AccessibleName = "Position";
this.bindingNavigatorPositionItem.AutoSize = false;
this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem";
this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 23);
this.bindingNavigatorPositionItem.Text = "0";
this.bindingNavigatorPositionItem.ToolTipText = "Current position";
//
// bindingNavigatorSeparator1
//
this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator1";
this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 25);
//
// bindingNavigatorMoveNextItem
//
this.bindingNavigatorMoveNextItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMoveNextItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image")));
this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem";
this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMoveNextItem.Text = "Move next";
//
// bindingNavigatorMoveLastItem
//
this.bindingNavigatorMoveLastItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.bindingNavigatorMoveLastItem.Image =
((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image")));
this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem";
this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true;
this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(23, 22);
this.bindingNavigatorMoveLastItem.Text = "Move last";
//
// bindingNavigatorSeparator2
//
this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator2";
this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25);
//
// cityBindingNavigatorSaveItem
//
this.cityBindingNavigatorSaveItem.DisplayStyle =
System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.cityBindingNavigatorSaveItem.Image =
((System.Drawing.Image)(resources.GetObject("cityBindingNavigatorSaveItem.Image")));
this.cityBindingNavigatorSaveItem.Name = "cityBindingNavigatorSaveItem";
this.cityBindingNavigatorSaveItem.Size = new System.Drawing.Size(23, 22);
this.cityBindingNavigatorSaveItem.Text = "Save Data";
this.cityBindingNavigatorSaveItem.Click += new
System.EventHandler(this.cityBindingNavigatorSaveItem_Click);
//
// cityDataGridView
//
this.cityDataGridView.AutoGenerateColumns = false;
this.cityDataGridView.ColumnHeadersHeightSizeMode =
System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.cityDataGridView.Columns.AddRange(new
System.Windows.Forms.DataGridViewColumn[] {
this.dataGridViewTextBoxColumn1,
this.dataGridViewTextBoxColumn2});
this.cityDataGridView.DataSource = this.cityBindingSource;
this.cityDataGridView.Location = new System.Drawing.Point(12, 28);
this.cityDataGridView.Name = "cityDataGridView";
this.cityDataGridView.Size = new System.Drawing.Size(259, 296);
this.cityDataGridView.TabIndex = 4;
//
// dataGridViewTextBoxColumn1
//
this.dataGridViewTextBoxColumn1.DataPropertyName = "City";
this.dataGridViewTextBoxColumn1.HeaderText = "City";
this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
//
// dataGridViewTextBoxColumn2
//
this.dataGridViewTextBoxColumn2.DataPropertyName = "Population";
this.dataGridViewTextBoxColumn2.HeaderText = "Population";
this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
//
// grpSort
//
this.grpSort.Controls.Add(this.btnName);
this.grpSort.Controls.Add(this.btnDescPopulation);
this.grpSort.Controls.Add(this.btnAscPopulation);
this.grpSort.Location = new System.Drawing.Point(294, 28);
this.grpSort.Name = "grpSort";
this.grpSort.Size = new System.Drawing.Size(243, 121);
this.grpSort.TabIndex = 0;
this.grpSort.TabStop = false;
this.grpSort.Text = "Sort By";
//
// btnName
//
this.btnName.Location = new System.Drawing.Point(65, 68);
this.btnName.Name = "btnName";
this.btnName.Size = new System.Drawing.Size(110, 41);
this.btnName.TabIndex = 2;
this.btnName.Text = "City Name";
this.btnName.UseVisualStyleBackColor = true;
this.btnName.Click += new System.EventHandler(this.btnName_Click);
//
// btnDescPopulation
//
this.btnDescPopulation.Location = new System.Drawing.Point(124, 21);
this.btnDescPopulation.Name = "btnDescPopulation";
this.btnDescPopulation.Size = new System.Drawing.Size(110, 41);
this.btnDescPopulation.TabIndex = 1;
this.btnDescPopulation.Text = "Population in Descending Order";
this.btnDescPopulation.UseVisualStyleBackColor = true;
this.btnDescPopulation.Click += new
System.EventHandler(this.btnDescPopulation_Click);
//
// btnAscPopulation
//
this.btnAscPopulation.Location = new System.Drawing.Point(8, 21);
this.btnAscPopulation.Name = "btnAscPopulation";
this.btnAscPopulation.Size = new System.Drawing.Size(110, 41);
this.btnAscPopulation.TabIndex = 0;
this.btnAscPopulation.Text = "Population in Ascending Order";
this.btnAscPopulation.UseVisualStyleBackColor = true;
this.btnAscPopulation.Click += new
System.EventHandler(this.btnAscPopulation_Click);
//
// grpDisplay
//
this.grpDisplay.Controls.Add(this.btnMinPopulation);
this.grpDisplay.Controls.Add(this.btnMaxPopulation);
this.grpDisplay.Controls.Add(this.btnAverage);
this.grpDisplay.Controls.Add(this.btnTotal);
this.grpDisplay.Location = new System.Drawing.Point(294, 155);
this.grpDisplay.Name = "grpDisplay";
this.grpDisplay.Size = new System.Drawing.Size(243, 121);
this.grpDisplay.TabIndex = 1;
this.grpDisplay.TabStop = false;
this.grpDisplay.Text = "Display";
//
// btnMinPopulation
//
this.btnMinPopulation.Location = new System.Drawing.Point(124, 68);
this.btnMinPopulation.Name = "btnMinPopulation";
this.btnMinPopulation.Size = new System.Drawing.Size(110, 41);
this.btnMinPopulation.TabIndex = 4;
this.btnMinPopulation.Text = "Lowest Population";
this.btnMinPopulation.UseVisualStyleBackColor = true;
this.btnMinPopulation.Click += new
System.EventHandler(this.btnMinPopulation_Click);
//
// btnMaxPopulation
//
this.btnMaxPopulation.Location = new System.Drawing.Point(8, 68);
this.btnMaxPopulation.Name = "btnMaxPopulation";
this.btnMaxPopulation.Size = new System.Drawing.Size(110, 41);
this.btnMaxPopulation.TabIndex = 3;
this.btnMaxPopulation.Text = "Highest Population";
this.btnMaxPopulation.UseVisualStyleBackColor = true;
this.btnMaxPopulation.Click += new
System.EventHandler(this.btnMaxPopulation_Click);
//
// btnAverage
//
this.btnAverage.Location = new System.Drawing.Point(124, 21);
this.btnAverage.Name = "btnAverage";
this.btnAverage.Size = new System.Drawing.Size(110, 41);
this.btnAverage.TabIndex = 2;
this.btnAverage.Text = "Average Population";
this.btnAverage.UseVisualStyleBackColor = true;
this.btnAverage.Click += new System.EventHandler(this.btnAverage_Click);
//
// btnTotal
//
this.btnTotal.Location = new System.Drawing.Point(8, 21);
this.btnTotal.Name = "btnTotal";
this.btnTotal.Size = new System.Drawing.Size(110, 41);
this.btnTotal.TabIndex = 1;
this.btnTotal.Text = "Total Population";
this.btnTotal.UseVisualStyleBackColor = true;
this.btnTotal.Click += new System.EventHandler(this.btnTotal_Click);
//
// btnExit
//
this.btnExit.Location = new System.Drawing.Point(359, 283);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(110, 41);
this.btnExit.TabIndex = 2;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// cityTableAdapter
//
this.cityTableAdapter.ClearBeforeFill = true;
//
// tableAdapterManager
//
this.tableAdapterManager.BackupDataSetBeforeUpdate = false;
this.tableAdapterManager.CityTableAdapter = this.cityTableAdapter;
this.tableAdapterManager.UpdateOrder =
Population_Database.CityDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.Inse
rtUpdateDelete;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnExit;
this.ClientSize = new System.Drawing.Size(560, 336);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.grpDisplay);
this.Controls.Add(this.grpSort);
this.Controls.Add(this.cityDataGridView);
this.Controls.Add(this.cityBindingNavigator);
this.Name = "Form1";
this.Text = "Population Database";
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.cityBindingNavigator)).EndInit();
this.cityBindingNavigator.ResumeLayout(false);
this.cityBindingNavigator.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.cityBindingSource)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cityDataSet)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cityDataGridView)).EndInit();
this.grpSort.ResumeLayout(false);
this.grpDisplay.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private CityDataSet cityDataSet;
private System.Windows.Forms.BindingSource cityBindingSource;
private CityDataSetTableAdapters.CityTableAdapter cityTableAdapter;
private CityDataSetTableAdapters.TableAdapterManager tableAdapterManager;
private System.Windows.Forms.BindingNavigator cityBindingNavigator;
private System.Windows.Forms.ToolStripButton bindingNavigatorAddNewItem;
private System.Windows.Forms.ToolStripLabel bindingNavigatorCountItem;
private System.Windows.Forms.ToolStripButton bindingNavigatorDeleteItem;
private System.Windows.Forms.ToolStripButton bindingNavigatorMoveFirstItem;
private System.Windows.Forms.ToolStripButton bindingNavigatorMovePreviousItem;
private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator;
private System.Windows.Forms.ToolStripTextBox bindingNavigatorPositionItem;
private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator1;
private System.Windows.Forms.ToolStripButton bindingNavigatorMoveNextItem;
private System.Windows.Forms.ToolStripButton bindingNavigatorMoveLastItem;
private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator2;
private System.Windows.Forms.ToolStripButton cityBindingNavigatorSaveItem;
private System.Windows.Forms.DataGridView cityDataGridView;
private System.Windows.Forms.DataGridViewTextBoxColumn
dataGridViewTextBoxColumn1;
private System.Windows.Forms.DataGridViewTextBoxColumn
dataGridViewTextBoxColumn2;
private System.Windows.Forms.GroupBox grpSort;
private System.Windows.Forms.GroupBox grpDisplay;
private System.Windows.Forms.Button btnDescPopulation;
private System.Windows.Forms.Button btnAscPopulation;
private System.Windows.Forms.Button btnName;
private System.Windows.Forms.Button btnMinPopulation;
private System.Windows.Forms.Button btnMaxPopulation;
private System.Windows.Forms.Button btnAverage;
private System.Windows.Forms.Button btnTotal;
private System.Windows.Forms.Button btnExit;
}
}

More Related Content

Similar to Program.csusing System; using System.Collections.Generic; usin.pdf

Programming in C#Define an application to include classes for Stud.pdf
Programming in C#Define an application to include classes for Stud.pdfProgramming in C#Define an application to include classes for Stud.pdf
Programming in C#Define an application to include classes for Stud.pdf
fashionscollect
 
Needs to be solved with Visual C# from the book Starting oout .pdf
Needs to be solved with Visual C# from the book Starting oout .pdfNeeds to be solved with Visual C# from the book Starting oout .pdf
Needs to be solved with Visual C# from the book Starting oout .pdf
foottraders
 
This project should be done in C# using Visual Studio - Windows Form.pdf
This project should be done in C# using Visual Studio - Windows Form.pdfThis project should be done in C# using Visual Studio - Windows Form.pdf
This project should be done in C# using Visual Studio - Windows Form.pdf
rajeshjangid1865
 
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docxMicrosoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
scroghamtressie
 

Similar to Program.csusing System; using System.Collections.Generic; usin.pdf (20)

React hooks
React hooksReact hooks
React hooks
 
Programming in C#Define an application to include classes for Stud.pdf
Programming in C#Define an application to include classes for Stud.pdfProgramming in C#Define an application to include classes for Stud.pdf
Programming in C#Define an application to include classes for Stud.pdf
 
2310 b 05
2310 b 052310 b 05
2310 b 05
 
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAMPROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
PROGRAMMING USING C# .NET - SARASWATHI RAMALINGAM
 
Needs to be solved with Visual C# from the book Starting oout .pdf
Needs to be solved with Visual C# from the book Starting oout .pdfNeeds to be solved with Visual C# from the book Starting oout .pdf
Needs to be solved with Visual C# from the book Starting oout .pdf
 
CS 151 Unit 7 Assignment
CS 151 Unit 7 AssignmentCS 151 Unit 7 Assignment
CS 151 Unit 7 Assignment
 
12 gui concepts 1
12 gui concepts 112 gui concepts 1
12 gui concepts 1
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
Tutorial 6.docx
Tutorial 6.docxTutorial 6.docx
Tutorial 6.docx
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
 
Coding java.txt
Coding java.txtCoding java.txt
Coding java.txt
 
Csphtp1 12
Csphtp1 12Csphtp1 12
Csphtp1 12
 
201003 - Abdullah.pdf
201003 - Abdullah.pdf201003 - Abdullah.pdf
201003 - Abdullah.pdf
 
16 interacting with user data contacts and appointments
16   interacting with user data contacts and appointments16   interacting with user data contacts and appointments
16 interacting with user data contacts and appointments
 
PyCon SG x Jublia - Building a simple-to-use Database Management tool
PyCon SG x Jublia - Building a simple-to-use Database Management toolPyCon SG x Jublia - Building a simple-to-use Database Management tool
PyCon SG x Jublia - Building a simple-to-use Database Management tool
 
Vaadin today and tomorrow
Vaadin today and tomorrowVaadin today and tomorrow
Vaadin today and tomorrow
 
This project should be done in C# using Visual Studio - Windows Form.pdf
This project should be done in C# using Visual Studio - Windows Form.pdfThis project should be done in C# using Visual Studio - Windows Form.pdf
This project should be done in C# using Visual Studio - Windows Form.pdf
 
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docxMicrosoft Visual C# 2012- An introduction to object-oriented programmi.docx
Microsoft Visual C# 2012- An introduction to object-oriented programmi.docx
 
New text document
New text documentNew text document
New text document
 
React Native custom components
React Native custom componentsReact Native custom components
React Native custom components
 

More from anandf0099

What is a Distributed System Compare it with a computer network sys.pdf
What is a Distributed System Compare it with a computer network sys.pdfWhat is a Distributed System Compare it with a computer network sys.pdf
What is a Distributed System Compare it with a computer network sys.pdf
anandf0099
 
USES OF FINANCIAL STATEMENT ANALYSISFINANCIAL STATEMENT ANALYSIS .pdf
USES OF FINANCIAL STATEMENT ANALYSISFINANCIAL STATEMENT ANALYSIS .pdfUSES OF FINANCIAL STATEMENT ANALYSISFINANCIAL STATEMENT ANALYSIS .pdf
USES OF FINANCIAL STATEMENT ANALYSISFINANCIAL STATEMENT ANALYSIS .pdf
anandf0099
 
The movement of watersolvent across the osmotic gradient takes plac.pdf
The movement of watersolvent across the osmotic gradient takes plac.pdfThe movement of watersolvent across the osmotic gradient takes plac.pdf
The movement of watersolvent across the osmotic gradient takes plac.pdf
anandf0099
 
Ques-1 Development of tube feet of CRINOIDEADevelopment of tube f.pdf
Ques-1 Development of tube feet of CRINOIDEADevelopment of tube f.pdfQues-1 Development of tube feet of CRINOIDEADevelopment of tube f.pdf
Ques-1 Development of tube feet of CRINOIDEADevelopment of tube f.pdf
anandf0099
 
package chegg;import java.util.ArrayList; import java.util.List;.pdf
package chegg;import java.util.ArrayList; import java.util.List;.pdfpackage chegg;import java.util.ArrayList; import java.util.List;.pdf
package chegg;import java.util.ArrayList; import java.util.List;.pdf
anandf0099
 
Issue of Equity or Debt are commonly used methods for business finan.pdf
Issue of Equity or Debt are commonly used methods for business finan.pdfIssue of Equity or Debt are commonly used methods for business finan.pdf
Issue of Equity or Debt are commonly used methods for business finan.pdf
anandf0099
 
In probability we have two types of eventsIndependent Events who.pdf
In probability we have two types of eventsIndependent Events who.pdfIn probability we have two types of eventsIndependent Events who.pdf
In probability we have two types of eventsIndependent Events who.pdf
anandf0099
 
i have written ths code as per your requirements with clear comments.pdf
i have written ths code as per your requirements with clear comments.pdfi have written ths code as per your requirements with clear comments.pdf
i have written ths code as per your requirements with clear comments.pdf
anandf0099
 
Hi,Please fidn the Answer.Sorting,h is Header .pdf
Hi,Please fidn the Answer.Sorting,h is Header .pdfHi,Please fidn the Answer.Sorting,h is Header .pdf
Hi,Please fidn the Answer.Sorting,h is Header .pdf
anandf0099
 

More from anandf0099 (20)

Riboflavin is required in the conversion of carbo.pdf
                     Riboflavin is required in the conversion of carbo.pdf                     Riboflavin is required in the conversion of carbo.pdf
Riboflavin is required in the conversion of carbo.pdf
 
PbS,Ag2O and CaSO4 are stable as they are insolub.pdf
                     PbS,Ag2O and CaSO4 are stable as they are insolub.pdf                     PbS,Ag2O and CaSO4 are stable as they are insolub.pdf
PbS,Ag2O and CaSO4 are stable as they are insolub.pdf
 
Optio D is the correct one. .pdf
                     Optio D is the correct one.                      .pdf                     Optio D is the correct one.                      .pdf
Optio D is the correct one. .pdf
 
Image not seenfound .pdf
                     Image not seenfound                             .pdf                     Image not seenfound                             .pdf
Image not seenfound .pdf
 
If multiple orbitals of the same energy are avail.pdf
                     If multiple orbitals of the same energy are avail.pdf                     If multiple orbitals of the same energy are avail.pdf
If multiple orbitals of the same energy are avail.pdf
 
What is a Distributed System Compare it with a computer network sys.pdf
What is a Distributed System Compare it with a computer network sys.pdfWhat is a Distributed System Compare it with a computer network sys.pdf
What is a Distributed System Compare it with a computer network sys.pdf
 
USES OF FINANCIAL STATEMENT ANALYSISFINANCIAL STATEMENT ANALYSIS .pdf
USES OF FINANCIAL STATEMENT ANALYSISFINANCIAL STATEMENT ANALYSIS .pdfUSES OF FINANCIAL STATEMENT ANALYSISFINANCIAL STATEMENT ANALYSIS .pdf
USES OF FINANCIAL STATEMENT ANALYSISFINANCIAL STATEMENT ANALYSIS .pdf
 
The movement of watersolvent across the osmotic gradient takes plac.pdf
The movement of watersolvent across the osmotic gradient takes plac.pdfThe movement of watersolvent across the osmotic gradient takes plac.pdf
The movement of watersolvent across the osmotic gradient takes plac.pdf
 
These groups are closely related not only is SO(2) a subgroup of O(.pdf
These groups are closely related not only is SO(2) a subgroup of O(.pdfThese groups are closely related not only is SO(2) a subgroup of O(.pdf
These groups are closely related not only is SO(2) a subgroup of O(.pdf
 
The probability of atom has zero quanta of energy is      P=Number.pdf
The probability of atom has zero quanta of energy is      P=Number.pdfThe probability of atom has zero quanta of energy is      P=Number.pdf
The probability of atom has zero quanta of energy is      P=Number.pdf
 
Copper turns green because it oxidizes. Coppe.pdf
                     Copper turns green because it oxidizes. Coppe.pdf                     Copper turns green because it oxidizes. Coppe.pdf
Copper turns green because it oxidizes. Coppe.pdf
 
CO2 and NO2 are acidic oxides as non-metal form a.pdf
                     CO2 and NO2 are acidic oxides as non-metal form a.pdf                     CO2 and NO2 are acidic oxides as non-metal form a.pdf
CO2 and NO2 are acidic oxides as non-metal form a.pdf
 
Ques-1 Development of tube feet of CRINOIDEADevelopment of tube f.pdf
Ques-1 Development of tube feet of CRINOIDEADevelopment of tube f.pdfQues-1 Development of tube feet of CRINOIDEADevelopment of tube f.pdf
Ques-1 Development of tube feet of CRINOIDEADevelopment of tube f.pdf
 
package chegg;import java.util.ArrayList; import java.util.List;.pdf
package chegg;import java.util.ArrayList; import java.util.List;.pdfpackage chegg;import java.util.ArrayList; import java.util.List;.pdf
package chegg;import java.util.ArrayList; import java.util.List;.pdf
 
B. propene. Solution B. p.pdf
                     B. propene. Solution                     B. p.pdf                     B. propene. Solution                     B. p.pdf
B. propene. Solution B. p.pdf
 
L{e^{-t}} = int _0 to infinty [e^{st}e^{2-t} dt = int _0 to infinty.pdf
L{e^{-t}} = int _0 to infinty [e^{st}e^{2-t} dt = int _0 to infinty.pdfL{e^{-t}} = int _0 to infinty [e^{st}e^{2-t} dt = int _0 to infinty.pdf
L{e^{-t}} = int _0 to infinty [e^{st}e^{2-t} dt = int _0 to infinty.pdf
 
Issue of Equity or Debt are commonly used methods for business finan.pdf
Issue of Equity or Debt are commonly used methods for business finan.pdfIssue of Equity or Debt are commonly used methods for business finan.pdf
Issue of Equity or Debt are commonly used methods for business finan.pdf
 
In probability we have two types of eventsIndependent Events who.pdf
In probability we have two types of eventsIndependent Events who.pdfIn probability we have two types of eventsIndependent Events who.pdf
In probability we have two types of eventsIndependent Events who.pdf
 
i have written ths code as per your requirements with clear comments.pdf
i have written ths code as per your requirements with clear comments.pdfi have written ths code as per your requirements with clear comments.pdf
i have written ths code as per your requirements with clear comments.pdf
 
Hi,Please fidn the Answer.Sorting,h is Header .pdf
Hi,Please fidn the Answer.Sorting,h is Header .pdfHi,Please fidn the Answer.Sorting,h is Header .pdf
Hi,Please fidn the Answer.Sorting,h is Header .pdf
 

Recently uploaded

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
SoniaTolstoy
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Recently uploaded (20)

Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

Program.csusing System; using System.Collections.Generic; usin.pdf

  • 1. Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace Population_Database { static class Program { static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Population_Database { public partial class Form1 : Form { public Form1() {
  • 2. InitializeComponent(); } private void cityBindingNavigatorSaveItem_Click(object sender, EventArgs e) { this.Validate(); this.cityBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.cityDataSet); } private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'cityDataSet.City' table. You can move, or remove it, as needed. this.cityTableAdapter.Fill(this.cityDataSet.City); } private void btnAscPopulation_Click(object sender, EventArgs e) { // Sort the table by population in ascending order this.cityTableAdapter.FillByAscPopulation(this.cityDataSet.City); } private void btnDescPopulation_Click(object sender, EventArgs e) { // Sort the table by population in descending order this.cityTableAdapter.FillByDescPopulation(this.cityDataSet.City); } private void btnName_Click(object sender, EventArgs e) { this.cityTableAdapter.FillByCity(this.cityDataSet.City); } private void btnTotal_Click(object sender, EventArgs e) { // Declare variable to hold total population. double totalPopulation; // Get the total population. totalPopulation = (double)this.cityTableAdapter.TotalPopulation(); // Display the total population. MessageBox.Show("Total Population: " + totalPopulation.ToString("n0"));
  • 3. } private void btnAverage_Click(object sender, EventArgs e) { // Declare variable to hold average population. double averagePopulation; // Get the average population. averagePopulation = (double)this.cityTableAdapter.AveragePopulation(); // Display the average population. MessageBox.Show("Average Population: " + averagePopulation.ToString("n0")); } private void btnMaxPopulation_Click(object sender, EventArgs e) { // Declare variable to hold highest population. double maxPopulation; // Get the highest population. maxPopulation = (double)this.cityTableAdapter.MaxPopulation(); // Display the highest population. MessageBox.Show("Highest Population: " + maxPopulation.ToString("n0")); } private void btnMinPopulation_Click(object sender, EventArgs e) { // Declare variable to hold lowest population. double minPopulation; // Get the lowest population. minPopulation = (double)this.cityTableAdapter.MinPopulation(); // Display the lowest population. MessageBox.Show("Lowest Population: " + minPopulation.ToString("n0")); } private void btnExit_Click(object sender, EventArgs e) { // Close the form. this.Close(); } } }
  • 4. Form1.Designer.cs namespace Population_Database { partial class Form1 { private System.ComponentModel.IContainer components = null; protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.cityBindingNavigator = new System.Windows.Forms.BindingNavigator(this.components); this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton(); this.cityBindingSource = new System.Windows.Forms.BindingSource(this.components); this.cityDataSet = new Population_Database.CityDataSet(); this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel(); this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorMovePreviousItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator(); this.bindingNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox(); this.bindingNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.bindingNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator();
  • 5. this.cityBindingNavigatorSaveItem = new System.Windows.Forms.ToolStripButton(); this.cityDataGridView = new System.Windows.Forms.DataGridView(); this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.grpSort = new System.Windows.Forms.GroupBox(); this.btnName = new System.Windows.Forms.Button(); this.btnDescPopulation = new System.Windows.Forms.Button(); this.btnAscPopulation = new System.Windows.Forms.Button(); this.grpDisplay = new System.Windows.Forms.GroupBox(); this.btnMinPopulation = new System.Windows.Forms.Button(); this.btnMaxPopulation = new System.Windows.Forms.Button(); this.btnAverage = new System.Windows.Forms.Button(); this.btnTotal = new System.Windows.Forms.Button(); this.btnExit = new System.Windows.Forms.Button(); this.cityTableAdapter = new Population_Database.CityDataSetTableAdapters.CityTableAdapter(); this.tableAdapterManager = new Population_Database.CityDataSetTableAdapters.TableAdapterManager(); ((System.ComponentModel.ISupportInitialize)(this.cityBindingNavigator)).BeginInit(); this.cityBindingNavigator.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.cityBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.cityDataSet)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.cityDataGridView)).BeginInit(); this.grpSort.SuspendLayout(); this.grpDisplay.SuspendLayout(); this.SuspendLayout(); // // cityBindingNavigator // this.cityBindingNavigator.AddNewItem = this.bindingNavigatorAddNewItem; this.cityBindingNavigator.BindingSource = this.cityBindingSource; this.cityBindingNavigator.CountItem = this.bindingNavigatorCountItem; this.cityBindingNavigator.DeleteItem = this.bindingNavigatorDeleteItem; this.cityBindingNavigator.Items.AddRange(new
  • 6. System.Windows.Forms.ToolStripItem[] { this.bindingNavigatorMoveFirstItem, this.bindingNavigatorMovePreviousItem, this.bindingNavigatorSeparator, this.bindingNavigatorPositionItem, this.bindingNavigatorCountItem, this.bindingNavigatorSeparator1, this.bindingNavigatorMoveNextItem, this.bindingNavigatorMoveLastItem, this.bindingNavigatorSeparator2, this.bindingNavigatorAddNewItem, this.bindingNavigatorDeleteItem, this.cityBindingNavigatorSaveItem}); this.cityBindingNavigator.Location = new System.Drawing.Point(0, 0); this.cityBindingNavigator.MoveFirstItem = this.bindingNavigatorMoveFirstItem; this.cityBindingNavigator.MoveLastItem = this.bindingNavigatorMoveLastItem; this.cityBindingNavigator.MoveNextItem = this.bindingNavigatorMoveNextItem; this.cityBindingNavigator.MovePreviousItem = this.bindingNavigatorMovePreviousItem; this.cityBindingNavigator.Name = "cityBindingNavigator"; this.cityBindingNavigator.PositionItem = this.bindingNavigatorPositionItem; this.cityBindingNavigator.Size = new System.Drawing.Size(560, 25); this.cityBindingNavigator.TabIndex = 3; this.cityBindingNavigator.Text = "bindingNavigator1"; // // bindingNavigatorAddNewItem // this.bindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorAddNewItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image"))); this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem"; this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorAddNewItem.Text = "Add new"; //
  • 7. // cityBindingSource // this.cityBindingSource.DataMember = "City"; this.cityBindingSource.DataSource = this.cityDataSet; // // cityDataSet // this.cityDataSet.DataSetName = "CityDataSet"; this.cityDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // bindingNavigatorCountItem // this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem"; this.bindingNavigatorCountItem.Size = new System.Drawing.Size(35, 22); this.bindingNavigatorCountItem.Text = "of {0}"; this.bindingNavigatorCountItem.ToolTipText = "Total number of items"; // // bindingNavigatorDeleteItem // this.bindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorDeleteItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image"))); this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem"; this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorDeleteItem.Text = "Delete"; // // bindingNavigatorMoveFirstItem // this.bindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorMoveFirstItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image"))); this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem";
  • 8. this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorMoveFirstItem.Text = "Move first"; // // bindingNavigatorMovePreviousItem // this.bindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorMovePreviousItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image")) ); this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem"; this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorMovePreviousItem.Text = "Move previous"; // // bindingNavigatorSeparator // this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator"; this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25); // // bindingNavigatorPositionItem // this.bindingNavigatorPositionItem.AccessibleName = "Position"; this.bindingNavigatorPositionItem.AutoSize = false; this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem"; this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 23); this.bindingNavigatorPositionItem.Text = "0"; this.bindingNavigatorPositionItem.ToolTipText = "Current position"; // // bindingNavigatorSeparator1 // this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator1"; this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 25); //
  • 9. // bindingNavigatorMoveNextItem // this.bindingNavigatorMoveNextItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorMoveNextItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image"))); this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem"; this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorMoveNextItem.Text = "Move next"; // // bindingNavigatorMoveLastItem // this.bindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorMoveLastItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image"))); this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem"; this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorMoveLastItem.Text = "Move last"; // // bindingNavigatorSeparator2 // this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator2"; this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25); // // cityBindingNavigatorSaveItem // this.cityBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.cityBindingNavigatorSaveItem.Image = ((System.Drawing.Image)(resources.GetObject("cityBindingNavigatorSaveItem.Image"))); this.cityBindingNavigatorSaveItem.Name = "cityBindingNavigatorSaveItem"; this.cityBindingNavigatorSaveItem.Size = new System.Drawing.Size(23, 22); this.cityBindingNavigatorSaveItem.Text = "Save Data";
  • 10. this.cityBindingNavigatorSaveItem.Click += new System.EventHandler(this.cityBindingNavigatorSaveItem_Click); // // cityDataGridView // this.cityDataGridView.AutoGenerateColumns = false; this.cityDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.cityDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridViewTextBoxColumn1, this.dataGridViewTextBoxColumn2}); this.cityDataGridView.DataSource = this.cityBindingSource; this.cityDataGridView.Location = new System.Drawing.Point(12, 28); this.cityDataGridView.Name = "cityDataGridView"; this.cityDataGridView.Size = new System.Drawing.Size(259, 296); this.cityDataGridView.TabIndex = 4; // // dataGridViewTextBoxColumn1 // this.dataGridViewTextBoxColumn1.DataPropertyName = "City"; this.dataGridViewTextBoxColumn1.HeaderText = "City"; this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; // // dataGridViewTextBoxColumn2 // this.dataGridViewTextBoxColumn2.DataPropertyName = "Population"; this.dataGridViewTextBoxColumn2.HeaderText = "Population"; this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; // // grpSort // this.grpSort.Controls.Add(this.btnName); this.grpSort.Controls.Add(this.btnDescPopulation); this.grpSort.Controls.Add(this.btnAscPopulation); this.grpSort.Location = new System.Drawing.Point(294, 28);
  • 11. this.grpSort.Name = "grpSort"; this.grpSort.Size = new System.Drawing.Size(243, 121); this.grpSort.TabIndex = 0; this.grpSort.TabStop = false; this.grpSort.Text = "Sort By"; // // btnName // this.btnName.Location = new System.Drawing.Point(65, 68); this.btnName.Name = "btnName"; this.btnName.Size = new System.Drawing.Size(110, 41); this.btnName.TabIndex = 2; this.btnName.Text = "City Name"; this.btnName.UseVisualStyleBackColor = true; this.btnName.Click += new System.EventHandler(this.btnName_Click); // // btnDescPopulation // this.btnDescPopulation.Location = new System.Drawing.Point(124, 21); this.btnDescPopulation.Name = "btnDescPopulation"; this.btnDescPopulation.Size = new System.Drawing.Size(110, 41); this.btnDescPopulation.TabIndex = 1; this.btnDescPopulation.Text = "Population in Descending Order"; this.btnDescPopulation.UseVisualStyleBackColor = true; this.btnDescPopulation.Click += new System.EventHandler(this.btnDescPopulation_Click); // // btnAscPopulation // this.btnAscPopulation.Location = new System.Drawing.Point(8, 21); this.btnAscPopulation.Name = "btnAscPopulation"; this.btnAscPopulation.Size = new System.Drawing.Size(110, 41); this.btnAscPopulation.TabIndex = 0; this.btnAscPopulation.Text = "Population in Ascending Order"; this.btnAscPopulation.UseVisualStyleBackColor = true; this.btnAscPopulation.Click += new
  • 12. System.EventHandler(this.btnAscPopulation_Click); // // grpDisplay // this.grpDisplay.Controls.Add(this.btnMinPopulation); this.grpDisplay.Controls.Add(this.btnMaxPopulation); this.grpDisplay.Controls.Add(this.btnAverage); this.grpDisplay.Controls.Add(this.btnTotal); this.grpDisplay.Location = new System.Drawing.Point(294, 155); this.grpDisplay.Name = "grpDisplay"; this.grpDisplay.Size = new System.Drawing.Size(243, 121); this.grpDisplay.TabIndex = 1; this.grpDisplay.TabStop = false; this.grpDisplay.Text = "Display"; // // btnMinPopulation // this.btnMinPopulation.Location = new System.Drawing.Point(124, 68); this.btnMinPopulation.Name = "btnMinPopulation"; this.btnMinPopulation.Size = new System.Drawing.Size(110, 41); this.btnMinPopulation.TabIndex = 4; this.btnMinPopulation.Text = "Lowest Population"; this.btnMinPopulation.UseVisualStyleBackColor = true; this.btnMinPopulation.Click += new System.EventHandler(this.btnMinPopulation_Click); // // btnMaxPopulation // this.btnMaxPopulation.Location = new System.Drawing.Point(8, 68); this.btnMaxPopulation.Name = "btnMaxPopulation"; this.btnMaxPopulation.Size = new System.Drawing.Size(110, 41); this.btnMaxPopulation.TabIndex = 3; this.btnMaxPopulation.Text = "Highest Population"; this.btnMaxPopulation.UseVisualStyleBackColor = true; this.btnMaxPopulation.Click += new System.EventHandler(this.btnMaxPopulation_Click);
  • 13. // // btnAverage // this.btnAverage.Location = new System.Drawing.Point(124, 21); this.btnAverage.Name = "btnAverage"; this.btnAverage.Size = new System.Drawing.Size(110, 41); this.btnAverage.TabIndex = 2; this.btnAverage.Text = "Average Population"; this.btnAverage.UseVisualStyleBackColor = true; this.btnAverage.Click += new System.EventHandler(this.btnAverage_Click); // // btnTotal // this.btnTotal.Location = new System.Drawing.Point(8, 21); this.btnTotal.Name = "btnTotal"; this.btnTotal.Size = new System.Drawing.Size(110, 41); this.btnTotal.TabIndex = 1; this.btnTotal.Text = "Total Population"; this.btnTotal.UseVisualStyleBackColor = true; this.btnTotal.Click += new System.EventHandler(this.btnTotal_Click); // // btnExit // this.btnExit.Location = new System.Drawing.Point(359, 283); this.btnExit.Name = "btnExit"; this.btnExit.Size = new System.Drawing.Size(110, 41); this.btnExit.TabIndex = 2; this.btnExit.Text = "Exit"; this.btnExit.UseVisualStyleBackColor = true; this.btnExit.Click += new System.EventHandler(this.btnExit_Click); // // cityTableAdapter // this.cityTableAdapter.ClearBeforeFill = true; // // tableAdapterManager
  • 14. // this.tableAdapterManager.BackupDataSetBeforeUpdate = false; this.tableAdapterManager.CityTableAdapter = this.cityTableAdapter; this.tableAdapterManager.UpdateOrder = Population_Database.CityDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.Inse rtUpdateDelete; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnExit; this.ClientSize = new System.Drawing.Size(560, 336); this.Controls.Add(this.btnExit); this.Controls.Add(this.grpDisplay); this.Controls.Add(this.grpSort); this.Controls.Add(this.cityDataGridView); this.Controls.Add(this.cityBindingNavigator); this.Name = "Form1"; this.Text = "Population Database"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.cityBindingNavigator)).EndInit(); this.cityBindingNavigator.ResumeLayout(false); this.cityBindingNavigator.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.cityBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.cityDataSet)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.cityDataGridView)).EndInit(); this.grpSort.ResumeLayout(false); this.grpDisplay.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } #endregion private CityDataSet cityDataSet; private System.Windows.Forms.BindingSource cityBindingSource; private CityDataSetTableAdapters.CityTableAdapter cityTableAdapter;
  • 15. private CityDataSetTableAdapters.TableAdapterManager tableAdapterManager; private System.Windows.Forms.BindingNavigator cityBindingNavigator; private System.Windows.Forms.ToolStripButton bindingNavigatorAddNewItem; private System.Windows.Forms.ToolStripLabel bindingNavigatorCountItem; private System.Windows.Forms.ToolStripButton bindingNavigatorDeleteItem; private System.Windows.Forms.ToolStripButton bindingNavigatorMoveFirstItem; private System.Windows.Forms.ToolStripButton bindingNavigatorMovePreviousItem; private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator; private System.Windows.Forms.ToolStripTextBox bindingNavigatorPositionItem; private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator1; private System.Windows.Forms.ToolStripButton bindingNavigatorMoveNextItem; private System.Windows.Forms.ToolStripButton bindingNavigatorMoveLastItem; private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator2; private System.Windows.Forms.ToolStripButton cityBindingNavigatorSaveItem; private System.Windows.Forms.DataGridView cityDataGridView; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; private System.Windows.Forms.GroupBox grpSort; private System.Windows.Forms.GroupBox grpDisplay; private System.Windows.Forms.Button btnDescPopulation; private System.Windows.Forms.Button btnAscPopulation; private System.Windows.Forms.Button btnName; private System.Windows.Forms.Button btnMinPopulation; private System.Windows.Forms.Button btnMaxPopulation; private System.Windows.Forms.Button btnAverage; private System.Windows.Forms.Button btnTotal; private System.Windows.Forms.Button btnExit; } } Solution Program.cs using System;
  • 16. using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Windows.Forms; namespace Population_Database { static class Program { static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Population_Database { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void cityBindingNavigatorSaveItem_Click(object sender, EventArgs e)
  • 17. { this.Validate(); this.cityBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.cityDataSet); } private void Form1_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'cityDataSet.City' table. You can move, or remove it, as needed. this.cityTableAdapter.Fill(this.cityDataSet.City); } private void btnAscPopulation_Click(object sender, EventArgs e) { // Sort the table by population in ascending order this.cityTableAdapter.FillByAscPopulation(this.cityDataSet.City); } private void btnDescPopulation_Click(object sender, EventArgs e) { // Sort the table by population in descending order this.cityTableAdapter.FillByDescPopulation(this.cityDataSet.City); } private void btnName_Click(object sender, EventArgs e) { this.cityTableAdapter.FillByCity(this.cityDataSet.City); } private void btnTotal_Click(object sender, EventArgs e) { // Declare variable to hold total population. double totalPopulation; // Get the total population. totalPopulation = (double)this.cityTableAdapter.TotalPopulation(); // Display the total population. MessageBox.Show("Total Population: " + totalPopulation.ToString("n0")); } private void btnAverage_Click(object sender, EventArgs e) {
  • 18. // Declare variable to hold average population. double averagePopulation; // Get the average population. averagePopulation = (double)this.cityTableAdapter.AveragePopulation(); // Display the average population. MessageBox.Show("Average Population: " + averagePopulation.ToString("n0")); } private void btnMaxPopulation_Click(object sender, EventArgs e) { // Declare variable to hold highest population. double maxPopulation; // Get the highest population. maxPopulation = (double)this.cityTableAdapter.MaxPopulation(); // Display the highest population. MessageBox.Show("Highest Population: " + maxPopulation.ToString("n0")); } private void btnMinPopulation_Click(object sender, EventArgs e) { // Declare variable to hold lowest population. double minPopulation; // Get the lowest population. minPopulation = (double)this.cityTableAdapter.MinPopulation(); // Display the lowest population. MessageBox.Show("Lowest Population: " + minPopulation.ToString("n0")); } private void btnExit_Click(object sender, EventArgs e) { // Close the form. this.Close(); } } } Form1.Designer.cs namespace Population_Database {
  • 19. partial class Form1 { private System.ComponentModel.IContainer components = null; protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.cityBindingNavigator = new System.Windows.Forms.BindingNavigator(this.components); this.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton(); this.cityBindingSource = new System.Windows.Forms.BindingSource(this.components); this.cityDataSet = new Population_Database.CityDataSet(); this.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel(); this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorMoveFirstItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorMovePreviousItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorSeparator = new System.Windows.Forms.ToolStripSeparator(); this.bindingNavigatorPositionItem = new System.Windows.Forms.ToolStripTextBox(); this.bindingNavigatorSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.bindingNavigatorMoveNextItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorMoveLastItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.cityBindingNavigatorSaveItem = new System.Windows.Forms.ToolStripButton(); this.cityDataGridView = new System.Windows.Forms.DataGridView(); this.dataGridViewTextBoxColumn1 = new
  • 20. System.Windows.Forms.DataGridViewTextBoxColumn(); this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.grpSort = new System.Windows.Forms.GroupBox(); this.btnName = new System.Windows.Forms.Button(); this.btnDescPopulation = new System.Windows.Forms.Button(); this.btnAscPopulation = new System.Windows.Forms.Button(); this.grpDisplay = new System.Windows.Forms.GroupBox(); this.btnMinPopulation = new System.Windows.Forms.Button(); this.btnMaxPopulation = new System.Windows.Forms.Button(); this.btnAverage = new System.Windows.Forms.Button(); this.btnTotal = new System.Windows.Forms.Button(); this.btnExit = new System.Windows.Forms.Button(); this.cityTableAdapter = new Population_Database.CityDataSetTableAdapters.CityTableAdapter(); this.tableAdapterManager = new Population_Database.CityDataSetTableAdapters.TableAdapterManager(); ((System.ComponentModel.ISupportInitialize)(this.cityBindingNavigator)).BeginInit(); this.cityBindingNavigator.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.cityBindingSource)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.cityDataSet)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.cityDataGridView)).BeginInit(); this.grpSort.SuspendLayout(); this.grpDisplay.SuspendLayout(); this.SuspendLayout(); // // cityBindingNavigator // this.cityBindingNavigator.AddNewItem = this.bindingNavigatorAddNewItem; this.cityBindingNavigator.BindingSource = this.cityBindingSource; this.cityBindingNavigator.CountItem = this.bindingNavigatorCountItem; this.cityBindingNavigator.DeleteItem = this.bindingNavigatorDeleteItem; this.cityBindingNavigator.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.bindingNavigatorMoveFirstItem, this.bindingNavigatorMovePreviousItem,
  • 21. this.bindingNavigatorSeparator, this.bindingNavigatorPositionItem, this.bindingNavigatorCountItem, this.bindingNavigatorSeparator1, this.bindingNavigatorMoveNextItem, this.bindingNavigatorMoveLastItem, this.bindingNavigatorSeparator2, this.bindingNavigatorAddNewItem, this.bindingNavigatorDeleteItem, this.cityBindingNavigatorSaveItem}); this.cityBindingNavigator.Location = new System.Drawing.Point(0, 0); this.cityBindingNavigator.MoveFirstItem = this.bindingNavigatorMoveFirstItem; this.cityBindingNavigator.MoveLastItem = this.bindingNavigatorMoveLastItem; this.cityBindingNavigator.MoveNextItem = this.bindingNavigatorMoveNextItem; this.cityBindingNavigator.MovePreviousItem = this.bindingNavigatorMovePreviousItem; this.cityBindingNavigator.Name = "cityBindingNavigator"; this.cityBindingNavigator.PositionItem = this.bindingNavigatorPositionItem; this.cityBindingNavigator.Size = new System.Drawing.Size(560, 25); this.cityBindingNavigator.TabIndex = 3; this.cityBindingNavigator.Text = "bindingNavigator1"; // // bindingNavigatorAddNewItem // this.bindingNavigatorAddNewItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorAddNewItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorAddNewItem.Image"))); this.bindingNavigatorAddNewItem.Name = "bindingNavigatorAddNewItem"; this.bindingNavigatorAddNewItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorAddNewItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorAddNewItem.Text = "Add new"; // // cityBindingSource // this.cityBindingSource.DataMember = "City";
  • 22. this.cityBindingSource.DataSource = this.cityDataSet; // // cityDataSet // this.cityDataSet.DataSetName = "CityDataSet"; this.cityDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // bindingNavigatorCountItem // this.bindingNavigatorCountItem.Name = "bindingNavigatorCountItem"; this.bindingNavigatorCountItem.Size = new System.Drawing.Size(35, 22); this.bindingNavigatorCountItem.Text = "of {0}"; this.bindingNavigatorCountItem.ToolTipText = "Total number of items"; // // bindingNavigatorDeleteItem // this.bindingNavigatorDeleteItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorDeleteItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorDeleteItem.Image"))); this.bindingNavigatorDeleteItem.Name = "bindingNavigatorDeleteItem"; this.bindingNavigatorDeleteItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorDeleteItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorDeleteItem.Text = "Delete"; // // bindingNavigatorMoveFirstItem // this.bindingNavigatorMoveFirstItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorMoveFirstItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveFirstItem.Image"))); this.bindingNavigatorMoveFirstItem.Name = "bindingNavigatorMoveFirstItem"; this.bindingNavigatorMoveFirstItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorMoveFirstItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorMoveFirstItem.Text = "Move first";
  • 23. // // bindingNavigatorMovePreviousItem // this.bindingNavigatorMovePreviousItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorMovePreviousItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMovePreviousItem.Image")) ); this.bindingNavigatorMovePreviousItem.Name = "bindingNavigatorMovePreviousItem"; this.bindingNavigatorMovePreviousItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorMovePreviousItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorMovePreviousItem.Text = "Move previous"; // // bindingNavigatorSeparator // this.bindingNavigatorSeparator.Name = "bindingNavigatorSeparator"; this.bindingNavigatorSeparator.Size = new System.Drawing.Size(6, 25); // // bindingNavigatorPositionItem // this.bindingNavigatorPositionItem.AccessibleName = "Position"; this.bindingNavigatorPositionItem.AutoSize = false; this.bindingNavigatorPositionItem.Name = "bindingNavigatorPositionItem"; this.bindingNavigatorPositionItem.Size = new System.Drawing.Size(50, 23); this.bindingNavigatorPositionItem.Text = "0"; this.bindingNavigatorPositionItem.ToolTipText = "Current position"; // // bindingNavigatorSeparator1 // this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator1"; this.bindingNavigatorSeparator1.Size = new System.Drawing.Size(6, 25); // // bindingNavigatorMoveNextItem // this.bindingNavigatorMoveNextItem.DisplayStyle =
  • 24. System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorMoveNextItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveNextItem.Image"))); this.bindingNavigatorMoveNextItem.Name = "bindingNavigatorMoveNextItem"; this.bindingNavigatorMoveNextItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorMoveNextItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorMoveNextItem.Text = "Move next"; // // bindingNavigatorMoveLastItem // this.bindingNavigatorMoveLastItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.bindingNavigatorMoveLastItem.Image = ((System.Drawing.Image)(resources.GetObject("bindingNavigatorMoveLastItem.Image"))); this.bindingNavigatorMoveLastItem.Name = "bindingNavigatorMoveLastItem"; this.bindingNavigatorMoveLastItem.RightToLeftAutoMirrorImage = true; this.bindingNavigatorMoveLastItem.Size = new System.Drawing.Size(23, 22); this.bindingNavigatorMoveLastItem.Text = "Move last"; // // bindingNavigatorSeparator2 // this.bindingNavigatorSeparator2.Name = "bindingNavigatorSeparator2"; this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25); // // cityBindingNavigatorSaveItem // this.cityBindingNavigatorSaveItem.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.cityBindingNavigatorSaveItem.Image = ((System.Drawing.Image)(resources.GetObject("cityBindingNavigatorSaveItem.Image"))); this.cityBindingNavigatorSaveItem.Name = "cityBindingNavigatorSaveItem"; this.cityBindingNavigatorSaveItem.Size = new System.Drawing.Size(23, 22); this.cityBindingNavigatorSaveItem.Text = "Save Data"; this.cityBindingNavigatorSaveItem.Click += new System.EventHandler(this.cityBindingNavigatorSaveItem_Click); //
  • 25. // cityDataGridView // this.cityDataGridView.AutoGenerateColumns = false; this.cityDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.cityDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridViewTextBoxColumn1, this.dataGridViewTextBoxColumn2}); this.cityDataGridView.DataSource = this.cityBindingSource; this.cityDataGridView.Location = new System.Drawing.Point(12, 28); this.cityDataGridView.Name = "cityDataGridView"; this.cityDataGridView.Size = new System.Drawing.Size(259, 296); this.cityDataGridView.TabIndex = 4; // // dataGridViewTextBoxColumn1 // this.dataGridViewTextBoxColumn1.DataPropertyName = "City"; this.dataGridViewTextBoxColumn1.HeaderText = "City"; this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1"; // // dataGridViewTextBoxColumn2 // this.dataGridViewTextBoxColumn2.DataPropertyName = "Population"; this.dataGridViewTextBoxColumn2.HeaderText = "Population"; this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; // // grpSort // this.grpSort.Controls.Add(this.btnName); this.grpSort.Controls.Add(this.btnDescPopulation); this.grpSort.Controls.Add(this.btnAscPopulation); this.grpSort.Location = new System.Drawing.Point(294, 28); this.grpSort.Name = "grpSort"; this.grpSort.Size = new System.Drawing.Size(243, 121); this.grpSort.TabIndex = 0;
  • 26. this.grpSort.TabStop = false; this.grpSort.Text = "Sort By"; // // btnName // this.btnName.Location = new System.Drawing.Point(65, 68); this.btnName.Name = "btnName"; this.btnName.Size = new System.Drawing.Size(110, 41); this.btnName.TabIndex = 2; this.btnName.Text = "City Name"; this.btnName.UseVisualStyleBackColor = true; this.btnName.Click += new System.EventHandler(this.btnName_Click); // // btnDescPopulation // this.btnDescPopulation.Location = new System.Drawing.Point(124, 21); this.btnDescPopulation.Name = "btnDescPopulation"; this.btnDescPopulation.Size = new System.Drawing.Size(110, 41); this.btnDescPopulation.TabIndex = 1; this.btnDescPopulation.Text = "Population in Descending Order"; this.btnDescPopulation.UseVisualStyleBackColor = true; this.btnDescPopulation.Click += new System.EventHandler(this.btnDescPopulation_Click); // // btnAscPopulation // this.btnAscPopulation.Location = new System.Drawing.Point(8, 21); this.btnAscPopulation.Name = "btnAscPopulation"; this.btnAscPopulation.Size = new System.Drawing.Size(110, 41); this.btnAscPopulation.TabIndex = 0; this.btnAscPopulation.Text = "Population in Ascending Order"; this.btnAscPopulation.UseVisualStyleBackColor = true; this.btnAscPopulation.Click += new System.EventHandler(this.btnAscPopulation_Click); // // grpDisplay
  • 27. // this.grpDisplay.Controls.Add(this.btnMinPopulation); this.grpDisplay.Controls.Add(this.btnMaxPopulation); this.grpDisplay.Controls.Add(this.btnAverage); this.grpDisplay.Controls.Add(this.btnTotal); this.grpDisplay.Location = new System.Drawing.Point(294, 155); this.grpDisplay.Name = "grpDisplay"; this.grpDisplay.Size = new System.Drawing.Size(243, 121); this.grpDisplay.TabIndex = 1; this.grpDisplay.TabStop = false; this.grpDisplay.Text = "Display"; // // btnMinPopulation // this.btnMinPopulation.Location = new System.Drawing.Point(124, 68); this.btnMinPopulation.Name = "btnMinPopulation"; this.btnMinPopulation.Size = new System.Drawing.Size(110, 41); this.btnMinPopulation.TabIndex = 4; this.btnMinPopulation.Text = "Lowest Population"; this.btnMinPopulation.UseVisualStyleBackColor = true; this.btnMinPopulation.Click += new System.EventHandler(this.btnMinPopulation_Click); // // btnMaxPopulation // this.btnMaxPopulation.Location = new System.Drawing.Point(8, 68); this.btnMaxPopulation.Name = "btnMaxPopulation"; this.btnMaxPopulation.Size = new System.Drawing.Size(110, 41); this.btnMaxPopulation.TabIndex = 3; this.btnMaxPopulation.Text = "Highest Population"; this.btnMaxPopulation.UseVisualStyleBackColor = true; this.btnMaxPopulation.Click += new System.EventHandler(this.btnMaxPopulation_Click); // // btnAverage //
  • 28. this.btnAverage.Location = new System.Drawing.Point(124, 21); this.btnAverage.Name = "btnAverage"; this.btnAverage.Size = new System.Drawing.Size(110, 41); this.btnAverage.TabIndex = 2; this.btnAverage.Text = "Average Population"; this.btnAverage.UseVisualStyleBackColor = true; this.btnAverage.Click += new System.EventHandler(this.btnAverage_Click); // // btnTotal // this.btnTotal.Location = new System.Drawing.Point(8, 21); this.btnTotal.Name = "btnTotal"; this.btnTotal.Size = new System.Drawing.Size(110, 41); this.btnTotal.TabIndex = 1; this.btnTotal.Text = "Total Population"; this.btnTotal.UseVisualStyleBackColor = true; this.btnTotal.Click += new System.EventHandler(this.btnTotal_Click); // // btnExit // this.btnExit.Location = new System.Drawing.Point(359, 283); this.btnExit.Name = "btnExit"; this.btnExit.Size = new System.Drawing.Size(110, 41); this.btnExit.TabIndex = 2; this.btnExit.Text = "Exit"; this.btnExit.UseVisualStyleBackColor = true; this.btnExit.Click += new System.EventHandler(this.btnExit_Click); // // cityTableAdapter // this.cityTableAdapter.ClearBeforeFill = true; // // tableAdapterManager // this.tableAdapterManager.BackupDataSetBeforeUpdate = false; this.tableAdapterManager.CityTableAdapter = this.cityTableAdapter;
  • 29. this.tableAdapterManager.UpdateOrder = Population_Database.CityDataSetTableAdapters.TableAdapterManager.UpdateOrderOption.Inse rtUpdateDelete; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnExit; this.ClientSize = new System.Drawing.Size(560, 336); this.Controls.Add(this.btnExit); this.Controls.Add(this.grpDisplay); this.Controls.Add(this.grpSort); this.Controls.Add(this.cityDataGridView); this.Controls.Add(this.cityBindingNavigator); this.Name = "Form1"; this.Text = "Population Database"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.cityBindingNavigator)).EndInit(); this.cityBindingNavigator.ResumeLayout(false); this.cityBindingNavigator.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.cityBindingSource)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.cityDataSet)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.cityDataGridView)).EndInit(); this.grpSort.ResumeLayout(false); this.grpDisplay.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } #endregion private CityDataSet cityDataSet; private System.Windows.Forms.BindingSource cityBindingSource; private CityDataSetTableAdapters.CityTableAdapter cityTableAdapter; private CityDataSetTableAdapters.TableAdapterManager tableAdapterManager; private System.Windows.Forms.BindingNavigator cityBindingNavigator; private System.Windows.Forms.ToolStripButton bindingNavigatorAddNewItem;
  • 30. private System.Windows.Forms.ToolStripLabel bindingNavigatorCountItem; private System.Windows.Forms.ToolStripButton bindingNavigatorDeleteItem; private System.Windows.Forms.ToolStripButton bindingNavigatorMoveFirstItem; private System.Windows.Forms.ToolStripButton bindingNavigatorMovePreviousItem; private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator; private System.Windows.Forms.ToolStripTextBox bindingNavigatorPositionItem; private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator1; private System.Windows.Forms.ToolStripButton bindingNavigatorMoveNextItem; private System.Windows.Forms.ToolStripButton bindingNavigatorMoveLastItem; private System.Windows.Forms.ToolStripSeparator bindingNavigatorSeparator2; private System.Windows.Forms.ToolStripButton cityBindingNavigatorSaveItem; private System.Windows.Forms.DataGridView cityDataGridView; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1; private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2; private System.Windows.Forms.GroupBox grpSort; private System.Windows.Forms.GroupBox grpDisplay; private System.Windows.Forms.Button btnDescPopulation; private System.Windows.Forms.Button btnAscPopulation; private System.Windows.Forms.Button btnName; private System.Windows.Forms.Button btnMinPopulation; private System.Windows.Forms.Button btnMaxPopulation; private System.Windows.Forms.Button btnAverage; private System.Windows.Forms.Button btnTotal; private System.Windows.Forms.Button btnExit; } }