Pages

Wednesday, 8 May 2013

Random Password

 private void RandomPassword()
    {
        string allowedChars = "";

        allowedChars = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0";

        char[] sep = { ',' };
        string[] arr = allowedChars.Split(sep);

        string passwordString = "";

        string temp = "";

        Random rand = new Random();
        for (int i = 0; i < 6; i++)
        {
            temp = arr[rand.Next(0, arr.Length)];
            passwordString += temp;
        }
        strPwd = passwordString;
    }

Thursday, 2 May 2013

FileUpload


 if (FileUpload1.HasFile)
        {
            string ext = Path.GetExtension(FileUpload1.FileName);
            if (ext.ToLower() == ".jpg" || ext.ToLower() == ".jpeg" || ext.ToLower() == ".png" || ext.ToLower() == ".gif" || ext.ToLower() == ".pdf" || ext.ToLower() == ".doc")
            {
                try
                {
                    int res = obj.GetCount();
                    if (res == 1)
                    {
                        MsgPanel0.Visible = true;
                        lblMsg0.Text = "<script>" + Environment.NewLine + "alert('Brochure Already inserted')</script>";
                        MsgPanel0.Controls.Add(lblMsg0);

                    }
                    else
                    {
                        string s = @"~\Brochure\" + FileUpload1.FileName;
                        FileUpload1.SaveAs(Server.MapPath(s));

                        obj.InsertBroucher(s);
                        getRecord();
                        Panel1.Visible = false;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }
            else
            {
                MsgPanel0.Visible = true;
                lblMsg0.Text = "<script>" + Environment.NewLine + "alert('Choose JPG/JPEG/GIF/PNG/PDF/DOC Files')</script>";
                MsgPanel0.Controls.Add(lblMsg0);
            }
        }
        else
        {
            MsgPanel0.Visible = true;
            lblMsg0.Text = "<script>" + Environment.NewLine + "alert('Select Brochure')</script>";
            MsgPanel0.Controls.Add(lblMsg0);
        }

Wednesday, 17 April 2013

HR Interview Questions I Faced in My Interview.....

I am very thankful to my current organization, because I have learned many things from there, especially a corporate culture. And now I think changes are necessary for me to enhance my skills knowledge and personal growth.

Tell me about a situation when your work was criticized.

I never got criticized by others, but I get feedback always. It gives me to clean up my works. I also never criticize others' work and always give feedback to them. If others also had made mistakes I always ready to help them.

I have done all my given assignments with my 100% efforts and knowledge. Some how, in some condition I felt that I can do better up to my expectations this because no body is 100% perfect.

Yes sir Why not, You can Contact to my present employer but not right now, as he is not aware with my job search. Once I selected you can, I am confident that You will get positive response.

I have faced many tough challenges in my life, specially personal life. The most important thing I came out with and learned is (be strong) and be sure that this specific situation has a period a full stop it will end anyway. It's the only reason makes me wake up with a smile on my face everyday no matter what.
Sir, I plan to improve my career progress each and every day. Even during this interview I am learning things which will be useful for my career. I learn from my mistakes and try to correct my self each and every day.
1. Everyone holds their good and bad points and that makes them human.

2. Strong points: approachable, spontaneous, energetic, punctual, having ability to prioritize things well, very supportive for his team members, a good motivator, strong in networking and an ambitious person. I have learnt a lot under him and he has always been helpful to me.

3. As far as weak ness is concerned, I got very little time to judge him but whatever time I have spent with him, did not encountered anything big enough that hampers a team growth and opportunities. He gave enough opportunities to each of us to grow as much as we can by pushing ourselves to highest limits.

4. I am grateful to him.
My Boss I an intelligent and hard worker, open minded and even though he is the boss he used to take suggestions from us and personally and professionally I have learned a lot from him. I thank him for motivating me and I never ever saw any negativeness in him.
I have done my best work in my previous position. Even whatever I am today that is the result of my past hard work. I have improved myself a lot by doing hard work and that experience will inspire me to lot to do well in future.
Yes sir it may be good but according to me I will be the most loyal person for the organization. I am sure that I will be in one of the top hard workers in the organization.
To report to a younger person than me is not a issue for me. I have felt nothing uncomfortable with that. I feel myself that it should not be an issue of matter for any one.
I never see the age of the person I see the talent in between them, that is why he is respectable. I feel comfortable.
For me my work is important, I don't bother to whom I'm reporting to, whether he/she is younger or old older, to me everybody are the employees so it will not effect my work.
I would like to add some more mistakes in my portfolio as Mistakes make experience and learning. I left lots of opportunities due to having fear of frailer so if it is possible I would like to attempt all the opportunities which I have left behind.
We really can't change our past but get lot of things to learn from the mistakes we have made in our past. So we can avoid those mistakes in future & be prepare for better future.
Money is important to every one. But my point is we improve our knowledge day by day. Money come easily. Money is base of human life. No one can said, I don't won't money. We working for a money. Money gives a luxurious life and develop our humanity in high level. We help some one money will obviously wanted in life. So money fill my career.
Well. Earning money is not a big deal for me but getting talented is more important.

I think that when we are young, we should try to learn more not to earn more.

So as I am young, work experience and knowledge is more important for me than money right now.


Monday, 1 April 2013

How to Get Response from the web page...


HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(orderno);

        HttpWebResponse httppres = (HttpWebResponse)myReq.GetResponse();
        System.IO.StreamReader sr = new System.IO.StreamReader(httppres.GetResponseStream());
        string responseString = sr.ReadToEnd();
        sr.Close();
        return responseString;

Thursday, 7 March 2013

Bind All Sheets data in Excel to Grid View...And Graphical representation for Excel Data


protected void Page_Load(object sender, EventArgs e)
    {

        GetExcelSheetNames(@"D:\Raj Collection For ASP Examples\Test1\FolderPath\raj.xls");
    }

    private void GetExcelSheetNames(string excelFile)
    {
        OleDbConnection objConn = null;
        System.Data.DataTable dt = null;
        try
        {
            DataSet ds = new DataSet();
            // Connection String.
            String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + excelFile + ";Extended Properties=Excel 8.0;";
            // Create connection.
            objConn = new OleDbConnection(connString);
            // Opens connection with the database.
            objConn.Open();
            // Get the data table containing the schema guid, and also sheet names.
            dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
            if (dt == null)
            {
                return;
            }
            String[] excelSheets = new String[dt.Rows.Count];
            int i = 0;
            // Add the sheet name to the string array.
            // And respective data will be put into dataset table
            foreach (DataRow row in dt.Rows)
            {
                excelSheets[i] = row["TABLE_NAME"].ToString();
                OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + excelSheets[i] + "]", objConn);
                OleDbDataAdapter oleda = new OleDbDataAdapter();
                oleda.SelectCommand = cmd;
                oleda.Fill(ds, "TABLE");
                i++;
            }
         
         
         
            // Bind the data to the GridView
            GridView1.DataSource = ds;
            GridView1.DataBind();
            Chart1.DataSource = ds.Tables[0].DefaultView;
            Chart1.DataBind();
            Chart1.Series[0].XValueMember = "StudentName";
            Chart1.Series[0].YValueMembers = "Marks";
            Chart1.Series[0].ToolTip = "Completed : " + "#PERCENT";//--Used to show tooltip
            Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;

            Chart2.DataSource = ds.Tables[0].DefaultView;
            Chart2.DataBind();
            Chart2.Series[0].XValueMember = "Grade";
            Chart2.Series[0].YValueMembers = "Marks";
            Chart2.Series[0].ToolTip = "Completed : " + "#PERCENT";//--Used to show tooltip
            Chart2.ChartAreas[0].Area3DStyle.Enable3D = true;

            Chart3.DataSource = ds.Tables[0].DefaultView;
            Chart3.DataBind();
            Chart3.Series[0].XValueMember = "StudentName";
            Chart3.Series[0].YValueMembers = "Marks";
            Chart3.Series[0].ToolTip = "Completed : " + "#PERCENT";//--Used to show tooltip
            Chart3.ChartAreas[0].Area3DStyle.Enable3D = true;

            Chart4.DataSource = ds.Tables[0].DefaultView;
            Chart4.DataBind();
            Chart4.Series[0].XValueMember = "StudentName";
            Chart4.Series[0].YValueMembers = "Marks";
            Chart4.Series[0].ToolTip = "Completed : " + "#PERCENT";//--Used to show tooltip
            Chart4.ChartAreas[0].Area3DStyle.Enable3D = true;

            Chart5.DataSource = ds.Tables[0].DefaultView;
            Chart5.DataBind();
            Chart5.Series[0].XValueMember = "StudentName";
            Chart5.Series[0].YValueMembers = "Marks";
            Chart5.Series[0].ToolTip = "Completed : " + "#PERCENT";//--Used to show tooltip
            Chart5.ChartAreas[0].Area3DStyle.Enable3D = true;
            Session["Table"] = ds.Tables[0];
           
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message);

        }
        finally
        {
            // Clean up.
            if (objConn != null)
            {
                objConn.Close();
                objConn.Dispose();
            }
            if (dt != null)
            {
                dt.Dispose();
            }
        }
    }

Tuesday, 19 February 2013

How to display records from the Excel Sheet..


 OleDbConnection conn = new OleDbConnection("Provider= Microsoft.ACE.OLEDB.12.0;Data Source=D:/Raj Collection For ASP Examples/Raj Practise Examples/Excel InsertData/Test3.xls; Extended Properties=\"Excel 12.0;HDR=YES;\"");
        conn.Open();
        string s = "Select * from [Sheet1$]";
        OleDbCommand cmd = new OleDbCommand(s, conn);
        DataSet ds = new DataSet();
        OleDbDataAdapter da = new OleDbDataAdapter(cmd);

        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
        conn.Close();

How to insert data from the User Panel to Excel Sheet

Take Two text boxes like id,name and take one button
Copy these code in Button Click event..


 if (TextBox1.Text != string.Empty && TextBox2.Text != string.Empty)
        {
            System.Data.OleDb.OleDbConnection MyConnection;
            System.Data.OleDb.OleDbCommand myCommand = new System.Data.OleDb.OleDbCommand();
            string sql = null;
            MyConnection = new System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='D:/Raj Collection For ASP Examples/Raj Practise Examples/Excel InsertData/Test3.xls';Extended Properties=Excel 8.0;");
            MyConnection.Open();
            myCommand.Connection = MyConnection;
            sql = "Insert into [Sheet1$] (TitleId,TitleName) values('" + TextBox1.Text + "','" + TextBox2.Text + "')";
            myCommand.CommandText = sql;
            myCommand.ExecuteNonQuery();
            MyConnection.Close();
            TextBox1.Text = string.Empty;
            TextBox2.Text = string.Empty;
        }



How to Store Excel Data into Sql Server..

Create one table in Sql server with What ever excel sheet have field names...


 //Create connection string to Excel work book
        string excelConnectionString =
        @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/Raj Collection For ASP Examples/Raj Practise Examples/Excel InsertData/Test3.xls;Extended Properties=""Excel 8.0;HDR=YES;""";

        //Create Connection to Excel work book
        OleDbConnection excelConnection =
        new OleDbConnection(excelConnectionString);

        //Create OleDbCommand to fetch data from Excel
        OleDbCommand cmd = new OleDbCommand
        ("Select [TitleId],[TitleName] from [Sheet1$]",
        excelConnection);

        excelConnection.Open();
        OleDbDataReader dReader;
        dReader = cmd.ExecuteReader();

        SqlBulkCopy sqlBulk = new SqlBulkCopy(con);
        con.Open();
        sqlBulk.DestinationTableName = "ExcelData";
        sqlBulk.ColumnMappings.Add("TitleId", "TitleId");
        sqlBulk.ColumnMappings.Add("TitleName", "TitleName");
        sqlBulk.WriteToServer(dReader);
        con.Close();

How to Retrieve data From the Excel

Copy These code and paste in to Button Event...Take One grid View then Bind the data....




OleDbConnection conn = new OleDbConnection("Provider= Microsoft.ACE.OLEDB.12.0;Data Source=D:/Raj Collection For ASP Examples/Raj Practise Examples/Excel InsertData/Test4.xls; Extended Properties=\"Excel 12.0;HDR=YES;\"");
        conn.Open();
        string s = "Select * from [Sheet1$] where TitleId='" + TextBox1.Text + "'";
        OleDbCommand cmd = new OleDbCommand(s, conn);
        DataSet ds = new DataSet();
        OleDbDataAdapter da = new OleDbDataAdapter(cmd);

        da.Fill(ds);

        dt.Columns.Add(new System.Data.DataColumn("TitleId", typeof(String)));
        dt.Columns.Add(new System.Data.DataColumn("TitleName", typeof(String)));
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            dr = dt.NewRow();
            dr[0] = ds.Tables[0].Rows[i]["TitleId"].ToString();
            dr[1] = ds.Tables[0].Rows[i]["TitleName"].ToString();
            dt.Rows.Add(dr);
        }

        GridView1.DataSource = dt;
        GridView1.DataBind();
        conn.Close();

How to Write Date into Excel From Sql Server

First Download Microsoft.Office.Interop.Excel.dll From the Internet...
While Programming on Excel we need to use these dll.
In Button Event Copy These Code...


Excel.Application excelApp = new Excel.Application();
        excelApp.Visible = true;
        Excel.Workbook newWorkbook = excelApp.Workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
        string workbookPath = @"D:/Raj Collection For ASP Examples/Raj Practise Examples/Excel InsertData/Test1.xls";
        Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath,
            0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "",
            true, false, 0, true, false, false);
        //-----jusqu ici il marche, il a ouvert excel------
        Excel.Sheets excelSheets = excelWorkbook.Worksheets;
        string currentSheet = "Sheet1";
        Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);
        // ici c'est l'etablissement de la conx avc la base

        con.Open();
        SqlDataAdapter sda = new SqlDataAdapter("SELECT MainMenuId,MainMenu FROM MainMenu", con);
        DataSet ds = new DataSet();
        sda.Fill(ds);
        //recuperer resultat requete
        for (int i = 1; i < ds.Tables[0].Rows.Count; i++)
        {
            String resultatreq = ds.Tables[0].Rows[i - 1]["MainMenuId"].ToString().Trim();
            String resultatreq1 = ds.Tables[0].Rows[i - 1]["MainMenu"].ToString().Trim();
            //ecrire le resultat dans excel

            Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("A" + (i + 1), "A" + (i + 1));
            excelCell.Value2 = resultatreq;
            Excel.Range excelCell1 = (Excel.Range)excelWorksheet.get_Range("B" + (i + 1), "B" + (i + 1));
            excelCell1.Value2 = resultatreq1;

            Excel.Range excelCell2 = (Excel.Range)excelWorksheet.get_Range("A" + 1, "A" + 1);
            excelCell2.Value2 = "TitleId";

            Excel.Range excelCell3 = (Excel.Range)excelWorksheet.get_Range("B" + 1, "B" + 1);
            excelCell3.Value2 = "TitleName";
        }