Tuesday 20 June 2023

VFP GETFLDSTATE function| check field modify or not in vfp | table field...



IF GETFLDSTATE("CITY") = 1
MESSAGEBOX("City Not Modified",0+64,"Manoj Kalla +919869166077")
ENDIF 

IF GETFLDSTATE("CITY") = 2
MESSAGEBOX("Yes, City Modified",0+64,"Manoj Kalla +919869166077")
=TABLEUPDATE(.T.)
ENDIF 

Thursday 15 June 2023

vfp Getenv function | get windows folder path in vfp | system user name ...


?GETENV("APPDATA")    : Application's User setting and configuration data.

?GETENV("COMPUTERNAME") : Computer Name
?GETENV("USERDOMAIN")
?GETENV("LOGONSERVER") : Server Name / Computer name
?GETENV("USERDOMAIN_ROAMINGPROFILE")


?GETENV("CommonProgramFiles") : ProgramFilesx86
?GETENV("CommonProgramFiles(x86)") : ProgramFilesx86
?GETENV("CommonProgramW6432") : CommonFiles 
?GETENV("ComSpec") : CMD.exe path

?GETENV("HOMEDRIVE") : Return Base drive / Windows Installation Drive
?GETENV("SystemDrive") : Return main system drive / windows drive

?GETENV("HOMEPATH") : Return \User\Admin path
?GETENV("LOCALAPPDATA") : Return Local AppData Path= C:\Users\Admin\AppData\Local

?GETENV("OneDrive") : Return OneDrive path.
?GETENV("OneDriveConsumer") : Return OneDrive path.

Friday 14 April 2023

vfp log error | vfp9 save runtime error in dbf | log error saving into t...




You can log the error in dbf table with the help of following code.


ERRLOG.PRG code

ON ERROR DO errHandler WITH ;
   ERROR(), MESSAGE(), MESSAGE(1), PROGRAM(), LINENO()
   clear
USE nodatabase  

PROCEDURE errHandler
   PARAMETER merror, mess, mess1, mprog, mlineno
   CLEAR
   ? 'Error number: ' + LTRIM(STR(merror))
   ? 'Error message: ' + mess
   ? 'Line of code with error: ' + mess1
   ? 'Line number of error: ' + LTRIM(STR(mlineno))
   ? 'Program with error: ' + mprog
   USE ErrorLog
   APPEND BLANK
   replace errorno WITH LTRIM(STR(merror))
   replace errmsg WITH mess
   replace errline WITH mess1
   replace lineno WITH LTRIM(STR(mlineno))
   replace progname WITH mprog
   replace errdatetim WITH DATETIME()
ENDPROC




Structure for table:   ERRORLOG.DBF
Number of data records:       7       
Date of last update:          04/09/23
Code Page:                    1252    
  Field   Field Name              Type                            Width       Dec     Index   Collate       Nulls        Next        Step
      1   ERRORNO                 Character                          10                                        No
      2   ERRMSG                  Character                         254                                        No
      3   ERRLINE                 Character                         254                                        No
      4   LINENO                  Character                          10                                        No
      5   PROGNAME                Character                          50                                        No
      6   ERRDATETIM              DateTime                            8                                        No
** Total **                                                         587



vfp log error, vfp9 save runtime error in dbf, log error saving into table, error save in dbf vfp

Sunday 2 April 2023

01 vfp error handle | Error handling in VFP9 | display error runtime in ...



Error Handling in Visual Foxpro VFP9

First.prg Code:

ON ERROR Do MsgDisp with ERROR(),MESSAGE()
CLEAR
USE FirstRec



MsgDisp.prg Code:

PARAMETERS ErrNo, Msg
MESSAGEBOX("Error No."+STR(ErrNo)+CHR(13)+CHR(13)+Msg,0+16,"Manoj Kalla Training")

Sunday 26 March 2023

06. aspnet mvc Create page with Entity Framework | Asp.Net MVC create re...


Asp.Net MVC CRUD 

Controller Code:  FreindController.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcTeach.Controllers
{
    public class FriendController : Controller
    {
        dbMbkTestEntities db = new dbMbkTestEntities();
        // GET: Friend
        public ActionResult Index()
        {
            var FrndList = (from a in db.tblFriends select a).ToList();
            return View(FrndList);
        }


        [HttpGet]
        public ActionResult Create()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Create(tblFriend frnd)
        {
            tblFriend newFrnd = new tblFriend();
            newFrnd.FriendName = frnd.FriendName;
            newFrnd.City = frnd.City;
            newFrnd.Mobile = frnd.Mobile;
            db.tblFriends.Add(frnd);
            db.SaveChanges();
            return RedirectToAction("Index");
        }
    }
}



@model MvcTeach.tblFriend

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>


@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>tblFriend</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @*<div class="form-group">
            @Html.LabelFor(model => model.FriendID, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.FriendID, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.FriendID, "", new { @class = "text-danger" })
            </div>
        </div>*@

        <div class="form-group">
            @Html.LabelFor(model => model.FriendName, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.FriendName, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.FriendName, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.City, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.City, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.City, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Mobile, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Mobile, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Mobile, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>

05. aspnet mvc index page List entity framework | asp.net mvc list page ...



CONTROLLER CODE:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MvcTeach.Controllers
{
    public class FriendController : Controller
    {
        dbMbkTestEntities db = new dbMbkTestEntities();
        // GET: Friend
        public ActionResult Index()
        {
            var FrndList = (from a in db.tblFriends select a).ToList();
            return View(FrndList);
        }

    
    }
}



INDEX.CSHTML page code



@model IEnumerable<MvcTeach.tblFriend>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table class="table">
    <tr>
        @*<th>
            @Html.DisplayNameFor(model => model.FriendID)
        </th>*@
        <th>
            @Html.DisplayNameFor(model => model.FriendName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.City)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Mobile)
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        @*<td>
            @Html.DisplayFor(modelItem => item.FriendID)
        </td>*@
        <td>
            @Html.DisplayFor(modelItem => item.FriendName)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.City)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Mobile)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.FriendID }) |
            @Html.ActionLink("Details", "Details", new { id=item.FriendID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.FriendID })
        </td>
    </tr>
}

</table>






Saturday 18 March 2023

Create Graph vfp save in General field DBF table | Save graph in dbf | S...


Before starting first create table ABC.DBF

Name -  Character  -100
gGraph - General 



============================================

Code: Graph2.prg
SET DATE BRITISH
#DEFINE TAB CHR(9)
#DEFINE CRLF CHR(13)+CHR(10)
#DEFINE DOGS_LOC "Dogs"
#DEFINE CATS_LOC "Cats"


_cliptext = ""+TAB+CATS_LOC+TAB+DOGS_LOC+CRLF+"1994"+TAB+"11"+TAB+"22"+CRLF+"1995"+TAB+"33"+TAB+"44"+CRLF+"1996"+TAB+"55"+TAB+"55"+CRLF

use abc
APPEND blank
replace name WITH TTOC(DATETIME())
APPEND GENERAL gGraph CLASS "MSGraph.Chart" DATA _Cliptext

Saturday 11 March 2023

Create graph using graph wizard in visual foxpro | Visual foxpro graph using wizard



CREATE CURSOR grafthis (QuarterType c(6), SalesAmt n(5,2))
INSERT INTO grafthis VALUES ("Q1", 100.45)
INSERT INTO grafthis VALUES ("Q2", 160.90)
INSERT INTO grafthis VALUES ("Q3", 120.09)
INSERT INTO grafthis VALUES ("Q4", 250.65)
DO HOME(1)+"Wizards\WZGraph.App" 

Tuesday 7 March 2023

grid export to xlsx | Convert Visual Foxpro Grid to XLSX Excel | VFP 9 G...




LOCAL lCXlsxPath

lCXlsxPath = SYS(5)+ADDBS(SYS(2003))+"InvoSum.xlsx"

thisform.vfpxworkbookxlsx1.SaveGridToWorkbookEx(thisform.grid1,lcxlsxpath,.T.,"InvoSummary")

Friday 3 March 2023

zatca qr code C# AspNet | QR Code ZATCA AspNet WebForm | zatca qr gene...



Zatca.aspx  UI QR CodeFile Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="zatca.aspx.cs" Inherits="ManojKallaTutorial.zatca" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
            <asp:Image ID="imgQrCode" runat="server" />
            <br />
        <br />  
        <asp:Button ID="btnSubmit" runat="server" Text="Generate QR Code"  OnClick="btnSubmit_Click"/>
    </div>
    </form>
</body>
</html>






Zatca.aspx.cs  QR CodeFile Code:


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

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

        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string SellerName = "Abudl Khalid Yeman";
            string TaxNo = "191786123125987";
            DateTime DtVal = DateTime.Now;
            Double TotalAmt = 100000;
            Double TaxAmt = 1000;
            string GenFile = GenerateQrCode(SellerName, TaxNo, DtVal, TotalAmt, TaxAmt);
            imgQrCode.ImageUrl = "http://localhost:50358/QR/"+GenFile;
       }

        public string GenerateQrCode(string SellerName, string TaxNo, DateTime DtTime,Double Total, Double Tax )
        {
            string FileName = DateTime.Now.ToString("yyyyMMddhhmmssfff") + ".png";
            TLVCls tlv = new TLVCls(SellerName, TaxNo, DtTime, Total, Tax);
            System.Drawing.Image img =  tlv.toQrCode();
            img.Save(@"C:\Users\Admin\Documents\visual studio 2015\Projects\EFDemoWebForm\Entity\QR\" + FileName, System.Drawing.Imaging.ImageFormat.Png);
            return FileName;
        }


    }
}




TLVCls Class File Code:


using System;
using System.Text;
using System.Drawing;
using System.Collections.Generic;
using ZXing;
using ZXing.Common;

namespace ManojKallaTutorial
{
    public class TLVCls
    {
        byte[] Seller;
        byte[] VatNo;
        byte[] dateTime;
        byte[] Total;
        byte[] Tax;

        public TLVCls(String Seller, String TaxNo, DateTime dateTime, Double Total, Double Tax)
        {
            this.Seller = Encoding.UTF8.GetBytes(Seller);
            this.VatNo = Encoding.UTF8.GetBytes(TaxNo);

            this.dateTime = Encoding.UTF8.GetBytes(dateTime.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'"));
            this.Total = Encoding.UTF8.GetBytes(Total.ToString());
            this.Tax = Encoding.UTF8.GetBytes(Tax.ToString());
        }

        private String getasText(int Tag, byte[] Value)
        {
            return (Tag).ToString("X2") + (Value.Length).ToString("X2") + BitConverter.ToString(Value).Replace("-", string.Empty);
        }

        private byte[] getBytes(int id, byte[] Value)
        {
            byte[] val = new byte[2 + Value.Length];
            val[0] = (byte)id;
            val[1] = (byte)Value.Length;
            Value.CopyTo(val, 2);
            return val;
        }

        private String getString()
        {
            String TLV_Text = "";
            TLV_Text += this.getasText(1, this.Seller);
            TLV_Text += this.getasText(2, this.VatNo);
            TLV_Text += this.getasText(3, this.dateTime);
            TLV_Text += this.getasText(4, this.Total);
            TLV_Text += this.getasText(5, this.Tax);
            return TLV_Text;
        }

        public override string ToString()
        {
            return this.getString();
        }

        public String ToBase64()
        {
            List<byte> TLV_Bytes = new List<byte>();
            TLV_Bytes.AddRange(getBytes(1, this.Seller));
            TLV_Bytes.AddRange(getBytes(2, this.VatNo));
            TLV_Bytes.AddRange(getBytes(3, this.dateTime));
            TLV_Bytes.AddRange(getBytes(4, this.Total));
            TLV_Bytes.AddRange(getBytes(5, this.Tax));
            return Convert.ToBase64String(TLV_Bytes.ToArray());
        }

        public Bitmap toQrCode(int width = 250, int height = 250)
        {

            BarcodeWriter barcodeWriter = new BarcodeWriter
            {
                Format = BarcodeFormat.QR_CODE,
                Options = new EncodingOptions
                {
                    Width = width,
                    Height = height
                }
            };
            Bitmap QrCode = barcodeWriter.Write(this.ToBase64());

            return QrCode;
        }


    }

}

Wednesday 1 March 2023

VFP how to create image button | VFP Image Command Button | Image on command button


Image on Command Button in Visual Foxpro 9 - VFP9| Image Button in Visual Foxpro 9 - VFP9



Double Click on Form goto Init


thisform.btnDelete.Picture = CURDIR()+"\DELETE.BMP"


Advantage of using CURDIR() is while vfp application run it will take current path automatically.


Don't use Picture property directly of command button. This recorded as hardcoded path in form.



Thank You








Tuesday 28 February 2023

05 Delete Record using Entity Framework Asp Net WebForm C# | Remove Record Hard Delete using Entity Framework Asp.Net WebForm


05 Delete Record using Entity Framework Asp Net WebForm C#, Remove Record Hard Delete using Entity Framework Asp.Net WebForm





Delete Page ASPX Code   (Delete-Friend.aspx):

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="delete-friend.aspx.cs" Inherits="ManojKallaTutorial.delete_friend" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
         <table>
            <tr>
                <td>
                    Fullname
                </td>
                <td>
                    <asp:TextBox ID="txtFullName" runat="server" ReadOnly="true"></asp:TextBox>
                </td>
            </tr>

            <tr>
                <td>
                    City
                </td>
                <td>
                    <asp:TextBox ID="txtCity" runat="server" ReadOnly="true"></asp:TextBox>
                </td>
            </tr>

            <tr>
                <td>
                    Mobile
                </td>
                <td>
                    <asp:TextBox ID="txtMobile" runat="server" ReadOnly="true"></asp:TextBox>
                </td>
            </tr>

            <tr>
                <td>
                    <asp:Button ID="btnSubmit" runat="server" Text="Delete" OnClick="btnSubmit_Click" />
                </td>
                <td>
                    <a href="Friend.aspx">Back</a>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>



Delete Page C# Code (Delete-Friend.aspx.cs):


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

namespace ManojKallaTutorial
{
    public partial class delete_friend : System.Web.UI.Page
    {
        dbMbkTestEntities db = new dbMbkTestEntities();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString.Count > 0)
                {
                    Int32 FIdInt;
                    string FID = Convert.ToString(Request.QueryString["fid"]);
                    if (!string.IsNullOrEmpty(FID))
                    {
                        FIdInt = Convert.ToInt32(FID);
                        var friendDet = (from a in db.tblFriends where a.FriendID == FIdInt select a).FirstOrDefault();
                        if (friendDet != null)
                        {
                            txtFullName.Text = friendDet.FriendName;
                            txtCity.Text = friendDet.City;
                            txtMobile.Text = friendDet.Mobile;
                        }
                    }
                    else
                    {
                        Response.Redirect("friend.aspx?msg=invalidfriend");
                    }

                }
                else
                {
                    Response.Redirect("friend.aspx?msg=NoFriendFoundOrInvalidFriend");
                }

            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            if (Request.QueryString.Count > 0)
            {
                Int32 FIdInt;
                string FID = Convert.ToString(Request.QueryString["fid"]);
                if (!string.IsNullOrEmpty(FID))
                {
                    FIdInt = Convert.ToInt32(FID);
                    var friendDet = (from a in db.tblFriends where a.FriendID == FIdInt select a).FirstOrDefault();
                    if (friendDet != null)
                    {
                        db.tblFriends.Remove(friendDet);
                        db.SaveChanges();
                        Response.Redirect("friend.aspx?msg=successfullydeleted");
                    }
                }
                else
                {
                    Response.Redirect("friend.aspx?msg=invalidfriend");
                }

            }
            else
            {
                Response.Redirect("friend.aspx?msg=NoFriendFoundOrInvalidFriend");
            }


        }
    }
}


Tuesday 14 February 2023

05.vfp icard print | Print specific record from report | print icard from visual foxpro.


05.vfp icard print | Print specific record from report

In this video you will learn how to print ICard using visual foxpro reporting and print specific record.

Github link: