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

📄 wage.cs

📁 主要介绍了系统的需求分析
💻 CS
📖 第 1 页 / 共 4 页
字号:
				this.ErrorHandle(E);

			}
			finally
			{
				this.DataReader1.Close();		
				this.Connection1.Close();	
			}
			this.textAbsence.Text=count.ToString();
			this.textAbsenceMoney.Text=Convert.ToString(count*100);
			return count*100;	

		}

		private int Get_LeaveEearly()
		{
			int count=0;
			System.DateTime beginDate=Convert.ToDateTime(this.dateTimePicker1.Text);
			System.DateTime endDate=Convert.ToDateTime(this.dateTimePicker2.Text);
			System.DateTime checkDate;
			this.commandStr="select Date from CheckoutRecord where EmployeeID="+"'"+this.textEmployeeID.Text+"'"+" and CheckType="+"'"+"早退"+"'";			
			this.Command1.CommandText=this.commandStr;
			try
			{
				this.Connection1.Open();
				this.DataReader1=this.Command1.ExecuteReader();
				while(this.DataReader1.Read())
				{
					checkDate=Convert.ToDateTime(DataReader1[0]);
					if(checkDate<=endDate&checkDate>=beginDate)
					{
						count+=1;
					}
				}
			}
			catch(Exception E)
			{
				this.ErrorHandle(E);

			}
			finally
			{
				this.DataReader1.Close();
				this.Connection1.Close();		
			}
						
			this.textLeaveEarlyCount.Text=count.ToString();
			this.textLeaveEarlyMoney.Text=Convert.ToString(count*50);			
			return count*50;

		}

		private int Get_SickLeave()
		{
			int count=0;
			System.DateTime beginDate=Convert.ToDateTime(this.dateTimePicker1.Text);
			System.DateTime endDate=Convert.ToDateTime(this.dateTimePicker2.Text);
			System.DateTime checkDate;

			this.commandStr="select Date,Days from LeaveRecord where EmployeeID="+"'"+this.textEmployeeID.Text+"'"+" and LeaveType="+"'"+"病假"+"'";			
			this.Command1.CommandText=this.commandStr;
			try
			{
				this.Connection1.Open();			
				this.DataReader1=this.Command1.ExecuteReader();			
				while(this.DataReader1.Read())
				{
					checkDate=Convert.ToDateTime(DataReader1[0]);
					if(checkDate<=endDate&checkDate>=beginDate)
					{
						count+=Convert.ToInt16(DataReader1[1]);					
					}
				}
			}
			catch(Exception E)
			{
				this.ErrorHandle(E);

			}
			finally
			{
				this.DataReader1.Close();			
				this.Connection1.Close();									
			}
			this.textSickLeaveCount.Text=count.ToString();
			this.textSickLeaveMoney.Text=Convert.ToString(count*10);
			return count*10;		

		}

		private int Get_AffairLeave()
		{
			int count=0;			
			System.DateTime beginDate=Convert.ToDateTime(this.dateTimePicker1.Text);
			System.DateTime endDate=Convert.ToDateTime(this.dateTimePicker2.Text);
			System.DateTime checkDate;

			this.commandStr="select Date,Days from LeaveRecord where EmployeeID="+"'"+this.textEmployeeID.Text+"'"+" and LeaveType="+"'"+"事假"+"'";			
			this.Command1.CommandText=this.commandStr;
			
			try
			{
				this.Connection1.Open();			
				this.DataReader1=this.Command1.ExecuteReader();			
				while(this.DataReader1.Read())
				{
					checkDate=Convert.ToDateTime(DataReader1[0]);
					if(checkDate<=endDate&checkDate>=beginDate)
					{
						count+=Convert.ToInt16(DataReader1[1]);					
					}
				}
			}
			catch(Exception E)
			{
				this.ErrorHandle(E);

			}
			finally
			{
					this.DataReader1.Close();			
			    	this.Connection1.Close();						
			}
			this.textAffairLeaveCount.Text=count.ToString();
			this.textAffairLeaveMoney.Text=Convert.ToString(count*10);
			return count*10;	

		}
		private int Get_RewardAndPunish()
		{
			int count=0;
			System.DateTime beginDate=Convert.ToDateTime(this.dateTimePicker1.Text);
			System.DateTime endDate=Convert.ToDateTime(this.dateTimePicker2.Text);
			System.DateTime checkDate;
			this.commandStr="select Date,Money from View_Reward where EmployeeID="+"'"+this.textEmployeeID.Text+"'"; 		
			this.Command1.CommandText=this.commandStr;
			try
			{
				this.Connection1.Open();			
				this.DataReader1=this.Command1.ExecuteReader();
				while(this.DataReader1.Read())
				{
					checkDate=Convert.ToDateTime(DataReader1[0]);
					if(checkDate<=endDate&checkDate>=beginDate)
					{
						count+=Convert.ToInt16(DataReader1[1]);					
					}				
				
				}
			}
			catch(Exception E)
			{
				this.ErrorHandle(E);

			}
			finally
			{
				this.DataReader1.Close();
				this.Connection1.Close();			
			}
			this.textRewardMoeny.Text=count.ToString();
			return count;			

		}

		private void btnCaculate_Click(object sender, System.EventArgs e)
		{
			if(this.textEmployeeID.Text=="")
			{
				MessageBox.Show("先输入职工号","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
				return;//如果没有职工号,则提示错误返回
			}
			int totalwage=0;
			int minus=0;
			int basicwage=this.Get_BasicWage();//获取基本工资			
			int bonus=Convert.ToInt16(this.numericUpDown2.Value);
			//获取奖金
			totalwage=bonus+basicwage;
			minus=this.Get_CheckLate()+this.Get_LeaveEearly()+this.Get_Absence()+this.Get_AffairLeave()+this.Get_SickLeave();
			//获取考勤罚款总数
			totalwage-=minus;
			totalwage+=this.Get_RewardAndPunish();			
			//加上奖惩汇总
			DecimalToUpper TotalWage = new DecimalToUpper();	
			this.lblTotalWage.Text = TotalWage.ToUpper(totalwage);	
			this.textTotalWage.Text=totalwage.ToString();	
			this.Buttons_Control(true);
		
		}
		private int Get_BasicWage()
		{
			int count;
			object o=null;
			this.commandStr="select BasicWage from View_BasicWage where EmployeeID="+"'"+this.textEmployeeID.Text+"'";
			this.Command1.CommandText=this.commandStr;
			try
			{
				this.Connection1.Open();
				o=this.Command1.ExecuteScalar();
				//执行程序返回结果
			}
			catch(System.Exception E)
			{
				this.ErrorHandle(E);
				
			}
			finally
			{
				this.Connection1.Close();
			}
			if(o.Equals(DBNull.Value))
			{
				count=0;//如果返回为空,则count为0
			}
			else
			{
				count=Convert.ToInt16(o);
			}			
			this.textBasicWage.Text=count.ToString();
			return count;
			//返回基本工资
		}

		private void ErrorHandle(Exception E)
		{
			MessageBox.Show(E.ToString());
		}

		private void Wage_Load(object sender, System.EventArgs e)
		{
			this.Buttons_Control(false);			
			
		}

		private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
			if(this.tabControl1.SelectedIndex==1)
			{
				this.DataSetViewWage.Clear();
				this.dataAdapter2.Fill(this.DataSetViewWage,"View_Wage");
			}

		}

		private void btnWageSearch_Click(object sender, System.EventArgs e)
		{
			this.DataViewWage.Table=this.DataSetViewWage.Tables["View_Wage"];
			//this.DataViewWage.RowFilter="EmployeeID="+"'"+this.textEmployeeID2.Text+"' and  (Date>'"+this.dateTimePicker3.Text+"' and Date<'"+this.dateTimePicker4.Text+"')";
			this.DataViewWage.RowFilter=this.SearchStr_Made();
			this.dataGrid1.DataSource=this.DataViewWage;
		}
		private string SearchStr_Made()
		{
			string searchStr=null;
			bool first=true;
			if(this.textEmployeeID2.Text!="")
			{
				searchStr="EmployeeID="+"'"+this.textEmployeeID2.Text+"'";
				first=false;
				this.selectStr1="职工号:"+this.textEmployeeID2.Text;
			}
			if(first)
			{
				searchStr="Date>="+"'"+this.dateTimePicker3.Text+"' and Date<='"+this.dateTimePicker4.Text+"'";
				this.selectStr1="日期:"+this.dateTimePicker3.Text+"-"+this.dateTimePicker4.Text;

			}
			else
			{
				searchStr+=" and  (Date>='"+this.dateTimePicker3.Text+"' and Date<='"+this.dateTimePicker4.Text+"')";
				this.selectStr1+="日期:"+this.dateTimePicker3.Text+"-"+this.dateTimePicker4.Text;

			}
			return searchStr;

		}

		private void btnWageExport_Click(object sender, System.EventArgs e)
		{
			Excel.Application myExcel = new Excel.Application ( ) ;
			myExcel.Application.Workbooks.Add ( true ) ;
			//让Excel文件可见
			myExcel.Visible=true;
			//第一行为报表名称
			myExcel.Cells[1,8]="工资查询记录";
			myExcel.Cells[2,8]="查询条件"+this.selectStr1;
			myExcel.Cells[3,9]="'"+DateTime.Now.ToShortDateString().ToString();

			//逐行写入数据,
			for(int i=0;i<14;i++)
			{
				myExcel.Cells[3,1+i]=this.ReportHeader[i];
			}																	
			for(int i=0;i<this.DataViewWage.Count;i++)
			{
				for(int j=0;j<14;j++)
				{
					//以单引号开头,表示该单元格为纯文本
					myExcel.Cells[5+i,1+j]="'"+this.DataViewWage[i][j].ToString();
				}
			}					
		
		}

		private void btnPeopleWageExport_Click(object sender, System.EventArgs e)
		{
			Excel.Application myExcel = new Excel.Application ( ) ;
			myExcel.Application.Workbooks.Add ( true ) ;
			//让Excel文件可见
			myExcel.Visible=true;
			//第一行为报表名称
			myExcel.Cells[1,2]="工资单";
			myExcel.Cells[2,3]="'"+DateTime.Now.ToShortDateString().ToString();
			int j=0;
			//逐行写入数据,
			for(int i=0;i<11;i++)
			{				
				myExcel.Cells[3+i,1]=this.ReportHeader[j];
				j++;
				if(j==1)j=4;
			}				
			myExcel.Cells[15,1]="工资总计:";																		
			myExcel.Cells[3,3]="'"+this.textEmployeeID.Text;
			myExcel.Cells[4,3]="'"+this.textBasicWage.Text;
			myExcel.Cells[5,3]="'"+this.numericUpDown2.Value;
			myExcel.Cells[6,3]="'"+this.textLateMoney.Text;
			myExcel.Cells[7,3]="'"+this.textLeaveEarlyMoney.Text;
			myExcel.Cells[8,3]="'"+this.textSickLeaveMoney.Text;
			myExcel.Cells[9,3]="'"+this.textAffairLeaveMoney.Text;
			myExcel.Cells[10,3]="'"+this.textRewardMoeny.Text;
			myExcel.Cells[11,3]="'"+this.textTotalWage.Text;
			myExcel.Cells[12,3]="'"+this.dateTimePicker1.Text;
			myExcel.Cells[13,3]="'"+this.dateTimePicker2.Text;		
			myExcel.Cells[15,3]="'"+this.lblTotalWage.Text;				
		
		}
	}
} 

⌨️ 快捷键说明

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