Search This Blog

Lets go..




Manage your Inventory | Grow your restaurant business | Manage your Employee | Control your accounts

Monday

Dynamic MenuStrip and Access privilege in Windows Forms

By: Mohammad Tuaha



Introduction

This article explain how to create a Database Driven MenuStrip and add Items to the MenuStrip using the ToolStripMenuItem class in a C# Windows Forms application.

First we need to create Database here I am using Sqlite DB. This more comfortable and platform dependent.  

2

2.  Parent Form


33. Manage User Form


3.1. Give User Privilege

 

----

     Code Section

    private void FrmParent_Load(object sender, EventArgs e)
        {
            // To make this Form the Parent Form

           this.IsMdiContainer = true;


            //Creating object of MenuStrip class

            MnuStrip = new MenuStrip();

            ////MnuStripItem = new ToolStripMenuItem("Exit");  
            ////MnuStrip.Items.Add(MnuStripItem);

            //string userid = "1001";
            //MnuStripItem = new ToolStripMenuItem(userid);
            //MnuStrip.Items.Add(MnuStripItem);

            //////Placing the control to the Form

            this.Controls.Add(MnuStrip);


            String connectionString ;
            connectionString = @"Data Source=dynamMenu.db;Version=3;New=False;Compress=True";
           // connectionString = "Data Source=(local); Initial Catalog=apostest; User ID=User_Profile;Password=User_Profile";
            //ConfigurationManager.ConnectionStrings["dbconn"].ConnectionString;
            conn = new SQLiteConnection(connectionString);
            String Sequel = "SELECT MAINMNU,MENUPARVAL,STATUS FROM MNU_PARENT where status = 'Y'";
            SQLiteDataAdapter da = new SQLiteDataAdapter(Sequel, conn);
            DataTable dt = new DataTable();

            conn.Open();
            da.Fill(dt);

            foreach (DataRow dr in dt.Rows)
            {
                MnuStripItem = new ToolStripMenuItem(dr["MAINMNU"].ToString());
                SubMenu(MnuStripItem, dr["MENUPARVAL"].ToString());
                MnuStrip.Items.Add(MnuStripItem);
            }

            // The Form.MainMenuStrip property determines the merge target.
            this.MainMenuStrip = MnuStrip;
           
        }
       

        public void SubMenu(ToolStripMenuItem mnu, string submenu)
        {
          // String Seqchild = "SELECT FRM_NAME FROM MNU_SUBMENU WHERE MENUPARVAL='" + submenu + "'";
            String Seqchild = "SELECT FRM_NAME FROM vw_pagerole WHERE MENUPARVAL='" + submenu + "' and status = 1 and UID = '" + toolUserID.Text + "' ";
            SQLiteDataAdapter dachildmnu = new SQLiteDataAdapter(Seqchild, conn);
            DataTable dtchild = new DataTable();
            dachildmnu.Fill(dtchild);

            foreach (DataRow dr in dtchild.Rows)
            {
                ToolStripMenuItem SSMenu = new ToolStripMenuItem(dr["FRM_NAME"].ToString(), null, new EventHandler(ChildClick));
                mnu.DropDownItems.Add(SSMenu);
            }

        }


---

Summary

In this article we have discussed how to create a Database Driven MenuStrip and access privilege in a Windows Form and adding Submenus using the ToolStripMenuItem class and registering the Event for the Child Forms and navigating through the forms in the Project to associate them with the Form Name dynamically in the database.

After finishing this article you can learn
How to create Login using Database.
How to create dynamic Menu
User access privilege / User role assign


Load Full Source Code






3.

 

Wednesday

Securing soap web service with Spring-WS using Wss4jSecurityInterceptor (Part-3 Client Part)

Sorry for late.
Description add later. Just follow this document.
http://docs.spring.io/spring-ws/site/reference/html/security.html 
I have just followed this article and writing code according to the instruction.
Complete source code download from bellow link:
https://www.dropbox.com/s/7bm6rgsmnozswyj/SecureSpringClient.zip?dl=0

If you will face any problem to run this code, feel free to  mail.
Please note that you must delete build folder from project and clean and build using Netbeans IDE again.

Thanks
Md Mahfuj Jia
Happy Coding...


Securing soap web service with Spring-WS using Wss4jSecurityInterceptor (Part-2 Server Part)

Sorry for late.
Description add later. Just follow this document.
http://docs.spring.io/spring-ws/site/reference/html/security.html 
I have just followed this article and writing code according to the instruction.
Complete source code download from bellow link:
https://www.dropbox.com/s/8pxx7mh8ljtpjkk/SecureSpringWS.zip?dl=0

If you will face any problem to run this code, feel free to  mail.

Thanks
Md Mahfuj Jia
Happy Coding...



Saturday

Securing soap web service with Spring-WS using Wss4jSecurityInterceptor (Part-1)

Author: Md Mahfuj Jia

Create Client/Server Keystores using Java Keytool

Run the following commands::

keytool -genkey -alias server -keyalg RSA -keystore server.jks
keytool -genkey -alias client -keyalg RSA -keystore client.jks
keytool -list -v -keystore server.jks -storepass server_public_keypass
keytool -export -file server.cert -keystore server.jks -storepass server_public_keypass -alias server
keytool -export -file client.cert -keystore client.jks -storepass client_public_keypass -alias client
keytool -import -file client.cert -keystore server.jks -storepass server_public_keypass -alias client
keytool -import -file server.cert -keystore client.jks -storepass client_public_keypass -alias server

Java keytool stores the keys and certificates in a keystore, protected by a keystore password. Further, it protects private key again with another password. A Java keystore contains private-public key pair and multiple trusted certificate entries. All entries in a keystore are referred by aliases. Both private key and self signed public key is referred by one alias while any other trusted certificates are referred by different individual aliases.

This is the first part of this tutorial. In second part we discuss about Spring web service server side security configuration and in 3rd part we make a secure client using spring web service client to consume this secure service.

These are some screen shots::




Thursday

Difference Between Web Service and API

By: Mohammad  Tuaha


A Web service is merely (নিছক) an API wrapped in HTTP. An API doesn’t always need to be web based.
 An API consists of a complete set of rules and specifications for a software program to follow in order to facilitate interaction. A Web service might not contain a complete set of specifications and sometimes might not be able to perform all the tasks that may be possible from a complete API.


API and Web service serve as a means of communication. The only difference is that a Web service facilitates interaction between two machines over a network.
An API acts as an interface between two different applications so that they can communicate with each other.
All Web services are APIs but all APIs are not Web services.

Web service
API
A Web service always needs a network for its operation.

An API doesn't need a network for its operation.

Web services might not perform all the operations.


API would perform all the operations.

A Web service uses only three styles of use: SOAP, REST and XML-RPC for communication.
API may use any style for communication.
A Web service is designed to have an interface that is depicted (ফোটানো) in a machine- process able format usually specified in Web Service Description Language (WSDL). Typically, “HTTP” is the most commonly used protocol for communication.
An API is a method by which the third-party vendors can write programs that interface easily with other programs.
In case of Web applications, the API used is web based. Desktop applications such as spreadsheets and word documents use VBA and COM-based APIs which don’t involve Web service. A server application such as Joomla may use a PHP-based API present within the server which doesn’t require Web service.
A web service typically offers a WSDL from which you can create client stubs automatically.
Web API can also be used to create OData services.
·         Web Services are based on the SOAP Protocol.

  
      Web services are based on standard defined by W3C.
·         Web API can be used to create any type of web service, most commonly RESTful services.
·         Web API can present the data in nearly any format not just JSON, or XML. (Csv, protobuf, streams etc.)
·         Web API is hosted in an OWIN framework.
·         Web API is easy to extend.





Enjoy Free code