Wednesday, 23 January 2013

string array sorting along with diifernt values like l15,l17,l2,r3




//string array sorting along with diifernt values like l15,l17,l2,r3

//here xlabels contain the list of varibles

  Array.Sort(xlabels, new AlphanumComparatorFast());


public class AlphanumComparatorFast : IComparer
    {
        public int Compare(object x, object y)
        {
            string s1 = x as string;
            if (s1 == null)
            {
                return 0;
            }
            string s2 = y as string;
            if (s2 == null)
            {
                return 0;
            }

            int len1 = s1.Length;
            int len2 = s2.Length;
            int marker1 = 0;
            int marker2 = 0;

            // Walk through two the strings with two markers.
            while (marker1 < len1 && marker2 < len2)
            {
                char ch1 = s1[marker1];
                char ch2 = s2[marker2];

                // Some buffers we can build up characters in for each chunk.
                char[] space1 = new char[len1];
                int loc1 = 0;
                char[] space2 = new char[len2];
                int loc2 = 0;

                // Walk through all following characters that are digits or
                // characters in BOTH strings starting at the appropriate marker.
                // Collect char arrays.
                do
                {
                    space1[loc1++] = ch1;
                    marker1++;

                    if (marker1 < len1)
                    {
                        ch1 = s1[marker1];
                    }
                    else
                    {
                        break;
                    }
                } while (char.IsDigit(ch1) == char.IsDigit(space1[0]));

                do
                {
                    space2[loc2++] = ch2;
                    marker2++;

                    if (marker2 < len2)
                    {
                        ch2 = s2[marker2];
                    }
                    else
                    {
                        break;
                    }
                } while (char.IsDigit(ch2) == char.IsDigit(space2[0]));

                // If we have collected numbers, compare them numerically.
                // Otherwise, if we have strings, compare them alphabetically.
                string str1 = new string(space1);
                string str2 = new string(space2);

                int result;

                if (char.IsDigit(space1[0]) && char.IsDigit(space2[0]))
                {
                    int thisNumericChunk = int.Parse(str1);
                    int thatNumericChunk = int.Parse(str2);
                    result = thisNumericChunk.CompareTo(thatNumericChunk);
                }
                else
                {
                    result = str1.CompareTo(str2);
                }

                if (result != 0)
                {
                    return result;
                }
            }
            return len1 - len2;
        }
    }

Friday, 4 January 2013

list of products add once stored procedure

/*
list of products add once
ProductID = 106,107,109,210
*/

Create PROCEDURE [dbo].[Nop_Product](Procedure name)
@ProductID varchar(max),
@UserName varchar(max)
as
begin
declare @CustomerID int
select @CustomerID=CustomerID from [Nop_Customer] where Username=@UserName
declare @CsvIds varchar(max)
declare @index int=0
set @CsvIds=@ProductID
select @index=CHARINDEX(',',@CsvIds,0)
--While loop started
while (@index >0 )
begin
declare @CUR_ProductID int = CONVERT(INT,(SUBSTRING (@CsvIds,1,@index-1)))
if not exists (select * from [Nop_Product_Customer_Mapping] where [ProductId] =@CUR_ProductID)
begin
INSERT INTO [dbo].[Nop_Product_Customer_Mapping]
           ([ProductId]
           ,[CustomerID])
     VALUES
           (@CUR_ProductID ,
            @CustomerID)
         
            end
            else
            begin
            update [dbo].[Nop_Product_Customer_Mapping] set [CustomerID]=@CustomerID where [ProductId]=@CUR_ProductID
            end
--print SUBSTRING (@CsvIds,1,@index-1)
set @CsvIds=SUBSTRING (@CsvIds,@index+1,LEN (@CsvIds))
select @index=CHARINDEX(',',@CsvIds,1)
end

if not exists (select * from [Nop_Product_Customer_Mapping] where [ProductId] =@CsvIds)
begin
INSERT INTO [dbo].[Nop_Product_Customer_Mapping]
           ([ProductId]
           ,[CustomerID])
     VALUES
           (@CsvIds ,
            @CustomerID)
         
            end
            else
            begin
            update [dbo].[Nop_Product_Customer_Mapping] set [CustomerID]=@CustomerID where [ProductId]=@CsvIds
            end
END

Datagridview multiple select Checkbox


  dgvChangeUserName.DataSource = _objProducts.GetAllProductsinUserName(mam._objAdmin.CustomerID, mam._objAdmin.IsAdmin);
Rectangle rect = dgvChangeUserName.GetCellDisplayRectangle(0, -1, true);
                rect.Y = 3;
                rect.X = rect.Location.X + (rect.Width / 4)-2;
                CheckBox checkboxHeader = new CheckBox();
                checkboxHeader.Name = "checkboxHeader";
                //datagridview[0, 0].ToolTipText = "sdfsdf";
                checkboxHeader.Size = new Size(18, 18);
                checkboxHeader.Location = rect.Location;
                checkboxHeader.CheckedChanged += new EventHandler(checkboxHeader_CheckedChanged);
                dgvChangeUserName.Controls.Add(checkboxHeader);




  void checkboxHeader_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox cbx=(CheckBox) sender;

            if (dgvChangeUserName.Rows[0].Cells.Count > 2)
            {
                dgvChangeUserName.Rows[0].Cells[2].Selected = true;
                dgvChangeUserName.Rows[0].Cells[2].Selected = false;
            }
            for (int intLoop = 0; intLoop < dgvChangeUserName.Rows.Count; intLoop++)
            {
               
                dgvChangeUserName.Rows[intLoop].Cells[0].Value = cbx.Checked;
             
            }
           
        }

Wednesday, 2 January 2013

First Time Load Display Popup


 if (document.cookie == "")  //Checking Whether First time or not
{
            document.cookie = 1;
}

set time intrvel to display popup



syntax:
setTimeout("Function",time);

Example
setTimeout("jQuery('#dialog').hide();$('#mask').hide();", 20000);

Tuesday, 1 January 2013

Open Popup in html


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple JQuery Modal Window from Queness</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script>

<script type="text/javascript">
    $(document).ready(function () {

        var id = '#dialog';

        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set heigth and width to mask to fill up the whole screen
        $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

        //transition effect
        $('#mask').fadeIn(1000);
        $('#mask').fadeTo("slow", 0.8);

        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();

        //Set the popup window to center
        $(id).css('top', winH / 2 - $(id).height() / 2);
        $(id).css('left', winW / 2 - $(id).width() / 2);

        //transition effect
        $(id).fadeIn(2000);

        //if close button is clicked
        $('.window .close').click(function (e) {
            //Cancel the link behavior
            e.preventDefault();

            $('#mask').hide();
            $('.window').hide();
        });

        //if mask is clicked
        $('#mask').click(function () {
            $(this).hide();
            $('.window').hide();
        });

    });

</script>

<style type="text/css">
body {
font-family:verdana;
font-size:15px;
}

a {color:#333; text-decoration:none}
a:hover {color:#ccc; text-decoration:none}

#mask {
  position:absolute;
  left:0;
  top:0;
  z-index:9000;
  background-color:#000;
  display:none;
}
#boxes .window {
  position:absolute;
  left:0;
  top:0;
  width:440px;
  height:400px;
  display:none;
  z-index:9999;
  padding:10px;
}

#boxes #dialog {
  width:375px;
  height:203px;
  padding:10px;
  background-color:#ffffff;
}

</style>
</head><body>
<h2><a href="http://www.queness.com/">Simple jQuery Modal Window Examples from Queness WebBlog</a></h2>
<div style="font-size: 10px; color: rgb(204, 204, 204);">Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License.</div>

<div id="boxes">
<div style="top: 10.5px; left: 50.5px; display: none;" id="dialog" class="window">

Simple Modal Window |
<a href="#" class="close">Close it</a>

<img src="sample.jpg"  alt="Sample" height="400px" width="500px"/>
</div>
<!-- Mask to cover the whole screen -->
<div style="width: 1478px; height: 602px; display: none; opacity: 0.8;" id="mask"></div>
</div>
</body>
</html>