Create MySQL Stored Function Custom Counter Number

 This Stored Function will create number with format (ymdcounter) such this 2010150034.


CREATE FUNCTION `{function_name}`() RETURNS varchar(25) CHARSET utf8mb4

    DETERMINISTIC

BEGIN

    DECLARE rowcount INT;

    DECLARE reval VARCHAR(25);

    

    SELECT COUNT(*) INTO rowcount

    FROM {table_name} where {field} = CURDATE();

    SELECT concat( DATE_FORMAT(CURDATE(),'%y%m%d') , LPAD((rowcount + 1),4,'0')) INTO reval;


RETURN reval;

END

Create MySQL Trigger Counter Number Before Save New Data

 before insert


CREATE `{function_name}` BEFORE INSERT ON `{table}` FOR EACH ROW BEGIN

    DECLARE rowcount INT;


    SELECT COUNT(*) 

    INTO rowcount

    FROM {table} where {field} = CURDATE();

SET NEW.{field_to_be_set} = concat( DATE_FORMAT(CURDATE(),'%y%m%d') , LPAD((rowcount + 1),4,'0'));

   

END;

Visual Studio At Publish Web Show Error : Can't find the valid AspnetMergePath

According to this tutorial and it work to me : https://www.it-swarm.net/id/asp.net/tidak-dapat-menemukan-aspnetmergepath-yang-valid-di-visual-web-developer-publish/1069394938/

First Im Open file : Microsoft.Web.Publishing.AspNetCompileMerge.targets
It located at : {Application_PATH}\packages\MSBuild.Microsoft.VisualStudio.Web.targets.14.0.0.3\tools\VSToolsPath\Web\Transform

At this segment :

        Name="GetAspNetMergePath"
      DependsOnTargets="$(GetAspNetMergePathDependsOn)"
      Condition ="'$(GetAspNetMergePath)' != 'false'">
   
        C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\
      aspnet_merge.exe
      $(TargetFrameworkSDKToolsDirectory)
   

               Text="Can't find the valid AspnetMergePath" />
 


I Added script at blue line... After that it work normally.

Java Convert Date Format

I have date data with format "2019-08-25T13:45:13+00:00" and I'd like to convert it into more simple format such 25-Aug-2019

Here's the code:

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); 
String strDate = "";
try {
    //dateInString is variable contain : 2019-08-25T13:45:13+00:00 
    Date date1 = formatter.parse(dateInString.replaceAll("Z$", "+0000")); 
    DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy");    
    strDate = dateFormat.format(date1); //you got the new date format on string
} catch (ParseException e) {
    e.printStackTrace(); 
}



Explanation about date format may be found at this link :
https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Java Android Recyclerview Slide or Swipe to Right or Horizontally

Hi there. Generally, the usage of recyclerview is vertically. This following script, recyclerview is used to display list items that previously uscrolled down to horizontally or swipe to the right.

On Adapter Class create add this variable :

private RecyclerView rvItemList; 
private RecyclerView.LayoutManager layoutManager; 
private RecyclerView.Adapter adapterList;

after looping creating listData :

mContext = this; // Context

rvItemList = (RecyclerView) findViewById(R.id.rv_list); //recyclerview
rvItemList.setHasFixedSize(true); 
layoutManager = new LinearLayoutManager(mContext);
rvItemList.setLayoutManager(layoutManager);
adapterQuestions = new RvQuizFormAdapter(listData, mContext);
 
//vertical or horizontal located on this options rvItemList.setLayoutManager( 
     new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false)
);
rvItemList.setAdapter(adapterQuestions);

Done !!

More discussion on comment below.

C dotnet Linq Adds a Condition if Not Empty Value

To remind me

This post contains a custom LINQ database query that will includes conditions if there are exist variables and ignores conditions on empty variables.

Following is an example in one method:


/* returning json value
 * with three conditions : vesselId, portCode, filterYear
 */

public JsonResult GetEvents(Decimal? vesselId, string portCode, string filterYear)
        {
            using (dbEntities dc = new dbEntities()) //define entities
            {
                var events = new List(); //define variable on searching table


                if(vesselId == 0) { vesselId = null; } //state variable condition to null value
                if (portCode.Equals("0")) { portCode = null; }//state variable condition to null value

                var qry = from sched in dc.TABLE select sched; //starting query

                if (vesselId != null) //state first condition if not null
                {
                    qry = qry.Where(n => n.VSL_ID== vesselId);
                }
                if ( !String.IsNullOrEmpty(portCode))//state second condition if not null
                {
                    qry = qry.Where(n => n.PORT.Equals(portCode));
                }
                if (!String.IsNullOrEmpty(filterYear))//state third condition if not null
                {
                    qry = qry.Where(n => n.YEAR.Equals(filterYear));
                }

                events = qry.ToList();


                return new JsonResult { Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; // returning as json value
            }
        }
That's it,,

Qaaf 7 & 8

7. Dan Kami hamparkan bumi itu dan Kami letakkan padanya gunung-gunung yang kokoh dan Kami tumbuhkan padanya segala macam tanaman yang indah dipandang mata, 8. untuk menjadi pelajaran dan peringatan bagi tiap-tiap hamba yang kembali.

indahnya hidup sekeliling jika kita bisa membuka mata, hati dan membagikan keindahan itu..

Bismillahirrohmanirrohim,, aku mulai blog baru ini.. semoga bisa menjadi manfaat.


salam,
fadlil sangaji