📄 统计信息.cs
字号:
}
catch(SqlException exe)
{
reader2.Close();
this.sqlConnection1.Close();
goto Finish;
}
finally
{
reader2.Close();
this.sqlConnection1.Close();
}
//收入计算
// and 花费!='0'
//总花费/0。025即为总上机时间
dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker2.Format = DateTimePickerFormat.Custom; // Display the date as "Mon 26 Feb 2001".
dateTimePicker3.Format = DateTimePickerFormat.Custom;
dateTimePicker4.Format = DateTimePickerFormat.Custom; // Display the date as "Mon 26 Feb 2001".
dateTimePicker1.CustomFormat = "yyyy-MM-dd";
dateTimePicker2.CustomFormat = "yyyy-MM-dd";
dateTimePicker3.CustomFormat = "yyyy-MM-dd";
dateTimePicker4.CustomFormat = "yyyy-MM-dd";
sql3="select sum(收费) from 收费流水表";
SqlCommand cmd3=new SqlCommand(sql3,this.sqlConnection1);
this.sqlConnection1.Open();
SqlDataReader reader3=cmd3.ExecuteReader();
try
{
if(reader3.Read())
{
Decimal income;
if(reader3.GetDecimal(0)!=0)
{
income=reader3.GetDecimal(0);
this.textBox2.Text=income.ToString();
}
else
{
goto Finish;
}
}
else
{
reader3.Close();
this.sqlConnection1.Close();
}
}
catch(SqlNullValueException exe)
{
reader3.Close();
this.sqlConnection1.Close();
this.textBox2.Text="0";
goto Finish;
}
catch(SqlException exe)
{
reader3.Close();
this.sqlConnection1.Close();
goto Finish;
}
finally
{
reader3.Close();
this.sqlConnection1.Close();
}
Finish:;
//连接combobox到数据库
this.sqlDataAdapter1.Fill(sds,"操作员表");
this.comboBox1.DataSource=sds.Tables["操作员表"];
this.comboBox1.DisplayMember="姓名";
this.comboBox1.Refresh();
}
private void btn_print_Click(object sender, System.EventArgs e)
{
}
private void btn_tongji_Click(object sender, System.EventArgs e)
{
}
private void button2_Click(object sender, System.EventArgs e)
{
//该日上机率=流水帐表中该日上下机时间差的和/80台*12时
}
private void button2_Click_1(object sender, System.EventArgs e)
{
//流水帐表中该日上下机时间差的和/80台*12时
// Display the date as "Mon 26 Feb 2001".
dateTimePicker1.CustomFormat = "yyyy-MM-dd";
dateTimePicker2.CustomFormat = "yyyy-MM-dd";
str1=dateTimePicker1.Text + " 08:00:00";
str2=dateTimePicker2.Text + " 22:00:00";
TimeSpan ts=DateTime.Parse(str2)-DateTime.Parse(str1);
daynumber=ts.Days; //两个datetimepicker的天数差
//615室上机率
// sum(花费)*100/(0.025*80*12*60)==sum(花费)/14.4
sql4="select sum(花费)/(14.4) from 流水帐表 where 上机区域='615' and 上机时间>'"+ str1 +"' and 下机时间<'"+ str2 +"'";
SqlCommand cmd4=new SqlCommand(sql4,this.sqlConnection1);
this.sqlConnection1.Open();
SqlDataReader reader4=cmd4.ExecuteReader();
try
{
if(reader4.Read())
{
Decimal income;
double shangjilv;
if(reader4.GetDecimal(0)!=0)
{
income=reader4.GetDecimal(0);
if(daynumber!=0)
{
shangjilv=double.Parse(income.ToString())/daynumber;
}
else
{
shangjilv=double.Parse(income.ToString());
}
this.textBox6.Text=shangjilv.ToString()+"%";
}
else
{
goto Finish;
}
}
else
{
reader4.Close();
this.sqlConnection1.Close();
goto Finish;
}
}
catch(SqlNullValueException exe)
{
MessageBox.Show("615缺少数据,暂不能统计!");
reader4.Close();
this.sqlConnection1.Close();
dateTimePicker1.Focus();
goto Finish;
}
catch(SqlException exe)
{
MessageBox.Show("您选择的数据有误,请重新选择!");
reader4.Close();
this.sqlConnection1.Close();
dateTimePicker1.Focus();
goto Finish;
}
finally
{
reader4.Close();
this.sqlConnection1.Close();
}
//515
sql5="select sum(花费)/14.4 from 流水帐表 where 上机区域='515' and 上机时间>'"+ str1 +"' and 下机时间<'"+ str2 +"'";
SqlCommand cmd5=new SqlCommand(sql5,this.sqlConnection1);
this.sqlConnection1.Open();
SqlDataReader reader5=cmd5.ExecuteReader();
try
{
if(reader5.Read())
{
Decimal income1;
double shangjilv515;
if (reader5.GetDecimal(0)!=0)
{
income1=reader5.GetDecimal(0);
if(daynumber!=0)
{
shangjilv515=double.Parse(income1.ToString())/daynumber;
}
else
{
shangjilv515=double.Parse(income1.ToString());
}
this.textBox7.Text=shangjilv515.ToString()+"%";
}
else
{
goto Finish;
}
}
else
{
reader5.Close();
this.sqlConnection1.Close();
goto Finish;
}
}
catch(SqlNullValueException exe)
{
MessageBox.Show("515缺少数据,暂不能统计");
reader5.Close();
this.sqlConnection1.Close();
dateTimePicker1.Focus();
goto Finish;
}
catch(SqlException exe)
{
MessageBox.Show("您选择的数据有误,请重新选择!");
reader5.Close();
this.sqlConnection1.Close();
dateTimePicker1.Focus();
goto Finish;
}
finally
{
reader5.Close();
this.sqlConnection1.Close();
}
Finish:;
}
private void button1_Click(object sender, System.EventArgs e)
{
str_teacher=comboBox1.Text;
str6=this.textBox5.Text;
str7=this.textBox8.Text;
str_starttime=dateTimePicker3.Text +" "+ str6 + ":00:00 ";
str_endtime=dateTimePicker4.Text +" "+ str7 + ":00:00 ";
sql6="select sum(收费) from 收费流水表 where 值班教师='"+comboBox1.Text+"' and 时间 >'" + str_starttime + "' and 时间 <'" + str_endtime + "'";
SqlCommand cmd6=new SqlCommand(sql6,this.sqlConnection1);
this.sqlConnection1.Open();
SqlDataReader reader6=cmd6.ExecuteReader();
try
{
if(reader6.Read())
{
this.textBox9.Text=reader6.GetSqlDecimal(0).ToString();
}
else
{
reader6.Close();
this.sqlConnection1.Close();
goto Finish;
}
}
catch(SqlNullValueException exe)
{
reader6.Close();
this.sqlConnection1.Close();
comboBox1.Focus();
textBox9.Text="0";
goto Finish;
}
catch(SqlException exe)
{
MessageBox.Show("您输入的数据有误,请重新输入!");
reader6.Close();
this.sqlConnection1.Close();
comboBox1.Focus();
goto Finish;
}
finally
{
reader6.Close();
this.sqlConnection1.Close();
}
Finish:;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -