Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
this is the code for report .. in this there are two parameters .. now this code look complex and i unable to understand

can anyone please explain this code...

also please suggest how to write this in less line of code.. means i compress this in few lines..

What I have tried:

1st class
C#
private int _ComplainID;
private string _ComplainTokenNo;

public int ComplainID
{ 
    get { return _ComplainID; }
    set { _ComplainID = value; }
}

public string ComplainTokenNo
{ 
    get { return _ComplainTokenNo; }
    set { _ComplainTokenNo = value; }
}

public DataSet GetComplainForEmail()
{
    DataSet ds;
    try
    {
        SqlParameter[] Params = 
        { 
            new SqlParameter("@ComplainID",SqlDbType.Int),
            new SqlParameter("@ComplainTokenNo",SqlDbType.VarChar)
        };
        
        if (ComplainID != 0 && ComplainID != null)
        {
            Params[0].Value = ComplainID;
        }
        else
        {
            Params[0].Value = DBNull.Value;
        }
        
        if (ComplainTokenNo != "" && ComplainTokenNo != null)
        {
            Params[1].Value = ComplainTokenNo;
        }
        else
        {
            Params[1].Value = DBNull.Value;
        }
        
        ds = GetDataSet("SP_De_ComplainMaster_Select_ReportEmail", Params);
        
        return ds;
    }
    catch (Exception ex)
    {
        throw new Exception(ex.Message);
    }
}

2nd class
C#
public void PrintComplainReport(int comID)
{
    ds = new DataSet();

    _sys = new clsDe_ComplainMaster();
    _sys.ComplainID = comID;
    _sys.BranchCode = Session["Branch_Code"].ToString();

    ds = _sys.GetComplainForEmail();

    ReportObj = new ReportInfo();
    ReportObj.ReportFileName = "rptComplain.rpt";
    ReportObj.ReportTitle = "Device Complain";
    ReportObj.ReportDataSet = ds;

    ds.Tables[0].TableName = "Complain";

    Hashtable ReportParameters = new Hashtable();

    sReportId = System.Guid.NewGuid().ToString();

    Session["RptInfo" + sReportId] = ReportObj;

    string sUrl = "~/Common/Reports/Viewer.aspx?RptId=" + sReportId;

    ScriptManager.RegisterStartupScript(this, this.GetType(), "newtab", "window.open('" + ResolveUrl(sUrl) + "');", true);
}
Posted
Updated 26-Apr-16 20:21pm
v2

1 solution

When you asked this question yesterday: Parameters less line of code[^]
You seemed to understand the code quite well, with 10 parameters.
And I told you how to write it with less code then.

Is there any point in asking questions if you are going to ignore the answers?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900