📄 moneymanege.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 人事管理
{
public partial class moneymanege : Form
{
data da = new data();
public static string aa;
public static int bb;
public moneymanege()
{
InitializeComponent();
}
private void moneymanege_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlDataAdapter sqlda = new SqlDataAdapter("select * from compensationView", da.link());
sqlda.Fill(ds, "compensation");
moneyview.DataSource = ds.Tables["compensation"];
da.link().Close();
}
//员工查询
private void selectworkerbtn_Click(object sender, EventArgs e)
{
if (moneyview.DataSource != null && moneyview.CurrentCell != null)
{
selectworker selewo = new selectworker();
selewo.ShowDialog();
if (selectworker.bj == true)
{
DataSet ds = new DataSet();
string txtName = selewo.workernametxt.Text;
string Email = selewo.emailtxt.Text;
string Depart = selewo.branchbox.Text;
SqlDataAdapter sqlda = new SqlDataAdapter("select * from compensationView", da.link());
SqlCommand sqlcomm = new SqlCommand("SELECT_money", da.link());
sqlcomm.CommandType = CommandType.StoredProcedure;
sqlcomm.Parameters.AddWithValue("@WorkerName", txtName);
sqlcomm.Parameters.AddWithValue("@WorkerEmail", Email);
sqlcomm.Parameters.AddWithValue("@branchnumname", Depart);
sqlcomm.ExecuteNonQuery();
sqlda = new SqlDataAdapter(sqlcomm);
sqlda.Fill(ds, "work");
moneyview.DataSource = ds.Tables["work"];
if (ds.Tables["work"].Rows.Count == 0)
{
sqlda = new SqlDataAdapter("select * from compensationView", da.link());
sqlda.Fill(ds, "compensation");
moneyview.DataSource = ds.Tables["compensation"];
MessageBox.Show("未查到符合条件的员工!");
}
}
da.link().Close();
}
else
{
MessageBox.Show("无相关部门的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
//历史查询
private void histrybtn_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlDataAdapter sqlda1 = new SqlDataAdapter("select * from compensationView", da.link());
sqlda1.Fill(ds);
aa = ds.Tables[0].Rows[moneyview.CurrentCell.RowIndex][1].ToString().Trim();
histrymoney hismo = new histrymoney();
hismo.ShowDialog();
}
//部门汇总
private void branchbtn_Click(object sender, EventArgs e)
{
if (moneyview.DataSource != null && moneyview.CurrentCell != null)
{
人事管理.HolidayManage.Branchcollect branchcollect = new 人事管理.HolidayManage.Branchcollect();
branchcollect.ShowDialog();
DataSet ds = new DataSet();
SqlCommand sqlcomm = new SqlCommand("select WorkerID from Worker inner join branchnum on branchnum.branchnumID=Worker.branchnumID where branchnumname='" + branchcollect.comboBox1.Text + "'", da.link());
//sqlda.Fill(ds, "Worker");
SqlDataReader sqldr = sqlcomm.ExecuteReader();
sqldr.Read();
try
{
bb = Convert.ToInt32(sqldr.GetValue(0).ToString());
}
catch
{
MessageBox.Show("无相关部门的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (bb != 0)
{
SqlDataAdapter sqlda1 = new SqlDataAdapter("select * from compensationView where 员工编号='" + bb + "'", da.link());
sqlda1.Fill(ds, "compensation");
moneyview.DataSource = ds.Tables["compensation"];
da.link().Close();
}
}
else
{
MessageBox.Show("无相关部门的信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
//薪资设定
private void setmoneybtn_Click(object sender, EventArgs e)
{
if (moneyview.DataSource != null && moneyview.CurrentCell != null)
{
setmoney setmo = new setmoney();
DataSet ds = new DataSet();
SqlDataAdapter sqlda1 = new SqlDataAdapter("select * from compensationView", da.link());
sqlda1.Fill(ds);
setmo.Tag = ds.Tables[0].Rows[moneyview.CurrentCell.RowIndex][0].ToString().Trim();
setmo.moneytxt.Text = ds.Tables[0].Rows[moneyview.CurrentCell.RowIndex][3].ToString().Trim();
setmo.ShowDialog();
da.link().Close();
SqlDataAdapter sqlda = new SqlDataAdapter("select * from compensationView", da.link());
sqlda.Fill(ds, "compensation");
moneyview.DataSource = ds.Tables["compensation"];
}
else
MessageBox.Show("没有指定的员工薪资信息");
}
//确定
private void yesbtn_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlDataAdapter sqlda = new SqlDataAdapter("select * from compensationView", da.link());
sqlda.Fill(ds, "compensation");
moneyview.DataSource = ds.Tables["compensation"];
da.link().Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -