?? frmhortationadd.cs
字號:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace HRP.Wage
{
public partial class frmHortationAdd : Form
{
public frmHortationAdd()
{
InitializeComponent();
}
Personnel.frmPactEmployee frm_pactemployee = new HRP.Personnel.frmPactEmployee();
BaseClass.SqlClass sqlclass = new HRP.BaseClass.SqlClass();
public frmHortation frmhortation;
public string strtype;
public string strtypeitem;
private void btnOpen_Click(object sender, EventArgs e)
{
frm_pactemployee.frmhortationadd = this;
frm_pactemployee.strtype = "frmhortationadd";
frm_pactemployee.ShowDialog();
}
BaseClass.WageClass wageclass = new HRP.BaseClass.WageClass();
private void btnAdd_Click(object sender, EventArgs e)
{
if(this.txtEmployeeID.Text=="")
{
MessageBox.Show("請選擇一個員工!");
return;
}
string strMonth = this.txtMonthWage.Text;
string strSub="";
if (strMonth.Length == 7)
{
for (int i = 0; i < strMonth.Length; i++)
{
if (i < 4)
{
strSub = this.txtMonthWage.Text.Substring(i, 1);
if (Char.IsNumber(strSub, 0) != true)
{
MessageBox.Show("年份書寫錯誤!");
return;
}
}
if (i == 4)
{
strSub = this.txtMonthWage.Text.Substring(i, 1);
if (strSub != "-")
{
MessageBox.Show("年份后必須輸入-");
return;
}
}
if (i > 4 && i < 7)
{
strSub = this.txtMonthWage.Text.Substring(i, 1);
if (Char.IsNumber(strSub, 0) != true)
{
MessageBox.Show("月份必須是數(shù)字!");
return;
}
}
}
if (Convert.ToInt32(this.txtMonthWage.Text.Substring(5, 2)) > 12)
{
MessageBox.Show("月份書寫錯誤!");
return;
}
}
else
{
MessageBox.Show("格式書寫錯誤!");
return;
}
try
{
wageclass.HortationAdd(strtype, this.txtMonthWage.Text, this.txtEmployeeID.Text, this.txtEmployeeName.Text, cmbHortationItem.Text, Convert.ToDouble(txtHortationNumber.Text), txtRemark.Text, Convert.ToDateTime(dtpHortationDate.Text));
frmhortation.dgvHortation.DataSource = sqlclass.SqlDaAd("select * from " + strtype, strtype).Tables[strtype];
this.Close();
}
catch
{
MessageBox.Show("操作失敗!", "失敗");
}
}
private void frmHortationAdd_Load(object sender, EventArgs e)
{
if (strtype == "tb_Hortation")
{
strtypeitem = "tb_HortationItem";
}
else
{
strtypeitem = "tb_ChastisementItem";
}
this.cmbHortationItem.DataSource = sqlclass.SqlDaAd("select * from " + strtypeitem, strtypeitem).Tables[strtypeitem];
this.cmbHortationItem.DisplayMember = "Name";
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -