Thursday, December 18, 2014

Custom Columns select using Crystal Report (Selected Columns to Be DISPLAYED IN CRYSTALREPORT AT RUN TIME)

First create a Data Set

Click on Add Button
It prompts for a message saying as




Click on Yes Button











ADD  YOUR COLUMNS  AS COLUMN1..........  COLUMNN



Add New Item



Select crystal report.rpt file and the below screen is visible



And Click on Ok button

And then press ctrl +alt +T


And click on  Ok BUTTON

In the Report Viewer Screen 

Press Ctrl+Alt +T 

In the Report 
Parameter Fields (Right Click and Select New)

Give the Name as col1

And Similarly Add 
Col2,col3,col4,
Similarly Add the Formula Fields as Below


And finally your database fields looks like 


Drag the controls 


.cs page

Add the following Namespaces
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;


write the following code in button click


------------------------------------------------------------------------------------
private string GetData()
    {
        ReportDocument reportDocument;
        ParameterFields paramFields;

        ParameterField paramField;
        ParameterDiscreteValue paramDiscreteValue;

        reportDocument = new ReportDocument();
        paramFields = new ParameterFields();

        string query = "SELECT ";
        int columnNo = 0;

        if (ChkEmpID.Checked)
        {
            columnNo++;
            query = query.Insert(query.Length, "EmpID as Column" + columnNo.ToString());


            paramField = new ParameterField();
            paramField.Name = "col" + columnNo.ToString();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = "EmpID";
            paramField.CurrentValues.Add(paramDiscreteValue);
            //Add the paramField to paramFields
            paramFields.Add(paramField);
        }
        if (ChkEmpName.Checked)
        {
            columnNo++;
            if (query.Contains("Column"))
            {
                query = query.Insert(query.Length, ", ");
            }
            query = query.Insert(query.Length, "Ename as Column" + columnNo.ToString());

            paramField = new ParameterField();
            paramField.Name = "col" + columnNo.ToString();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = "Ename";
            paramField.CurrentValues.Add(paramDiscreteValue);
            //Add the paramField to paramFields
            paramFields.Add(paramField);
        }
        if (ChkDesignation.Checked)
        {
            columnNo++;
            if (query.Contains("Column"))
            {
                query = query.Insert(query.Length, ", ");
            }
            query = query.Insert(query.Length, "Designation as Column" + columnNo.ToString());


            paramField = new ParameterField();
            paramField.Name = "col" + columnNo.ToString();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = "Designation";
            paramField.CurrentValues.Add(paramDiscreteValue);
            //Add the paramField to paramFields
            paramFields.Add(paramField);
        }
        if (chksalary.Checked)
        {
            columnNo++;
            if (query.Contains("Column"))
            {
                query = query.Insert(query.Length, ", ");
            }
            query = query.Insert(query.Length, "Salary as Column" + columnNo.ToString());


            paramField = new ParameterField();
            paramField.Name = "col" + columnNo.ToString();
            paramDiscreteValue = new ParameterDiscreteValue();
            paramDiscreteValue.Value = "Salary";
            paramField.CurrentValues.Add(paramDiscreteValue);
            //Add the paramField to paramFields
            paramFields.Add(paramField);
        }

        CrystalReportViewer1.ParameterFieldInfo = paramFields;
        query += " FROM Employee";
        return query;
    }


 OUTPUT





Wednesday, December 17, 2014

Multi Select DropDown with CheckBox

Add the following Scripts

Add the Following Scripts

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

    <link href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css"
        rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>

    <link href="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/css/bootstrap-multiselect.css"
        rel="stylesheet" type="text/css" />

    <script src="http://cdn.rawgit.com/davidstutz/bootstrap-multiselect/master/dist/js/bootstrap-multiselect.js"
        type="text/javascript"></script>

    <script type="text/javascript">
        $(function () {
            $('[id*=lsNames]').multiselect({
                includeSelectAllOption: true
            });
        });
    </script>



<asp:ListBox ID="lsNames" runat="server" SelectionMode="Multiple">
        <asp:ListItem Text="a" Value="1" />
        <asp:ListItem Text="b" Value="2" />
        <asp:ListItem Text="c" Value="3" />
        <asp:ListItem Text="d" Value="4" />
        <asp:ListItem Text="e" Value="5" />

    </asp:ListBox>
       <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />


on button click 
write the following code

string message = "";
        foreach (ListItem item in lsNames.Items)
        {
            if (item.Selected)
            {
                message += item.Text + " " + item.Value + "\\n";
            }
        }
        ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('" + message + "');", true);


Output





Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...