Tuesday 31 May 2022

vfp fast report from prg file | create report from code in foxpro | repo...




CLOSE TABLES all
SELECT 0
USE friends

CREATE REPORT FriendRepo FROM Friends COLUMN FIELDS FriendName,City,Mobile
REPORT FORM friendrepo preview

Monday 23 May 2022

VFP Extract DBF Field structure to DBF File | Save Dbf Field Structure to Dbf vfp





DbfStru.Dbf

PARAMETERS DbfVal
**** Pass DBF name only, without extension.
CLOSE TABLES ALL 

IF  FILE("&DbfVal"+".dbf") = .T.
SELECT 0
USE "&DbfVal" ALIAS db
gnFieldCount = AFIELDS(gaFieldsArray)
SELECT 0
USE DbfStru  EXCLUSIVE
DELETE FOR DbfName = DbfVal
PACK 
mFieldName = ""
mFieldType = ""
mFieldSize = ""
FOR nCount = 1 TO gnFieldCount 
SELECT db
mFieldName = gaFieldsArray(nCount,1)
mFieldType = TYPE(mFieldName)
mFieldSize = FSIZE(mFieldName)


SELECT DbfStru
APPEND BLANK
Replace DbfName WITH DbfVal
Replace FieldName WITH mFieldName
Replace FieldType WITH mFieldType
Replace FieldSize WITH mFieldsize

ENDFOR 


RETURN DbfVal+" Structure Generated Successfully."
ELSE
RETURN DbfVal+" Not Found."
ENDIF 

Sunday 8 May 2022

convert number integer to date in javascript | jquery datatable asp.ne...



WebForm1.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="JavascriptDateTimeConversion.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>jQuery DataTable</title>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<link href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.2/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
    $(function () {
        $.ajax({
            type: "POST",
            url: "WebForm1.aspx/ContactList",
            data: '{}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccess,
            failure: function (response) {
                alert(response.d);
            },
            error: function (response) {
                alert(response.d);
            }
        });
    });
    function OnSuccess(response) {
        $("[id*=contact]").DataTable(
        {
            bLengthChange: true,
            lengthMenu: [[5, 10, -1], [5, 10, "All"]],
            bFilter: true,
            bSort: true,
            bPaginate: true,
            data: response.d,
            columns: [{ 'data': 'ContactID'},
                      { 'data': 'FullName' },
                      { 'data': 'EmailID' },
                      {
                        'data': 'DOB', "render": function (data) {
                            return getDateString(data);
                        }
                    }]
        });
    };

    function getDateString(date) {
        var dateObj = new Date(parseInt(date.substr(6)));
        var options = { year: "numeric", month: "numeric", day: "numeric" };
        return dateObj.toLocaleDateString("en-GB");
    }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="margin-top:100px;">
        <table id="contact" class="table table-striped table-bordered" >
<thead style="background-color:#DC5807; color:White; font-weight:bold">
<tr style="border:solid 1px #000000">
<td>ContactID</td>
<td>FullName</td>
<td>EmailID</td>
<td>DOB</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
    </div>
    </form>
</body>
</html>




WebForm1.aspx.cs :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

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

        }


        [WebMethod(EnableSession = true)]
        public static List<tblContact> ContactList()
        {
            List<tblContact> tbl = new List<tblContact>();
            dbContactsEntities db = new dbContactsEntities();

            var fld = db.tblContacts.ToList();

            return fld;
        }


    }
}