Jump to content

C# noob question number 4

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
12 replies to this topic

#1
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
Hello,

I am currently right now using access (ya i know it sucks but doing an example), ok i have 2 tables with a relation to them that is called customer ID, what i am stuck is this, the first listview pulls up all userdata and of course from table 1 which table 1 has customer ID, which by default will have a row highlighted already, so for listview 2, i want to show the row from listview 1, that user should have more than 1 account, which i want to display in listview2, how do i go about saying like, if user from listview 1 is highlighted, in listview 2 display all accounts found in table2 to display in listview2... anyone?


thanks
Its only funny till someone gets hurt.... THEN ITS HILARIOUS :)

#2
lobo521

lobo521

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
Check SelectedIndexChanged event on listview.

#3
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
here is what i got so far, but its not working because it says at: i < dt.Rows.Count, the error says : Object reference not set to an instance of an object... not sure what that means but here is the code i have below:


public void filllist()

        {

            DataTable dt = ds.Tables["Accounts"];

            //DataColumn AccountDcolumn = ds2.Tables["Accounts"].Columns[inc];

            DataRow AccountDrow = ds2.Tables["Accounts"].Rows[inc];

            int y = Convert.ToInt32(AccountDrow.ItemArray.GetValue(0).ToString());

            DataRow drow = ds.Tables["Customer"].Rows[inc];

            int x = Convert.ToInt32(drow.ItemArray.GetValue(0).ToString());

            listView1.Items.Clear();


for (int i = 0; i < dt.Rows.Count; i++)

            {

                if (y == x)

                {

                    DataRow datarow = ds.Tables["Accounts"].Rows[i];

                    ListViewItem lvi = new ListViewItem();

                    lvi.Text = drow.ItemArray.GetValue(0).ToString();

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(0).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(1).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(2).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(3).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(4).ToString());

                    listView1.Items.Add(lvi);

                }

                 

            }

  

        }


thanks
Its only funny till someone gets hurt.... THEN ITS HILARIOUS :)

#4
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
Hello,

I see now that its a null that is causing the problem, tried to do the following:


public void filllist()

        {

            DataTable dt = new DataTable();

            dt = ds.Tables["Accounts"];

            //DataColumn AccountDcolumn = ds2.Tables["Accounts"].Columns[inc];

            DataRow AccountDrow = ds2.Tables["Accounts"].Rows[inc];

            int y = Convert.ToInt32(AccountDrow.ItemArray.GetValue(0).ToString());

            DataRow drow = ds.Tables["Customer"].Rows[inc];

            int x = Convert.ToInt32(drow.ItemArray.GetValue(0).ToString());

            listView1.Items.Clear();


for (int i = 0; i < dt.Rows.Count; i++)

            {

                if (y == x)

                {

                    DataRow datarow = ds.Tables["Accounts"].Rows[i];

                    ListViewItem lvi = new ListViewItem();

                    lvi.Text = drow.ItemArray.GetValue(0).ToString();

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(0).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(1).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(2).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(3).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(4).ToString());

                    listView1.Items.Add(lvi);

                }


                 

            }

  

        }


with no success... still same error message at same location, i looked up the error and it is a null problem, how do i get it to not equal to null anyone?
Its only funny till someone gets hurt.... THEN ITS HILARIOUS :)

#5
lobo521

lobo521

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
Sorry without full compilable program i can't help you ;/

#6
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
here is the entire code, sorry about that, let me know if you find anything.

thank you


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Data.OleDb;


namespace accessproject01

{

    public partial class Mainform : Form

    {

        public Mainform()

        {

            InitializeComponent();


            con.ConnectionString = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:/db1.mdb";

            con.Open();


            string sql = "SELECT * from Customer";

            string sql2 = "SELECT * from Accounts";

            da = new OleDbDataAdapter(sql, con);

            da2 = new OleDbDataAdapter(sql2, con);

            da.Fill(ds, "Customer");

            da2.Fill(ds2, "Accounts");


            Navigaterecords();

            maxrow = ds.Tables["Customer"].Rows.Count;

            filllist();

        }


        OleDbConnection con = new OleDbConnection();

        DataSet ds = new DataSet();

        DataSet ds2 = new DataSet();

        OleDbDataAdapter da;

        OleDbDataAdapter da2;

        int maxrow = 0;

        int inc = 0;



        public void Navigaterecords()

        {

            DataRow drow = ds.Tables["Customer"].Rows[inc];

            txtbox_name.Text = drow.ItemArray.GetValue(1).ToString();

            txtbox_address.Text = drow.ItemArray.GetValue(2).ToString();

            txtbox_city.Text = drow.ItemArray.GetValue(3).ToString();

            txt_state.Text = drow.ItemArray.GetValue(4).ToString();

            txt_Zipcode.Text = drow.ItemArray.GetValue(5).ToString();

        }


        public void filllist()

        {

            DataTable dt = new DataTable();

            dt = ds.Tables["Accounts"];

            //DataColumn AccountDcolumn = ds2.Tables["Accounts"].Columns[inc];

            DataRow AccountDrow = ds2.Tables["Accounts"].Rows[inc];

            int y = Convert.ToInt32(AccountDrow.ItemArray.GetValue(0).ToString());

            DataRow drow = ds.Tables["Customer"].Rows[inc];

            int x = Convert.ToInt32(drow.ItemArray.GetValue(0).ToString());

            listView1.Items.Clear();



            /*

            while (x == y)

            {

                //DataColumn datacolumn = ds2.Tables["Accounts"].Columns[y];

                

                //DataRow datarow = ds2.Tables["Accounts"].Columns[y];

                    ListViewItem lvi = new ListViewItem();

                    lvi.Text = drow.ItemArray.GetValue(0).ToString();

                    //lvi.SubItems.Add(datacolumn.ItemArray.GetValue(0).ToString());

                    //lvi.SubItems.Add(datarow.ItemArray.GetValue(1).ToString());

                    //lvi.SubItems.Add(datarow.ItemArray.GetValue(2).ToString());

                    //lvi.SubItems.Add(datarow.ItemArray.GetValue(3).ToString());

                    //lvi.SubItems.Add(datarow.ItemArray.GetValue(4).ToString());

                    listView1.Items.Add(lvi);

                 

            }

             */

            for (int i = 0; i < dt.Rows.Count; i++)

            {

                if (y == x)

                {

                    DataRow datarow = ds.Tables["Accounts"].Rows[i];

                    ListViewItem lvi = new ListViewItem();

                    lvi.Text = drow.ItemArray.GetValue(0).ToString();

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(0).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(1).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(2).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(3).ToString());

                    lvi.SubItems.Add(datarow.ItemArray.GetValue(4).ToString());

                    listView1.Items.Add(lvi);

                }


                 

            }

  

        }


        private void btn_add_Click(object sender, EventArgs e)

        {

            txtbox_address.Clear();

            txtbox_city.Clear();

            txtbox_name.Clear();

        }


        private void btn_submit_Click(object sender, EventArgs e)

        {

            using (OleDbConnection connection = new OleDbConnection(con.ConnectionString))

            {

                OleDbDataAdapter adapter = new OleDbDataAdapter();

                adapter.SelectCommand = new OleDbCommand("Select * from Customer", connection);

                OleDbCommandBuilder builder = new OleDbCommandBuilder(adapter);


                connection.Open();


                adapter.Fill(ds, "Customer");


                DataRow newCustomerRow = ds.Tables["Customer"].NewRow();


                int maxrow1 = ds.Tables["Customer"].Rows.Count;

                DataRow Drow0 = ds.Tables["Customer"].Rows[maxrow1 - 1];

                int newnumber = Convert.ToInt32(Drow0.ItemArray.GetValue(0));

                newnumber = newnumber + 1;

                newCustomerRow[0] = newnumber;

                newCustomerRow[1] = txtbox_name.Text;

                newCustomerRow[2] = txtbox_address.Text;

                newCustomerRow[3] = txtbox_city.Text;

                newCustomerRow[4] = txt_state.Text;

                newCustomerRow[5] = txt_Zipcode.Text;


                ds.Tables["Customer"].Rows.Add(newCustomerRow);


                adapter.Update(ds, "Customer");

            }

        }


        private void btn_nextrecord_Click(object sender, EventArgs e)

        {

            if (inc != maxrow - 1)

            {

                inc++;

                Navigaterecords();

            }

            else

                MessageBox.Show("No more rows");

        }


        private void btn_previous_Click(object sender, EventArgs e)

        {

            if (inc > 0)

            {

                inc--;

                Navigaterecords();

            }

            else

                MessageBox.Show("No more records");

        }


        private void btn_firstrecord_Click(object sender, EventArgs e)

        {

            inc = 0;

            Navigaterecords();

        }


        private void btn_lastrecord_Click(object sender, EventArgs e)

        {

            inc = maxrow - 1;

            Navigaterecords();

        }


        private void btn_update_Click(object sender, EventArgs e)

        {

            OleDbCommandBuilder cb = new OleDbCommandBuilder(da);


            DataRow dr = ds.Tables["Customer"].Rows[inc];


            dr[1] = txtbox_name.Text;

            dr[2] = txtbox_address.Text;

            dr[3] = txtbox_city.Text;


            da.Update(ds, "Customer");


            MessageBox.Show("Entry Updated");

        }


        private void btn_delete_Click(object sender, EventArgs e)

        {

            OleDbCommandBuilder cb = new OleDbCommandBuilder(da);


            ds.Tables["Customer"].Rows[inc].Delete();


            maxrow--;

            inc = 0;

            Navigaterecords();


            da.Update(ds, "Customer");

            MessageBox.Show("Record Deleted");

        }


        private void btn_close_Click(object sender, EventArgs e)

        {

            this.Close();

        }


        private void btn_newaccount_Click(object sender, EventArgs e)

        {


        }

    }

}


Its only funny till someone gets hurt.... THEN ITS HILARIOUS :)

#7
lobo521

lobo521

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
If error is in first line of Navigaterecords method i suppose there is no row in table Customer. If there is error in one of "...Text = drow.ItemArray.GetValue(...).ToString();" lines value in that column is null and you can't call method ToString() on null.

If not:
I still don't have your designer code and mdb file. Upload zip file with your project to some file sharing server like rapidshare.

#8
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
Hello I have attached the project to a zip folder, let me know, i figured out some of it, i was pointing to the wrong dataset, i was pointing to dataset = ds and not ds2, i should really get back on my proper naming convention (Pascal), but still trying to figure out how to get the correct accounts only shown when the user customer ID is shown.

Sadly i cant upload the mdb file, it says its invalid, yet its only 280kb.

Attached Files


Its only funny till someone gets hurt.... THEN ITS HILARIOUS :)

#9
Siten0308

Siten0308

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 302 posts
Hello

Duh.. here is the database or the mdb access file for my project, let me know if you find any way to do what i am requesting :)

thank you

Attached Files

  • Attached File  db1.zip   23.9K   2 downloads

Its only funny till someone gets hurt.... THEN ITS HILARIOUS :)

#10
lobo521

lobo521

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
There is no table Accounts in ds dataset. Use ds2 for accesing Accounts table.

#11
lobo521

lobo521

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
Made few changes. Try name variables and methods by what they contain or do you will avoid mistakes like ds ds2 thing.

Mainform

using System;

using System.Data;

using System.Windows.Forms;

using System.Data.OleDb;


namespace accessproject01

{

    public partial class Mainform : Form

    {

        public Mainform()

        {

            InitializeComponent();


            con.ConnectionString = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:/db1.mdb";

            con.Open();


            string sql = "SELECT * from Customer";

            string sql2 = "SELECT * from Accounts";

            da = new OleDbDataAdapter(sql, con);

            da2 = new OleDbDataAdapter(sql2, con);

            da.Fill(dsCustomer, "Customer");

            da2.Fill(dsAccounts, "Accounts");


            Navigaterecords();

            maxrow = dsCustomer.Tables["Customer"].Rows.Count;

        }


        OleDbConnection con = new OleDbConnection();

        DataSet dsCustomer = new DataSet();

        DataSet dsAccounts = new DataSet();

        OleDbDataAdapter da;

        OleDbDataAdapter da2;

        int maxrow;

        int customerIndex;



        public void Navigaterecords()

        {

            DataRow drow = dsCustomer.Tables["Customer"].Rows[customerIndex];

            txtbox_name.Text = drow.ItemArray.GetValue(1).ToString();

            txtbox_address.Text = drow.ItemArray.GetValue(2).ToString();

            txtbox_city.Text = drow.ItemArray.GetValue(3).ToString();

            txt_state.Text = drow.ItemArray.GetValue(4).ToString();

            txt_Zipcode.Text = drow.ItemArray.GetValue(5).ToString();


        	Filllist();

        }


		public void Filllist()

		{

			string customerId = GetActiveCustomerId();


			lvCustomerAccounts.Items.Clear();


			foreach (DataRow customerAccount in dsAccounts.Tables["Accounts"].Rows)

			{

				if (customerAccount.ItemArray.GetValue(0).ToString() != customerId)

					continue;


				var lvi = new ListViewItem {Text = customerAccount.ItemArray.GetValue(0).ToString()};


				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(0).ToString());

				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(1).ToString());

				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(2).ToString());

				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(3).ToString());

				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(4).ToString());


				lvCustomerAccounts.Items.Add(lvi);

			}


		}


		private string GetActiveCustomerId()

		{

			var drow = dsCustomer.Tables["Customer"].Rows[customerIndex];

			return drow.ItemArray.GetValue(0).ToString();

		}


    	private void btn_add_Click(object sender, EventArgs e)

        {

            txtbox_address.Clear();

            txtbox_city.Clear();

            txtbox_name.Clear();

        }


        private void btn_submit_Click(object sender, EventArgs e)

        {

            using (var connection = new OleDbConnection(con.ConnectionString))

            {

            	var cutomerDataAdapter =

            		new OleDbDataAdapter

            			{

            				SelectCommand = new OleDbCommand("Select * from Customer", connection)

            			};


            	connection.Open();


                cutomerDataAdapter.Fill(dsCustomer, "Customer");


                var newCustomerRow = dsCustomer.Tables["Customer"].NewRow();


            	newCustomerRow[0] = GetNewCustomerId();

                newCustomerRow[1] = txtbox_name.Text;

                newCustomerRow[2] = txtbox_address.Text;

                newCustomerRow[3] = txtbox_city.Text;

                newCustomerRow[4] = txt_state.Text;

                newCustomerRow[5] = txt_Zipcode.Text;


                dsCustomer.Tables["Customer"].Rows.Add(newCustomerRow);


                cutomerDataAdapter.Update(dsCustomer, "Customer");

            }

        }


    	private int GetNewCustomerId()

    	{

    		var customerRowCount = dsCustomer.Tables["Customer"].Rows.Count;

    		var lastCustomer = dsCustomer.Tables["Customer"].Rows[customerRowCount - 1];

    		return Convert.ToInt32(lastCustomer.ItemArray.GetValue(0)) + 1;

    	}


    	private void btn_nextrecord_Click(object sender, EventArgs e)

        {

            if (customerIndex != maxrow - 1)

            {

                customerIndex++;

                Navigaterecords();

            }

            else

                MessageBox.Show("No more rows");

        }


        private void btn_previous_Click(object sender, EventArgs e)

        {

            if (customerIndex > 0)

            {

                customerIndex--;

                Navigaterecords();

            }

            else

                MessageBox.Show("No more records");

        }


        private void btn_firstrecord_Click(object sender, EventArgs e)

        {

            customerIndex = 0;

            Navigaterecords();

        }


        private void btn_lastrecord_Click(object sender, EventArgs e)

        {

            customerIndex = maxrow - 1;

            Navigaterecords();

        }


        private void btn_update_Click(object sender, EventArgs e)

        {

            DataRow dr = dsCustomer.Tables["Customer"].Rows[customerIndex];


            dr[1] = txtbox_name.Text;

            dr[2] = txtbox_address.Text;

            dr[3] = txtbox_city.Text;


            da.Update(dsCustomer, "Customer");


            MessageBox.Show("Entry Updated");

        }


        private void btn_delete_Click(object sender, EventArgs e)

        {

            dsCustomer.Tables["Customer"].Rows[customerIndex].Delete();


            maxrow--;

            customerIndex = 0;

            Navigaterecords();


            da.Update(dsCustomer, "Customer");

            MessageBox.Show("Record Deleted");

        }


        private void btn_close_Click(object sender, EventArgs e)

        {

            this.Close();

        }


        private void btn_newaccount_Click(object sender, EventArgs e)

        {


        }

    }

}


Mainform designer

namespace accessproject01

{

    partial class Mainform

    {

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.IContainer components = null;


        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

        protected override void Dispose(bool disposing)

        {

            if (disposing && (components != null))

            {

                components.Dispose();

            }

            base.Dispose(disposing);

        }


        #region Windows Form Designer generated code


        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

            this.lvCustomerAccounts = new System.Windows.Forms.ListView();

            this.clmn_customerID = new System.Windows.Forms.ColumnHeader();

            this.btn_add = new System.Windows.Forms.Button();

            this.btn_submit = new System.Windows.Forms.Button();

            this.btn_nextrecord = new System.Windows.Forms.Button();

            this.btn_previous = new System.Windows.Forms.Button();

            this.btn_lastrecord = new System.Windows.Forms.Button();

            this.btn_firstrecord = new System.Windows.Forms.Button();

            this.txtbox_name = new System.Windows.Forms.TextBox();

            this.txtbox_address = new System.Windows.Forms.TextBox();

            this.txtbox_city = new System.Windows.Forms.TextBox();

            this.label1 = new System.Windows.Forms.Label();

            this.label2 = new System.Windows.Forms.Label();

            this.label3 = new System.Windows.Forms.Label();

            this.btn_update = new System.Windows.Forms.Button();

            this.btn_delete = new System.Windows.Forms.Button();

            this.label4 = new System.Windows.Forms.Label();

            this.txt_Zipcode = new System.Windows.Forms.TextBox();

            this.lbl_state = new System.Windows.Forms.Label();

            this.txt_state = new System.Windows.Forms.TextBox();

            this.btn_newaccount = new System.Windows.Forms.Button();

            this.btn_close = new System.Windows.Forms.Button();

            this.clmn_accountnumber = new System.Windows.Forms.ColumnHeader();

            this.clmn_accounttype = new System.Windows.Forms.ColumnHeader();

            this.clmn_dateopened = new System.Windows.Forms.ColumnHeader();

            this.clmn_balance = new System.Windows.Forms.ColumnHeader();

            this.SuspendLayout();

            // 

            // lvCustomerAccounts

            // 

            this.lvCustomerAccounts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {

            this.clmn_customerID,

            this.clmn_accountnumber,

            this.clmn_accounttype,

            this.clmn_dateopened,

            this.clmn_balance});

            this.lvCustomerAccounts.Location = new System.Drawing.Point(33, 338);

            this.lvCustomerAccounts.Name = "lvCustomerAccounts";

            this.lvCustomerAccounts.Size = new System.Drawing.Size(487, 200);

            this.lvCustomerAccounts.TabIndex = 0;

            this.lvCustomerAccounts.UseCompatibleStateImageBehavior = false;

            this.lvCustomerAccounts.View = System.Windows.Forms.View.Details;

            // 

            // clmn_customerID

            // 

            this.clmn_customerID.Text = "Customer ID";

            this.clmn_customerID.Width = 75;

            // 

            // btn_add

            // 

            this.btn_add.Location = new System.Drawing.Point(272, 39);

            this.btn_add.Name = "btn_add";

            this.btn_add.Size = new System.Drawing.Size(75, 23);

            this.btn_add.TabIndex = 1;

            this.btn_add.Text = "Add";

            this.btn_add.UseVisualStyleBackColor = true;

            this.btn_add.Click += new System.EventHandler(this.btn_add_Click);

            // 

            // btn_submit

            // 

            this.btn_submit.Location = new System.Drawing.Point(272, 91);

            this.btn_submit.Name = "btn_submit";

            this.btn_submit.Size = new System.Drawing.Size(75, 23);

            this.btn_submit.TabIndex = 2;

            this.btn_submit.Text = "Submit";

            this.btn_submit.UseVisualStyleBackColor = true;

            this.btn_submit.Click += new System.EventHandler(this.btn_submit_Click);

            // 

            // btn_nextrecord

            // 

            this.btn_nextrecord.Location = new System.Drawing.Point(200, 185);

            this.btn_nextrecord.Name = "btn_nextrecord";

            this.btn_nextrecord.Size = new System.Drawing.Size(113, 23);

            this.btn_nextrecord.TabIndex = 3;

            this.btn_nextrecord.Text = "Next Record";

            this.btn_nextrecord.UseVisualStyleBackColor = true;

            this.btn_nextrecord.Click += new System.EventHandler(this.btn_nextrecord_Click);

            // 

            // btn_previous

            // 

            this.btn_previous.Location = new System.Drawing.Point(33, 185);

            this.btn_previous.Name = "btn_previous";

            this.btn_previous.Size = new System.Drawing.Size(112, 23);

            this.btn_previous.TabIndex = 4;

            this.btn_previous.Text = "Previous Record";

            this.btn_previous.UseVisualStyleBackColor = true;

            this.btn_previous.Click += new System.EventHandler(this.btn_previous_Click);

            // 

            // btn_lastrecord

            // 

            this.btn_lastrecord.Location = new System.Drawing.Point(200, 236);

            this.btn_lastrecord.Name = "btn_lastrecord";

            this.btn_lastrecord.Size = new System.Drawing.Size(113, 23);

            this.btn_lastrecord.TabIndex = 5;

            this.btn_lastrecord.Text = "Last Record";

            this.btn_lastrecord.UseVisualStyleBackColor = true;

            this.btn_lastrecord.Click += new System.EventHandler(this.btn_lastrecord_Click);

            // 

            // btn_firstrecord

            // 

            this.btn_firstrecord.Location = new System.Drawing.Point(33, 236);

            this.btn_firstrecord.Name = "btn_firstrecord";

            this.btn_firstrecord.Size = new System.Drawing.Size(112, 23);

            this.btn_firstrecord.TabIndex = 6;

            this.btn_firstrecord.Text = "First Record";

            this.btn_firstrecord.UseVisualStyleBackColor = true;

            this.btn_firstrecord.Click += new System.EventHandler(this.btn_firstrecord_Click);

            // 

            // txtbox_name

            // 

            this.txtbox_name.Location = new System.Drawing.Point(107, 12);

            this.txtbox_name.Name = "txtbox_name";

            this.txtbox_name.Size = new System.Drawing.Size(136, 20);

            this.txtbox_name.TabIndex = 7;

            // 

            // txtbox_address

            // 

            this.txtbox_address.Location = new System.Drawing.Point(107, 46);

            this.txtbox_address.Name = "txtbox_address";

            this.txtbox_address.Size = new System.Drawing.Size(136, 20);

            this.txtbox_address.TabIndex = 8;

            // 

            // txtbox_city

            // 

            this.txtbox_city.Location = new System.Drawing.Point(107, 74);

            this.txtbox_city.Name = "txtbox_city";

            this.txtbox_city.Size = new System.Drawing.Size(136, 20);

            this.txtbox_city.TabIndex = 9;

            // 

            // label1

            // 

            this.label1.AutoSize = true;

            this.label1.Location = new System.Drawing.Point(56, 15);

            this.label1.Name = "label1";

            this.label1.Size = new System.Drawing.Size(35, 13);

            this.label1.TabIndex = 10;

            this.label1.Text = "Name";

            // 

            // label2

            // 

            this.label2.AutoSize = true;

            this.label2.Location = new System.Drawing.Point(46, 49);

            this.label2.Name = "label2";

            this.label2.Size = new System.Drawing.Size(45, 13);

            this.label2.TabIndex = 11;

            this.label2.Text = "Address";

            // 

            // label3

            // 

            this.label3.AutoSize = true;

            this.label3.Location = new System.Drawing.Point(56, 77);

            this.label3.Name = "label3";

            this.label3.Size = new System.Drawing.Size(24, 13);

            this.label3.TabIndex = 12;

            this.label3.Text = "City";

            // 

            // btn_update

            // 

            this.btn_update.Location = new System.Drawing.Point(33, 282);

            this.btn_update.Name = "btn_update";

            this.btn_update.Size = new System.Drawing.Size(112, 23);

            this.btn_update.TabIndex = 13;

            this.btn_update.Text = "Update";

            this.btn_update.UseVisualStyleBackColor = true;

            this.btn_update.Click += new System.EventHandler(this.btn_update_Click);

            // 

            // btn_delete

            // 

            this.btn_delete.Location = new System.Drawing.Point(200, 282);

            this.btn_delete.Name = "btn_delete";

            this.btn_delete.Size = new System.Drawing.Size(113, 23);

            this.btn_delete.TabIndex = 14;

            this.btn_delete.Text = "Delete";

            this.btn_delete.UseVisualStyleBackColor = true;

            this.btn_delete.Click += new System.EventHandler(this.btn_delete_Click);

            // 

            // label4

            // 

            this.label4.AutoSize = true;

            this.label4.Location = new System.Drawing.Point(41, 142);

            this.label4.Name = "label4";

            this.label4.Size = new System.Drawing.Size(50, 13);

            this.label4.TabIndex = 15;

            this.label4.Text = "Zip Code";

            // 

            // txt_Zipcode

            // 

            this.txt_Zipcode.Location = new System.Drawing.Point(107, 139);

            this.txt_Zipcode.Name = "txt_Zipcode";

            this.txt_Zipcode.Size = new System.Drawing.Size(136, 20);

            this.txt_Zipcode.TabIndex = 16;

            // 

            // lbl_state

            // 

            this.lbl_state.AutoSize = true;

            this.lbl_state.Location = new System.Drawing.Point(49, 108);

            this.lbl_state.Name = "lbl_state";

            this.lbl_state.Size = new System.Drawing.Size(32, 13);

            this.lbl_state.TabIndex = 17;

            this.lbl_state.Text = "State";

            // 

            // txt_state

            // 

            this.txt_state.Location = new System.Drawing.Point(107, 105);

            this.txt_state.Name = "txt_state";

            this.txt_state.Size = new System.Drawing.Size(100, 20);

            this.txt_state.TabIndex = 18;

            // 

            // btn_newaccount

            // 

            this.btn_newaccount.Location = new System.Drawing.Point(398, 309);

            this.btn_newaccount.Name = "btn_newaccount";

            this.btn_newaccount.Size = new System.Drawing.Size(122, 23);

            this.btn_newaccount.TabIndex = 19;

            this.btn_newaccount.Text = "Add New Account";

            this.btn_newaccount.UseVisualStyleBackColor = true;

            this.btn_newaccount.Click += new System.EventHandler(this.btn_newaccount_Click);

            // 

            // btn_close

            // 

            this.btn_close.Location = new System.Drawing.Point(445, 544);

            this.btn_close.Name = "btn_close";

            this.btn_close.Size = new System.Drawing.Size(75, 23);

            this.btn_close.TabIndex = 20;

            this.btn_close.Text = "Close";

            this.btn_close.UseVisualStyleBackColor = true;

            this.btn_close.Click += new System.EventHandler(this.btn_close_Click);

            // 

            // clmn_accountnumber

            // 

            this.clmn_accountnumber.Text = "Account Number";

            this.clmn_accountnumber.Width = 120;

            // 

            // clmn_accounttype

            // 

            this.clmn_accounttype.Text = "Account Type";

            this.clmn_accounttype.Width = 110;

            // 

            // clmn_dateopened

            // 

            this.clmn_dateopened.Text = "Date Opened";

            this.clmn_dateopened.Width = 100;

            // 

            // clmn_balance

            // 

            this.clmn_balance.Text = "Balance";

            this.clmn_balance.Width = 75;

            // 

            // Mainform

            // 

            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

            this.ClientSize = new System.Drawing.Size(553, 596);

            this.Controls.Add(this.btn_close);

            this.Controls.Add(this.btn_newaccount);

            this.Controls.Add(this.txt_state);

            this.Controls.Add(this.lbl_state);

            this.Controls.Add(this.txt_Zipcode);

            this.Controls.Add(this.label4);

            this.Controls.Add(this.btn_delete);

            this.Controls.Add(this.btn_update);

            this.Controls.Add(this.label3);

            this.Controls.Add(this.label2);

            this.Controls.Add(this.label1);

            this.Controls.Add(this.txtbox_city);

            this.Controls.Add(this.txtbox_address);

            this.Controls.Add(this.txtbox_name);

            this.Controls.Add(this.btn_firstrecord);

            this.Controls.Add(this.btn_lastrecord);

            this.Controls.Add(this.btn_previous);

            this.Controls.Add(this.btn_nextrecord);

            this.Controls.Add(this.btn_submit);

            this.Controls.Add(this.btn_add);

            this.Controls.Add(this.lvCustomerAccounts);

            this.Name = "Mainform";

            this.Text = "Mainform";

            this.ResumeLayout(false);

            this.PerformLayout();


        }


        #endregion


        private System.Windows.Forms.ListView lvCustomerAccounts;

        private System.Windows.Forms.Button btn_add;

        private System.Windows.Forms.Button btn_submit;

        private System.Windows.Forms.Button btn_nextrecord;

        private System.Windows.Forms.Button btn_previous;

        private System.Windows.Forms.Button btn_lastrecord;

        private System.Windows.Forms.Button btn_firstrecord;

        private System.Windows.Forms.TextBox txtbox_name;

        private System.Windows.Forms.TextBox txtbox_address;

        private System.Windows.Forms.TextBox txtbox_city;

        private System.Windows.Forms.Label label1;

        private System.Windows.Forms.Label label2;

        private System.Windows.Forms.Label label3;

        private System.Windows.Forms.ColumnHeader clmn_customerID;

        private System.Windows.Forms.Button btn_update;

        private System.Windows.Forms.Button btn_delete;

        private System.Windows.Forms.Label label4;

        private System.Windows.Forms.TextBox txt_Zipcode;

        private System.Windows.Forms.Label lbl_state;

        private System.Windows.Forms.TextBox txt_state;

        private System.Windows.Forms.Button btn_newaccount;

        private System.Windows.Forms.Button btn_close;

        public System.Windows.Forms.ColumnHeader clmn_accountnumber;

        private System.Windows.Forms.ColumnHeader clmn_accounttype;

        public System.Windows.Forms.ColumnHeader clmn_dateopened;

        private System.Windows.Forms.ColumnHeader clmn_balance;

    }

}



#12
lobo521

lobo521

    Learning Programmer

  • Members
  • PipPipPip
  • 57 posts
Made few changes. Try name variables and methods by what they contain or do you will avoid mistakes like ds ds2 thing.

Mainform

using System;

using System.Data;

using System.Windows.Forms;

using System.Data.OleDb;


namespace accessproject01

{

    public partial class Mainform : Form

    {

        public Mainform()

        {

            InitializeComponent();


            con.ConnectionString = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:/db1.mdb";

            con.Open();


            string sql = "SELECT * from Customer";

            string sql2 = "SELECT * from Accounts";

            da = new OleDbDataAdapter(sql, con);

            da2 = new OleDbDataAdapter(sql2, con);

            da.Fill(dsCustomer, "Customer");

            da2.Fill(dsAccounts, "Accounts");


            Navigaterecords();

            maxrow = dsCustomer.Tables["Customer"].Rows.Count;

        }


        OleDbConnection con = new OleDbConnection();

        DataSet dsCustomer = new DataSet();

        DataSet dsAccounts = new DataSet();

        OleDbDataAdapter da;

        OleDbDataAdapter da2;

        int maxrow;

        int customerIndex;



        public void Navigaterecords()

        {

            DataRow drow = dsCustomer.Tables["Customer"].Rows[customerIndex];

            txtbox_name.Text = drow.ItemArray.GetValue(1).ToString();

            txtbox_address.Text = drow.ItemArray.GetValue(2).ToString();

            txtbox_city.Text = drow.ItemArray.GetValue(3).ToString();

            txt_state.Text = drow.ItemArray.GetValue(4).ToString();

            txt_Zipcode.Text = drow.ItemArray.GetValue(5).ToString();


        	Filllist();

        }


		public void Filllist()

		{

			string customerId = GetActiveCustomerId();


			lvCustomerAccounts.Items.Clear();


			foreach (DataRow customerAccount in dsAccounts.Tables["Accounts"].Rows)

			{

				if (customerAccount.ItemArray.GetValue(0).ToString() != customerId)

					continue;


				var lvi = new ListViewItem {Text = customerAccount.ItemArray.GetValue(0).ToString()};


				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(0).ToString());

				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(1).ToString());

				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(2).ToString());

				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(3).ToString());

				lvi.SubItems.Add(customerAccount.ItemArray.GetValue(4).ToString());


				lvCustomerAccounts.Items.Add(lvi);

			}


		}


		private string GetActiveCustomerId()

		{

			var drow = dsCustomer.Tables["Customer"].Rows[customerIndex];

			return drow.ItemArray.GetValue(0).ToString();

		}


    	private void btn_add_Click(object sender, EventArgs e)

        {

            txtbox_address.Clear();

            txtbox_city.Clear();

            txtbox_name.Clear();

        }


        private void btn_submit_Click(object sender, EventArgs e)

        {

            using (var connection = new OleDbConnection(con.ConnectionString))

            {

            	var cutomerDataAdapter =

            		new OleDbDataAdapter

            			{

            				SelectCommand = new OleDbCommand("Select * from Customer", connection)

            			};


            	connection.Open();


                cutomerDataAdapter.Fill(dsCustomer, "Customer");


                var newCustomerRow = dsCustomer.Tables["Customer"].NewRow();


            	newCustomerRow[0] = GetNewCustomerId();

                newCustomerRow[1] = txtbox_name.Text;

                newCustomerRow[2] = txtbox_address.Text;

                newCustomerRow[3] = txtbox_city.Text;

                newCustomerRow[4] = txt_state.Text;

                newCustomerRow[5] = txt_Zipcode.Text;


                dsCustomer.Tables["Customer"].Rows.Add(newCustomerRow);


                cutomerDataAdapter.Update(dsCustomer, "Customer");

            }

        }


    	private int GetNewCustomerId()

    	{

    		var customerRowCount = dsCustomer.Tables["Customer"].Rows.Count;

    		var lastCustomer = dsCustomer.Tables["Customer"].Rows[customerRowCount - 1];

    		return Convert.ToInt32(lastCustomer.ItemArray.GetValue(0)) + 1;

    	}


    	private void btn_nextrecord_Click(object sender, EventArgs e)

        {

            if (customerIndex != maxrow - 1)

            {

                customerIndex++;

                Navigaterecords();

            }

            else

                MessageBox.Show("No more rows");

        }


        private void btn_previous_Click(object sender, EventArgs e)

        {

            if (customerIndex > 0)

            {

                customerIndex--;

                Navigaterecords();

            }

            else

                MessageBox.Show("No more records");

        }


        private void btn_firstrecord_Click(object sender, EventArgs e)

        {

            customerIndex = 0;

            Navigaterecords();

        }


        private void btn_lastrecord_Click(object sender, EventArgs e)

        {

            customerIndex = maxrow - 1;

            Navigaterecords();

        }


        private void btn_update_Click(object sender, EventArgs e)

        {

            DataRow dr = dsCustomer.Tables["Customer"].Rows[customerIndex];


            dr[1] = txtbox_name.Text;

            dr[2] = txtbox_address.Text;

            dr[3] = txtbox_city.Text;


            da.Update(dsCustomer, "Customer");


            MessageBox.Show("Entry Updated");

        }


        private void btn_delete_Click(object sender, EventArgs e)

        {

            dsCustomer.Tables["Customer"].Rows[customerIndex].Delete();


            maxrow--;

            customerIndex = 0;

            Navigaterecords();


            da.Update(dsCustomer, "Customer");

            MessageBox.Show("Record Deleted");

        }


        private void btn_close_Click(object sender, EventArgs e)

        {

            this.Close();

        }


        private void btn_newaccount_Click(object sender, EventArgs e)

        {


        }

    }

}


Mainform designer

namespace accessproject01

{

    partial class Mainform

    {

        /// <summary>

        /// Required designer variable.

        /// </summary>

        private System.ComponentModel.IContainer components = null;


        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>

        protected override void Dispose(bool disposing)

        {

            if (disposing && (components != null))

            {

                components.Dispose();

            }

            base.Dispose(disposing);

        }


        #region Windows Form Designer generated code


        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()

        {

            this.lvCustomerAccounts = new System.Windows.Forms.ListView();

            this.clmn_customerID = new System.Windows.Forms.ColumnHeader();

            this.btn_add = new System.Windows.Forms.Button();

            this.btn_submit = new System.Windows.Forms.Button();

            this.btn_nextrecord = new System.Windows.Forms.Button();

            this.btn_previous = new System.Windows.Forms.Button();

            this.btn_lastrecord = new System.Windows.Forms.Button();

            this.btn_firstrecord = new System.Windows.Forms.Button();

            this.txtbox_name = new System.Windows.Forms.TextBox();

            this.txtbox_address = new System.Windows.Forms.TextBox();

            this.txtbox_city = new System.Windows.Forms.TextBox();

            this.label1 = new System.Windows.Forms.Label();

            this.label2 = new System.Windows.Forms.Label();

            this.label3 = new System.Windows.Forms.Label();

            this.btn_update = new System.Windows.Forms.Button();

            this.btn_delete = new System.Windows.Forms.Button();

            this.label4 = new System.Windows.Forms.Label();

            this.txt_Zipcode = new System.Windows.Forms.TextBox();

            this.lbl_state = new System.Windows.Forms.Label();

            this.txt_state = new System.Windows.Forms.TextBox();

            this.btn_newaccount = new System.Windows.Forms.Button();

            this.btn_close = new System.Windows.Forms.Button();

            this.clmn_accountnumber = new System.Windows.Forms.ColumnHeader();

            this.clmn_accounttype = new System.Windows.Forms.ColumnHeader();

            this.clmn_dateopened = new System.Windows.Forms.ColumnHeader();

            this.clmn_balance = new System.Windows.Forms.ColumnHeader();

            this.SuspendLayout();

            // 

            // lvCustomerAccounts

            // 

            this.lvCustomerAccounts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {

            this.clmn_customerID,

            this.clmn_accountnumber,

            this.clmn_accounttype,

            this.clmn_dateopened,

            this.clmn_balance});

            this.lvCustomerAccounts.Location = new System.Drawing.Point(33, 338);

            this.lvCustomerAccounts.Name = "lvCustomerAccounts";

            this.lvCustomerAccounts.Size = new System.Drawing.Size(487, 200);

            this.lvCustomerAccounts.TabIndex = 0;

            this.lvCustomerAccounts.UseCompatibleStateImageBehavior = false;

            this.lvCustomerAccounts.View = System.Windows.Forms.View.Details;

            // 

            // clmn_customerID

            // 

            this.clmn_customerID.Text = "Customer ID";

            this.clmn_customerID.Width = 75;

            // 

            // btn_add

            // 

            this.btn_add.Location = new System.Drawing.Point(272, 39);

            this.btn_add.Name = "btn_add";

            this.btn_add.Size = new System.Drawing.Size(75, 23);

            this.btn_add.TabIndex = 1;

            this.btn_add.Text = "Add";

            this.btn_add.UseVisualStyleBackColor = true;

            this.btn_add.Click += new System.EventHandler(this.btn_add_Click);

            // 

            // btn_submit

            // 

            this.btn_submit.Location = new System.Drawing.Point(272, 91);

            this.btn_submit.Name = "btn_submit";

            this.btn_submit.Size = new System.Drawing.Size(75, 23);

            this.btn_submit.TabIndex = 2;

            this.btn_submit.Text = "Submit";

            this.btn_submit.UseVisualStyleBackColor = true;

            this.btn_submit.Click += new System.EventHandler(this.btn_submit_Click);

            // 

            // btn_nextrecord

            // 

            this.btn_nextrecord.Location = new System.Drawing.Point(200, 185);

            this.btn_nextrecord.Name = "btn_nextrecord";

            this.btn_nextrecord.Size = new System.Drawing.Size(113, 23);

            this.btn_nextrecord.TabIndex = 3;

            this.btn_nextrecord.Text = "Next Record";

            this.btn_nextrecord.UseVisualStyleBackColor = true;

            this.btn_nextrecord.Click += new System.EventHandler(this.btn_nextrecord_Click);

            // 

            // btn_previous

            // 

            this.btn_previous.Location = new System.Drawing.Point(33, 185);

            this.btn_previous.Name = "btn_previous";

            this.btn_previous.Size = new System.Drawing.Size(112, 23);

            this.btn_previous.TabIndex = 4;

            this.btn_previous.Text = "Previous Record";

            this.btn_previous.UseVisualStyleBackColor = true;

            this.btn_previous.Click += new System.EventHandler(this.btn_previous_Click);

            // 

            // btn_lastrecord

            // 

            this.btn_lastrecord.Location = new System.Drawing.Point(200, 236);

            this.btn_lastrecord.Name = "btn_lastrecord";

            this.btn_lastrecord.Size = new System.Drawing.Size(113, 23);

            this.btn_lastrecord.TabIndex = 5;

            this.btn_lastrecord.Text = "Last Record";

            this.btn_lastrecord.UseVisualStyleBackColor = true;

            this.btn_lastrecord.Click += new System.EventHandler(this.btn_lastrecord_Click);

            // 

            // btn_firstrecord

            // 

            this.btn_firstrecord.Location = new System.Drawing.Point(33, 236);

            this.btn_firstrecord.Name = "btn_firstrecord";

            this.btn_firstrecord.Size = new System.Drawing.Size(112, 23);

            this.btn_firstrecord.TabIndex = 6;

            this.btn_firstrecord.Text = "First Record";

            this.btn_firstrecord.UseVisualStyleBackColor = true;

            this.btn_firstrecord.Click += new System.EventHandler(this.btn_firstrecord_Click);

            // 

            // txtbox_name

            // 

            this.txtbox_name.Location = new System.Drawing.Point(107, 12);

            this.txtbox_name.Name = "txtbox_name";

            this.txtbox_name.Size = new System.Drawing.Size(136, 20);

            this.txtbox_name.TabIndex = 7;

            // 

            // txtbox_address

            // 

            this.txtbox_address.Location = new System.Drawing.Point(107, 46);

            this.txtbox_address.Name = "txtbox_address";

            this.txtbox_address.Size = new System.Drawing.Size(136, 20);

            this.txtbox_address.TabIndex = 8;

            // 

            // txtbox_city

            // 

            this.txtbox_city.Location = new System.Drawing.Point(107, 74);

            this.txtbox_city.Name = "txtbox_city";

            this.txtbox_city.Size = new System.Drawing.Size(136, 20);

            this.txtbox_city.TabIndex = 9;

            // 

            // label1

            // 

            this.label1.AutoSize = true;

            this.label1.Location = new System.Drawing.Point(56, 15);

            this.label1.Name = "label1";

            this.label1.Size = new System.Drawing.Size(35, 13);

            this.label1.TabIndex = 10;

            this.label1.Text = "Name";

            // 

            // label2

            // 

            this.label2.AutoSize = true;

            this.label2.Location = new System.Drawing.Point(46, 49);

            this.label2.Name = "label2";

            this.label2.Size = new System.Drawing.Size(45, 13);

            this.label2.TabIndex = 11;

            this.label2.Text = "Address";

            // 

            // label3

            // 

            this.label3.AutoSize = true;

            this.label3.Location = new System.Drawing.Point(56, 77);

            this.label3.Name = "label3";

            this.label3.Size = new System.Drawing.Size(24, 13);

            this.label3.TabIndex = 12;

            this.label3.Text = "City";

            // 

            // btn_update

            // 

            this.btn_update.Location = new System.Drawing.Point(33, 282);

            this.btn_update.Name = "btn_update";

            this.btn_update.Size = new System.Drawing.Size(112, 23);

            this.btn_update.TabIndex = 13;

            this.btn_update.Text = "Update";

            this.btn_update.UseVisualStyleBackColor = true;

            this.btn_update.Click += new System.EventHandler(this.btn_update_Click);

            // 

            // btn_delete

            // 

            this.btn_delete.Location = new System.Drawing.Point(200, 282);

            this.btn_delete.Name = "btn_delete";

            this.btn_delete.Size = new System.Drawing.Size(113, 23);

            this.btn_delete.TabIndex = 14;

            this.btn_delete.Text = "Delete";

            this.btn_delete.UseVisualStyleBackColor = true;

            this.btn_delete.Click += new System.EventHandler(this.btn_delete_Click);

            // 

            // label4

            // 

            this.label4.AutoSize = true;

            this.label4.Location = new System.Drawing.Point(41, 142);

            this.label4.Name = "label4";

            this.label4.Size = new System.Drawing.Size(50, 13);

            this.label4.TabIndex = 15;

            this.label4.Text = "Zip Code";

            // 

            // txt_Zipcode

            // 

            this.txt_Zipcode.Location = new System.Drawing.Point(107, 139);

            this.txt_Zipcode.Name = "txt_Zipcode";

            this.txt_Zipcode.Size = new System.Drawing.Size(136, 20);

            this.txt_Zipcode.TabIndex = 16;

            // 

            // lbl_state

            // 

            this.lbl_state.AutoSize = true;

            this.lbl_state.Location = new System.Drawing.Point(49, 108);

            this.lbl_state.Name = "lbl_state";

            this.lbl_state.Size = new System.Drawing.Size(32, 13);

            this.lbl_state.TabIndex = 17;

            this.lbl_state.Text = "State";

            // 

            // txt_state

            // 

            this.txt_state.Location = new System.Drawing.Point(107, 105);

            this.txt_state.Name = "txt_state";

            this.txt_state.Size = new System.Drawing.Size(100, 20);

            this.txt_state.TabIndex = 18;

            // 

            // btn_newaccount

            // 

            this.btn_newaccount.Location = new System.Drawing.Point(398, 309);

            this.btn_newaccount.Name = "btn_newaccount";

            this.btn_newaccount.Size = new System.Drawing.Size(122, 23);

            this.btn_newaccount.TabIndex = 19;

            this.btn_newaccount.Text = "Add New Account";

            this.btn_newaccount.UseVisualStyleBackColor = true;

            this.btn_newaccount.Click += new System.EventHandler(this.btn_newaccount_Click);

            // 

            // btn_close

            // 

            this.btn_close.Location = new System.Drawing.Point(445, 544);

            this.btn_close.Name = "btn_close";

            this.btn_close.Size = new System.Drawing.Size(75, 23);

            this.btn_close.TabIndex = 20;

            this.btn_close.Text = "Close";

            this.btn_close.UseVisualStyleBackColor = true;

            this.btn_close.Click += new System.EventHandler(this.btn_close_Click);

            // 

            // clmn_accountnumber

            // 

            this.clmn_accountnumber.Text = "Account Number";

            this.clmn_accountnumber.Width = 120;

            // 

            // clmn_accounttype

            // 

            this.clmn_accounttype.Text = "Account Type";

            this.clmn_accounttype.Width = 110;

            // 

            // clmn_dateopened

            // 

            this.clmn_dateopened.Text = "Date Opened";

            this.clmn_dateopened.Width = 100;

            // 

            // clmn_balance

            // 

            this.clmn_balance.Text = "Balance";

            this.clmn_balance.Width = 75;

            // 

            // Mainform

            // 

            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

            this.ClientSize = new System.Drawing.Size(553, 596);

            this.Controls.Add(this.btn_close);

            this.Controls.Add(this.btn_newaccount);

            this.Controls.Add(this.txt_state);

            this.Controls.Add(this.lbl_state);

            this.Controls.Add(this.txt_Zipcode);

            this.Controls.Add(this.label4);

            this.Controls.Add(this.btn_delete);

            this.Controls.Add(this.btn_update);

            this.Controls.Add(this.label3);

            this.Controls.Add(this.label2);

            this.Controls.Add(this.label1);

            this.Controls.Add(this.txtbox_city);

            this.Controls.Add(this.txtbox_address);

            this.Controls.Add(this.txtbox_name);

            this.Controls.Add(this.btn_firstrecord);

            this.Controls.Add(this.btn_lastrecord);

            this.Controls.Add(this.btn_previous);

            this.Controls.Add(this.btn_nextrecord);

            this.Controls.Add(this.btn_submit);

            this.Controls.Add(this.btn_add);

            this.Controls.Add(this.lvCustomerAccounts);

            this.Name = "Mainform";

            this.Text = "Mainform";

            this.ResumeLayout(false);

            this.PerformLayout();


        }


        #endregion


        private System.Windows.Forms.ListView lvCustomerAccounts;

        private System.Windows.Forms.Button btn_add;

        private System.Windows.Forms.Button btn_submit;

        private System.Windows.Forms.Button btn_nextrecord;

        private System.Windows.Forms.Button btn_previous;

        private System.Windows.Forms.Button btn_lastrecord;

        private System.Windows.Forms.Button btn_firstrecord;

        private System.Windows.Forms.TextBox txtbox_name;

        private System.Windows.Forms.TextBox txtbox_address;

        private System.Windows.Forms.TextBox txtbox_city;

        private System.Windows.Forms.Label label1;

        private System.Windows.Forms.Label label2;

        private System.Windows.Forms.Label label3;

        private System.Windows.Forms.ColumnHeader clmn_customerID;

        private System.Windows.Forms.Button btn_update;

        private System.Windows.Forms.Button btn_delete;

        private System.Windows.Forms.Label label4;

        private System.Windows.Forms.TextBox txt_Zipcode;

        private System.Windows.Forms.Label lbl_state;

        private System.Windows.Forms.TextBox txt_state;

        private System.Windows.Forms.Button btn_newaccount;

        private System.Windows.Forms.Button btn_close;

        public System.Windows.Forms.ColumnHeader clmn_accountnumber;

        private System.Windows.Forms.ColumnHeader clmn_accounttype;

        public System.Windows.Forms.ColumnHeader clmn_dateopened;

        private System.Windows.Forms.ColumnHeader clmn_balance;

    }

}