⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customerform.cs

📁 这是一个保障消费者合法权益的系统.使用C #和SQL Server终于实现了这一功能的系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// textBox4
			// 
			this.textBox4.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.customerDataSet1, "tblCustomer.Make"));
			this.textBox4.Location = new System.Drawing.Point(456, 88);
			this.textBox4.Name = "textBox4";
			this.textBox4.Size = new System.Drawing.Size(160, 20);
			this.textBox4.TabIndex = 11;
			this.textBox4.Text = "";
			// 
			// sqlDataAdapter1
			// 
			this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
			this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
			this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
			this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									  new System.Data.Common.DataTableMapping("Table", "tblCustomer", new System.Data.Common.DataColumnMapping[] {
																																																					 new System.Data.Common.DataColumnMapping("CarNo", "CarNo"),
																																																					 new System.Data.Common.DataColumnMapping("Name", "Name"),
																																																					 new System.Data.Common.DataColumnMapping("Address", "Address"),
																																																					 new System.Data.Common.DataColumnMapping("Make", "Make")})});
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = @"DELETE FROM tblCustomer WHERE (CarNo = @Original_CarNo) AND (Address = @Original_Address OR @Original_Address IS NULL AND Address IS NULL) AND (Make = @Original_Make OR @Original_Make IS NULL AND Make IS NULL) AND (Name = @Original_Name OR @Original_Name IS NULL AND Name IS NULL)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CarNo", System.Data.SqlDbType.NVarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CarNo", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Address", System.Data.SqlDbType.NVarChar, 255, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Address", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Make", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Make", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Name", System.Data.SqlDbType.NVarChar, 255, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Name", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "data source=geetanjali-d190;initial catalog=CMS;integrated security=SSPI;persist " +
				"security info=False;workstation id=GEETANJALI-D190;packet size=4096";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO tblCustomer(CarNo, Name, Address, Make) VALUES (@CarNo, @Name, @Addre" +
				"ss, @Make); SELECT CarNo, Name, Address, Make FROM tblCustomer WHERE (CarNo = @C" +
				"arNo)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CarNo", System.Data.SqlDbType.NVarChar, 15, "CarNo"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Name", System.Data.SqlDbType.NVarChar, 255, "Name"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Address", System.Data.SqlDbType.NVarChar, 255, "Address"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Make", System.Data.SqlDbType.NVarChar, 50, "Make"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT CarNo, Name, Address, Make FROM tblCustomer";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE tblCustomer SET CarNo = @CarNo, Name = @Name, Address = @Address, Make = @Make WHERE (CarNo = @Original_CarNo) AND (Address = @Original_Address OR @Original_Address IS NULL AND Address IS NULL) AND (Make = @Original_Make OR @Original_Make IS NULL AND Make IS NULL) AND (Name = @Original_Name OR @Original_Name IS NULL AND Name IS NULL); SELECT CarNo, Name, Address, Make FROM tblCustomer WHERE (CarNo = @CarNo)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@CarNo", System.Data.SqlDbType.NVarChar, 15, "CarNo"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Name", System.Data.SqlDbType.NVarChar, 255, "Name"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Address", System.Data.SqlDbType.NVarChar, 255, "Address"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Make", System.Data.SqlDbType.NVarChar, 50, "Make"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_CarNo", System.Data.SqlDbType.NVarChar, 15, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "CarNo", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Address", System.Data.SqlDbType.NVarChar, 255, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Address", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Make", System.Data.SqlDbType.NVarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Make", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Name", System.Data.SqlDbType.NVarChar, 255, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Name", System.Data.DataRowVersion.Original, null));
			// 
			// btnNext
			// 
			this.btnNext.Location = new System.Drawing.Point(568, 224);
			this.btnNext.Name = "btnNext";
			this.btnNext.Size = new System.Drawing.Size(40, 23);
			this.btnNext.TabIndex = 13;
			this.btnNext.Text = ">";
			this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
			// 
			// txtDisplayPosition
			// 
			this.txtDisplayPosition.Enabled = false;
			this.txtDisplayPosition.Location = new System.Drawing.Point(152, 224);
			this.txtDisplayPosition.Name = "txtDisplayPosition";
			this.txtDisplayPosition.Size = new System.Drawing.Size(344, 20);
			this.txtDisplayPosition.TabIndex = 14;
			this.txtDisplayPosition.Text = "";
			this.txtDisplayPosition.TextChanged += new System.EventHandler(this.txtDisplayPosition_TextChanged);
			// 
			// btnBack
			// 
			this.btnBack.Location = new System.Drawing.Point(48, 224);
			this.btnBack.Name = "btnBack";
			this.btnBack.Size = new System.Drawing.Size(40, 23);
			this.btnBack.TabIndex = 15;
			this.btnBack.Text = "<";
			this.btnBack.Click += new System.EventHandler(this.btnBack_Click_1);
			// 
			// CustomerForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(680, 273);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.btnBack,
																		  this.txtDisplayPosition,
																		  this.btnNext,
																		  this.textBox4,
																		  this.textBox3,
																		  this.textBox2,
																		  this.textBox1,
																		  this.lblMake,
																		  this.lblAddress,
																		  this.lblName,
																		  this.lblCarNo,
																		  this.Exit,
																		  this.btnCancel,
																		  this.btnEdit,
																		  this.btnSave});
			this.Name = "CustomerForm";
			this.Text = "CustomerForm";
			this.Load += new System.EventHandler(this.CustomerForm_Load);
			((System.ComponentModel.ISupportInitialize)(this.customerDataSet1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		
		private void btnEdit_Click(object sender, System.EventArgs e)
		{
			customerDataSet1.Clear();
			sqlDataAdapter1.Fill(customerDataSet1);
			CurrentPosition();
			
		}

		private void btnSave_Click(object sender, System.EventArgs e)
		{
			sqlDataAdapter1.Update(customerDataSet1);
			MessageBox.Show("Database updated!");
		}

		private void btnBack_Click(object sender, System.EventArgs e)
		{
			btnBack.BindingContext[customerDataSet1, "tblCustomer"].Position -=1 ;
			CurrentPosition();

		}

		private void btnNext_Click(object sender, System.EventArgs e)
		{
			btnNext.BindingContext[customerDataSet1, "tblCustomer"].Position +=1 ;
			CurrentPosition();

		}

		private void CustomerForm_Load(object sender, System.EventArgs e)
		{
		
		}
		private void CurrentPosition()
		{
			int currentPosition, ctr;
			ctr = this.BindingContext[customerDataSet1, "tblCustomer"].Count;
		
			if(ctr == 0)
			{
				txtDisplayPosition.Text = "(There are no records in the Customer table.)";
			}
			else 
			{
					currentPosition = this.BindingContext[customerDataSet1, "tblCustomer"].Position + 1;
				txtDisplayPosition.Text = currentPosition.ToString() + " of " + ctr.ToString() ;
			}
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			customerDataSet1.Clear();
		}

		private void Exit_Click(object sender, System.EventArgs e)
		{
			Form1 newForm1 = new  Form1();
			newForm1.Show();
			this.Hide();
		}

		private void textBox1_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void txtDisplayPosition_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void btnBack_Click_1(object sender, System.EventArgs e)
		{
			btnBack.BindingContext[customerDataSet1, "tblCustomer"].Position -=1 ;
			CurrentPosition();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -