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

📄 incometax.cs

📁 Visual C#.NET数据库开发经典案例解析,这里有1到3的案例
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.备注.Format = "";
			this.备注.FormatInfo = null;
			this.备注.HeaderText = "备注";
			this.备注.MappingName = "备注";
			this.备注.NullText = "";
			this.备注.Width = 200;
			// 
			// toolBar1
			// 
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.tbarBtnSave,
																						this.tbarBtnDelete,
																						this.toolBarQuit});
			this.toolBar1.DropDownArrows = true;
			this.toolBar1.ImageList = this.imageList1;
			this.toolBar1.Location = new System.Drawing.Point(0, 0);
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.ShowToolTips = true;
			this.toolBar1.Size = new System.Drawing.Size(592, 41);
			this.toolBar1.TabIndex = 24;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// tbarBtnSave
			// 
			this.tbarBtnSave.ImageIndex = 0;
			this.tbarBtnSave.Text = "保存修改";
			this.tbarBtnSave.ToolTipText = "保存修改";
			// 
			// tbarBtnDelete
			// 
			this.tbarBtnDelete.ImageIndex = 1;
			this.tbarBtnDelete.Text = "删除数据";
			this.tbarBtnDelete.ToolTipText = "删除数据";
			// 
			// toolBarQuit
			// 
			this.toolBarQuit.ImageIndex = 2;
			this.toolBarQuit.Text = "退出";
			this.toolBarQuit.ToolTipText = "退出";
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// 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", "个人所得税表", new System.Data.Common.DataColumnMapping[] {
																																																				new System.Data.Common.DataColumnMapping("编号", "编号"),
																																																				new System.Data.Common.DataColumnMapping("级数", "级数"),
																																																				new System.Data.Common.DataColumnMapping("不计税工资", "不计税工资"),
																																																				new System.Data.Common.DataColumnMapping("工资下限", "工资下限"),
																																																				new System.Data.Common.DataColumnMapping("工资上限", "工资上限"),
																																																				new System.Data.Common.DataColumnMapping("个人所得税率", "个人所得税率"),
																																																				new System.Data.Common.DataColumnMapping("速算扣除数", "速算扣除数"),
																																																				new System.Data.Common.DataColumnMapping("备注", "备注")})});
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = @"DELETE FROM 个人所得税表 WHERE (编号 = @Original_编号) AND (不计税工资 = @Original_不计税工资) AND (个人所得税率 = @Original_个人所得税率) AND (备注 = @Original_备注 OR @Original_备注 IS NULL AND 备注 IS NULL) AND (工资上限 = @Original_工资上限) AND (工资下限 = @Original_工资下限) AND (级数 = @Original_级数) AND (速算扣除数 = @Original_速算扣除数)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "编号", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_不计税工资", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "不计税工资", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_个人所得税率", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "个人所得税率", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_备注", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "备注", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_工资上限", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "工资上限", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_工资下限", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "工资下限", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_级数", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "级数", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_速算扣除数", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "速算扣除数", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=localhost;Integrated Security=SSPI;Database=hrmbook;";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO 个人所得税表(编号, 级数, 不计税工资, 工资下限, 工资上限, 个人所得税率, 速算扣除数, 备注) VALUES (@编号, @级数" +
				", @不计税工资, @工资下限, @工资上限, @个人所得税率, @速算扣除数, @备注); SELECT 编号, 级数, 不计税工资, 工资下限, 工资上限," +
				" 个人所得税率, 速算扣除数, 备注 FROM 个人所得税表 WHERE (编号 = @编号)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@编号", System.Data.SqlDbType.Int, 4, "编号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@级数", System.Data.SqlDbType.VarChar, 2, "级数"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@不计税工资", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "不计税工资", System.Data.DataRowVersion.Current, null));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工资下限", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "工资下限", System.Data.DataRowVersion.Current, null));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工资上限", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "工资上限", System.Data.DataRowVersion.Current, null));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@个人所得税率", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "个人所得税率", System.Data.DataRowVersion.Current, null));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@速算扣除数", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "速算扣除数", System.Data.DataRowVersion.Current, null));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 50, "备注"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 编号, 级数, 不计税工资, 工资下限, 工资上限, 个人所得税率, 速算扣除数, 备注 FROM 个人所得税表";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE 个人所得税表 SET 编号 = @编号, 级数 = @级数, 不计税工资 = @不计税工资, 工资下限 = @工资下限, 工资上限 = @工资上限, 个人所得税率 = @个人所得税率, 速算扣除数 = @速算扣除数, 备注 = @备注 WHERE (编号 = @Original_编号) AND (不计税工资 = @Original_不计税工资) AND (个人所得税率 = @Original_个人所得税率) AND (备注 = @Original_备注 OR @Original_备注 IS NULL AND 备注 IS NULL) AND (工资上限 = @Original_工资上限) AND (工资下限 = @Original_工资下限) AND (级数 = @Original_级数) AND (速算扣除数 = @Original_速算扣除数); SELECT 编号, 级数, 不计税工资, 工资下限, 工资上限, 个人所得税率, 速算扣除数, 备注 FROM 个人所得税表 WHERE (编号 = @编号)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@编号", System.Data.SqlDbType.Int, 4, "编号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@级数", System.Data.SqlDbType.VarChar, 2, "级数"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@不计税工资", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "不计税工资", System.Data.DataRowVersion.Current, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工资下限", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "工资下限", System.Data.DataRowVersion.Current, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@工资上限", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "工资上限", System.Data.DataRowVersion.Current, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@个人所得税率", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "个人所得税率", System.Data.DataRowVersion.Current, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@速算扣除数", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "速算扣除数", System.Data.DataRowVersion.Current, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@备注", System.Data.SqlDbType.VarChar, 50, "备注"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_编号", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "编号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_不计税工资", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "不计税工资", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_个人所得税率", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "个人所得税率", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_备注", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "备注", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_工资上限", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "工资上限", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_工资下限", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "工资下限", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_级数", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "级数", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_速算扣除数", System.Data.SqlDbType.Decimal, 13, System.Data.ParameterDirection.Input, false, ((System.Byte)(26)), ((System.Byte)(2)), "速算扣除数", System.Data.DataRowVersion.Original, null));
			// 
			// IncomeTax
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(592, 423);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.toolBar1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "IncomeTax";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "【个人所得税率】";
			this.Load += new System.EventHandler(this.IncomeTax_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion
		//--------------------初始化窗体,读入数据------------------
		private void IncomeTax_Load(object sender, System.EventArgs e)
		{
			this.sqlDataAdapter1.Fill(this.dataSet11.个人所得税表);
		}

		//--------------保存修改过的数据或删除某条数据------------------
		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if(e.Button.ToolTipText == "保存修改")
			{
				try
				{
					/*int row = this.dataGrid1.CurrentCell.RowNumber;
					//将当前所在行往下移动一行,为便于实现同步保存
					//(否则会出现修改的最后一行无法保存,因为它还处于编辑状态)
					this.dataGrid1.CurrentCell = new DataGridCell(row+1,0); 
					//使光标回到修改前的当前行来
					this.dataGrid1.CurrentCell = new DataGridCell(row,0);*/
					if (this.dataSet11.个人所得税表.GetChanges() != null)
					{
						this.sqlDataAdapter1.Update(this.dataSet11);
						MessageBox.Show("数据保存成功!","信息");
						return;
					}
					else
					{
						MessageBox.Show("没有修改任何数据!","信息");
						return;
					}
				}
				catch
				{
					MessageBox.Show("数据修改失败,请重试!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
					return;
				}
			}
			if(e.Button.ToolTipText == "删除数据")
			{
				if (MessageBox.Show("      确实要删除这条记录吗?","询问",MessageBoxButtons.YesNo) == DialogResult.Yes)
				{
					int intRowNumber = this.dataGrid1.CurrentCell.RowNumber;
					try
					{
						this.dataSet11.个人所得税表.Rows[intRowNumber].Delete();
						this.sqlDataAdapter1.Update(this.dataSet11.个人所得税表);
						MessageBox.Show("数据删除成功!","信息");
						return;
					}
					catch
					{
						MessageBox.Show("数据删除失败,请重试!","提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
						return;
					}
				}
			}
			if (e.Button.ToolTipText == "退出")
			{
				this.Close();
			}
		}
	}
}

⌨️ 快捷键说明

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