Total Pageviews

16 April 2012

How Create profile in crystal report with help of Asp.net

Here we are representing to make complete profile any employee or other Use. First of all if you want to make crystal report then install the setup of crystal report 2008 or 2010 as wish you want to install. If you are using .Net framework 2008 then install crystal report 2008 and when Use .Net Framework 4.0 then install crystall report 2010. Now Implement this programe hope this usefull for you.............

Add caption

Default2.aspx=>


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html xmlns="http://www.w3.org/1999/xhtml">


<head runat="server">


<style type="text/css">


.Gridview


{


font-family:Verdana;


font-size:10pt;


font-weight:normal;


color:black;


}


</style>

 

 

 


    <title></title>


</head>


<body>


    <form id="form1" runat="server">


    <div>


    <table>


    <tr>


<td>


Employee Name:


</td>


<td>


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>


</td>


</tr>


<tr>


<td>


Designation:


</td>


<td>


<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>


</td>


</tr>


<tr>


<td>


Date of Birth:


</td>


<td>


<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>


</td>


</tr>


<tr>


<td>


Date of anniversary:


</td>


<td>


<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>


</td>


</tr>


<tr>


<td>


Permanent Address:


</td>


<td>


<asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>


</td>


</tr>


<tr>


<td>


Image:


</td>


<td>


<asp:TextBox ID="txtImageName" runat="server"></asp:TextBox>


</td>


</tr>


<tr>


<td>


Upload Image:


</td>


<td>


<asp:FileUpload ID="fileuploadImage" runat="server" />


</td>


</tr>


<tr>


<td>


</td>


<td>


<asp:Button ID="btnUpload" runat="server" Text="Upload" onclick="btnUpload_Click" />


    <asp:Button ID="Button1" runat="server" onclick="Button1_Click"


        Text="Sow Profile" />


</td>


</tr>


</table>


</div>

 

 

 


    </form>


</body>


</html>

 

 

 

Default.aspx.cs=>


using System;


using System.Collections.Generic;


using System.Linq;


using System.Web;


using System.Web.UI;


using System.Web.UI.WebControls;


using System.IO;


using System.Data.SqlClient;


using System.Data;


using System.Configuration;

 

 

 


public partial class Default2 : System.Web.UI.Page


{


    string strcon = ConfigurationManager.ConnectionStrings["dbconnection"].ToString();

 

 

 


    protected void Page_Load(object sender, EventArgs e)


    {


        if (!IsPostBack)


        {


          


        }

 

 

 


    }


    protected void btnUpload_Click(object sender, EventArgs e)


    {


       


        if (fileuploadImage.HasFile)


        {


          


            int length = fileuploadImage.PostedFile.ContentLength;


           


            byte[] imgbyte = new byte[length];


          


            HttpPostedFile img = fileuploadImage.PostedFile;


          


            img.InputStream.Read(imgbyte, 0, length);


            string imagename = txtImageName.Text;


           


            SqlConnection connection = new SqlConnection(strcon);


            connection.Open();


            SqlCommand cmd = new SqlCommand("INSERT INTO Image (ImageName,Image,User_name,Designation,Date_birth,Date_anivesary,permanentadd) VALUES (@imagename,@imagedata,@User_name,@Designation,@Date_birth,@Date_anivesary,@permanentadd)", connection);


            cmd.Parameters.Add("@imagename", SqlDbType.VarChar, 50).Value = imagename;


            cmd.Parameters.Add("@imagedata", SqlDbType.Image).Value = imgbyte;


            cmd.Parameters.Add("@User_name", SqlDbType.VarChar, 50).Value = imagename;


            cmd.Parameters.Add("@Designation", SqlDbType.VarChar, 50).Value = imagename;


            cmd.Parameters.Add("@Date_birth", SqlDbType.VarChar, 50).Value = imagename;


            cmd.Parameters.Add("@Date_anivesary", SqlDbType.VarChar, 50).Value = imagename;


            cmd.Parameters.Add("@permanentadd", SqlDbType.VarChar, 50).Value = imagename;


            int count = cmd.ExecuteNonQuery();


            connection.Close();


            if (count == 1)


            {


              


                txtImageName.Text = string.Empty;


                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmessage", "javascript:alert('" + imagename + " image inserted successfully')", true);


            }


        }


    }

 


    protected void Button1_Click(object sender, EventArgs e)


    {


        Response.Redirect("User.aspx");


    }


}

 

 

Web config=>

 <add name="dbconnection" connectionString="Data Source=AMRIT;Initial Catalog=AMBROSIA;Integrated Security=True" providerName="System.Data.SqlClient"/>

 



 

No comments:

Post a Comment

Contact Form

Name

Email *

Message *