📄 frmfailure.cs
字号:
break;
}
}
}
#endregion
#region 报表查询处理(故障查询)
private void QueryReport()
{
for(int i=1;i<=4;i++)
{
for(int j=1;j<=4;j++)
{
grdRAccept.set_TextMatrix(i,j,"0");
}
}
InitAnalyseCol();
for(int i=0 ;i< 6 ; i++)
{
if (i<=2)
{
arrstrGrd[i,0] = grdRAccept.get_TextMatrix(1,i+2);
}
else
{
arrstrGrd[i,0] = grdRAccept.get_TextMatrix(3,i-1);
}
}
frm.CreateAllCharts(0);
}
#endregion
#region 急抢修井盖丢失统计分析处理(处理列)
private void InitAnalyseCol()
{
string mstrName,mstr;
int liValue=0,k=0,k1=0;
Double lfValue;
DataTable dtCom =new DataTable();
SqlConnection cnnCom = new SqlConnection(strConn);
cnnCom.Open();
dtCom.Clear();
mstrName="Select Complete.SlipCause as SlipCause From Complete,Accept " +
" Where len(Complete.AcceptNO) = 17 And Complete.AcceptNO=Accept.AcceptNO And ContentID<>'井盖丢失' And"+
" Substring(Complete.AcceptNO,6,6) ='" + dtpAStart.Value.ToString("yyyyMM") +"'" ;
SqlDataAdapter sdaCom =new SqlDataAdapter( mstrName,cnnCom);
try
{
sdaCom.Fill(dtCom);
}
catch(SqlException expSql)
{
MessageBox.Show(expSql.ToString(), this.Text);
return;
}
cnnCom.Close();
sdaCom.Dispose();
cnnCom.Dispose();
if (dtCom.Rows.Count < 1)
{
return;
}
for(int j=0;j<dtCom.Rows.Count;j++)
{
myDataRow=dtCom.Rows[j];
mstrName=myDataRow["SlipCause"].ToString();
for(int i=0;mstrName.Length > 0;i++)
{
if (mstrName.IndexOf(";",0) < 0)
{
mstr=mstrName;
}
else
{
mstr=mstrName.Substring(0,mstrName.IndexOf(";",0));
}
if (mstr=="00101")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(1,2)) + 1;
grdRAccept.set_TextMatrix(1,2,liValue.ToString());
}
else if (mstr=="00102")
{
k=Int32.Parse(grdRAccept.get_TextMatrix(1,3)) +1;
grdRAccept.set_TextMatrix(1,3,k.ToString());
}
else
{
k1=Int32.Parse(grdRAccept.get_TextMatrix(1,4)) +1;
grdRAccept.set_TextMatrix(1,4,k1.ToString());
}
mstrName=mstrName.Substring(mstrName.IndexOf(";",0) + 1);
}
}
k= System.DateTime.Now.Year - 1;
SqlConnection cnnCom1 = new SqlConnection(strConn);
cnnCom1.Open();
dtCom.Clear();
mstrName="Select Complete.SlipCause as SlipCause From Complete,Accept " +
" Where len(Complete.AcceptNO) = 17 And Complete.AcceptNO=Accept.AcceptNO And ContentID<>'井盖丢失' And"+
" Substring(Complete.AcceptNO,6,6) ='" + k.ToString() + dtpAStart.Value.ToString("MM") +"'" ;
SqlDataAdapter sdaCom1 =new SqlDataAdapter( mstrName,cnnCom1);
try
{
sdaCom1.Fill(dtCom);
}
catch(SqlException expSql)
{
MessageBox.Show(expSql.ToString(), this.Text);
return;
}
cnnCom1.Close();
sdaCom1.Dispose();
cnnCom1.Dispose();
if (dtCom.Rows.Count >= 1)
{
for(int j=0;j<dtCom.Rows.Count;j++)
{
myDataRow=dtCom.Rows[j];
mstrName=myDataRow["SlipCause"].ToString();
for(int i=0;mstrName.Length > 0;i++)
{
if (mstrName.IndexOf(";",0) < 0)
{
mstr=mstrName;
}
else
{
mstr=mstrName.Substring(0,mstrName.IndexOf(";",0));
}
if (mstr=="00101")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(3,2)) + 1;
grdRAccept.set_TextMatrix(3,2,liValue.ToString());
}
else if (mstr=="00102")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(3,3)) +1;
grdRAccept.set_TextMatrix(3,3,liValue.ToString());
}
else
{
k1=Int32.Parse(grdRAccept.get_TextMatrix(3,4)) +1;
grdRAccept.set_TextMatrix(3,4,k1.ToString());
}
mstrName=mstrName.Substring(mstrName.IndexOf(";",0) + 1);
}
}
}
liValue=0;
liValue=Int32.Parse(grdRAccept.get_TextMatrix(1,2)) + Int32.Parse(grdRAccept.get_TextMatrix(1,3)) +
Int32.Parse(grdRAccept.get_TextMatrix(1,4));
grdRAccept.set_TextMatrix(1,1,liValue.ToString());
grdRAccept.set_TextMatrix(2,1,liValue.ToString());
liValue=Int32.Parse(grdRAccept.get_TextMatrix(3,2)) + Int32.Parse(grdRAccept.get_TextMatrix(3,3)) +
Int32.Parse(grdRAccept.get_TextMatrix(3,4));
grdRAccept.set_TextMatrix(3,1,liValue.ToString());
grdRAccept.set_TextMatrix(4,1,liValue.ToString());
grdRAccept.set_TextMatrix(1,0,dtpAStart.Value.ToString("yyyy年MM月"));
grdRAccept.set_TextMatrix(2,0,dtpAStart.Value.ToString("yyyy年MM月"));
grdRAccept.set_TextMatrix(3,0,k.ToString()+ "年" + dtpAStart.Value.ToString("MM月"));
grdRAccept.set_TextMatrix(4,0,k.ToString()+ "年" + dtpAStart.Value.ToString("MM月"));
if (Int32.Parse(grdRAccept.get_TextMatrix(1,1))!=0)
{
lfValue=(Double.Parse(grdRAccept.get_TextMatrix(1,2))/Double.Parse(grdRAccept.get_TextMatrix(1,1)))*100;
grdRAccept.set_TextMatrix(2,2,lfValue.ToString("0.00") + "%");
lfValue=(Double.Parse(grdRAccept.get_TextMatrix(1,3))/Double.Parse(grdRAccept.get_TextMatrix(1,1)))*100;
grdRAccept.set_TextMatrix(2,3,lfValue.ToString("0.00") + "%");
lfValue=(Double.Parse(grdRAccept.get_TextMatrix(1,4))/Double.Parse(grdRAccept.get_TextMatrix(1,1)))*100;
grdRAccept.set_TextMatrix(2,4,lfValue.ToString("0.00") + "%");
}
if (Int32.Parse(grdRAccept.get_TextMatrix(3,1))!=0)
{
lfValue=(Double.Parse(grdRAccept.get_TextMatrix(3,2))/Double.Parse(grdRAccept.get_TextMatrix(3,1)))*100;
grdRAccept.set_TextMatrix(4,2,lfValue.ToString("0.00") + "%");
lfValue=(Double.Parse(grdRAccept.get_TextMatrix(3,3))/Double.Parse(grdRAccept.get_TextMatrix(3,1)))*100;
grdRAccept.set_TextMatrix(4,3,lfValue.ToString("0.00") + "%");
lfValue=(Double.Parse(grdRAccept.get_TextMatrix(3,4))/Double.Parse(grdRAccept.get_TextMatrix(3,1)))*100;
grdRAccept.set_TextMatrix(4,4,lfValue.ToString("0.00") + "%");
}
}
#endregion
#region 报表查询打印处理
private void Print(bool print)
{
MisPrinter webmis = new MisPrinter(); //打印组件
Title title = new Title();
title.Text ="急抢修故障月统计分析";
webmis.Title = "急抢修故障月统计分析";
webmis.Caption = " —— " + dtpAStart.Value.ToString("yyyy年MM月") ;
Header header = new Header(1,4);
header.IsDrawAllPage = true;
header.SetText(0,0,"月统计分析时间:" + dtpAStart.Value.ToString("yyyy年MM月")) ; //实际上可以设置header.DataSource
header.SetText(0,2,"制表单位:调度室");
webmis.Header = header;
MultiHeader multiHeader = new MultiHeader(1,5);
multiHeader.DiagonalLineRows = 2.5F; //试试其它的数如3 又如1.5F
multiHeader.SetText(0,1,"合计");
multiHeader.SetText(0,2,"腐蚀");
multiHeader.SetText(0,3,"外界破坏");
multiHeader.SetText(0,4,"管堵及其它");
webmis.MultiHeader = multiHeader;
Body body = new Body();
body.ColsAlignString = "CCCCC";
int mcols = 5;
int mrows = 4;
string[,] arrstrGrid = new string[mrows,mcols];
for(int i=0 ;i< mrows ; i++)
{
for(int j=0 ;j< mcols ; j++)
{
arrstrGrid[i,j] = grdRAccept.get_TextMatrix(i+1,j);
}
}
body.GridText = arrstrGrid; //body.GridText = arrstrGrid;
webmis.Body = body;
webmis.IsSubTotalPerPage = true;
GoldPrinter.Bottom bottom = new Bottom(); //Top/Bottom的另一种方式
bottom.Text = "||打印日期:" + System.DateTime.Now.ToLongDateString();
webmis.Bottom = bottom;
//将注释去掉试试看
Sewing sewing = new Sewing(20,SewingDirectionFlag.Left);
webmis.Sewing = sewing;
webmis.IsSewingLine = true; //打印装订线
webmis.IsSubTotalPerPage = true; //每页加小计
if (print)
{
webmis.Print();
}
else
{
webmis.Preview();
}
webmis.Dispose();
webmis = null;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -