📄 frmwell.cs
字号:
{
this.frm.Dispose();
this.frm = null;
}
}
#region 工具条按钮处理
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
switch(toolBar1.Buttons.IndexOf(e.Button))
{
case 0: //查询
{
QueryReport();
break;
}
case 1: //打印预览
{
this.Print(false);
break;
}
case 2: //打印
{
this.Print(true);
break;
}
case 3: //退出
{
this.Close();
if(!(this.frm == null))
{
this.frm.Dispose();
this.frm = null;
}
break;
}
}
}
#endregion
#region 报表查询处理(井盖丢失)
private void QueryReport()
{
if (dtpAStart.Value > dtpAEnd.Value )
{
MessageBox.Show("开始日期不能大于结束日期!","提示",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);
return;
}
for(int i=1;i<=14;i++)
{
grdRAccept.set_TextMatrix(i,1,"0");
}
InitAnalyseCol();
for(int i=0 ;i< 13 ; i++)
{
arrstrGrd[i,0] = grdRAccept.get_TextMatrix(i+1,1);
}
frm.CreateAllCharts(300);
}
#endregion
#region 急抢修井盖丢失统计分析处理(处理列)
private void InitAnalyseCol()
{
string mstrName;
int liValue=0;
SqlConnection cnnCom = new SqlConnection(strConn);
cnnCom.Open();
dtTable.Clear();
mstrName="Select distinct * From Accept Where ContentID = '井盖丢失' And Astate<>'接警单作废' And" +
" ADate >='" + dtpAStart.Value.ToString("yyyy-MM-dd") +"' And ADate <='" + dtpAEnd.Value + "'" ;
SqlDataAdapter sdaCom =new SqlDataAdapter( mstrName,cnnCom);
try
{
sdaCom.Fill(dtTable);
}
catch(SqlException expSql)
{
MessageBox.Show(expSql.ToString(), this.Text);
return;
}
cnnCom.Close();
sdaCom.Dispose();
cnnCom.Dispose();
if (dtTable.Rows.Count < 1)
{
return;
}
for(int j=0;j<dtTable.Rows.Count;j++)
{
myDataRow=dtTable.Rows[j];
mstrName=myDataRow["SpotID"].ToString();
if (mstrName=="东城区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(1,1)) + 1;
grdRAccept.set_TextMatrix(1,1,liValue.ToString());
}
else if (mstrName=="西城区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(2,1)) + 1;
grdRAccept.set_TextMatrix(2,1,liValue.ToString());
}
else if (mstrName=="朝阳区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(3,1)) + 1;
grdRAccept.set_TextMatrix(3,1,liValue.ToString());
}
else if (mstrName=="海淀区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(4,1)) + 1;
grdRAccept.set_TextMatrix(4,1,liValue.ToString());
}
else if (mstrName=="宣武区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(5,1)) + 1;
grdRAccept.set_TextMatrix(5,1,liValue.ToString());
}
else if (mstrName=="崇文区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(6,1)) + 1;
grdRAccept.set_TextMatrix(6,1,liValue.ToString());
}
else if (mstrName=="石景山区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(7,1)) + 1;
grdRAccept.set_TextMatrix(7,1,liValue.ToString());
}
else if (mstrName=="丰台区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(8,1)) + 1;
grdRAccept.set_TextMatrix(8,1,liValue.ToString());
}
else if (mstrName=="通州区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(9,1)) + 1;
grdRAccept.set_TextMatrix(9,1,liValue.ToString());
}
else if (mstrName=="顺义区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(10,1)) + 1;
grdRAccept.set_TextMatrix(10,1,liValue.ToString());
}
else if (mstrName=="房山区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(11,1)) + 1;
grdRAccept.set_TextMatrix(11,1,liValue.ToString());
}
else if (mstrName=="大兴区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(12,1)) + 1;
grdRAccept.set_TextMatrix(12,1,liValue.ToString());
}
else if (mstrName=="门头沟区")
{
liValue=Int32.Parse(grdRAccept.get_TextMatrix(13,1)) + 1;
grdRAccept.set_TextMatrix(13,1,liValue.ToString());
}
}
liValue=0;
for(int i=1;i<=13;i++)
{
liValue=liValue +Int32.Parse(grdRAccept.get_TextMatrix(i,1));
}
grdRAccept.set_TextMatrix(14,1,liValue.ToString());
}
#endregion
#region 报表查询打印处理
private void Print(bool print)
{
MisPrinter webmis = new MisPrinter(); //打印组件
Title title = new Title();
title.Text ="急抢修井盖丢失统计查询";
webmis.Title = "急抢修井盖丢失统计查询";
webmis.Caption = " —— " + dtpAStart.Value.ToString("y") ;
Header header = new Header(1,4);
header.IsDrawAllPage = true;
header.SetText(0,0,"井盖丢失时间:" + dtpAStart.Value.ToString("yyyy年MM月dd日")) ; //实际上可以设置header.DataSource
header.SetText(0,1,"—— " + dtpAEnd.Value.ToString("yyyy年MM月dd日"));
header.SetText(0,2,"制表单位:调度室");
webmis.Header = header;
MultiHeader multiHeader = new MultiHeader(1,2);
multiHeader.DiagonalLineRows = 2.5F; //试试其它的数如3 又如1.5F
multiHeader.SetText(0,1,"小计");
webmis.MultiHeader = multiHeader;
Body body = new Body();
body.ColsAlignString = "CC";
int mcols = 2;
int mrows = 14;
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 + -