Beispiel #1
0
        private void paintReport(string strWellNo)
        {
            //已审
            try
            {
                string strFrom = String.Format("{0}-{1}-{2}", this.dtpFrom.Value.Year.ToString(), this.dtpFrom.Value.Month.ToString(), this.dtpFrom.Value.Day.ToString());
                string strTo   = String.Format("{0}-{1}-{2}", this.dtpTo.Value.Year.ToString(), this.dtpTo.Value.Month.ToString(), this.dtpTo.Value.Day.ToString());

                string strTitle = String.Format("时间范围:{0}至{1}", strFrom, strTo);

                string[] strText = new string[7];
                strText[0] = "监测站编号";
                strText[1] = "单位名称";
                strText[2] = "已用水量";
                strText[3] = "剩余水量";
                strText[4] = "总水量";
                strText[5] = "流量";
                strText[6] = "上报时间";

                printDoc.crpPrint crpPrintObj = new BengZhan.printDoc.crpPrint();
                CrystalDecisions.CrystalReports.Engine.TextObject toTitle = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTime"];
                toTitle.Text = strTitle;
                for (int i = 0; i < 7; i++)
                {
                    int    iNum         = i + 1;
                    string strTextTitle = "Text" + iNum.ToString();
                    CrystalDecisions.CrystalReports.Engine.TextObject to = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects[strTextTitle];
                    to.Text = strText[i].ToString();
                }

                //*************************************************Sql查询部分***************
                //wellNo不为空
                string strSql = String.Format("select wellNo as Field1,depName as Field2,usedWaterAmount as Field3,leftWaterAmount as Field4,allWaterAmount as Field5,flowWaterAmount as Field6,time as Field7 from tbWellAmount where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and wellNo='{2}' order by time", strFrom, strTo, strWellNo);
                if (strWellNo.Trim() == "")
                {
                    //wellNo为空
                    strSql = String.Format("select wellNo as Field1,depName as Field2,usedWaterAmount as Field3,leftWaterAmount as Field4,allWaterAmount as Field5,flowWaterAmount as Field6,time as Field7 from tbWellAmount where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}')  order by time", strFrom, strTo);
                }
                //****************************************************************************


                DataTable dt = null;
                CDBConnection.getDataTable(ref dt, strSql, "tbWellAmount");

                crpPrintObj.SetDataSource(dt);
                this.crpvWater.ReportSource = crpPrintObj;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #2
0
        /// <summary>
        /// 日统计
        /// </summary>
        /// <param name="strWellNo"></param>
        private void paintDayStatic(string strWellNo)
        {
            //已审
            try
            {
                string strFrom = String.Format("{0}-{1}-{2}", this.dtpFrom.Value.Year.ToString(), this.dtpFrom.Value.Month.ToString(), this.dtpFrom.Value.Day.ToString());
                string strTo   = String.Format("{0}-{1}-{2}", this.dtpTo.Value.Year.ToString(), this.dtpTo.Value.Month.ToString(), this.dtpTo.Value.Day.ToString());

                string strTitle = String.Format("时间范围:{0}至{1}", strFrom, strTo);

                string[] strText = new string[7];
                strText[0] = "监测站编号";
                strText[1] = "单位名称";
                strText[2] = "已用水量";
                strText[3] = "剩余水量";
                strText[4] = "总水量";
                strText[5] = "流量";
                strText[6] = "上报时间";

                printDoc.crpPrint crpPrintObj = new BengZhan.printDoc.crpPrint();
                CrystalDecisions.CrystalReports.Engine.TextObject toTitle = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTime"];
                toTitle.Text = strTitle;
                for (int i = 0; i < 7; i++)
                {
                    int    iNum         = i + 1;
                    string strTextTitle = "Text" + iNum.ToString();
                    CrystalDecisions.CrystalReports.Engine.TextObject to = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects[strTextTitle];
                    to.Text = strText[i].ToString();
                }

                DataTable dt = new DataTable();
                dt = this.getStaticDt(strWellNo, strFrom, strTo);

                crpPrintObj.SetDataSource(dt);
                this.crpvWater.ReportSource = crpPrintObj;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #3
0
        public bool printDt(DataTable dt)
        {
            try
            {
                string strTitle = String.Format("打印时间:{0}", System.DateTime.Now.ToString());

                string[] strText = new string[7];
                strText[0] = "监测站编号";
                strText[1] = "单位名称";
                strText[2] = "已用水量";
                strText[3] = "剩余水量";
                strText[4] = "总水量";
                strText[5] = "流量";
                strText[6] = "上报时间";

                printDoc.crpPrint crpPrintObj = new BengZhan.printDoc.crpPrint();
                CrystalDecisions.CrystalReports.Engine.TextObject toTitle = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTime"];
                toTitle.Text = strTitle;
                for (int i = 0; i < 7; i++)
                {
                    int    iNum         = i + 1;
                    string strTextTitle = "Text" + iNum.ToString();
                    CrystalDecisions.CrystalReports.Engine.TextObject to = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects[strTextTitle];
                    to.Text = strText[i].ToString();
                }


                DataTable dtPrint = new  DataTable();
                dtPrint.Columns.Add(new DataColumn("Field1"));
                dtPrint.Columns.Add(new DataColumn("Field2"));
                dtPrint.Columns.Add(new DataColumn("Field3"));
                dtPrint.Columns.Add(new DataColumn("Field4"));
                dtPrint.Columns.Add(new DataColumn("Field5"));
                dtPrint.Columns.Add(new DataColumn("Field6"));
                dtPrint.Columns.Add(new DataColumn("Field7"));

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dtPrint.NewRow();
                    dr["Field1"] = dt.Rows[i][0].ToString();
                    dr["Field2"] = dt.Rows[i][1].ToString();
                    dr["Field3"] = dt.Rows[i][2].ToString();
                    dr["Field4"] = dt.Rows[i][3].ToString();
                    dr["Field5"] = dt.Rows[i][4].ToString();
                    dr["Field6"] = dt.Rows[i][5].ToString();
                    dr["Field7"] = dt.Rows[i][7].ToString();
                    dtPrint.Rows.Add(dr);
                }


                crpPrintObj.SetDataSource(dtPrint);
                //打印窗体
                Form rptForm = new Form();
                rptForm.Text            = "预览";
                rptForm.FormBorderStyle = FormBorderStyle.FixedToolWindow;
                rptForm.WindowState     = System.Windows.Forms.FormWindowState.Maximized;
                CrystalDecisions.Windows.Forms.CrystalReportViewer rptView = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
                rptForm.Controls.Add(rptView);
                rptView.Dock            = System.Windows.Forms.DockStyle.Fill;
                rptView.ReportSource    = crpPrintObj;
                rptView.ShowCloseButton = true;
                rptForm.ShowDialog();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(false);
            }
        }
Beispiel #4
0
        //*******************数据库操作区*****************
        #region "数据库查询"
/// <summary>
/// 已审
/// </summary>
/// <param name="strWellNo">监测站编号</param>
/// <param name="strUserName">操作员名称</param>
        private void paintReport(string strWellNo, string strUserName)
        {
            try
            {
                string strFrom  = String.Format("{0}-{1}-{2}", this.dtpFrom.Value.Year.ToString(), this.dtpFrom.Value.Month.ToString(), this.dtpFrom.Value.Day.ToString());
                string strTo    = String.Format("{0}-{1}-{2}", this.dtpTo.Value.Year.ToString(), this.dtpTo.Value.Month.ToString(), this.dtpTo.Value.Day.ToString());
                string strTitle = "";


                //监测站统计sql1******************************sql语句
                string strSql = String.Format("select tbSal.wellNo as Field1,depName as Field2,price as Field3,salMony as Field4,salAmount as Field5,salPer as Field6,time as Field7 from tbSal,tbWell where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and tbSal.wellNo=tbWell.wellNo and tbSal.wellNo='{2}' order by time", strFrom, strTo, strWellNo);
                strTitle = "单位购水统计表";
                if (strWellNo.Trim() == "")
                {
                    if (strUserName.Trim() == "")
                    {
                        //无查询条件sql2
                        strSql = String.Format("select tbSal.wellNo as Field1,depName as Field2,price as Field3,salMony as Field4,salAmount as Field5,salPer as Field6,time as Field7 from tbSal,tbWell where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and tbSal.wellNo=tbWell.wellNo order by time", strFrom, strTo);
                    }
                    else
                    {
                        //操作员统计sql3*****
                        strSql   = String.Format("select tbSal.wellNo as Field1,depName as Field2,price as Field3,salMony as Field4,salAmount as Field5,salPer as Field6,time as Field7 from tbSal,tbWell where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and tbSal.wellNo=tbWell.wellNo and tbSal.salPer='{2}' order by time", strFrom, strTo, strUserName);
                        strTitle = "操作员售水统计表";
                    }
                }
                //**************************************


                //统计合计
                DataTable dt = null;
                CDBConnection.getDataTable(ref dt, strSql, "tbSalWater");
                double iSalAmount = 0, iSalMony = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    iSalAmount = iSalAmount + Convert.ToDouble(dt.Rows[i]["Field5"]);
                    iSalMony   = iSalMony + Convert.ToDouble(dt.Rows[i]["Field4"]);
                }
                DataRow dr = dt.NewRow();
                dr["Field1"] = "合计";
                dr["Field4"] = iSalMony.ToString();
                dr["Field5"] = iSalAmount.ToString();
                dt.Rows.Add(dr);
                //************************

                //报表显示
                string   strTime = String.Format("时间范围:{0}至{1}", strFrom, strTo);
                string[] strText = new string[7];
                strText[0] = "监测站编号";
                strText[1] = "单位名称";
                strText[2] = "售水单价";
                strText[3] = "售水金额";
                strText[4] = "售水量";
                strText[5] = "售水人";
                strText[6] = "售水时间";

                printDoc.crpPrint crpPrintObj = new BengZhan.printDoc.crpPrint();
                CrystalDecisions.CrystalReports.Engine.TextObject toTitle = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTime"];
                toTitle.Text = strTime;
                toTitle      = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTitle"];
                if (strTitle != "")
                {
                    toTitle.Text = strTitle;
                }
                for (int i = 0; i < 7; i++)
                {
                    int    iNum         = i + 1;
                    string strTextTitle = "Text" + iNum.ToString();
                    CrystalDecisions.CrystalReports.Engine.TextObject to = (CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects[strTextTitle];
                    to.Text = strText[i].ToString();
                }

                crpPrintObj.SetDataSource(dt);
                this.crpSalWater.ReportSource = crpPrintObj;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #5
0
        private void paintReport(string strWellNo)
        {
            //����
            try
            {
                string strFrom=String.Format("{0}-{1}-{2}",this.dtpFrom.Value.Year.ToString(),this.dtpFrom.Value.Month.ToString(),this.dtpFrom.Value.Day.ToString());
                string strTo=String.Format("{0}-{1}-{2}",this.dtpTo.Value.Year.ToString(),this.dtpTo.Value.Month.ToString(),this.dtpTo.Value.Day.ToString());

                string strTitle=String.Format("ʱ�䷶Χ��{0}��{1}",strFrom,strTo);

                string[] strText=new string[7];
                strText[0]="���վ���";
                strText[1]="�����";
                strText[2]="����ˮ��";
                strText[3]="ʣ��ˮ��";
                strText[4]="��ˮ��";
                strText[5]="����";
                strText[6]="�ϱ�ʱ��";

                printDoc.crpPrint crpPrintObj=new BengZhan.printDoc.crpPrint();
                CrystalDecisions.CrystalReports.Engine.TextObject toTitle=(CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTime"];
                toTitle.Text=strTitle;
                for(int i=0;i<7;i++)
                {
                    int iNum=i+1;
                    string strTextTitle="Text"+iNum.ToString();
                    CrystalDecisions.CrystalReports.Engine.TextObject to=(CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects[strTextTitle];
                    to.Text=strText[i].ToString();
                }

                //*************************************************Sql��ѯ����***************
                //wellNo����
                string strSql=String.Format("select wellNo as Field1,depName as Field2,usedWaterAmount as Field3,leftWaterAmount as Field4,allWaterAmount as Field5,flowWaterAmount as Field6,time as Field7 from tbWellAmount where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and wellNo='{2}' order by time",strFrom,strTo,strWellNo);
                if(strWellNo.Trim()=="")
                {
                    //wellNo��
                    strSql=String.Format("select wellNo as Field1,depName as Field2,usedWaterAmount as Field3,leftWaterAmount as Field4,allWaterAmount as Field5,flowWaterAmount as Field6,time as Field7 from tbWellAmount where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}')  order by time",strFrom,strTo);
                }
                //****************************************************************************

                DataTable dt=null;
                CDBConnection.getDataTable(ref dt,strSql,"tbWellAmount");

                crpPrintObj.SetDataSource(dt);
                this.crpvWater.ReportSource=crpPrintObj;

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #6
0
        /// <summary>
        /// ��ͳ��
        /// </summary>
        /// <param name="strWellNo"></param>
        private void paintDayStatic(string strWellNo)
        {
            //����
            try
            {
                string strFrom=String.Format("{0}-{1}-{2}",this.dtpFrom.Value.Year.ToString(),this.dtpFrom.Value.Month.ToString(),this.dtpFrom.Value.Day.ToString());
                string strTo=String.Format("{0}-{1}-{2}",this.dtpTo.Value.Year.ToString(),this.dtpTo.Value.Month.ToString(),this.dtpTo.Value.Day.ToString());

                string strTitle=String.Format("ʱ�䷶Χ��{0}��{1}",strFrom,strTo);

                string[] strText=new string[7];
                strText[0]="���վ���";
                strText[1]="�����";
                strText[2]="����ˮ��";
                strText[3]="ʣ��ˮ��";
                strText[4]="��ˮ��";
                strText[5]="����";
                strText[6]="�ϱ�ʱ��";

                printDoc.crpPrint crpPrintObj=new BengZhan.printDoc.crpPrint();
                CrystalDecisions.CrystalReports.Engine.TextObject toTitle=(CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTime"];
                toTitle.Text=strTitle;
                for(int i=0;i<7;i++)
                {
                    int iNum=i+1;
                    string strTextTitle="Text"+iNum.ToString();
                    CrystalDecisions.CrystalReports.Engine.TextObject to=(CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects[strTextTitle];
                    to.Text=strText[i].ToString();
                }

                DataTable dt=new DataTable();
                dt=this.getStaticDt(strWellNo,strFrom,strTo);

                crpPrintObj.SetDataSource(dt);
                this.crpvWater.ReportSource=crpPrintObj;
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #7
0
        /// <summary>
        /// ����
        /// </summary>
        /// <param name="strWellNo">���վ���</param>
        /// <param name="strUserName">����Ա����</param>
        private void paintReport(string strWellNo,string strUserName)
        {
            try
            {
                string strFrom=String.Format("{0}-{1}-{2}",this.dtpFrom.Value.Year.ToString(),this.dtpFrom.Value.Month.ToString(),this.dtpFrom.Value.Day.ToString());
                string strTo=String.Format("{0}-{1}-{2}",this.dtpTo.Value.Year.ToString(),this.dtpTo.Value.Month.ToString(),this.dtpTo.Value.Day.ToString());
                string strTitle="";

                //���վͳ��sql1******************************sql���
                string strSql=String.Format("select tbSal.wellNo as Field1,depName as Field2,price as Field3,salMony as Field4,salAmount as Field5,salPer as Field6,time as Field7 from tbSal,tbWell where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and tbSal.wellNo=tbWell.wellNo and tbSal.wellNo='{2}' order by time",strFrom,strTo,strWellNo);
                strTitle="��λ��ˮͳ�Ʊ�";
                if(strWellNo.Trim()=="")
                {
                    if(strUserName.Trim()=="")
                    {
                        //�޲�ѯ����sql2
                        strSql=String.Format("select tbSal.wellNo as Field1,depName as Field2,price as Field3,salMony as Field4,salAmount as Field5,salPer as Field6,time as Field7 from tbSal,tbWell where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and tbSal.wellNo=tbWell.wellNo order by time",strFrom,strTo);
                    }
                    else
                    {
                        //����Աͳ��sql3*****
                        strSql=String.Format("select tbSal.wellNo as Field1,depName as Field2,price as Field3,salMony as Field4,salAmount as Field5,salPer as Field6,time as Field7 from tbSal,tbWell where (cast(floor(cast(time as float)) as datetime) between '{0}' and '{1}') and tbSal.wellNo=tbWell.wellNo and tbSal.salPer='{2}' order by time",strFrom,strTo,strUserName);
                        strTitle="����Ա��ˮͳ�Ʊ�";
                    }

                }
                //**************************************

                //ͳ�ƺϼ�
                DataTable dt=null;
                CDBConnection.getDataTable(ref dt,strSql,"tbSalWater");
                double iSalAmount=0,iSalMony=0;
                for(int i=0;i<dt.Rows.Count;i++)
                {
                    iSalAmount=iSalAmount+Convert.ToDouble(dt.Rows[i]["Field5"]);
                    iSalMony=iSalMony+Convert.ToDouble(dt.Rows[i]["Field4"]);
                }
                DataRow dr=dt.NewRow();
                dr["Field1"]="�ϼ�";
                dr["Field4"]=iSalMony.ToString();
                dr["Field5"]=iSalAmount.ToString();
                dt.Rows.Add(dr);
                //************************

                //������ʾ
                string strTime=String.Format("ʱ�䷶Χ��{0}��{1}",strFrom,strTo);
                string[] strText=new string[7];
                strText[0]="���վ���";
                strText[1]="�����";
                strText[2]="��ˮ����";
                strText[3]="��ˮ���";
                strText[4]="��ˮ��";
                strText[5]="��ˮ��";
                strText[6]="��ˮʱ��";

                printDoc.crpPrint crpPrintObj=new BengZhan.printDoc.crpPrint();
                CrystalDecisions.CrystalReports.Engine.TextObject toTitle=(CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTime"];
                toTitle.Text=strTime;
                toTitle=(CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects["txtTitle"];
                if(strTitle!="")
                {
                    toTitle.Text=strTitle;
                }
                for(int i=0;i<7;i++)
                {
                    int iNum=i+1;
                    string strTextTitle="Text"+iNum.ToString();
                    CrystalDecisions.CrystalReports.Engine.TextObject to=(CrystalDecisions.CrystalReports.Engine.TextObject)crpPrintObj.ReportDefinition.ReportObjects[strTextTitle];
                    to.Text=strText[i].ToString();
                }

                crpPrintObj.SetDataSource(dt);
                this.crpSalWater.ReportSource=crpPrintObj;

            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }