Monday 26 February 2018

Get row Index and value inside the table control click on button using jquery

////////////// HTML

<table id="gridid">
  <thead>
    <tr class="ui-widget-header ">
      <th>Head1</th>
      <th>Head2</th>
      <th>Head3</th>
      <th>Head4</th>
      <th>Head5</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><input type='textbox' class="buttoncss"/></td>
      <td><input type='textbox' class="buttoncss"/></td>
      <td><input type='textbox' class="buttoncss"/></td>
      <td><input type='textbox' class="buttoncss"/></td>     
    </tr>
    <tr>
      <td><input type='textbox'/></td>
      <td><input type='textbox'/></td>
      <td><input type='textbox'/></td>
      <td><input type='textbox'/></td>    
    </tr>
  </tbody>
</table>



//////////////////////////// js

<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>

$(document).ready(function(){
           $(".buttoncss").change(function () {
               var vv = $(this).val();
               //alert(vv);
               var $row = $(this).closest("tr");    // Find the row
               var rn = $row.index() + 2
               //  alert(rn);
               $('#gridid tr').eq(rn).find('td').each(function () {
                   $(this).find('input').each(function () {
                       if ($(this).is('input[type="textbox"]')) {
                           $(this).val(vv);
                           // var textval = $(this).val();
                           //  alert(textval);
                       }
                   });
               });

               //$(this).closest('tr').find('td').each(function() {
               //     var textval = $(this).text();
               //     alert(textval);
               // });
           });
       });

Sunday 25 February 2018

Sql Queries for Database help

1. ///// Get store procedure using sql query

       sp_helptext DeleteEmployee



2. ///// Get used spaces in database

   exec sp_spaceused



3. ///// Get ldf and mdf information and path

   EXEC sp_helpdb @dbname= 'Test'



4. ///// Remove or shrink extra space from Database.

DBCC SHRINKDATABASE(Test, 10)



Check used space of all Database using SQL Query

///////////////
SELECT sys.databases.name, CONVERT(VARCHAR,SUM(size)*8/1024)+' MB' AS [Total disk space] FROM sys.databases  
JOIN sys.master_files ON  sys.databases.database_id=sys.master_files.database_id 
GROUP BY sys.databases.name ORDER BY sys.databases.name 







Get Table columns each loop with rowIndex using jquery

<table>
                        <tbody>
                            <tr>
                                <td>
                                    first row
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    second row
                                </td>
                                <td>
                                    second row
                                </td>
                                <td>
                                    second row
                                </td>
                                <td>
                                    second row
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    third row
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    fourth row
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    fifth row
                                </td>
                            </tr>
                        </tbody>
                    </table>





/////////////////////////

   <script>
                        function GetData () {
                            $('table tr').click(function () {
                                alert(this.rowIndex);
                                $('table tr').eq(this.rowIndex).find('td').each(function () {
                                    alert($(this).html());
                                });
                            });
                        }
                    </script>



Monday 12 February 2018

Error Of JSON max length - Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property

//////////// Setting inside web.config file

<system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="999999999"/>
      </webServices>
    </scripting>

  </system.web.extensions>

Friday 9 February 2018

Generate PDF using itextsharp using asp.net with StringBuilder

//////////////// NameSpace

using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;

using iTextSharp.text.html.simpleparser;


protected void Generate_PDF(object sender, EventArgs e)
    {
        //Dummy data for Invoice (Bill).
        string TagName= "Krishraja88";
        int Name= "Krishna";
        DataTable dt = new DataTable();
        dt.Columns.AddRange(new DataColumn[5] {
                            new DataColumn("ProductId", typeof(string)),
                            new DataColumn("Product", typeof(string)),
                            new DataColumn("Price", typeof(int)),
                            new DataColumn("Quantity", typeof(int)),
                            new DataColumn("Total", typeof(int))});
        dt.Rows.Add(101, "Product1", 2010, 5, 10020);
        dt.Rows.Add(102, "Product1", 4100, 2, 8010);
        dt.Rows.Add(103, "Product1", 3010, 3, 9200);
        dt.Rows.Add(104, "Product1", 5150, 2, 11300);

        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter hw = new HtmlTextWriter(sw))
            {
                StringBuilder sb = new StringBuilder();

                //Generate Invoice (Bill) Header.
                sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>");
                sb.Append("<tr><td align='center' style='background-color: #18B5F0' colspan = '2'><b>Order Sheet</b></td></tr>");
                sb.Append("<tr><td colspan = '2'></td></tr>");
                sb.Append("<tr><td><b>Name: </b>");
                sb.Append(Name);
                sb.Append("</td><td align = 'right'><b>Date: </b>");
                sb.Append(DateTime.Now);
                sb.Append(" </td></tr>");
                sb.Append("<tr><td colspan = '2'><b>Tag Name: </b>");
                sb.Append(TagName);
                sb.Append("</td></tr>");
                sb.Append("</table>");
                sb.Append("<br />");

                //Generate Invoice (Bill) Items Grid.
                sb.Append("<table border = '1'>");
                sb.Append("<tr>");
                foreach (DataColumn column in dt.Columns)
                {
                    sb.Append("<th style = 'background-color: #D20B0C;color:#ffffff'>");
                    sb.Append(column.ColumnName);
                    sb.Append("</th>");
                }
                sb.Append("</tr>");
                foreach (DataRow row in dt.Rows)
                {
                    sb.Append("<tr>");
                    foreach (DataColumn column in dt.Columns)
                    {
                        sb.Append("<td>");
                        sb.Append(row[column]);
                        sb.Append("</td>");
                    }
                    sb.Append("</tr>");
                }
                sb.Append("<tr><td align = 'right' colspan = '");
                sb.Append(dt.Columns.Count - 1);
                sb.Append("'>Total</td>");
                sb.Append("<td>");
                sb.Append(dt.Compute("sum(Total)", ""));
                sb.Append("</td>");
                sb.Append("</tr></table>");

                //Export HTML String as PDF.
                StringReader sr = new StringReader(sb.ToString());
                Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
                HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                pdfDoc.Open();
                htmlparser.Parse(sr);
                pdfDoc.Close();
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment;filename=Invoice_" + orderNo + ".pdf");
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Write(pdfDoc);
                Response.End();
            }
        }
    }


Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...