Thursday, May 26, 2011

Read.csv from data


        if (!string.IsNullOrEmpty(fpPriceData.FileName))
            {
                if (fpPriceData.FileName.Contains(".csv"))
                {                  
                                 

                   
                    string strpath = System.IO.Path.GetTempPath() + "\\" + Guid.NewGuid().ToString("N") + ".csv";
                    fpPriceData.PostedFile.SaveAs(strpath);

                 
                 

                    #region code for using .csv files
                    //uncomment this code if we want to use .csv files

                    StreamReader str = new StreamReader(strpath);
                    DataTable dtEntireTable = oCOMClass.GetCompleteDataForCSV(str);

                    #endregion
                  }
              }



  public DataTable GetCompleteDataForCSV(StreamReader srdr)
    {
        //  System.IO.StreamReader srdr = new System.IO.StreamReader(strm);
        DataTable m_dtCSV = new DataTable();
        String strLine = String.Empty;
        Int32 iLineCount = 0;
        do
        {
            strLine = srdr.ReadLine();
            if (strLine == null)
            {
                break;
            }
            if (0 == iLineCount++)
            {
                m_dtCSV = this.CreateDataTableForCSVData(strLine);
            }
            else
            {
                this.AddDataRowToTable(strLine, m_dtCSV);
            }
        } while (true);

        return m_dtCSV;
    }
    private DataTable CreateDataTableForCSVData(String strLine)
    {
        DataTable dt = new DataTable("CSVTable");
        String[] strVals = strLine.Split(new char[] { ',' });
        m_iColumnCount = strVals.Length;
        int idx = 0;
        foreach (String strVal in strVals)
        {
            String strColumnName = String.Format(strVal);
            // String strColumnName = String.Format("Column-{0}", idx++);

            dt.Columns.Add(strColumnName, Type.GetType("System.String"));
        }
        return dt;
    }
    private DataRow AddDataRowToTable(String strCSVLine, DataTable dt)
    {
        String[] strVals = strCSVLine.Split(new char[] { ',' });
        Int32 iTotalNumberOfValues = strVals.Length;
        // If number of values in this line are more than the columns
        // currently in table, then we need to add more columns to table.
        //if (iTotalNumberOfValues > m_iColumnCount)
        //{
        //    Int32 iDiff = iTotalNumberOfValues - m_iColumnCount;
        //    for (Int32 i = 0; i < iDiff; i++)
        //    {
        //        String strColumnName = String.Format("Column-{0}", (m_iColumnCount + i));
        //        dt.Columns.Add(strColumnName, Type.GetType("System.String"));
        //    }
        //    m_iColumnCount = iTotalNumberOfValues;
        //}
        int idx = 1;
        DataRow drow = dt.NewRow();
        foreach (String strVal in strVals)
        {
            //  String strColumnName = String.Format("Column-{0}", idx++);

            drow[idx - 1] = strVal.Trim();
            idx++;

        }
        dt.Rows.Add(drow);
        return drow;
    }  

Read excel from data


Add namespace
using Excel = Microsoft.Office.Interop.Excel;

Add reference
Microsoft.Office.Interop.Excel

private void button1_Click(object sender, EventArgs e)
        {
            Excel.Application xlApp ;
            Excel.Workbook xlWorkBook ;
            Excel.Worksheet xlWorkSheet ;
            Excel.Range range ;
            double str1;
            double str;
           

            xlApp = new Excel.ApplicationClass();
            xlWorkBook = xlApp.Workbooks.Open("E:\\Sharmila\\Documents\\Data.xlsx", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

            range = xlWorkSheet.UsedRange;
            System.Array arrValues = (System.Array)range.Cells.Value2;

        

            for (int i = 1; i < arrValues.Length; i++)
            {
               
              
                str = Convert.ToDouble(arrValues.GetValue(i,1).ToString());
                str1 = Convert.ToDouble(arrValues.GetValue(i+1,1).ToString());
                DateTime MyDate = DateTime.FromOADate(str);
                DateTime MyDate1 = DateTime.FromOADate(str1);
                int diff = MyDate1.Second - MyDate.Second;
                if (diff > 1)
                {
                    MessageBox.Show("Error");
               
                }
            }
          
        

            xlWorkBook.Close(true, null, null);
            xlApp.Quit();

           
        }

Saturday, March 19, 2011

Top Compinies HR Email IDS

Email Id's of IT Companies & Consultants

Some of them are outdated but pretty much good information

  1. Wipro - careers@wipro.com
  2. American Data Solutions - adsihr@gafri.com
  3. Healtheon jobs@healtheonindia.com
  4. HCL Tech resumeblr@hclt.com
  5. Bharti Telesoft careers@bhartitelesoft.com
  6. IBM osudar@in.ibm.com mamol@in.ibm.com
  7. For Lucent skg@spectrumconsultants.com
  8. GE India itl.geitc@geind.ge.com Bangalore
  9. iCope hrd@icope.com Wireless
  10. NATIONAL careers@malkauns.nsc.com Embedded
  11. Philips pscareers2000@philips.com Embedded
  12. BOSCALLEO hr@boscalleo.com Ecomm
  13. IT Solutions careers_2000@its.soft.net
  14. HCL Tech careerb@msdc.hcltech.com
  15. NIHILENT career@nihilent.com
  16. Infosys careers@inf.com
  17. CISCO india_jobs@cisco.com Networking
  18. ! PEOPLE.COM speri@techpeople-india.com US
  19. NetBrahma Want2b@netbrahma.com Systems
  20. SunCoreSoft hrd@suncoresoft.com
  21. Ishoni jobs@ishoni.com
  22. LG Software I walkin@lgsi.com Ecom , Embedded
  23. HPS Global hps.rmg@hpsglobal.com
  24. Reliance , US jobs@reliance.com
  25. ESCOSOFT carer@escosoft-tech.com US
  26. SERANOVA careerindia@seraova.com Ecom
  27. TeleSoft hrd@indts.com Telecom
  28. SSI infinity@ssi-technologies.com Bangalore
  29. MelStar bstp@melstar.com Bombay Chennai
  30. USInteractive careers@usinteractive.com US
  31. Cerebra jobs@cerebracomputers.com
  32. Empowertel hrindia@empowertel.com
  33. PTC hrtoi@india.ptc.com PUNE
  34. Siri Technolgoies hr@siritech.com
  35. ALIT hr@alit.soft.net
  36. i-Flex sandeep.bhattacharya@iflexsolutions.com
  37. CosmoNet hrd@cosmonetsolutions.com
  38. POLARIS resume_toib@polaris.co.in
  39. RAS Infotech resumes@rasinfotech.com
  40. SIP Technolgies hrd@siptech.co.in
  41. SNS Tech careers@snstech.com
  42. AUTODESK crvcon@vsnl.com
  43. LGSoft onsite_java@lgsi.com
  44. Kindle work_here@kindlesystems.com PUNE US UK
  45. InfoStrands infostrands@gtvltd.com
  46. ObjectOrb hr@objectorb.com
  47. Comnet hrd@comneti.com telecom
  48. CIS hrtelecom@cisindia.com
  49. OnwardGroup geetha_cherian@onwardgroup..com
  50. Green Microsystems jobs@greenmicrosystems.com
  51. STPI personnel@stpb.soft.net
  52. Quark careers@quark.stpm.soft.net MOHALI
  53. DelDot subbu@deldot.com
  54. SUBEX ganesh@subegroup.com
  55. SIERRAOPT career@sierraopt.com
  56. DSQ recruit_ecom@md.in.dsqsoft.com CHENNAI
  57. IIC hr@iictechnologies.com
  58. CYBERTECH ecomjobs@cybertech.com
  59. FormulaSys resumes@FormulaSys.com US
  60. WorkFlow hr@workflow.com
  61. SystemLogic got2b@SystemLogic.com
  62. CyberAnalysts resume@cyberanalysts.com
  63. IMPETUS hr@impetus.co.in INDORE
  64. VISTEON svadivel@VISTEON.com EMBEDDED
  65. Amadee myjobs@amadee.de INTERNET
  66. WEBTEK webtek_jobs@dresdner-bank.com
  67. CIRRUS LOGIC hrd@cirrus.stpp.soft.net
  68. TCS Chennai resume@chennai.tcs.com
  69. TVSFUGEN mjojo@tvsfugen.com
  70. Onscan -Wireless - jobs@onscan.com
  71. EmbeddedWireless jobs@EmbeddedWireless.com
  72. DECCANET career@deccanetdesigns.com
  73. DuskValley joinus@DuskValley.com
  74. duskvalley@vsnl.com INTERNET
  75. SEMA hrd@sema.co.in CALCUTTA TElecom
  76. FTD future4u@ftdpl.com.sg DSP / Telecom
  77. SAS careers@sasi.com
  78. SPIKE design@spikeindia.soft.net EDA / ASIC
  79. HCL freedom@ggn.hcltech.com
  80. Aptech corporatetrg@aptech.co.in
  81. Datamatics psaib@datamatics.com BOMBAY
  82. AQUILA hrd@aquila.soft.net Graphics , EBusiness
  83. DATUM careers@datumtec.com
  84. HUGHES resumetoib@hss.hns.com
  85. AMBER india_jobs@ambernetworks.com Networking
  86. Integra career@integramicro.com
  87. Lante cvindia@lante.com DELHI -Ecom
  88. RELQ RELQusa@RELQ.com
  89. Sonata-US hrd@sonata-software.com
  90. career@sonata-software.com
  91. ZAP hrdbg@skillsandjobs.com
  92. Zensar dreamcareers@zensar.com
  93. Spectrum , Singapore ravikum@mbox2.singnet.com.sg
  94. Forbes, UK forbeshr@bgl.vsnl.net.in
  95. forbesbg@bgl.vsnl.net.in
  96. Synopsys guru@synopsys.com
  97. JobCurry Australia map@jobcurry.com
  98. Singapore, UNIX cn66@vsnl.com
  99. Sun Tech US hr@suntechnologies.com
  100. HCL Tech - careers@noida.hclt.com Noida
  101. Infosys - engserv@inf.com
  102. HTC - htc.blr@htcinc.com
  103. CGSmith - resume@cgs.cgsmith.soft.net
  104. APCC - irecruit@apcc.com
  105. TechDrive sunitha@techdriveintl.com
  106. UniqueComputing careers@uniquecomputing.com US
  107. Accord Soft asiapacific@accord-soft.com
  108. ZenSoft hrd.zensoft@pacific.net.sg Singapore
  109. Zenith hr@zenithsoft.com Mumbai
  110. Velocient rsg@in.velocient.com Delhi , US
  111. Selectica hr_bgl@selectica.com
  112. Think Inc. jobs@thinkbn.com Coimbatore -
  113. Mphasis hr@mphasis.com
  114. Digital di.recruit@digital.com
  115. Alopa hrindia@alopa.com
  116. Silicon Automation Systems careers@sasi.com
  117. Birla Software recruitment@birlasoftware.com
  118. WebXL jobs@webxl.com
  119. Talisma got2b@talisma.com
  120. Aditi got2b@aditi.com want2b@aditi.com
  121. AmSoft hrd@amsoftis.com
  122. Bangalore Software jobs@bangaloresoftware.com
  123. ARTHUR ANDERSEN rescw@arthurandersen.com
  124. Raffles careers@raffles.soft.net
  125. ECosmos hr_ecosmos@netkracker.com
  126. SAP sanjukta.sarkar@sap.com
  127. PUNDITS protocol@pundits.com
  128. AZTEC jobs@aztecsoft.com
  129. Infy Banking Software banking_hrd@infy.com
  130. Infy IS Software careers.IS@inf.com
  131. ! HPS(Perot) Global opportunities@hpsblr.soft.net
  132. CSS jobs@csshome.net
  133. CBSI recruiting@cbsinc.com
  134. NetGalactic hr@netgalactic.com
  135. Orbit-e livefree@orbit-e.com
  136. is3c hr@is3c.com
  137. Tenet jobs@tenetindia.com
  138. GMR Info opportunities@gmrinfo.com
  139. Intergraph resume_india@intergraph.com
  140. Net-Kraft be@net-kraft.com
  141. Honeywell career@hiso.honeywell.com
  142. TEIL hrssg@teil.soft.net
  143. CMG careers@cmg.nu
  144. CMC hrd@blr.cmc.net.in
  145. ComInsights general@cominsights.com
  146. MultiTech - resume@multitech.co.in
  147. Placement Companies : infdim@vsnl.com
  148. Reach Consulting reach@vsnl.com rebus@vsnl.com
  149. NexAge Consulting - jobs@nexageconsulting.com
  150. iihmr@iihmr.org
  151. ibelong@zeenext.com
  152. JK Consultants jkconsultants@vsnl.com
  153. loginjobs@vsnl.com
  154. infdim@vsnl.com
  155. pdotblr@usa.net
  156. anil.ballari@indusconsultants,com
  157. Consulti consulti@vsnl.com
  158. msindinc@aol.com
  159. vma@vsnl.com Wireless
  160. careers@inficompsys.com
  161. resumes@sysprotech.com
  162. careerindia@satyamonline.com
  163. careerindia@123india.com
  164. resoft@satyam.net.in
  165. sixsigma@bgl.vsnl.net.in

Wednesday, September 15, 2010

Thursday, July 8, 2010

Saturday, May 22, 2010

find the single row in gridview

da = new SqlDataAdapter("select * from tblleavemaster", cn);
        ds.Reset();
        da.Fill(ds, "tblleavemaster");
        if (ds.Tables[0].Rows.Count > 0)
        {
            foreach (GridViewRow gr1 in gvclasslist.Rows)
            {
                foreach (DataTable myTable in ds.Tables)
                {
                    foreach (DataRow myRow in myTable.Rows)
                    {
                        leavesid = Convert.ToInt32(myRow["studentid"].ToString());
                        DateTime fromdate = Convert.ToDateTime(myRow["fromdate"].ToString());
                        DateTime Todate = Convert.ToDateTime(myRow["todate"].ToString());
                        DateTime todaydate = DateTime.Now;
                        System.Web.UI.WebControls.Label lbl = new System.Web.UI.WebControls.Label();
                        lbl = (System.Web.UI.WebControls.Label)gr1.FindControl("Label1");
                        attendancesid = Convert.ToInt32(lbl.Text);
                        if (leavesid == attendancesid)
                        {
                            if (Todate <= todaydate)
                            {
                                gr1.Enabled = true;
                            }
                            else
                            {
                                gr1.Enabled = false;
                            }


                        }
                    }
                }

upload image and save binary format show image in picture box

if (fileuploadlogo.PostedFile.ContentLength == 0)
        {
            lblerrordesc.Visible = true;
            lblerrordesc.Text = "Please Upload Photo !!!";
        }
        else
        {
            Stream imgStream = fileuploadlogo.PostedFile.InputStream;
            int imgLen = fileuploadlogo.PostedFile.ContentLength;
            string imgContentType = fileuploadlogo.PostedFile.ContentType;
            byte[] imgBinaryData = new byte[imgLen];
            int n = imgStream.Read(imgBinaryData, 0, imgLen);
            photodata = imgBinaryData;
            phototype = imgContentType;
            Session["photodata"] = imgBinaryData;
            Session["phototype"] = imgContentType;
            Image3.ImageUrl = "studentphoto.aspx?type=" + imgContentType + "";
        }

Sunday, April 25, 2010

Grid view code

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
    SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());

    protected void Page_Load(object sender, EventArgs e)
    {
        //if(!IsPostBack)
        //{
        //  BinData();
        //  //ddlfill();
        //}
        BinData();
     
           }

    protected void BinData()
    {
        //SqlDataAdapter sqlDa = new SqlDataAdapter("select * from Gridview", sqlCon);
        //DataSet Ds = new DataSet();
        //sqlDa.Fill(Ds, "Gridview");
        //GridView1.DataSource = Ds.Tables["Gridview"].DefaultView;
        //GridView1.DataBind();

        sqlCon.Open();
        SqlCommand sqlCmd = new SqlCommand("select * from Gridview",sqlCon);
        SqlDataReader dr = sqlCmd.ExecuteReader();
        if(dr.Read())
        {
            GridView1.DataSource = dr;
            GridView1.DataBind();
       
        }

        sqlCon.Close();


    }
    //public void ddlfill()
    //{
    //    for (byte i = 1; i < GridView1.PageCount; i++)
    //    {
    //        DropDownList1.Items.Add(i.ToString());
    //    }
    //}

   
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

protected void  GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
//  GridView1.PageIndex=e.NewPageIndex;
//    BinData();
//   btnSearch.Text = (e.NewPageIndex + 1) + "/out of/" + GridView1.PageCount;
}
protected void  GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
    //GridView1.EditIndex=e.NewEditIndex;
    //BinData();

}
protected void  GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
    //GridView1.EditIndex= -1;
    //BinData();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    int sid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
    GridViewRow row = GridView1.Rows[e.RowIndex];
    TextBox TSname = (TextBox)row.FindControl("txtSName");
    TextBox TSclass = (TextBox)row.FindControl("txtSClass");
    TextBox TSCollege = (TextBox)row.FindControl("txtSCollege");
    TextBox TSCourse = (TextBox)row.FindControl("txtSCourse");
    TextBox TSPlace = (TextBox)row.FindControl("txtSPlace");
    SqlCommand sqlCmd = new SqlCommand();
    sqlCon.Open();
    sqlCmd.Connection = sqlCon;
    sqlCmd.CommandType = CommandType.StoredProcedure;
    sqlCmd.CommandText = "usp_update";
    sqlCmd.Parameters.Add("@sid", SqlDbType.Int).Value = sid;
    sqlCmd.Parameters.Add("@sname", SqlDbType.VarChar, 50).Value = TSname.Text;
    sqlCmd.Parameters.Add("@sclass", SqlDbType.VarChar, 50).Value = TSclass.Text;
    sqlCmd.Parameters.Add("@scollege", SqlDbType.VarChar, 50).Value = TSCollege.Text;
    sqlCmd.Parameters.Add("@scourse", SqlDbType.VarChar, 50).Value = TSCourse.Text;
    sqlCmd.Parameters.Add("@splace", SqlDbType.VarChar, 50).Value = TSPlace.Text;
    sqlCmd.ExecuteNonQuery();
    sqlCon.Close();
    GridView1.EditIndex = -1;
    BinData();


}

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    int sid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
    GridViewRow row = GridView1.Rows[e.RowIndex];
    SqlCommand sqlcmd = new SqlCommand();
    sqlCon.Open();
    sqlcmd.Connection = sqlCon;
    sqlcmd.CommandType = CommandType.StoredProcedure;
    sqlcmd.CommandText = "usp_delete";
    sqlcmd.Parameters.Add("@sid", SqlDbType.Int).Value = sid;
    sqlcmd.ExecuteNonQuery();
    sqlCon.Close();
    GridView1.EditIndex = -1;
    BinData();


}
protected void Button1_Click(object sender, EventArgs e)
{

    if (ddlSelect.SelectedIndex > 0)
    {
        SqlDataAdapter sqlDa = new SqlDataAdapter("select * from sdetails where " + ddlSelect.SelectedItem.Text + " like  '%" + txtSearch.Text + "%'", sqlCon);
        DataSet Ds = new DataSet();
        sqlDa.Fill(Ds, "sdetails");
        GridView1.DataSource = Ds.Tables["sdetails"].DefaultView;

        GridView1.DataBind();
    }

    else
    {
        SqlDataAdapter sqlDa = new SqlDataAdapter("select * from sdetails", sqlCon);
        DataSet Ds = new DataSet();
        sqlDa.Fill(Ds, "sdetails");
        GridView1.DataSource = Ds.Tables["sdetails"].DefaultView;
        GridView1.DataBind();

    }
}


protected void ddlSelect_SelectedIndexChanged(object sender, EventArgs e)
{

}

protected void btnCancel_Click(object sender, EventArgs e)
{
    SqlDataAdapter sqlDa = new SqlDataAdapter("select * from sdetails", sqlCon);
    DataSet Ds = new DataSet();
    sqlDa.Fill(Ds, "sdetails");
    GridView1.DataSource = Ds.Tables["sdetails"].DefaultView;
    GridView1.DataBind();
}
protected void btnDelete_Click(object sender, EventArgs e)
{
    for (int i = 0; i < GridView1.Rows.Count; i++)
    {
        CheckBox ch = (CheckBox)GridView1.Rows[i].FindControl("chkDel");
        if (ch.Checked == true)
        {
            Label l1 = (Label)GridView1.Rows[i].FindControl("lblSid");
            sqlCon.Open();
            SqlCommand sqlCmd = new SqlCommand("delete from sdetails where sid='" + l1.Text + "'", sqlCon);
            sqlCmd.ExecuteNonQuery();
            sqlCon.Close();
        }

    }
    BinData();
}
protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
{

}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
    GridView1.PageIndex = DropDownList1.SelectedIndex;
    BinData();
    btnShow.Text = (DropDownList1.SelectedIndex + 1) + "Outof" + GridView1.PageCount;
}
protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
    CheckBox ch;
    CheckBox chkall = (CheckBox)GridView1.HeaderRow.FindControl("Chkall");
    if (chkall.Checked == true)
    {
        foreach (GridViewRow gvr in GridView1.Rows)
        {
            ch = (CheckBox)gvr.FindControl("chkDel");
            ch.Checked = true;

        }
    }
    else
    {
        foreach (GridViewRow gvr in GridView1.Rows)
        {
            ch = (CheckBox)gvr.FindControl("chkDel");
            ch.Checked = false;

        }
    }
}
protected void btnInsert_Click(object sender, EventArgs e)
{
    TextBox TSid = (TextBox)GridView1.FooterRow.FindControl("txtSid");
    TextBox TSname = (TextBox)GridView1.FooterRow.FindControl("txtSName");
    TextBox TSclass = (TextBox)GridView1.FooterRow.FindControl("txtSClass");
    TextBox TSCollege = (TextBox)GridView1.FooterRow.FindControl("txtSCollege");
    TextBox TSCourse = (TextBox)GridView1.FooterRow.FindControl("txtSCourse");
    TextBox TSPlace = (TextBox)GridView1.FooterRow.FindControl("txtSPlace");
    sqlCon.Open();
    SqlCommand sqlCmd = new SqlCommand("insert into sdetails values('" + TSid.Text + "','" + TSname.Text + "','" + TSclass.Text + "','" + TSCollege.Text + "','" + TSCourse.Text + "','" + TSPlace.Text + "')", sqlCon);
    sqlCmd.ExecuteNonQuery();
    sqlCon.Close();
    TSid.Text = "";
    TSid.Text = "submitted";
}
protected void chkall_CheckedChanged(object sender, EventArgs e)
{
    CheckBox ch;
    CheckBox chkall = (CheckBox)GridView1.HeaderRow.FindControl("Chkall");
    if (chkall.Checked == true)
    {
        foreach (GridViewRow gvr in GridView1.Rows)
        {
            ch = (CheckBox)gvr.FindControl("chkDel");
            ch.Checked = true;

        }
    }
    else
    {
        foreach (GridViewRow gvr in GridView1.Rows)
        {
            ch = (CheckBox)gvr.FindControl("chkDel");
            ch.Checked = false;

        }
    }
}
protected void GridView1_SelectedIndexChanged2(object sender, EventArgs e)
{

}
}

Monday, April 19, 2010

code for login controls for sql server

protected void Login1_Authenticate(object sender,
AuthenticateEventArgs e)
    {   string u_id=Login1.UserName;
        string pwd=Login1.Password;

        SqlConnection con = new
SqlConnection("uid=sa;pwd=nivt;server=.;database=jobportal");
        try
        {
            con.Open();
            SqlDataAdapter da = new SqlDataAdapter("select *
from rec_registration where rec_username='" + u_id + "'", con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            if (Login1.UserName ==
ds.Tables[0].Rows[0][0].ToString() && Login1.Password ==
ds.Tables[0].Rows[0][1].ToString())
            {
                Session["rec_uid"] = u_id;
                Session["rec_uname"] =
ds.Tables[0].Rows[0][3].ToString();
                Session["rec_type"] =
ds.Tables[0].Rows[0][5].ToString();

               Response.Redirect("rec_home.aspx");
                
            }
            else
            {
                Label2.Text = "Invalid Username/Password:";

            }
        }
        catch(Exception ex)
        {
            Label3.Text = ex.Message.ToString();
            Label2.Text = "Invalid Username";

        }
        finally
        {
            if (con.State == ConnectionState.Open)
            {
                con.Close();
            }
        }

    }

Friday, April 16, 2010

How to store image file in Sql server database?

//use this code to store image file in sql server database

//get directory Path(C:\\Temp) where image has stored and 
use these two method in ur program

        private void GetImagePath(string strDirectoryPath)
        {
            DirectoryInfo mobjDirInfo = new DirectoryInfo
(strDirectoryPath);
            //object[] mobjStore = new object
[Directory.GetFiles(strDirectoryPath, "*.JPG").Length];
            int counter =1;
            foreach (FileInfo fl in mobjDirInfo.GetFiles
("*.JPG"))
            {
                // Create a new stream to load this photo 
into
                FileStream stream = new FileStream
(fl.FullName.ToString(), FileMode.Open, FileAccess.Read);

                // Create a buffer to hold the stream bytes
                byte[] buffer = new byte[stream.Length];

                // Read the bytes from this stream
                stream.Read(buffer, 0, (int)stream.Length);

                // Now we can close the stream
                stream.Close();

                // Extract out the name of the file an use 
it for the name of the photo
                string strName = 
Path.GetFileNameWithoutExtension(fl.Name.ToString());

                // Insert the image into the database and 
add it to the tree
                InsertImageIntoDatabase(ref buffer, 
strName, counter);
                buffer = null;
                counter = counter+1;
            }
        }


//Insert Images into sql server (create table TBLIMAGE
(PHOTOID int,PHOTONAME varchar(20),PHOTO IMAGE))
        private void InsertImageIntoDatabase(ref byte[] 
buffer, string strPhotoName, int intPhotoid)
        {
            if (mobjConn.State == ConnectionState.Closed)
            {
                mobjConn.Open();
            }
            
            mobjCmd = new SqlCommand("Insert Into TBLIMAGE 
values(@PHOTOID,@PHOTONAME,@PHOTO)", mobjConn);
            mobjCmd.Parameters.Add("@PHOTOID", intPhotoid);
            mobjCmd.Parameters.Add
("@PHOTONAME",strPhotoName);
            mobjCmd.Parameters.Add("@PHOTO", buffer);
            mobjCmd.ExecuteNonQuery();

        }

//if u have any query please revert back

Saturday, April 10, 2010

how to install the silver light to vs studio 2008

step:1


Down load the sp1 from below sit:

http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=fbee1648-7106-44a7-9649-6d9f6d58056e&displayLang=en


Step2:

Thursday, April 8, 2010

Downloading all type of files from Gridview

 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
         try
    {
        int fileindex = (int)GridView1.SelectedValue;

         string dbPath = null;
   
        DataSet path = Download.GetresourcePath(fileindex);

        foreach (DataRow row in path.Tables["filepath"].Rows)
        {
            dbPath = string.Format("{0}", row["filepath"]);

         }

            string filePath = @dbPath;

             string fileName = Path.GetFileName(filePath);

            System.IO.Stream stream = null;

            stream = new FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
            long bytesToRead = stream.Length;
            Response.ContentType = "application/octet-stream";

             Response.AddHeader("content-Disposition", "attachment; filename=" + fileName);

              while (bytesToRead > 0)
            {
                if (Response.IsClientConnected)
            {
                byte[] buffer = new Byte[10000];
                int length = stream.Read(buffer, 0, 10000);
                Response.OutputStream.Write(buffer, 0, length);
                Response.Flush();
                bytesToRead = bytesToRead - length;
            }
            else
                {
                    bytesToRead = -1;

                }
        }
        }
        catch (Exception ex)
        {

        }

        }

Tuesday, April 6, 2010

Down load file from Solution Explorar

protected void Button2_Click(object sender, EventArgs e)
    {
        string s = DropDownList1.SelectedItem.Text;
        Response.Clear();
        Response.AddHeader("content-disposition", string.Format("attachment;filename={0}", s));
        Response.Charset = "";
        Response.ContentType = "application/vnd.xls";

        StringWriter stringWrite = new StringWriter();
        HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
    
        Response.Write(stringWrite.ToString());
        Response.End();
    }


Retrive the files For Dropdownlist


 protected void Page_Load(object sender, EventArgs e)
    {
        retrivefiles();
    }
    public void retrivefiles()
    {
      
        DirectoryInfo dinfo = new DirectoryInfo(Server.MapPath(("." + @"\images\")));
        FileInfo[] fileslist = dinfo.GetFiles();
        foreach (FileInfo fi in fileslist)
        {
            DropDownList1.Items.Add(fi.Name);
        }
    }

export data from gridview to excel And Pdf

Export To Excel
protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Clear();
        Response.AddHeader("content-disposition", "attachment;filename=DocumentReport.xls");
        Response.Charset = "";
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = "application/vnd.ms-excel";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        GridView gv = new GridView();
        gv.DataSource = ds;
        gv.DataBind();

     gv.RenderControl(htmlWrite);
        Response.Write(stringWrite.ToString());
        Response.End();
    }


export to Pdf


 protected void Button2_Click(object sender, EventArgs e)
    {

        Response.Clear();
        Response.AddHeader("content-disposition", "attachment;filename=DocumentReport.pdf");
        Response.Charset = "";
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ContentType = "application/pdf";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
        GridView gv = new GridView();
        gv.DataSource = ds;
        gv.DataBind();
       gv.RenderControl(htmlWrite);
        Response.Write(stringWrite.ToString());
        Response.End();
    }

Retrive the data from excel sheet ,Xml And Sql server2005

 protected void Button1_Click(object sender, EventArgs e)
    {
        sqlCon.Open();
        SqlCommand cmd = new SqlCommand("select type from spreadsheet where spreadsheetname='" + DropDownList1.SelectedItem.Text + "'", sqlCon);
        SqlDataReader dr = cmd.ExecuteReader();
        string type="";
        if (dr.Read())
        {
            type = dr[0].ToString();
        }
        sqlCon.Close();
        string filename = DropDownList1.SelectedItem.Text;
        switch (type)
        {
            case "Excel":
               
                string conn = ("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath(".\\datasources\\" + filename) + ";Extended Properties=\"Excel 8.0;\""); // or use instead of Excel 8.0 - Excel 5.0
                string SSQL = "SELECT *  from [sheet1$]";
                OleDbDataAdapter oleDA = new OleDbDataAdapter(SSQL, conn); // here use oleDataReader
                DataSet ds = new DataSet();
                //oleDA.TableMappings.Add("Table","ExcelTest"); // Require
                oleDA.Fill(ds);
                GridView1.DataSource = ds.Tables[0].DefaultView; // or [ ds ]
                GridView1.DataBind();
                break;
            case "XML":
                DataSet ds1 = new DataSet();
                ds1.ReadXml(Server.MapPath(@".\datasources\" + filename));
                GridView1.DataSource = ds1.Tables[0];
                GridView1.DataBind();
                break;
            case "SQLSERVER":
                SqlCommand cmd1 = new SqlCommand("select * from "+filename,sqlCon);
                SqlDataAdapter da = new SqlDataAdapter();
                DataSet ds2 = new DataSet();
                da.Fill(ds2);
                GridView1.DataSource= ds2.Tables[0];
                GridView1.DataBind();
                break;
        }




Get the All filenames in to dropdownlist from solution Explorar

 SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString());
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string username = (string)Session["username"];
            sqlCon.Open();
            SqlCommand cmd = new SqlCommand("select spreadsheetname from spreadsheet where username='"+username+"'", sqlCon);
            SqlDataReader dr = cmd.ExecuteReader();
            DropDownList1.Items.Add("Select");
            while (dr.Read())
            {
                DropDownList1.Items.Add(dr[0].ToString());
            }
            sqlCon.Close();
        }
    }
   
    }

Monday, April 5, 2010

to show the nested grid

l1 = (LinkButton)GridView1.Rows[GridView1.Rows.Count].FindControl("Label1");



GridView childgrid = (GridView)GridView1.Rows[1].Cells[3].Controls[1];

SqlDataAdapter sqlDa = new SqlDataAdapter("select * from dept where branchno='" + l1.Text + "'", con);
DataSet ds = new DataSet();
sqlDa.Fill(ds);
childgrid.DataSource = ds;
childgrid.DataBind();

Thursday, December 31, 2009

Setting Up PayPal Sandbox To Our Web Forms

I had a fair bit of trouble getting the sandbox setup properly for paypal so I thought I would put some steps down to make it a bit more easier for anyone just getting started with setting up the pay pal sandbox.

1 - Go to https://developer.paypal.com/ and click the sign up now button. create an account (your username must be a different one if you have a paypal account)

2 - Click on Test Accounts, and add a business and personal account (note that if you are an australian you cant get the API keys without selecting US from the where do you live dropdown). Take note of the passwords that you use. When you create an account it creates a test bank account and test credit card for you to test your code with. You can also take note of these details for use later on in your testing.

3 - Click on API credentials, and take note of your API account, username, password and Signature. These are obviously used within your code config.

4 - Click on Test Accounts, and making sure your business account is selected, click on the enter sandbox test site button.

5 - Sign into your test site with your business account users details, your business accounts username should already be pre-filled in on the login form. Note that you must login with your business account details and not your API credentials.

6 - In the My Account Overview page, click on the step buttons to confirm your details and setup the api permissions.

7 - Most of the standard methods are activated once you have done this, but some are not. To check your api permissions click on my account/profile to go to your profile summary, then in your account information links click on API Access. Check the boxes next to the API's you wish to use, then click submit.

8 - You will prolly need some funds in your account if you are using payment methods such as mass pay, so click the Add Funds button and add some cash. Note that this is for testing use only and the money transfer is from a fictional bank.

9- These funds that you transferred need to be cleared, go to my accounts and scroll down to the bottom, you will see the fund transfers in the list, click on details link for that transaction, then click on clear transaction to complete the process.

That should be it, double check you have your API credentials setup properly in your code and you should be able to hit the sandbox for testing.

happy coding :)

Friday, December 18, 2009

what is the difference between .net2.0 and .net3.5

The .NET Framework 3.0 is Microsoft's managed code programming model. It is a superset of the .NET Framework 2.0, combining .NET Framework 2.0 components with new technologies for building applications that have visually stunning user experiences, seamless and secure communication, and the ability to model a range of business processes. In addition to the .NET Framework 2.0, it includes Windows Presentation Foundation (WPF), Windows Workflow Foundation (WF), Windows Communication Foundation (WCF), and Windows CardSpace.

Net 3.0 is an add-on to .Net 2.0. It contains three
Libraries for Windows
Presentation Foundation (WPF), Windows Workflow Foundation
(WF) and Windows
Communication Foundation (WCF) (and Windows Cardspace).
You can use these in
Visual Studio 2005 by adding extensions.

.Net 3.5 is the next .Net version after 2.0 shipped with
Visual Studio 2008


.NET 3.5 has LINQ, ASP.NET AJAX, new controls, richer WCF support, and a few other features that aren't in .NET 3.0. For server/asp.net scenarios I'd probably always recommend going with .NET 3.5. For client scenarios, .NET 3.0 is interesting to target since is pre-installed on all versions of Windows Vista - so you have good deployment of the runtime.


Note that all applications that target .NET 3.0 or .NET 2.0 will work run on .NET 3.5. You can't use the new features in .NET 3.5 if you target .NET 3.0 - but your application will obviously still work

What are the differences between Dataset and DataReader


Dataset is in memory representation of the Database. where 
you can create tables, relations between tables, add 
primary key to tables and also manipulate the data 
retrieved form the database. It allows us to work in 
connection less environment.
 
Datareader is like forward only readonly cursor, which is 
used to retrieve data. data manipulation is not possible 
while using datareader. datareader continously keeps the 
connection open.
 
A ds (dataset) can be used when the connection is closed.
A dr (datareader) needs the connection open to be used.
A ds can be used to modify or delete or insert data in the 
database. 
A data reader can be used only to read data
 
A ds can let you access the info on any order at any time.
A dr lets you access the info only one time per item and 
only in a sequential order.
 
A ds data can be loaded in longer time than a dr can be 
loaded at.
 
A ds can contain separated and structured data from several 
database tables. 
A dr can contain data in one register per item, that 
register can include data from serveral tables id the sql 
select statement so indicates, but it has no separate 
structure per table.


Thursday, December 17, 2009

Check All Checkbox In GridView To Bulk Edit Or Update ASP.NET C# NET

 chkselect all put autopostback=true;
 
protected void chkSelectAll_CheckedChanged
                               (object sender, EventArgs e)
{
 CheckBox chkAll = 
    (CheckBox)GridView1.HeaderRow.FindControl("chkSelectAll");
 if (chkAll.Checked == true)
 {
   foreach (GridViewRow gvRow in GridView1.Rows)
   {
    CheckBox chkSel = 
         (CheckBox)gvRow.FindControl("chkSelect");
    chkSel.Checked = true;
    TextBox txtname = (TextBox)gvRow.FindControl("txtName");
    TextBox txtlocation = (TextBox)gvRow.FindControl("txtLocation");
    txtname.ReadOnly = false;
    txtlocation.ReadOnly = false;
    txtname.ForeColor = System.Drawing.Color.Black;
    txtlocation.ForeColor = System.Drawing.Color.Black;
   }
 }
 else
 {
  foreach (GridViewRow gvRow in GridView1.Rows)
  {
   CheckBox chkSel = (CheckBox)gvRow.FindControl("chkSelect");
   chkSel.Checked = false;
   TextBox txtname = (TextBox)gvRow.FindControl("txtName");
   TextBox txtlocation = (TextBox)gvRow.FindControl("txtLocation");
   txtname.ReadOnly = true;
   txtlocation.ReadOnly = true;
   txtname.ForeColor = System.Drawing.Color.Blue;
   txtlocation.ForeColor = System.Drawing.Color.Blue;
   }
  }
}