コード例 #1
0
        private void btnPrivew_Click(object sender, EventArgs e)
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Application.StartupPath + "\\Reports\\rptAddressReport.rpt");


            string searchQury = @"select con.* ,cat.CategoryName from Contacts con inner join Category cat on con.CategoryID=cat.CategoryID where 1=1";

            if (this.cbxCompany.SelectedIndex > 0)
            {
                searchQury += " and con.CompanyName='" + this.cbxCompany.Text + "'";
            }

            if (this.cboCity.SelectedIndex > 0)
            {
                searchQury += " and con.City='" + this.cboCity.Text + "'";
            }

            if (this.cbxCategory.SelectedIndex > 0)
            {
                searchQury += " and cat.CategoryID=" + this.cbxCategory.SelectedValue + "";
            }

            rd.Database.Tables[0].SetDataSource(new Bll.AddressBook().GetGridSearch(searchQury));
            //rd.SetDataSource(new Bll.AddressBook().GetGridSearch(searchQury));

            /////////para
            var prmRpt = new ParameterDiscreteValue();

            prmRpt.Value = "Company Name: " + this.cbxCompany.Text + "";
            rd.ParameterFields["prmCompany"].CurrentValues.Clear();
            rd.ParameterFields["prmCompany"].CurrentValues.Add(prmRpt);

            prmRpt       = new ParameterDiscreteValue();
            prmRpt.Value = "City: " + this.cboCity.Text + "";
            rd.ParameterFields["prmCity"].CurrentValues.Clear();
            rd.ParameterFields["prmCity"].CurrentValues.Add(prmRpt);

            prmRpt       = new ParameterDiscreteValue();
            prmRpt.Value = "Category: " + this.cbxCategory.Text + "";
            rd.ParameterFields["prmCategory"].CurrentValues.Clear();
            rd.ParameterFields["prmCategory"].CurrentValues.Add(prmRpt);
            /////////para

            RptViewer rptv = new RptViewer();

            rptv.rptRD1   = rd;
            rptv.rptTitle = "Address Book";
            rptv.ShowDialog();
        }
コード例 #2
0
        private void btnPrivew_Click(object sender, EventArgs e)
        {
            //string strWherex =this.dtFromDateTime.Value.ToString();

            ReportDocument rd = new ReportDocument();

            rd.Load(Application.StartupPath + "\\Reports\\rptCallRecordsReport.rpt");

            string strWhere = "";

            if (cbxContactPerson.SelectedIndex > 0)
            {
                strWhere += " and car.CallingPerson='" + this.cbxContactPerson.Text + "'";
            }

            strWhere += " and CONVERT(datetime,'" + this.dtFromDateTime.Value.ToString() + "')<=car.CallDateTime";
            strWhere += " and CONVERT(datetime,'" + this.dtToDateTime.Value.ToString() + "')>=car.CallDateTime";

            //if (this.chbxIsOutgoing.Checked)
            //{
            //    if (this.rdbIsOutGoing.Checked)
            //    {
            //        strWhere += " and IsOutgoing=1";
            //    }
            //    else
            //    {
            //        strWhere += " and IsOutgoing=0";
            //    }
            //}

            if (this.CbxOutgoing.SelectedIndex > 0)
            {
                if (CbxOutgoing.Text == "OutGoing")
                {
                    strWhere += " and IsOutgoing=1";
                }
                else
                {
                    strWhere += " and IsOutgoing=0";
                }
            }

            //if (this.cbxCompany.SelectedIndex>0)
            //{
            //    strWhere += " and CompanyName='"+this.cbxCompany.Text+"'";
            //}

            if (this.cbxCity.SelectedIndex > 0)
            {
                strWhere += " and City='" + this.cbxCity.Text + "'";
            }

            if (this.cbxCategory.SelectedIndex > 0)
            {
                strWhere += " and car.CategoryID=" + cbxCategory.SelectedValue + "";
            }

            if (this.cbxCallStatusSearch.SelectedIndex > 0)
            {
                strWhere += " and CallStatus='" + this.cbxCallStatusSearch.Text + "'";
            }

            //DataTable dt = new Bll.CallRecords().GetGrideData(strWhere);

            rd.Database.Tables[0].SetDataSource(new Bll.CallRecords().GetGrideData(strWhere));

            ///////////para
            var prmRpt = new ParameterDiscreteValue();

            prmRpt.Value = "Calling Person: " + this.cbxContactPerson.Text + "";
            rd.ParameterFields["CallingPerson"].CurrentValues.Clear();
            rd.ParameterFields["CallingPerson"].CurrentValues.Add(prmRpt);

            prmRpt       = new ParameterDiscreteValue();
            prmRpt.Value = "From DateTime: " + this.dtFromDateTime.Value.ToString("dd-MMM-yyyy hh:mm:ss tt") + "";
            rd.ParameterFields["FromDateTime"].CurrentValues.Clear();
            rd.ParameterFields["FromDateTime"].CurrentValues.Add(prmRpt);

            prmRpt       = new ParameterDiscreteValue();
            prmRpt.Value = "To DateTime: " + this.dtToDateTime.Value.ToString("dd-MMM-yyyy hh:mm:ss tt") + "";
            rd.ParameterFields["ToDateTime"].CurrentValues.Clear();
            rd.ParameterFields["ToDateTime"].CurrentValues.Add(prmRpt);


            prmRpt = new ParameterDiscreteValue();
            //if (this.chbxIsOutgoing.Checked)
            //{
            //    if (this.rdbIsOutGoing.Checked)
            //    {
            //        prmRpt.Value = "Is Outgoing:";
            //    }
            //    else
            //    {
            //        prmRpt.Value = "Is Incoming:";
            //    }
            //}
            //else
            //{
            //    prmRpt.Value = "Outgoing & Incoming:";
            //}
            if (this.CbxOutgoing.SelectedIndex > 0)
            {
                if (this.CbxOutgoing.Text == "OutGoing")
                {
                    prmRpt.Value = "Is Outgoing:";
                }
                else
                {
                    prmRpt.Value = "Is Incoming:";
                }
            }
            else
            {
                prmRpt.Value = "Outgoing & Incoming:";
            }

            rd.ParameterFields["IsOutgoing"].CurrentValues.Clear();
            rd.ParameterFields["IsOutgoing"].CurrentValues.Add(prmRpt);


            //prmRpt = new ParameterDiscreteValue();
            //prmRpt.Value = "Company Name: " + this.cbxCompany.Text + "";
            //rd.ParameterFields["CompanyName"].CurrentValues.Clear();
            //rd.ParameterFields["CompanyName"].CurrentValues.Add(prmRpt);

            prmRpt       = new ParameterDiscreteValue();
            prmRpt.Value = "City: " + this.cbxCity.Text + "";
            rd.ParameterFields["City"].CurrentValues.Clear();
            rd.ParameterFields["City"].CurrentValues.Add(prmRpt);

            prmRpt       = new ParameterDiscreteValue();
            prmRpt.Value = "Category: " + this.cbxCategory.Text + "";
            rd.ParameterFields["Category"].CurrentValues.Clear();
            rd.ParameterFields["Category"].CurrentValues.Add(prmRpt);

            prmRpt       = new ParameterDiscreteValue();
            prmRpt.Value = "Status: " + this.cbxCallStatusSearch.Text + "";
            rd.ParameterFields["Status"].CurrentValues.Clear();
            rd.ParameterFields["Status"].CurrentValues.Add(prmRpt);

            ///////////para

            RptViewer rptv = new RptViewer();

            rptv.rptRD1   = rd;
            rptv.rptTitle = "Address Book";
            rptv.ShowDialog();
        }