Saturday 7 October 2017

Hall Ticket Format in HTML CODE

Hall Ticket Format in HTML CODE

Css


<style type="text/css">
        .Mystar
        {
            color: Red;
        }
        .card
        {
            box-shadow: 1px 4px 8px 1px rgba(0, 0, 0, 0.2);
            width: 650px;
            margin: auto;
            text-align: left;
            border: 2px solid;
        }
        button
        {
            border: none;
            outline: 0;
            display: inline-block;
            padding: 8px;
            color: #000;
            background-color: #3e9dff;
            text-align: center;
            cursor: pointer;
            width: 100%;
            font-size: 18px;
            font-weight: bold;
        }
     
        .title
        {
            color: grey;
            font-size: 18px;
        }

    </style>

Tuesday 25 July 2017

Excel upload Student data in database and Validations

Excel upload Student data in database code


Asp.net

<table class="table table-striped table-bordered ">
                 
                        <tr>
                            <td>
                                Select File :
                            </td>
                            <td>
                                <asp:FileUpload ID="FileUpload1" runat="server" ToolTip="Select Only Excel File" />
                            </td>
                            <td>
                                <asp:Button ID="Button1" runat="server" Text="Upload" OnClick="Button1_Click" class="btn btn-success btn-rounded btn-ef btn-ef-6 btn-ef-6c mb-10" />
                            </td>
                         
                        </tr>
                    </table>
                    <table class="table table-striped table-bordered ">
                        <tr>
                            <td>
                                <p>
                                    <asp:Label ID="Label2" runat="server" Text="label"></asp:Label>
                                </p>
                            </td>
                        </tr>
                    </table>
----------------------------------------------------------------------
C# Code
      public string query;
        public string constr;
        public SqlCommand com;
        public SqlConnection con;
          DataSet ds;
        DataTable Dt;
        public void connection()
        {

            constr = ConfigurationManager.ConnectionStrings["oConnContactDb"].ToString();
            con = new SqlConnection(constr);
            con.Open();

        }
private bool ValidateDate(string date)
        {

            try
            {

                string[] dateParts = date.Split('/');

                DateTime testDate = new DateTime(Convert.ToInt32(dateParts[2]), Convert.ToInt32(dateParts[1]), Convert.ToInt32(dateParts[0]));

                return true;

            }

            catch
            {

                return false;

            }

        }
 protected void Button1_Click(object sender, EventArgs e)
        {
            Label2.Visible = true;
            string filePath = FileUpload1.PostedFile.FileName;
            string filename1 = Path.GetFileName(filePath);
            string ext = Path.GetExtension(filename1);

            string type = String.Empty;

            if (!FileUpload1.HasFile)
            {
                Label2.Text = "Please Select File";
            }
            else
                if (FileUpload1.HasFile)
                {

                    try
                    {
                        // Added by vithal wadje for Csharp-Corner contribution

                        switch (ext)
                        {
                            case ".xls":

                                type = "application/vnd.ms-excel";

                                break;

                            case ".xlsx":
                                type = "application/vnd.ms-excel";

                                break;
                        }

                        if (type != String.Empty)
                        {
                            connection();
                            Stream fs = FileUpload1.PostedFile.InputStream;
                            BinaryReader br = new BinaryReader(fs);
                            Byte[] bytes = br.ReadBytes((Int32)fs.Length);
                            string FileName = FileUpload1.FileName;
                            string path = string.Concat(Server.MapPath("~/Document/" + FileUpload1.FileName));

                       
                         
                            FileUpload1.PostedFile.SaveAs(path);
                            OleDbConnection OleDbcon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;");
                            OleDbcon.Open();
                            DataTable dtExcelSchema;
                            dtExcelSchema = OleDbcon.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                            string SheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
                            OleDbcon.Close();
                            OleDbCommand cmd = new OleDbCommand("SELECT * From [" + SheetName + "]", OleDbcon);
                            OleDbDataAdapter objAdapter1 = new OleDbDataAdapter(cmd);
                            ds = new DataSet();
                            objAdapter1.Fill(ds);
                            Dt = ds.Tables[0];


                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {

                              //  if (System.Text.RegularExpressions.Regex.IsMatch(Dt.Rows[i][0].ToString(), "^[a-zA-Z]"))
                                //{
                                    if (Dt.Rows[i][0].ToString() == "")
                                    {

                                        int RowNo = i + 1;

                                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Candate Name in row " + RowNo + "');", true);

                                        return;

                                    }
                               // }
                                else if (!System.Text.RegularExpressions.Regex.IsMatch(Dt.Rows[i][0].ToString(), "^[a-zA-Z]"))
                                {
                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('This Candate Name accepts only alphabetical characters');", true);
                                }
                           

                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {

                                if (Dt.Rows[i][1].ToString() == "")
                                {

                                    int RowNo = i + 1;

                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Father Name in row " + RowNo + "');", true);

                                    return;

                                }
                                else if (!System.Text.RegularExpressions.Regex.IsMatch(Dt.Rows[i][1].ToString(), "^[a-zA-Z]"))
                                {
                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('This Father Name accepts only alphabetical characters');", true);
                                }

                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {

                                string date = DateTime.Parse(Dt.Rows[i][2].ToString()).ToString("dd/MM/yyyy");

                                if (!ValidateDate(date))
                                {
                                    int RowNo = i + 2;

                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Wrong Date format in row " + RowNo + "');", true);

                                    return;
                                }

                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {
                                int VAge;
                                if (int.TryParse(Dt.Rows[i][3].ToString(), out VAge))
                                {
                                    if (Dt.Rows[i][3].ToString() == "")
                                    {

                                        int RowNo = i + 1;

                                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Age in row " + RowNo + "');", true);

                                        return;

                                    }
                                }
                                else
                                {
                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Age in Numeric');", true);
                             
                                }

                             
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {

                                if (Dt.Rows[i][4].ToString() == "")
                                {

                                    int RowNo = i + 1;

                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Gender in row " + RowNo + "');", true);

                                    return;

                                }
                                else if (!System.Text.RegularExpressions.Regex.IsMatch(Dt.Rows[i][4].ToString(), "^[a-zA-Z]"))
                                {
                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('This Gender accepts only alphabetical characters');", true);
                                }
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {

                                if (Dt.Rows[i][5].ToString() == "")
                                {

                                    int RowNo = i + 1;

                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Qualification in row " + RowNo + "');", true);

                                    return;

                                }
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {

                                if (Dt.Rows[i][6].ToString() == "")
                                {

                                    int RowNo = i + 1;

                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter SocialCategory in row " + RowNo + "');", true);

                                    return;

                                }
                                else if (!System.Text.RegularExpressions.Regex.IsMatch(Dt.Rows[i][6].ToString(), "^[a-zA-Z]"))
                                {
                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('This SocialCategory accepts only alphabetical characters');", true);
                                }
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {

                                if (Dt.Rows[i][7].ToString() == "")
                                {

                                    int RowNo = i + 1;

                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Person With Disability in row " + RowNo + "');", true);

                                    return;

                                }
                                else if (!System.Text.RegularExpressions.Regex.IsMatch(Dt.Rows[i][7].ToString(), "^[a-zA-Z]"))
                                {
                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('This Person With Disability accepts only alphabetical characters');", true);
                                }
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {
                                if (Dt.Rows[i][8].ToString() == "")
                                {
                                    int RowNo = i + 1;
                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Complite Address in row " + RowNo + "');", true);
                                    return;
                                }
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {
                                int vBatchId;
                                if (int.TryParse(Dt.Rows[i][9].ToString(), out vBatchId))
                                {
                                    if (Dt.Rows[i][9].ToString() == "")
                                    {
                                        int RowNo = i + 1;
                                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Batch ID in row " + RowNo + "');", true);
                                        return;
                                    }
                                }
                                else
                                {
                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Batch ID in Numeric');", true);
                                }
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {
                                int vAadharCardNo;
                                if (int.TryParse(Dt.Rows[i][10].ToString(), out vAadharCardNo))
                                 {
                                     if (Dt.Rows[i][10].ToString() == "")
                                     {
                                         int RowNo = i + 1;
                                         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter AadharCardNo in row " + RowNo + "');", true);
                                         return;
                                     }
                                 }
                                 else
                                 {
                                     ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Aadhar Card No in Numeric');", true);
                                 }
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {
                                int vphoneNo;
                               // if (int.TryParse(Dt.Rows[i][11].ToString(), out vphoneNo))
                                //{
                                    if (Dt.Rows[i][11].ToString() == "")
                                    {
                                        int RowNo = i + 1;
                                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Phone no in row " + RowNo + "');", true);
                                        return;
                                    }
                                //}
                                    else if (int.TryParse(Dt.Rows[i][11].ToString(), out vphoneNo))
                                    {
                                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Phone no in Numeric');", true);
                                    }
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {
                                if (Dt.Rows[i][12].ToString() == "")
                                {
                                    int RowNo = i + 1;
                                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "InvalidArgs", "alert('Please enter Email id in row " + RowNo + "');", true);
                                    return;
                                }
                            }
                            for (int i = 0; i < Dt.Rows.Count; i++)
                            {
                                DataRow row = Dt.Rows[i];
                                int columnCount = Dt.Columns.Count;
                                string[] columns = new string[columnCount];
                                for (int j = 0; j < columnCount; j++)
                                {
                                    columns[j] = row[j].ToString();
                                }
                                //DateTime Fromdate = Convert.ToDateTime(columns[2]);
                                //string FromformattedDate = Fromdate.ToString("yyyy-MM-dd");
                                DateTime Fromdate = DateTime.Parse(columns[2]);
                                string FromformattedDate = Fromdate.ToString("yyyy-MM-dd");

                                query = "insert into tbl_BioStudentRegstration(Name_of_the_candidate,Fathers_Name,Date_of_birth,Age,Gender,Qualification,SocialCategory,PersonWithDisability,Candidate_Address,Batch_Id,AadharCardNo,Phoneno,Email_Id,TrainingCenter_Id,Register_for)" + "VALUES('" + columns[0] + "','" + columns[1] + "','" + FromformattedDate + "',Convert(varchar(10),'" + columns[3] + "',103),'" + columns[4] + "','" + columns[5] + "','" + columns[6] + "','" + columns[7] + "','" + columns[8] + "','" + columns[9] + "','" + columns[10] + "','" + columns[11] + "','" + columns[12] + "','" + ValidateRequest.TrainingCID + "','Excel')";
                                com = new SqlCommand(query, con);
                               ;
                                com.ExecuteNonQuery();
                                Label2.ForeColor = System.Drawing.Color.Green;
                                Label2.Text = "File Uploaded Successfully";
                                OleDbcon.Close();
                            }

                        }
                        else
                        {
                            Label2.ForeColor = System.Drawing.Color.Red;

                            Label2.Text = "Select Only Excel File having extension .xlsx or .xls ";

                        }
                    }
                    catch (Exception ex)
                    {
                        Label2.Text = "Error: " + ex.Message.ToString();
                    }

                }
        }
------------------------------------------
Example :














Thursday 20 July 2017

Teamwork Inspirational Video | Business Success Motivational Stories

ID Card Design in vertical

CSS
--------
 <style type="text/css">
        .card
        {
            box-shadow: 1px 4px 8px 1px rgba(0, 0, 0, 0.2);
            transition: 0.3s;
            height: 40%;
            width: 55%;
            border-radius: 5px;
            margin: auto;
            text-align: left;
        }
        button
        {
            border: none;
            outline: 0;
            display: inline-block;
            padding: 8px;
            color: #000;
            background-color: #3e9dff;
            text-align: center;
            cursor: pointer;
            width: 100%;
            font-size: 18px;
            font-weight: bold;
        }
       
       
        .title
        {
            color: grey;
            font-size: 18px;
        }
    </style>

HTML Code :
-----------------------------------

<table class="card">
            <tr>
                <td colspan="3">
                    <img src="../images/NTR3.jpg" width="100%;" alt="Logo" />
                </td>
            </tr>
            <tr>
                <td colspan="3" style="text-align: center; background: #fcff4b;">
                    <asp:Image ID="imgpo" Width="100px" Height="90px" Style="margin: 2px 5px -86px 0;
                        float: right;" runat="server" onerror="this.onload = null; this.src='Documents/photo1.jpg';" />
                </td>
            </tr>
            <tr style="background: #fcff4b;">
                <td style="padding-left: 10px; font-weight: bold; width: 120px;">
                    NAME
                </td>
                <td>
                    :
                </td>
                <td style="font-weight: bold;">
                    <asp:Label ID="lblName" runat="server" CssClass="uppercase"></asp:Label>
                </td>
            </tr>
            <tr style="background: #fcff4b;">
                <td style="padding-left: 10px; font-weight: bold;">
                    Father Name
                </td>
                <td>
                    :
                </td>
                <td style="font-weight: bold;">
                    <asp:Label ID="lblFathername" runat="server"></asp:Label>
                </td>
            </tr>
            <tr style="background: #fcff4b;">
                <td style="padding-left: 10px; font-weight: bold;">
                    Course
                </td>
                <td>
                    :
                </td>
                <td style="font-weight: bold;">
                    <asp:Label ID="lblCourse" runat="server"></asp:Label>
                </td>
            </tr>
            <tr style="background: #fcff4b;">
                <td style="padding-left: 10px; font-weight: bold;">
                    Valid Upto
                </td>
                <td>
                    :
                </td>
                <td style="font-weight: bold;">
                    <asp:Label ID="lblValidity" runat="server">9 Months</asp:Label>
                </td>
            </tr>
            <tr style="background: #fcff4b;">
                <td style="padding-left: 10px; font-weight: bold;">
                    Mobile No
                </td>
                <td>
                    :
                </td>
                <td style="font-weight: bold;">
                    <asp:Label ID="lblMobileno" runat="server"></asp:Label>
                </td>
            </tr>
            <tr style="background: #fcff4b;">
                <td style="padding-left: 10px; font-weight: bold;">
                    Blood Group
                </td>
                <td>
                    :
                </td>
                <td style="font-weight: bold;">
                    <asp:Label ID="lblBloodgroup" runat="server"></asp:Label>
                </td>
            </tr>
            <tr style="background: #fcff4b;">
                <td style="padding-left: 10px; font-weight: bold;">
                    ID CARD NO
                </td>
                <td>
                    :
                </td>
                <td style="font-weight: bold;">
                    <asp:Label ID="ldlIDCARDNO" runat="server">0000</asp:Label>
                </td>
            </tr>
            <tr style="background: #fcff4b;">
                <td colspan="3">
                    <img src="../images/IASSIGNATER4.jpg" style="margin: -40px 15px -86px 0; float: right;"
                        alt="sigen" />
                    <span style="float: right;padding: 0px 20px 5px 0;font-weight: bold;">Managing Director</span>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <table>
                        <tr>
                            <td>
                                <img src="../images/DLSC LOGO1.png" alt="Logo" style="width: 75px; height: 75px;
                                    margin: 0 0px 7px 0px;" />
                            </td>
                            <td>
                                <div>
                                    <span style="color: red; font-size: 22px; font-weight: bold;">Dr. Lakshmaiah IAS Study
                                        Circle</span><br />
                                    <span style="color: Black; font-size: 16px; font-weight: bold;">Ashoknagar 'X' Roads,
                                        Hyderabad-500 020.</span><br />
                                    <span style="color: Black; font-size: 16px; font-weight: bold; padding-left: 45px;">
                                        040-27671427 / +91-8500218036</span>
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>

ID Card Formate in horizontal

CSS
 <style type="text/css">
        .card
        {
            box-shadow: 1px 4px 8px 1px rgba(0, 0, 0, 0.2);
            max-width: 300px;
            margin: auto;
            text-align: left;
        }
        button
        {
            border: none;
            outline: 0;
            display: inline-block;
            padding: 8px;
            color: #000;
            background-color: #3e9dff;
            text-align: center;
            cursor: pointer;
            width: 100%;
            font-size: 18px;
            font-weight: bold;
        }
       
       
        .title
        {
            color: grey;
            font-size: 18px;
        }
    </style>


HTML Code :

<table class="card">
            <tr>
                <td colspan="3">
                    <table>
                        <tr>
                            <td>
                                <img src="../images/IAS-logo.png" alt="Logo" style="width: 75px; height: 75px; margin: 0 0px 7px 0px;">
                            </td>
                            <td>
                                <div>
                                    <span style="color: red; font-size: 20px; font-weight: bold;">Dr. Lakshmaiah</span><br />
                                    <span style="color: red; font-size: 20px; font-weight: bold;">IAS Study Circle</span><br />
                                    <span style="color: blue;">040-27671427/8500218036</span>
                                </div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="3" style="text-align: center; background: #3e9dff;">
                    <span style="color: #000; font-weight: bold;">STUDENT ID CARD</span><br />
                    <asp:Image ID="imgpo" Width="100px" Height="100px" Style="margin: 5px 0 0px 0;" runat="server"
                        onerror="this.onload = null; this.src='Documents/photo1.jpg';" />
                </td>
            </tr>
            <tr>
                <td style="padding: 10px 0 1px 10px;">
                    ID NO
                </td>
                <td>
                    :
                </td>
                <td>
                    <asp:Label ID="lblIdno" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 10px;">
                    NAME
                </td>
                <td>
                    :
                </td>
                <td>
                    <asp:Label ID="lblName" runat="server" CssClass="uppercase"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 10px;">
                    Father name
                </td>
                <td>
                    :
                </td>
                <td>
                    <asp:Label ID="lblFathername" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 10px;">
                    Mobile No
                </td>
                <td>
                    :
                </td>
                <td>
                    <asp:Label ID="lblMobileno" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 10px;">
                    Course
                </td>
                <td>
                    :
                </td>
                <td>
                    <asp:Label ID="lblCourse" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 10px;">
                    Category
                </td>
                <td>
                    :
                </td>
                <td>
                    <asp:Label ID="lblCategory" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td style="padding-left: 10px;">
                    Validity
                </td>
                <td>
                    :
                </td>
                <td>
                    <asp:Label ID="lblValidity" runat="server">9 Months</asp:Label>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                  <img src="../images/IASSIGNATER.jpg" style="margin: -18px 15px -86px 0; float: right;"
                        alt="sigen" />
                    <span style="float: right; padding: 5px 20px 5px 0;">Director</span>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <p>
                        <button>
                          rajumsdotnet.blogspot.in</button></p>
                </td>
            </tr>
        </table>
    </div>

Print Java Script and Button

<script type="text/javascript">
        function printContent(el) {
            var restorepage = document.body.innerHTML;
            var printcontent = document.getElementById(el).innerHTML;
            document.body.innerHTML = printcontent;
            window.print();
            document.body.innerHTML = restorepage;
        }
    </script>
 <div id="div1" class="block">
       some text..............
</div>
  <button class="btn btn-success" type="button" onclick="printContent('div1')" style="width: 60px;">
        Print
    </button>

Create Installer File for Windows Application using Visual Studio


Introduction

Here we will learn how to create installer file for windows application in c# using visual studio with examples or create setup file for windows form application in visual studio in c# with example. By using setup project in visual studio setup and deployment section templates we can easily create installer or setup file for windows application in c#.

Description
 
In previous articles I explained set startup page in windows applicationshow the progressbar in windows application in c#, vb.netbind data to datagridview with example in c#, vb.net, export datagridview data to excel with example in c#, vb.netconstructors in c# with examplesdifference between virtual, override, new keywords in c#
 and many articles relating to asp.netc#vb.net and JQuery. Now I will explain how to create installer or setup file for windows form application in visual studio using c# with example.

Hall Ticket Format in HTML CODE

Hall Ticket Format in HTML CODE Css <style type="text/css">         .Mystar         {             color: Red;     ...