📄 archievementform.cs
字号:
//文件名:ArchievementForm.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace MyPersonnel
{
public partial class ArchievementForm : Form
{
public ArchievementForm()
{
InitializeComponent();
}
private void 工作业绩BindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
this.Validate();
this.工作业绩BindingSource.EndEdit();
this.工作业绩TableAdapter.Update(this.myPersonnelDataSet.工作业绩);
}
private void ArchievementForm_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“myPersonnelDataSet.工作业绩”中。您可以根据需要移动或移除它。
this.工作业绩TableAdapter.Fill(this.myPersonnelDataSet.工作业绩);
this.myPersonnelDataSet.工作业绩.Rows.Clear();
}
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
{
//自动计算工作业绩自编号
String MySQLConnectionString = global::MyPersonnel.Properties.Settings.Default.MyPersonnelConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
SqlCommand MyCommand = MyConnection.CreateCommand();
MyCommand.CommandText = "Select max(自编号) 最大编号 From 工作业绩";
object MyResult = MyCommand.ExecuteScalar();
Int64 MyID = 1;
if (MyResult != System.DBNull.Value)
{
String MyMaxID = MyResult.ToString().Trim();
MyMaxID = MyMaxID.Substring(2, MyMaxID.Length - 2);
MyID = Convert.ToInt64(MyMaxID) + 1;
}
int MyLength = MyID.ToString().Length;
string MyNewID = "";
switch (MyLength)
{
case 1:
MyNewID = "YJ0000000" + MyID.ToString();
break;
case 2:
MyNewID = "YJ000000" + MyID.ToString();
break;
case 3:
MyNewID = "YJ00000" + MyID.ToString();
break;
case 4:
MyNewID = "YJ0000" + MyID.ToString();
break;
case 5:
MyNewID = "YJ000" + MyID.ToString();
break;
case 6:
MyNewID = "YJ00" + MyID.ToString();
break;
case 7:
MyNewID = "YJ0" + MyID.ToString();
break;
}
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
this.自编号TextBox.Text = MyNewID;
}
private void 查询ToolStripButton_Click(object sender, EventArgs e)
{
String MySQLConnectionString = global::MyPersonnel.Properties.Settings.Default.MyPersonnelConnectionString;
SqlConnection MyConnection = new SqlConnection(MySQLConnectionString);
MyConnection.Open();
string MySQL = "Select * From 基本档案 Where 姓名 LIKE '" + this.员工姓名ToolStripTextBox.Text + "' AND (员工编号 NOT IN(SELECT 员工编号 FROM 离职管理))";
DataTable MyPersonnelTable = new DataTable();
SqlDataAdapter MyDataAdapter = new SqlDataAdapter(MySQL, MyConnection);
MyDataAdapter.Fill(MyPersonnelTable);
this.基本档案DataGridView.DataSource = MyPersonnelTable;
if (MyConnection.State == ConnectionState.Open)
{
MyConnection.Close();
}
}
private void 基本档案DataGridView_Click(object sender, EventArgs e)
{
this.员工编号TextBox.Text = this.基本档案DataGridView.CurrentRow.Cells[1].Value.ToString();
this.员工姓名TextBox.Text = this.基本档案DataGridView.CurrentRow.Cells[3].Value.ToString();
}
private void 基本档案DataGridView_SelectionChanged(object sender, EventArgs e)
{
string My员工姓名 = this.基本档案DataGridView.CurrentRow.Cells[3].Value.ToString();
try
{
this.工作业绩TableAdapter.FillBy(this.myPersonnelDataSet.工作业绩, My员工姓名);
}
catch (System.Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -