Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Ok down to two errors but I can't figure out how to fix it? The errors are: Severity Code Description Project File Line Suppression State

Ok down to two errors but I can't figure out how to fix it? The errors are:

Severity

Code

Description

Project

File

Line

Suppression State

Error

CS1061

'object' does not contain a definition for 'OrderBy' and no extension method 'OrderBy' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

CustomerContact

42

Active

Severity

Code

Description

Project

File

Line

Suppression State

Error

CS1061

'object' does not contain a definition for 'local' and no extension method 'local' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

CustomerContact

47

Active

Form1 cs

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace CustomerContact { public partial class Contacts : Form { public Contacts() { InitializeComponent(); } // End constructor

// Entity Framework DbContext private AddressExample.AddressBookEntities dbcontext = null;

// fill our addressBindingSource with all rows, ordered by name private void RefreshContacts() { // Dispose old DbContext, if any if (dbcontext != null) dbcontext.Dispose();

// create new DbContext so we can reorder records based on edits dbcontext = new AddressExample.AddressBookEntities();

//use LINQ to order the Addresses table contents by last name, then first name dbcontext.Addresses .OrderBy(entry => entry.LastName) .ThenBy(entry => entry.FirstName) .Load();

// specify DataSource for AddressBindingSource addressBindingSource.DataSource = dbcontext.Addresses.local; addressBindingSource.MoveFirst(); // go to first result findTextBox.Clear(); // clear the Find TextBox } // End method RefreshContacts

// when the form load, fill it with data from the database private void Contacts_Load(object sender, EventArgs e) { RefreshContacts(); // fill binding with data from database } // end method Contacts_Load

// click event handler for the Save Button in the BlindNavigator saves the changes made in the data private void addressBindingNavigatorSaveItem_Click( object sender, EventArgs e) { Validate(); // validate input fields addressBindingSource.EndEdit(); // complete current edit, if any try to save changes

try { dbcontext.SaveChanges(); // write changes to database } // end try catch (DbEntityValidateException) { MessageBox.Show("Columns cannot be empty, Entity Validation Exception"); } // end catch

RefreshContacts(); // change back to intial unfiltered data } // end method addressBindingNavigatorSaveItem_Click

[Serializable] private class DbEntityValidateException : Exception { public DbEntityValidateException() { }

public DbEntityValidateException(string message) : base(message) { }

public DbEntityValidateException(string message, Exception innerException) : base(message, innerException) { }

protected DbEntityValidateException(SerializationInfo info, StreamingContext context) : base(info, context) { } }

private class addressBindingSource { internal static object DataSource;

internal static void EndEdit() { throw new NotImplementedException(); }

internal static void MoveFirst() { throw new NotImplementedException(); } }

private class findTextBox { internal static void Clear() { throw new NotImplementedException(); } } } }

Form1.designer

using System.Windows.Forms;

namespace CustomerContact { partial class Contacts { ///

/// Required designer variable. /// private System.ComponentModel.IContainer components = null;

///

/// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }

#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form)); this.textBox1 = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.textBox2 = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.textBox3 = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.textBox4 = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); this.textBox5 = new System.Windows.Forms.TextBox(); this.label5 = new System.Windows.Forms.Label(); this.textBox6 = new System.Windows.Forms.TextBox(); this.label6 = new System.Windows.Forms.Label(); this.label7 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); this.bindingNavigator1 = new System.Windows.Forms.BindingNavigator(this.components); 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.bindingNavigatorCountItem = new System.Windows.Forms.ToolStripLabel(); 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.bindingNavigatorAddNewItem = new System.Windows.Forms.ToolStripButton(); this.bindingNavigatorDeleteItem = new System.Windows.Forms.ToolStripButton(); this.button2 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.bindingNavigator1)).BeginInit(); this.bindingNavigator1.SuspendLayout(); this.SuspendLayout(); // // textBox1 // this.textBox1.Location = new System.Drawing.Point(109, 47); this.textBox1.Name = "textBox1"; this.textBox1.ReadOnly = true; this.textBox1.Size = new System.Drawing.Size(228, 20); this.textBox1.TabIndex = 0; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(11, 50); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(62, 13); this.label1.TabIndex = 1; this.label1.Text = "Address ID:"; // // textBox2 // this.textBox2.Location = new System.Drawing.Point(109, 84); this.textBox2.Name = "textBox2"; this.textBox2.Size = new System.Drawing.Size(228, 20); this.textBox2.TabIndex = 2; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(11, 87); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(60, 13); this.label2.TabIndex = 3; this.label2.Text = "First Name:"; // // textBox3 // this.textBox3.Location = new System.Drawing.Point(109, 124); this.textBox3.Name = "textBox3"; this.textBox3.Size = new System.Drawing.Size(228, 20); this.textBox3.TabIndex = 4; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(10, 127); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(61, 13); this.label3.TabIndex = 5; this.label3.Text = "Last Name:"; // // textBox4 // this.textBox4.Location = new System.Drawing.Point(109, 161); this.textBox4.Name = "textBox4"; this.textBox4.Size = new System.Drawing.Size(228, 20); this.textBox4.TabIndex = 6; // // label4 // this.label4.AutoSize = true; this.label4.Location = new System.Drawing.Point(10, 164); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(39, 13); this.label4.TabIndex = 7; this.label4.Text = "E-Mail:"; // // textBox5 // this.textBox5.Location = new System.Drawing.Point(109, 199); this.textBox5.Name = "textBox5"; this.textBox5.Size = new System.Drawing.Size(228, 20); this.textBox5.TabIndex = 8; // // label5 // this.label5.AutoSize = true; this.label5.Location = new System.Drawing.Point(10, 202); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(81, 13); this.label5.TabIndex = 9; this.label5.Text = "Phone Number:"; // // textBox6 // this.textBox6.Location = new System.Drawing.Point(109, 259); this.textBox6.Name = "textBox6"; this.textBox6.Size = new System.Drawing.Size(172, 20); this.textBox6.TabIndex = 10; // // label6 // this.label6.AutoSize = true; this.label6.Location = new System.Drawing.Point(10, 243); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(130, 13); this.label6.TabIndex = 11; this.label6.Text = "Find an entry by last name"; // // label7 // this.label7.AutoSize = true; this.label7.Location = new System.Drawing.Point(10, 261); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(61, 13); this.label7.TabIndex = 12; this.label7.Text = "Last Name:"; // // button1 // this.button1.Location = new System.Drawing.Point(287, 256); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 13; this.button1.Text = "Find"; this.button1.UseVisualStyleBackColor = true; // // bindingNavigator1 // this.bindingNavigator1.AddNewItem = this.bindingNavigatorAddNewItem; this.bindingNavigator1.CountItem = this.bindingNavigatorCountItem; this.bindingNavigator1.DeleteItem = this.bindingNavigatorDeleteItem; this.bindingNavigator1.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.bindingNavigator1.Location = new System.Drawing.Point(0, 0); this.bindingNavigator1.MoveFirstItem = this.bindingNavigatorMoveFirstItem; this.bindingNavigator1.MoveLastItem = this.bindingNavigatorMoveLastItem; this.bindingNavigator1.MoveNextItem = this.bindingNavigatorMoveNextItem; this.bindingNavigator1.MovePreviousItem = this.bindingNavigatorMovePreviousItem; this.bindingNavigator1.Name = "bindingNavigator1"; this.bindingNavigator1.PositionItem = this.bindingNavigatorPositionItem; this.bindingNavigator1.Size = new System.Drawing.Size(372, 25); this.bindingNavigator1.TabIndex = 14; this.bindingNavigator1.Text = "bindingNavigator1"; // // 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"; // // 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"; // // bindingNavigatorSeparator1 // this.bindingNavigatorSeparator1.Name = "bindingNavigatorSeparator"; 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 = "bindingNavigatorSeparator"; this.bindingNavigatorSeparator2.Size = new System.Drawing.Size(6, 25); // // 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"; // // 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"; // // button2 // this.button2.Location = new System.Drawing.Point(133, 285); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(106, 23); this.button2.TabIndex = 15; this.button2.Text = "Browse All Entries"; this.button2.UseVisualStyleBackColor = true; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(372, 327); this.Controls.Add(this.button2); this.Controls.Add(this.bindingNavigator1); this.Controls.Add(this.button1); this.Controls.Add(this.label7); this.Controls.Add(this.label6); this.Controls.Add(this.textBox6); this.Controls.Add(this.label5); this.Controls.Add(this.textBox5); this.Controls.Add(this.label4); this.Controls.Add(this.textBox4); this.Controls.Add(this.label3); this.Controls.Add(this.textBox3); this.Controls.Add(this.label2); this.Controls.Add(this.textBox2); this.Controls.Add(this.label1); this.Controls.Add(this.textBox1); this.Name = "Form1"; this.Text = "Address Book"; ((System.ComponentModel.ISupportInitialize)(this.bindingNavigator1)).EndInit(); this.bindingNavigator1.ResumeLayout(false); this.bindingNavigator1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout();

}

#endregion

private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox textBox4; private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox textBox5; private System.Windows.Forms.Label label5; private System.Windows.Forms.TextBox textBox6; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label7; private System.Windows.Forms.Button button1; private System.Windows.Forms.BindingNavigator bindingNavigator1; 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.Button button2; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

Explain consumer behaviour.

Answered: 1 week ago

Question

Explain the factors influencing consumer behaviour.

Answered: 1 week ago