📄 salarymanage.h
字号:
this->groupBox2->Controls->Add(this->btnHandout);
this->groupBox2->Controls->Add(this->btnCalculate);
this->groupBox2->Controls->Add(this->btnImport);
this->groupBox2->Controls->Add(this->label23);
this->groupBox2->Controls->Add(this->tBoxImportDate);
this->groupBox2->Controls->Add(this->label22);
this->groupBox2->Controls->Add(this->tBoxCurrentDate);
this->groupBox2->Dock = System::Windows::Forms::DockStyle::Top;
this->groupBox2->Location = System::Drawing::Point(0, 41);
this->groupBox2->Name = S"groupBox2";
this->groupBox2->Size = System::Drawing::Size(640, 79);
this->groupBox2->TabIndex = 6;
this->groupBox2->TabStop = false;
//
// btnHandout
//
this->btnHandout->Location = System::Drawing::Point(544, 24);
this->btnHandout->Name = S"btnHandout";
this->btnHandout->Size = System::Drawing::Size(96, 24);
this->btnHandout->TabIndex = 16;
this->btnHandout->Text = S"工资发放";
this->btnHandout->Click += new System::EventHandler(this, btnHandout_Click);
//
// btnCalculate
//
this->btnCalculate->Location = System::Drawing::Point(440, 24);
this->btnCalculate->Name = S"btnCalculate";
this->btnCalculate->Size = System::Drawing::Size(96, 24);
this->btnCalculate->TabIndex = 15;
this->btnCalculate->Text = S"计算当月工资";
this->btnCalculate->Click += new System::EventHandler(this, btnCalculate_Click);
//
// btnImport
//
this->btnImport->Location = System::Drawing::Point(328, 25);
this->btnImport->Name = S"btnImport";
this->btnImport->Size = System::Drawing::Size(96, 24);
this->btnImport->TabIndex = 14;
this->btnImport->Text = S"导入工资历史";
this->btnImport->Click += new System::EventHandler(this, btnImport_Click);
//
// label23
//
this->label23->Location = System::Drawing::Point(167, 32);
this->label23->Name = S"label23";
this->label23->Size = System::Drawing::Size(56, 16);
this->label23->TabIndex = 13;
this->label23->Text = S"导入月份";
//
// tBoxImportDate
//
this->tBoxImportDate->Location = System::Drawing::Point(231, 28);
this->tBoxImportDate->Name = S"tBoxImportDate";
this->tBoxImportDate->Size = System::Drawing::Size(80, 21);
this->tBoxImportDate->TabIndex = 12;
this->tBoxImportDate->Text = S"";
//
// label22
//
this->label22->Location = System::Drawing::Point(10, 32);
this->label22->Name = S"label22";
this->label22->Size = System::Drawing::Size(56, 16);
this->label22->TabIndex = 11;
this->label22->Text = S"当前月份";
//
// tBoxCurrentDate
//
this->tBoxCurrentDate->Location = System::Drawing::Point(74, 28);
this->tBoxCurrentDate->Name = S"tBoxCurrentDate";
this->tBoxCurrentDate->Size = System::Drawing::Size(80, 21);
this->tBoxCurrentDate->TabIndex = 10;
this->tBoxCurrentDate->Text = S"";
//
// SalaryManage
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 14);
this->ClientSize = System::Drawing::Size(640, 421);
this->Controls->Add(this->dgrdSalary);
this->Controls->Add(this->groupBox2);
this->Controls->Add(this->groupBox1);
this->Controls->Add(this->toolBar1);
this->Name = S"SalaryManage";
this->Text = S"工资发放";
this->Load += new System::EventHandler(this, SalaryManage_Load);
this->groupBox1->ResumeLayout(false);
(__try_cast<System::ComponentModel::ISupportInitialize * >(this->dgrdSalary))->EndInit();
this->groupBox2->ResumeLayout(false);
this->ResumeLayout(false);
}
private: System::Void SalaryManage_Load(System::Object * sender, System::EventArgs * e)
{
//查询月工资统计表
String* tempSQL = new String("Select * from 月工资统计表");
String* tempTableName = new String("月工资统计表");
this->SalaryAdapter = new SqlDataAdapter();
this->MyDataBase->SelectDataBase(this->SalaryAdapter,this->ds,tempSQL,tempTableName);
this->cmSalary = __try_cast<CurrencyManager*>(this->BindingContext->Item[this->ds->Tables->Item[S"月工资统计表"]]);
this->dgrdSalary->DataSource = this->ds->Tables->Item[S"工资单"];
this->DataGridStateControl();
this->DataBidings();
}
//------------------设置表格样式----------------------
void DataGridStateControl()
{
DataGridTableStyle* ts = new DataGridTableStyle();
DataGridNoActiveCellColumn* aTextColumn;
ts->AlternatingBackColor = Color::LightGray;
ts->MappingName = this->ds->Tables->Item[S"工资单"]->TableName;
int numCols = this->ds->Tables->Item[S"工资单"]->Columns->Count;
for(int i = 0;i < numCols;i++)
{
aTextColumn = new DataGridNoActiveCellColumn();
aTextColumn->get_TextBox()->Enabled = false;
aTextColumn->MappingName = this->ds->Tables->Item[S"工资单"]->Columns->Item[i]->ColumnName;
aTextColumn->HeaderText = this->ds->Tables->Item[S"工资单"]->Columns->Item[i]->ColumnName;
aTextColumn->NullText = S"";
aTextColumn->Format = S"D";
ts->GridColumnStyles->Add(aTextColumn);
}
this->dgrdSalary->TableStyles->Add(ts);
this->dgrdSalary->Select(0);
}
//------------------设置数据绑定----------------------
void DataBidings()
{
this->tBoxBaseSalary->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"基本工资");
this->tBoxFloatSalary->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"浮动工资");
this->tBoxContractAllowance->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"合同补");
this->tBoxFoodAllowance->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"粮副补");
this->tBoxHouseAllowance->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"房补");
this->tBoxTemporyAllowance->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"临时补");
this->tBoxDutySalary->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"职务工资");
this->tBoxAgeSalary->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"工龄工资");
this->tBoxAssessSalary->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"考核工资");
this->tBoxBonus->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"奖金");
this->tBoxRent->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"房租");
this->tBoxEleWaterRate->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"水电费");
this->tBoxLeave->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"请假扣除");
this->tBoxAttendance->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"考勤扣除");
this->tBoxAmerce->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"罚款");
this->tBoxHouseFund->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"住房公积金");
this->tBoxMedicare->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"医疗保险");
this->tBoxEndownInsurance->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"养老保险");
this->tBoxJobInsurance->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"失业保险");
this->tBoxBearInsurance->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"生育保险");
this->tBoxWoundInsurance->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"工伤保险");
this->tBoxCurrentDate->DataBindings->Add("Text",this->ds->Tables->Item[S"月工资统计表"],"月份");
}
//------------------------计算当月工资------------------------------------
private: System::Void btnCalculate_Click(System::Object * sender, System::EventArgs * e)
{
//调用存储过程
String* tempSQL = S"exec sf_当月工资统计";
try
{
this->MyDataBase->SQLOperate(tempSQL);
}
catch(Exception* e)
{
MessageBox::Show(e->Message,S"提示");
}
//刷新表中的数据
this->ds->Tables->Item[S"工资单"]->Clear();
this->ds->Tables->Item[S"月工资统计表"]->Clear();
this->strSQL = S"SELECT 职员基本信息表.职员编号, 职员基本信息表.姓名, 月工资统计表.日期, 月工资统计表.应发金额合计, 月工资统计表.应扣金额合计, 月工资统计表.工资合计, 月工资统计表.个人所得税, 月工资统计表.实发金额, 月工资统计表.发放否, 月工资统计表.月份, 月工资统计表.职员编号 AS Expr1 FROM 职员基本信息表 INNER JOIN 月工资统计表 ON 职员基本信息表.职员编号 = 月工资统计表.职员编号";
this->strTableName = S"工资单";
this->ds = this->MyDataBase->SelectDataBase(this->strSQL,this->strTableName);
this->dgrdSalary->DataSource = this->ds->Tables->Item[S"工资单"]->DefaultView;
tempSQL = new String("Select * from 月工资统计表");
String* tempTableName = new String("月工资统计表");
this->SalaryAdapter = new SqlDataAdapter();
this->MyDataBase->SelectDataBase(this->SalaryAdapter,this->ds,tempSQL,tempTableName);
}
//-----------------------导入工资历史------------------------------------
private: System::Void btnImport_Click(System::Object * sender, System::EventArgs * e)
{
String* thisMonth = this->tBoxCurrentDate->Text;
String* ImportMonth = this->tBoxImportDate->Text;
//检查输入
if(String::Compare(thisMonth,String::Empty) == 0)
{
MessageBox::Show(S"请输入当前月份!",S"提示");
return;
}
if(String::Compare(ImportMonth,String::Empty) == 0)
{
MessageBox::Show(S"请输入导入月份!",S"提示");
return;
}
//调用存储过程
String* tempSQL = String::Format(S"exec sf_形成月工资统计表 '{0}','{1}'",ImportMonth,thisMonth);
try
{
this->MyDataBase->SQLOperate(tempSQL);
}
catch(Exception* e)
{
MessageBox::Show(e->Message,S"提示");
}
//刷新表中的数据
this->ds->Tables->Item[S"工资单"]->Clear();
this->ds->Tables->Item[S"月工资统计表"]->Clear();
this->strSQL = S"SELECT 职员基本信息表.职员编号, 职员基本信息表.姓名, 月工资统计表.日期, 月工资统计表.应发金额合计, 月工资统计表.应扣金额合计, 月工资统计表.工资合计, 月工资统计表.个人所得税, 月工资统计表.实发金额, 月工资统计表.发放否, 月工资统计表.月份, 月工资统计表.职员编号 AS Expr1 FROM 职员基本信息表 INNER JOIN 月工资统计表 ON 职员基本信息表.职员编号 = 月工资统计表.职员编号";
this->strTableName = S"工资单";
this->ds = this->MyDataBase->SelectDataBase(this->strSQL,this->strTableName);
this->dgrdSalary->DataSource = this->ds->Tables->Item[S"工资单"]->DefaultView;
tempSQL = new String("Select * from 月工资统计表");
String* tempTableName = new String("月工资统计表");
this->SalaryAdapter = new SqlDataAdapter();
this->MyDataBase->SelectDataBase(this->SalaryAdapter,this->ds,tempSQL,tempTableName);
}
//--------------------------发放工资----------------------------------------
private: System::Void btnHandout_Click(System::Object * sender, System::EventArgs * e)
{
if(this->ds->Tables->Item[S"工资单"]->Rows->Count <= 0)
{
//如果表格为空,则表示工资已经发放完毕
MessageBox::Show(S"工资发放完毕",S"提示");
}
String* strMessage = String::Format(S"是否为 {0} 发放工资?",this->ds->Tables->Item[S"工资单"]->Rows->Item[this->dgrdSalary->CurrentCell.RowNumber]->Item[S"姓名"]->ToString()->Trim());
if(MessageBox::Show(strMessage,S"询问",MessageBoxButtons::YesNo) == DialogResult::Yes)
{
int row = this->dgrdSalary->CurrentCell.RowNumber;
//int col = this->dgrdSalary->CurrentCell.ColumnNumber;
String* strID = this->ds->Tables->Item[S"工资单"]->Rows->Item[row]->Item[S"职员编号"]->ToString()->Trim();
String* tempSQL = String::Format(S"exec sf_当月工资发放 '{0}'",strID);
//调用存储过程
try
{
this->MyDataBase->SQLOperate(tempSQL);
}
catch(Exception* e)
{
MessageBox::Show(e->Message,S"提示");
}
//刷新表中的数据
this->ds->Tables->Item[S"工资单"]->Clear();
this->strSQL = S"SELECT 职员基本信息表.职员编号,职员基本信息表.姓名, 月工资统计表.日期, 月工资统计表.应发金额合计,月工资统计表.应扣金额合计, 月工资统计表.工资合计, 月工资统计表.个人所得税,月工资统计表.实发金额, 月工资统计表.发放否 FROM 月工资统计表 INNER JOIN 职员基本信息表 ON 月工资统计表.职员编号 = 职员基本信息表.职员编号";
this->strTableName = S"工资单";
this->ds = this->MyDataBase->SelectDataBase(this->strSQL,this->strTableName);
this->dgrdSalary->DataSource = this->ds->Tables->Item[S"工资单"]->DefaultView;
if(this->ds->Tables->Item[S"工资单"]->Rows->Count > 0)
{
if(row < this->ds->Tables->Item[S"工资单"]->Rows->Count)
{
this->dgrdSalary->CurrentRowIndex = row;
this->dgrdSalary->Select(row);
}
else
{
this->dgrdSalary->CurrentRowIndex = this->ds->Tables->Item[S"工资单"]->Rows->Count - 1;
this->dgrdSalary->Select(this->ds->Tables->Item[S"工资单"]->Rows->Count - 1);
}
}
}
}
private: System::Void toolBar1_ButtonClick(System::Object * sender, System::Windows::Forms::ToolBarButtonClickEventArgs * e)
{
if(String::Compare(e->Button->ToolTipText->Trim(),S"首记录") == 0)
{
this->dgrdSalary->UnSelect(this->cmSalary->Position);
this->cmSalary->Position = 0;
this->dgrdSalary->Select(this->cmSalary->Position);
this->dgrdSalary->CurrentRowIndex = this->cmSalary->Position;
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"上一记录") == 0)
{
if(this->cmSalary->Position > 0)
{
this->dgrdSalary->UnSelect(this->cmSalary->Position);
this->cmSalary->Position--;
this->dgrdSalary->Select(this->cmSalary->Position);
this->dgrdSalary->CurrentRowIndex = this->cmSalary->Position;
}
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"下一记录") == 0)
{
if(this->cmSalary->Position < this->cmSalary->Count - 1)
{
this->dgrdSalary->UnSelect(this->cmSalary->Position);
this->cmSalary->Position++;
this->dgrdSalary->Select(this->cmSalary->Position);
this->dgrdSalary->CurrentRowIndex = this->cmSalary->Position;
}
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"尾记录") == 0)
{
this->dgrdSalary->UnSelect(this->cmSalary->Position);
this->cmSalary->Position = this->cmSalary->Count - 1;
this->dgrdSalary->Select(this->cmSalary->Position);
this->dgrdSalary->CurrentRowIndex = this->cmSalary->Position;
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"保存修改") == 0)
{
//检查新记录
if(this->tBoxBaseSalary->Text->Trim() == S"")
{
MessageBox::Show(S"基本工资不能为空!",S"提示");
return;
}
//提交修改
this->cmSalary->EndCurrentEdit();
//更新数据库
this->MyDataBase->UpdateDataBase(this->SalaryAdapter,this->ds,S"月工资统计表");
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"取消修改") == 0)
{
this->cmSalary->CancelCurrentEdit();
}
else if(String::Compare(e->Button->ToolTipText->Trim(),S"退出") == 0)
{
this->Close();
}
}
private: System::Void dgrdSalary_CurrentCellChanged(System::Object * sender, System::EventArgs * e)
{
this->cmSalary->Position = this->dgrdSalary->CurrentRowIndex;
}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -