Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,173 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,945 people online right now. Registration is fast and FREE... Join Now!




How to pass parameter from a window application form to a crystal repo

 
Reply to this topicStart new topic

How to pass parameter from a window application form to a crystal repo, I have a window application which passess date,on the basis of the dat

sandip_0303
5 Jan, 2008 - 01:46 AM
Post #1

New D.I.C Head
*

Joined: 5 Jan, 2008
Posts: 1

CODE
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Data.SqlClient;
using System.Data;
using TestParameter.Class;

namespace TestParameter
{
    /// <summary>
    /// Summary description for DepositsToBeTransferredToInvestorsFund.
    /// </summary>
    public class DepositsToBeTransferredToInvestorsFund : System.Windows.Forms.Form
    {
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.DateTimePicker dateTimePicker1;
        private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1;
        private System.Windows.Forms.Button btn_Show;
        private System.Windows.Forms.Button btn_Exit;
        private CommonClass objcc=new CommonClass();
        private string ason_date,to_date,dmy,dmy1,dep_m,dep_m1,dep_d,dep_d1,dep_y,dep_y1,d_y,d_y1;
        private string sql;
        private SqlCommand cmd;
        private SqlDataAdapter da;
        private TableLogOnInfo loginfo=new TableLogOnInfo();
        private int int_y,int_y1;

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public DepositsToBeTransferredToInvestorsFund()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        #region Windows Form Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
            this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
            this.btn_Show = new System.Windows.Forms.Button();
            this.btn_Exit = new System.Windows.Forms.Button();
            this.SuspendLayout();
            //
            // label1
            //
            this.label1.Location = new System.Drawing.Point(40, 104);
            this.label1.Name = "label1";
            this.label1.TabIndex = 0;
            this.label1.Text = "label1";
            //
            // label2
            //
            this.label2.Location = new System.Drawing.Point(424, 8);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(344, 23);
            this.label2.TabIndex = 1;
            this.label2.Text = "label2";
            //
            // dateTimePicker1
            //
            this.dateTimePicker1.Location = new System.Drawing.Point(152, 112);
            this.dateTimePicker1.Name = "dateTimePicker1";
            this.dateTimePicker1.TabIndex = 2;
            //
            // crystalReportViewer1
            //
            this.crystalReportViewer1.ActiveViewIndex = -1;
            this.crystalReportViewer1.DisplayGroupTree = false;
            this.crystalReportViewer1.Location = new System.Drawing.Point(32, 152);
            this.crystalReportViewer1.Name = "crystalReportViewer1";
            this.crystalReportViewer1.ReportSource = null;
            this.crystalReportViewer1.Size = new System.Drawing.Size(960, 584);
            this.crystalReportViewer1.TabIndex = 3;
            //
            // btn_Show
            //
            this.btn_Show.Location = new System.Drawing.Point(640, 104);
            this.btn_Show.Name = "btn_Show";
            this.btn_Show.Size = new System.Drawing.Size(136, 23);
            this.btn_Show.TabIndex = 4;
            this.btn_Show.Text = "Show";
            this.btn_Show.Click += new System.EventHandler(this.btn_Show_Click);
            //
            // btn_Exit
            //
            this.btn_Exit.Location = new System.Drawing.Point(792, 104);
            this.btn_Exit.Name = "btn_Exit";
            this.btn_Exit.Size = new System.Drawing.Size(120, 23);
            this.btn_Exit.TabIndex = 5;
            this.btn_Exit.Text = "Exit";
            this.btn_Exit.Click += new System.EventHandler(this.btn_Exit_Click);
            //
            // DepositsToBeTransferredToInvestorsFund
            //
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(1028, 746);
            this.Controls.Add(this.btn_Exit);
            this.Controls.Add(this.btn_Show);
            this.Controls.Add(this.crystalReportViewer1);
            this.Controls.Add(this.dateTimePicker1);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Name = "DepositsToBeTransferredToInvestorsFund";
            this.Text = "DepositsToBeTransferredToInvestorsFund";
            this.ResumeLayout(false);

        }
        #endregion

        private void btn_Exit_Click(object sender, System.EventArgs e)
        {
          this.Close();
        }

        private void btn_Show_Click(object sender, System.EventArgs e)
        {
            objcc.OpenConnection();
            dmy=dateTimePicker1.Value.ToShortDateString();
            d_y=dmy.Remove(0,3).ToString().Trim();
            dep_m=d_y.Remove(2,5).Trim();
            dep_y=d_y.Remove(0,3).Trim();
            dep_d=dmy.Remove(2,8).Trim();
            ason_date=dep_y + "/" + dep_m + "/" + dep_d;
            int_y=Convert.ToInt16(dep_y);
            int_y1=(int_y-7);
            dep_y1=Convert.ToString(int_y1);
            to_date=dep_y1 + "/" + dep_m + "/" + dep_d;
            TestParameter.DepositsToBeTransferred dtbt=new DepositsToBeTransferred();

            // ********************************************************************************
********
            ParameterFields myparams=new ParameterFields();
            ParameterField  myparam=new ParameterField();
            ParameterDiscreteValue myDiscreteValue=new ParameterDiscreteValue();
            myparam.Name="mat_date";
            myDiscreteValue.Value=ason_date;
            myparam.CurrentValues.Add(myDiscreteValue);
            myparams.Add(myparam);
            crystalReportViewer1.ParameterFieldInfo=myparams;
            //crystalReportViewer1.SelectionFormula="{Reconcile.int_date}=cur_date";
            //crystalReportViewer1.ReportSource=para;
            // ********************************************************************************
******
            loginfo.ConnectionInfo.ServerName="msd_sandip_156";
            loginfo.ConnectionInfo.UserID="sa";
            loginfo.ConnectionInfo.Password="msd";
            loginfo.ConnectionInfo.DatabaseName="FDS";
            dtbt.Database.Tables[0].ApplyLogOnInfo(loginfo);
            //para.Database.Tables[0].ApplyLogOnInfo(loginfo);
            DataTable dt=new DataTable();
            try
            {
                sql="select Deposit.l_no,Deposit.fdr_no,Ledger.dep_name,Deposit.dep_amnt,Deposit.rep_date,Deposit.mat_date,Deposit.mat_code from Deposit,Ledger where Deposit.l_no=Ledger.l_no and Deposit.mat_code='" + "M" + "'and Deposit.mat_date<='" + to_date + "'order by Deposit.mat_date";
                da=new SqlDataAdapter(sql,objcc.con);
                dt.Clear();
                da.Fill(dt);
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            dtbt.Database.Tables[0].SetDataSource(dt);
            crystalReportViewer1.ReportSource=dtbt;
            crystalReportViewer1.Zoom(1);
            objcc.CloseConnection();
        }
    }
}


Error:CrystalDecisions.Shared.ParameterField does not contain a definition for name.
If you have asolution for this please help
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 12:45AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month