How to merge excel-sheet in one sheet in asp.net


Description:-

In this blog I am going to explain how we could merge two different excel sheets into one using C# programming. For this demo I have taken a console application, check the below steps and use the code as it is. Here I have Created Sample Code to Understand how to Merger Two different file in to one.

1. First of all create two different Excel files and put some data into those sheets, remember to RENAME the worksheet name because same name will create Error while processing Merging process.
2. Add References. At minimum, you will need below references.

using Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.Runtime.InteropServices;

Now Create Method and Apply below code for Merge two ExcelSheet into One.

private static void MergeExcelNew()
{
  Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
  Workbook bookDest = null;
  Worksheet sheetDest = null;
  Workbook bookSource = null;
  Worksheet sheetSource = null;
  string sTempPath = @"C:\Users\UmesH\Desktop\J.xlsx";
  string sFinalPath = @"C:\Users\UmesH\Desktop\H.xlsx";
  try
  {
    //OpenBook
    bookDest = app.Workbooks._Open(sFinalPath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
    bookSource = app.Workbooks._Open(sTempPath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
    sheetSource = (Worksheet)bookDest.Worksheets[1];
    sheetDest = (Worksheet)bookSource.Worksheets[1];

    //CopyData
    sheetDest = (Worksheet)bookDest.Worksheets[1];
    int ss = bookDest.Sheets.Count;
    sheetSource.Copy(After: bookSource.Worksheets[ss]);
    bookDest.Close(false, Missing.Value, Missing.Value);

    //Save
    bookDest.Saved = true;
    bookSource.Saved = true;
  }
  catch (Exception ex)
  {
    Console.WriteLine("Exception Occured while releasing object " + ex.ToString());
  }
  finally
  {
    app.ActiveWorkbook.Save();
    app.Quit();
    Console.WriteLine("Done");
    Console.ReadLine();
    Marshal.ReleaseComObject(app);
    GC.Collect();
  }
}

Now Call this Method in Main method.

static void Main(string[] args)
{
  MergeExcelNew();
}

Output:-
Now run your Application and you will get First ExcelSheet Sheet into Second ExcelSheet Sheet with Same name. So you don’t need to Enter Manually data from Different ExcelSheet.

Convert comma separated string to table in SQL

Convert comma separated string to table in SQL

Description:-

How to convert comma separated nvarchar to table records in sql. Create function to convert comma Delimited value string to table.

Incoming search terms

Convert Comma Separated String to Table in SQL, How to convert comma separated NVARCHAR to table, separate comma separated values and store in table in sql, (Delimited) String to Table in SQL Server, Comma Delimited Value To Table – SQL Server, Convert comma separated string to table, Split a string to a table using SQL, Converting Comma Separated Value to Rows, Convert comma separated string to list sql server, SQL convert table to comma delimited string.

Following are the steps to Convert comma separated string to table in SQL

Create function:- 

Create new function in your database and then execute it with suitable parameter. Over here we used two parameter one is String and another one is Delimiter that used for split the string.

CREATE FUNCTION [dbo].[CSVToTable]
(
@String VARCHAR(8000),
@Delimiter CHAR(1)
)    

RETURNS @temptable TABLE (
items VARCHAR(8000)
)

AS
BEGIN
 DECLARE @idx INT
 DECLARE @slice VARCHAR(8000)

 SELECT @idx = 1
 IF len(@String)<1 or @String is null  RETURN
 
 WHILE @idx!= 0
 BEGIN
  SET @idx = charindex(@Delimiter,@String)
  IF @idx!=0
   SET @slice = left(@String,@idx - 1)
  ELSE
   SET @slice = @String

  IF(len(@slice)>0)
   INSERT INTO @temptable(Items) VALUES( @slice  )

  SET @String = right(@String,len(@String) - @idx)
  IF len(@String) = 0 BREAK
 END
RETURN
END

EXECUTE FUNCTION

After creating function you need to execute it. Pass only two parameter “String” and “Delimiter” as per created function.

SELECT *FROM CSVToTable('A-B-C-D','-')

Output:-


A
B
C
D

get last row from excel-sheet in dynamics ax


Description:-

In this article we will see about how to count last row from excel-sheet. if we want last row from excel for perform any operation like progress-bar, we want to set progress-bar on file upload or insert into table from excel-sheet then we want how may records are inserted or ho many records are reaming then we want last row. or else more operation. here is the code to get last row from excel-sheet.

Code:-

staticvoid getlastrow(Args _args)
{
    SysExcelApplication application,excelApp;
    SysExcelWorkbooks workbooks,excelWorkBooks;
    SysExcelWorkbook workbook;
    SysExcelWorksheets worksheets;
    SysExcelWorksheet worksheet,excelWorkSheet;
    SysExcelCells cells,excelCells;
    COMVariantType type,type1;
    COM        excelCOM;
    Int lastRow;
    ;
    application = SysExcelApplication::construct();
    workbooks = application.workbooks();
    filename = "<Excel-sheet path>";
    try
    {
        workbooks.open(filename);
    }
    catch (Exception::Error)
    {
        throw error("File cannot be opened.");
    }
    workbook = workbooks.item(1);
    worksheets = workbook.worksheets();
    worksheet = worksheets.itemFromNum(3);
    cells = worksheet.cells();
    excelCOM = cells.comObject();
    excelCOM = excelCOM.SpecialCells(11);  // 11 = xlCellTypeLastCell
    lastRow = excelCOM.Row();              // Row for the last cell
    info(strFmt("Last rows - %1",lastRow));
    application.quit();
}

Create folder in directory in asp.net


Description:-

In this article we will see about how to create folder on directory using directory class in dot net. here I have given simple example to read and easily understand. I have used directory class to create folder on server. It’s pretty easy to create folder in server directory in dot net using directory class.

Default.aspx:-

<div>
  <asp:TextBox ID="txtDirName" runat="server" />
  <asp:Button ID="btnCreate" runat="server" Text="Create Folder" OnClick="btnCreate_Click" />
  <asp:Label ID="lblMessage" runat="server" />
</div>

Default.aspx.cs:-


protected void btnCreate_Click(object sender, EventArgs e)
{
  string directoryPath = Server.MapPath("~/") + txtDirName.Text;
  if (!Directory.Exists(directoryPath))
  {
    Directory.CreateDirectory(directoryPath);
    lblMessage.Text = "Directory created";
  }
  else
    lblMessage.Text = "Directory already exists";
}

Write data in text file in dynamics ax

Write data in text file in dynamics ax

Description:-

In this article we will see about how to write data into text file. You can use the TextIo X++ class or the CLRInterop. Here are 2 X++ jobs to demonstrate both approaches. you can see my other article for how to read and write text file using different classes in dynamics Ax.

Code:-

static void Job_TextIO(Args _args)
{
    TextIo textIo;
    #File
    ;
    textIo = new TextIo(@"C:\textIOtest.txt", #IO_WRITE);
    textIo.write("Line 1\n");
    textIo.write("Line 2");
}

static void Job_StreamWriter(Args _args)
{
    System.IO.StreamWriter sw;
    InteropPermission perm = new InteropPermission(InteropKind::ClrInterop);
    ;
    perm.assert();
    sw = new System.IO.StreamWriter(@"C:\test.txt");
    sw.WriteLine("Line 1");
    sw.WriteLine("Line 2");
    sw.Flush();
    sw.Close();
    sw.Dispose();
    CodeAccessPermission::revertAssert();
}

Container in dynamics ax

Description:-

In this article we will see about container. Here I have created Job to Dynamically set data in Container and read data from Container. Here I have used for loop to set data in container and when data load in container and after we want to display it on infolog for that I have create another for loop based on container length and get data from container. Here when we run we can little different data in container if we want some value and we don’t we want some data from container that we can set it in ax to get whatever we want from container. Here is the simple demo example to read and set data in container in ax.

Example:-

Static void Container_Check(Args _args)
{
  container daxConBeta;
  str charHolder = 'ume12sh';
  str 20 pa;
  real  r1 = 101200,r;
  real LengthCon;
  int i,j;
  ;
  for(i = 1; i<= 5; i++)
  {
    daxConBeta += str2con("Test");
    daxConBeta += str2con(int2str(i));
  }
  LengthCon = conLen(daxConBeta);
  for(i = 1; i<= LengthCon; i = i+2)
  {
    pa =conpeek(daxConBeta,i);
    info(strFmt("%1",pa));
    r=conPeek(daxConBeta,i+1);
    info(strFmt("%1",r));        
  }
  info(strFmt("Container Length - %1",LengthCon));
  info(strFmt("Container daxConBetaconPeek() values are :- %1, %2,%3,%4,%5,Length - %6", 
                conPeek(daxConBeta, 1),
                conPeek(daxConBeta, 2),
                conPeek(daxConBeta, 3),
                conPeek(daxConBeta, 4),
                conPeek(daxConBeta, 5),
                LengthCon));
}

Output:-



How to replace data in container OR How to use conpoke() in dynamics ax

How to replace data in container OR How to use conpoke() in dynamics ax

Description:-

In this Article we will see about container in ax. There are more functionality in container to do in ax it’s like array to store data in container and read it from container. A container can be stored in the database as a dataBasecoloumn created through AOT especially used to store images/files as a blob. For example assignment of a container to another container variable and container functions such as conIns(), conDel(), conPoke(), += etc. are actually creating a new copy of the container. Here is the demo Example of container in Ax.

conpoke :- Use conpoke to replace (poke) an item in a container.

EX:- container conPoke(container container,int start,anytype element,...)

static void conPokeExample(Args _arg)
{
    container c1 = ["item1", "item2", "item3"];
    container c2;
    int i;
 
    void conPrint(container c)
    {
        for (i = 1 ; i <= conLen(c) ; i++)
        {
            print conPeek(c, i);
        }
    }
    ;
    conPrint(c1);
    c2 = conPoke(c1, 2, "PokedItem");
    print "";
    conPrint(c2);
    pause;
}

Generate special charactor in SQL

Description:-

In this article we will see how to generate special character in Sql. Here is the simple tricks to generate special character in Sql. However I got it from sqlauthority. Here is the Mistry to generate it in Sql. Here is the character set which is appropriate to generate special character. 

SELECT 'ú' --'ALT + 163'
SELECT '¾' --'ALT + 0190'
SELECT 'Æ' --'ALT + 146'
SELECT 'þ' --'ALT + 0254'


You use above characters in your html or SQL Editor in SQL Server Management Studio and you would be able to generate those special characters. 

NOTE: - I received a follow up question by a user who was not able to go find an ALT key on the keyboard. Here is a hint, the two keys which are besides your longest key (space-bar) with ALT mentioned on it, is the ALT key. Apple keyboards use the option key in place of the ALT key.

get current system date time in SQL Server

get current system date time in SQL Server

Description:-

In this article we will see about how to get system date and time using Sql server. there are many functions to get current system date time in Sql server. here is the different ways to get current system date and time.
 
SELECT 'SYSDATETIME' AS FunctionName, SYSDATETIME() AS DateTimeFormat
SELECT 'SYSDATETIMEOFFSET', SYSDATETIMEOFFSET()
SELECT 'SYSUTCDATETIME', SYSUTCDATETIME()
SELECT 'CURRENT_TIMESTAMP', CURRENT_TIMESTAMP
SELECT 'GETDATE', GETDATE()
SELECT 'GETUTCDATE', GETUTCDATE() 

validating the domain or check whether user is enabled in dynamics ax


Description:-

This job gets the user related information only if domain is correct and user is enabled.

static void validateDomain_getDetails(Args _args)
{
    xAxaptauserManager um = new xAxaptauserManager();
    xAxaptaUserdetails userdetails;
    ;
    if(um.validateDomain('DomainName'))
    {
        userdetails =  um.getDomainUser('DomainName','username');
        if(userdetails.isUserEnabled(0))
        {
            printuserdetails.getUserName(0);
            printuserdetails.getUserMail(0);
            printuserdetails.getUserSid(0); 
            pause;
        } 
    }
}
Compile Application using axbuild command in Ax

Compile Application using axbuild command in Ax

Description:-

The new way to compile AX application through command prompt is introduced in AX 2012 CU7. This is much faster than the traditional way of compiling. It takes approx. 1-2 hours to compile depends on your server

1.       Run command prompt by Run As Administrator.
2.       go to  C:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin\.
3.       Use command to run compilation. axbuild xppcompileall.


Auto refresh page using javascript in asp.net


Description:-

In this article we will see about how to auto refresh page using JavaScript In asp.net. Here I have create simple we application to display auto refresh with page onload in web page. Using JavaScript call the function to refresh the page in asp.net. for start the timer and stop the timer for after refreshing page. We can set time for when we want to refresh the page onload event.

Default.aspx:-

<body onload="InitializeTimer(5)">
  <form id="form1"runat="server">
  <div>
    <font>This page will be refreshed after
      <asp:Label ID="lbltime" runat="server" Style="font-weight: bold;"></asp:Label>
    </font>
    <font>seconds</font>
  </div>
  </form>
</body>

JavaScript Code:-

<script type="text/javascript" language="JavaScript">
  var secs;
  var timerID = null;
  var timerRunning = false;
  var delay = 1000;

  function InitializeTimer(seconds) {
  //Set the length of the timer, in seconds
            secs = seconds;
            StopTheClock();
            StartTheTimer();
        }

  function StopTheClock() {
  if (timerRunning)
                clearTimeout(timerID);
            timerRunning = false;
        }

  function StartTheTimer() {
  if (secs == 0) {
                StopTheClock();
  // Here's where you put something useful that's
  // supposed to happen after the allotted time.
  // For example, you could display a message:
                window.location.href = window.location.href;
                alert("Your page has been refreshed !!!!");
            }
  else {
  //self.status = 'Remaining: ' + secs;
                document.getElementById("lbltime").innerText = secs + " ";
                secs = secs - 1;
                timerRunning = true;
                timerID = self.setTimeout("StartTheTimer()", delay);
            }
        }
</script>

Default.aspx.cs:-
Or else we can set time on code behind to start timer when page load. Here is the sample code to start time on code behind.

protected void Page_Load(object sender, EventArgs e)
{
  try
  {
    lit.Text = "<script>InitializeTimer(" + 5 + ");</script>";
  }
  catch (Exception Ex)
  {
    Response.Write(System.Reflection.MethodInfo.GetCurrentMethod().Name + "-->" + Ex.Message);
  }
}

Ajax animation demo using animation extender in asp.net part-1


Description:-

In this article we will Create animation demo using Ajax Control in webpage. To create animation extender register Ajax Control toolkit in your webpage and use Control what you want to use in your webpage. Here I have use panel control to display label control and use animation extender to display animation in my webpage. Animation Extender has many properties to create animation any webpage. Here I have created sample animation extender to create animation using Ajaxcontrol.

OnmouseOver Property to create when we mouse over in panel then it will create animation on panel what we have to do in animation extender. Here I the sample code what I have use in the animation extender.

Default.aspx:-

<div>
  <ajaxtoolkit:ToolkitScriptManager ID="Sc1" runat="server"></ajaxtoolkit:ToolkitScriptManager>
  <asp:Panel ID="AnimationPnl" runat="server" BackColor="#FCF4BF" Height="250px" Width="400px" BorderWidth="1">
    <asp:Label ID="lblText" runat="server" Text="PAY ATTENTION TO THIS PANEL TO SEE ANIMATIONS EFFECTS!!!" Font-Bold="True" ForeColor="#303174"> </asp:Label>
  </asp:Panel>
  <br /><br />
  <asp:LinkButton ID="lnkClick" runat="server" Text="Get Mouse on Me!!"></asp:LinkButton>
  <ajaxtoolkit:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID="lnkClick">
    <Animations>
      <OnMouseOver>     
        <Resize AnimationTarget="AnimationPnl"  Width="200" Height="200" Unit="px" />  
      </OnMouseOver>  
    </Animations>
  </ajaxtoolkit:AnimationExtender>
</div>
Make Dangerous Virus or Delete all files from C:\ Drive

Make Dangerous Virus or Delete all files from C:\ Drive

Description:-

In this post I will teach you to make simple yet very powerful or you can say dangerous computer virus using a batch file. No software is required to make this virus, Notepad is enough for it. The good thing about this virus is it is not detected by any Antivirus. 

What this virus will do?  
 
You will create this virus using batch file programming. This virus will delete the C Drive completely. The good thing about this virus is that it is not detected by antivirus.
 
How to make the virus?

   1. Open Notepad and copy below code into it. 

@Echo off
Del C:\ *.* |y

   2. Save this file as virus.bat (Name can be anything but .bat is must)
   3. Now, running this file will delete all the content of C Drive.

Warning: Please don't try to run on your own computer or else it will delete all the content of your C Drive. I will not be responsible for any damage done to your computer.

How to use progress bar in dynamics ax Part1

Description:-

In this article we will see about how to get prime Number from 1 to 10000. It’s little difficult to get. Here I have used progress bar to get prime number for little display information while counting prime number between those two numbers what we have set for from to to in code. Here I have used progress bar for information it counting the prime number and after done it will display information in Infolog window. In Progressbar it pretty easy to set and we can set animation in Progressbar to display in windows. Here is the simple Job code to Used Progressbar in Ax.

Code:-

Static void Progress_PrimeNumber(Args _args)
{
    #avifiles
    boolean checkPrime,_showProgess = true;
    SysOperationProgress progressBar = newSysOperationProgress();
    int counter,out;
    ;
    counter = 1;
    out = 10000;
    while(counter < out)
    {
        checkPrime = ((counter mod2)!=0&& (counter mod3) !=0);
        if(checkPrime)
        {
            info(strfmt("its a prime number %1",counter));
        }
        progressBar.incCount();
        progressBar.setCaption(strfmt("Generating the prime number for %1",counter));
        progressBar.setAnimation(#aviUpdate);
        //#AviFindFile);
        //progress.setAnimation(#AviTransfer);
        progressBar.setText(strfmt("Processing %1 out of %2",counter,out));
        counter++;
        progressBar.update(true);
    }
}

Output:-

Ajax animation demo using animation extender in asp.net part-3

Description:-

Here is the article to create animation in webpage. In this article we will Create animation demo using Ajax Control in webpage. To create animation extender register Ajax Control toolkit in your webpage and use Control what you want to use in your webpage. Here I have use panel control to display label control and use animation extender to display animation in my webpage. Animation Extender has many properties to create animation any webpage. Here I have created sample animation extender to create animation using Ajaxcontrol.

OnmouseOver Property to create when we mouse over in panel then it will create animation on panel what we have to do in animation extender. Here I the sample code what I have use in the animation extender.

Default.aspx:-

<div>
  <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
  <div>
    <asp:Panel ID="pnAnimation" runat="server" CssClass="movingPanel">
      <b>Animated Using AnimationExtender</b>
    </asp:Panel>
    <br />
    <asp:AnimationExtender ID="AnimationExtender1" runat="server" TargetControlID="pnAnimation">
      <Animations>
        <OnClick>
          <Sequence>
            <%-- Disable the button --%>
            <EnableAction Enabled="false" />
            <%-- Show the flyout --%>
            <Parallel AnimationTarget="pnAnimation" Duration=".3" Fps="25">
              <Move Horizontal="150" Vertical="-25" />
              <Resize Height="260" Width="280" />
              <Color AnimationTarget="pnAnimation" 
                PropertyKey="backgroundColor"
                StartValue="#68CB8C" EndValue="#84BDE7"  />
            </Parallel>
          </Sequence>
        </OnClick>
      </Animations>
    </asp:AnimationExtender>
  </div>
</div>

Here I have used Style for panel Control in webpage layout.

<style>
  .movingPanel
  {
    position: fixed;
    height: 200px;
    width: 150px;
    top: 300px;
    left: 200px;
    border-width: 1px;
    border-color: Black;
    border-style: double;
    background-color: #5ADD83;
  }
</style>

Ajax animation demo using animation extender in asp.net part-2


Description:-

In this article we will Create animation demo using Ajax Control in webpage. To create animation extender register Ajax Control toolkit in your webpage and use Control what you want to use in your webpage. Here I have use panel control to display label control and use animation extender to display animation in my webpage. Animation Extender has many properties to create animation any webpage. Here I have created sample animation extender to create animation using Ajaxcontrol.

OnmouseOver Property to create when we mouse over in panel then it will create animation on panel what we have to do in animation extender. Here I the sample code what I have use in the animation extender.

Default.aspx:-

<div>
  <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
  <asp:Panel ID="AnimationPnl" runat="server" BackColor="#FCF4BF" Height="250px" Width="400px" BorderWidth="2">
    <asp:Label ID="lblText" runat="server" Text="PAY ATTENTION TO THIS PANEL TO SEE ANIMATIONS EFFECTS!!!" Font-Bold="True" ForeColor="#303174"></asp:Label>
  </asp:Panel>
  <br />
  <br />
  <asp:LinkButton ID="lnkClick" runat="server" Text="Click Me!!"></asp:LinkButton>
  <ajaxtoolkit:AnimationExtender ID="AnEx1" runat="server" TargetControlID="lnkClick">
    <Animations>
      <OnClick>
        <Sequence>
          <Color 
            AnimationTarget="AnimationPnl" 
            Duration="3000" 
            Property="style" 
            PropertyKey="backgroundColor"
            StartValue="#CE0E3F" 
            EndValue="#FFFFFF" /> 
          </Sequence>
      </OnClick>
    </Animations>
  </ajaxtoolkit:AnimationExtender>
</div>

How to add logo on retail pos receipt in dynamics ax 2012


Description:-

In this article we will see how to create logo in receipt format in Ax Retail POS Receipt Design. Here I have Create Article to Show you how to Design Receipt format in Ax Receipt Profile to Print it.

Printing a company logo on receipts is a common practice which can easily be implemented in the AX for Retail POS.  The process described below applies whether you are using AX 2009 or AX 2012.  Note this only applies when using an OPOS printer.  See the update note at the end for further details.

The first step is to add the Logo field to your receipt’s layout.  To add this, open the Receipt designer for the desired receipt.  Select either the Header or Footer section using one of the buttons in the lower left, as these are the only areas where the logo is permitted.  Next, locate the Logo object in the list of available fields and drag it to the desired location within the layout.  The area highlighted in red shows where the logo has been placed in a sample layout.  Click the Save button, close the designer, and run the scheduler jobs to push changes to the terminal. 


The second step is providing the logo image.  The logo must be a .bmp image.  You may need to experiment with image dimensions and file size to find those that work best with your printer.  If you are having trouble with this you may need to contact the printer manufacturer for specifications. Attached to this post is a sample RetailPOSLogo.bmp image that I commonly use in testing. 

Once you have a BMP image that you are ready to test, you need to do one of two things in order for it to be printed:
  1. Name the file RetailPOSLogo.bmp and copy it into the \Retail POS\ folder, along with the POS.exe. The image must have this exact name.
  2. Using utilities provided by the manufacturer, upload the image into the printer’s NVRAM.  There may be additional configuration needed on the printer if you choose this route.  For assistance with this process consult the printer’s documentation or manufacturer.  I suggest testing with the RetailPOSLogo.bmp process and if desired attempt the printer upload later.  This way you have a known working image and would be limited to troubleshooting printer setup.
The last step in this process is testing.  Start the Point of Sale, login, and perform an operation to print the modified receipt.  For example, if you have just modified the Customer receipt all you need to do is ring up an item and perform the payment operation.  If all has gone well you should see the Logo image on your receipt.

A few final notes on receipt logo printing:
  • If your receipt layout changes don’t seem to be getting saved, make sure you are clicking the Save button. Closing the layout designer without clicking Save will discard your changes unlike most AX forms.
  • If you’ve noticed the Logo settings from the screenshot below in the Hardware profile, do not be confused.  These settings are deprecated and do not impact the printing of the Logo.

  • If desired, the above settings could be implemented through customization of the receipt printing logic using the POS Plug-ins
  • With some printers, we have seen that adding the Logo object to the receipt layout will cause receipts to print blank, or with just the receipt barcode if barcodes are enabled.  This occurs when the printer cannot print the image, or if there is not an image found.  To resolve this you just need to find an image that works, or remove the logo object from your layout.

Update:-  

I recently had an inquiry on the topic of printing logos in which a Windows printer was being used.  The printing of a logo image is only done when using an OPOS printer.  This may be a potential customization in the Peripherals service available through the Retail Plug-ins as that is where you can find the code used to print with both OPOS and Windows devices.

How to drop store procedure in SQL


Description:-

in  this article we will see about how to drop storeprocedure using sql query. here is simple demo example to remove all store procedure from Database. after also you can see a list of procedure removed from your database.

SQL Query:-

DECLARE @spName varchar(1000)

DECLARE spcurs cursOR
FOR SELECT [name] FROM sys.objects WHERE TYPE = 'p' -- p defines the stored procedure

OPEN spcurs
FETCH NEXT FROM spcurs INTO @spName
while @@fetch_status = 0
BEGIN
    exec('DROP PROCEDURE ' + @spName)
    print 'Deleted procedure -> '+ @spName
    FETCH NEXT  FROM spcurs INTO @spName
END
CLOSE spcurs

DEALLOCATE spcurs

How to add click event for dynamic button element in jquery in asp.net


Description:-

Bind click event on dynamically added element HTML tags. Here this article explains how to add click event for dynamic added element. In jQuery for click event we can simply use .click() method which works fine, but when you add dynamic HTML and try to achieve click event for it, then there you face problem .i.e .click() is not working. Yeah you are right .click() is not working because it’s not loaded on dom , so now what we are going to do is we use  .on() method which is added in jQuery v 1.7.

The .on() method attaches event handlers to the currently selected set of elements in the jQuery object.

Prototype : .on( events [, selector ] [, data ], handler )

Description: Attach an event handler function for one or more events to the selected elements.

Example 1: Click event for dynamically added li tags
HTML Markup: 

Here we having UL list tag and then dynamically LI tag gets added. So now how to achieve click event on this dynamically added element in Jquery.

XHTML:-

<ul id="myUL">
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
  <li>Four</li>
</ul>

Here myUL– is the id which is already there on dom when the page loads.

JavaScript:

Now by using .on() will able to bind the click event on dynamically added HTML tag .i.e click event for dynamic li tags.

<script type="text/javascript">
   $('#myUL').on('click', 'li', function () {
     console.log('you clicked me');
     alert("Clicked");
   });
</script>

Example 2: JQuery click event for dynamically added row and divs .i.e. tr 
HTML Markup:- 

Here we have HTML table, and dynamically tr table rows get added, so now we want to bind click event for dynamic tr table rows using jQuery .on() method

XHTML:-

<table id="myTable">
  <tr>
      <td>row 1 col 1</td>
      <td>row 1 col 2</td>
  </tr>
  <tr>
      <td>row 2 col 1</td>
      <td>row 2 col 2</td>
  </tr>
</table>

JavaScript:

Here myTable is my table id, and on each dynamically added trwe can bind click event as shown in below code.

<script type="text/javascript">
   $('#myTable').on('click', 'tr', function () {
       alert($(this).text());
     });
   //Same for div
   //Note: .itemName is the class of dynamically added element under parent div container .i.e myDIv
   $('#myDiv').on('hover', '.itemName', function () {
       alert($(this).text());
     });
</script>

Here myDiv – is parent Div id,  .itemName- each span which have itemName call will alert its data.

For older jQuery library  – 1.7
We can use .live() (method is deprecated in 1.7 and removed in 1.9)

Prototype : .live(events, handler )

Description: Attach an event handler for all elements which match the current selector, now and in the future.
JavaScript:-

<script type="text/javascript">
   $('#myUL li').live('click', function () {
      alert('hello!');
    });
</script>

Note:  Use of the .live() method is no longer recommended since later versions of jQuery offer better methods that do not have its drawbacks.
Hope you enjoyed this tutorial. If you have any recommendations, please let us know what you think in the comment section below! See you again next time!