Monday, October 24, 2016

Generate Barcode using C Sharp.


Barcode Font

First we should download the Font from the Url which is given below


Once downloaded follow the below steps.

1. Extract the ZIP file.

2. Click and Execute INSTALL.exe file.

Output:





*.aspx


<div>

        <table class="auto-style1">
            <tr>
                <td>
                    <asp:Label ID="lblNumber" runat="server" style="text-align:right" Text="Enter Number"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtNumber" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>
                    <asp:Button ID="btnGenerate" runat="server" Text="Generate" OnClick="btnGenerate_Click" style="height: 26px" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
                </td>
            </tr>                  
        </table>
        </div>


*.CS


using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication3
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnGenerate_Click(object sender, EventArgs e)
        {
            string barCode = txtNumber.Text;
            System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
            using (Bitmap bitMap = new Bitmap(barCode.Length * 40, 80))
            {
                using (Graphics graphics = Graphics.FromImage(bitMap))
                {
                    Font oFont = new Font("IDAutomationHC39M", 16);
                    PointF point = new PointF(2f, 2f);
                    SolidBrush blackBrush = new SolidBrush(Color.Black);
                    SolidBrush whiteBrush = new SolidBrush(Color.White);
                    graphics.FillRectangle(whiteBrush, 0, 0, bitMap.Width, bitMap.Height);
                    graphics.DrawString("*" + barCode + "*", oFont, blackBrush, point);
                }
                using (MemoryStream ms = new MemoryStream())
                {
                    bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                    byte[] byteImage = ms.ToArray();
                    Convert.ToBase64String(byteImage);
                    imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
                }
                PlaceHolder1.Controls.Add(imgBarCode);
            }
        }
    }
}

Query Shortcuts in SQL Server Management Studio


we can create shorcuts in SQL Management Studio. Some of the shortcuts are predefined,

Examples

"Alt + F1" will execute "sp_help"

"Ctrl + 1" will execute "sp_who".

You can create new shortcuts for your own queries

Go to Sql Server Management Studio

Tools --> Options ---> Environment ---> Keyboard ---> Query Shortcuts


For example, you can create a shortcut for:
Syntax
"Ctrl + 3 " : SELECT * FROM  (single space after from keyword)
Use just the  table name in new query and press "ctrl + 3" and query will executed.





Sunday, October 23, 2016

What is the difference between String and string in C#?


Example :

string s = "uday";

String S = "uday";

string is an alias for System.String. So technically, there is no difference. It's like int vs. System.Int32.

string is a c sharp keyword.

It is recommended to use string any time when you're referring to an object.

e.g :  string name = "uday";

Where as use String if you need to refer specifically to the class. e.g.

string firstname= String.Format("Uday" {0}!", name);

This is the style that Microsoft tends to use in their examples

Note: You must have to include a using System when using String, otherwise you get the following error:

The type or namespace name 'String' could not be found (are you missing a using directive or an assembly reference?)

These are the aliases defined:

Alias     CLR type

string   System.String

sbyte    System.SByte

byte     System.Byte

Note:  String represents the System.String class while the string is the keyword for the System.String that we can use to create string objects.

Thursday, January 21, 2016

Very Useful jQuery code examples

zoom element text on Mouse over 

Javascript Code:

<script type="text/javascript">
        $(document).ready(function () {
            var oldSize = parseFloat($("#ZOOM").css('font-size'));
            var newSize = oldSize * 2;
            $("#ZOOM").hover(
              function () {
                  $("#ZOOM").animate({ fontSizenewSize }, 200);
              },
              function () {
                  $("#ZOOM").animate({ fontSizeoldSize }, 200);
              }
           );
        });
    </script>
    <style type="text/css">
        #ZOOM
        {
        font-size:10pt;
        font-family:'Times New Roman';
        }
    </style>


Design.aspx:




Output:



zoom Image




Output:

disable spacebar


output:

to find out which key was pressed


Design:



Output:


Monday, December 14, 2015

More Information About Git.


If you want to find out the branches which you have created. Please follow the below steps
Go to Visual Studio (Git  ->Git Bash)






Type the below command as

git branch





Find out by author Name:
git log --author="AuthorName"
Example: git log --author="Uday Kumar"
Output: It will display all your commit id and branches which you created from beginning.
 


You can also use regular expressions to create more complex searches. For example, the following command searches for commits by either 
Vijay Bhasker or Krishna Chaitanya

git log --author="
Vijay Bhasker \| Krishna Chaitanya"
Note that the author’s email is also included with the author’s name, so you can use this option to search by email, too.
git branch -a    (shows both remote and local branches.)
git branch -r      shows remote branches



TO DELETE A COMMIT


If you commited one file in commit by mistake and want to delete that commit id (Assume GlobalDataConfiguration.config)
I have modified the GlobalDataConfiguration.config 

 
Now I click on save to commit this File.

Now I have commited the file.

 

Now I want to delete that Commit Id.
You can use the below command
 
git reset --hard HEAD~1
 
The HEAD~1 means the commit before head.
Or, you could look at the output of git log, find the commit id of the commit you want to back up to, and then do this:
git reset --hard <sha1-commit-id>
 
After deleting the commit id you can see that page is getting loaded.
 


Kubernetes

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