What is Database Management system (DBMS)?


Definition 1:

A database management system (DBMS) is a software used to store and manage data. A DBMS stores data in databases and uses data models to describe the various ways of organizing data.

Definition 2:

Database Management System  is the task of maintaining databases so that information is readily available.

DBMS's are designed to maintain large volumes of data.Management of data involves:

  • Defining structures of data storage.
  • Providing mechanisms for data manipulation such as adding, editing, and deleting data.
  • Providing data security against unauthorized access.


What is a Database?


Definition:

A database is a collection of logically related information.


Following are the top 10 database engines using by companies around the globe:

  • Oracle
  • MySQL
  • Microsoft SQL Server
  • PostgreSQL
  • DB2
  • MongoDB
  • Microsoft Access
  • SQLite
  • Sybase
  • Teradata

What is Relational Database Management System (RDBMS)?


Definition:

A relational database management system (RDBMS) is an advanced version of DBMS that also defines the relationship between the various data values. It helps in organizing and accessing data more efficiently than DBMS.

What is a Class in Object Oriented Programming (OOP)?


Definition:

Class is a declaration, a template, or a blueprint that can be used to classify objects.

For example, the peacock, the sparrow, and the kingfisher are all birds. All of them share characteristics that are common to the family of birds. All of them lay eggs, are covered with feathers, have hollow bone structures, and have the ability to fly. Therefore, they share structural and behavioral similarities and belong to the class called Birds.


What is an object in Object Orientation (OOP)?


Definition 1:

An object is a combination of messages and data. Objects can receive and send messages and use messages to interact with each other. The messages contain information that is to be passed to the recipient object.


Definition 2:

An object literally means a 'material thing' that is capable of being presented to the senses.


Definition 3:

An object is a tangible entity that may exhibit some well-defined behavior. For example, let us consider a tennis ball:

  • A tennis ball is a tangible entity, with a visible boundary.
  • A tennis ball has a specific defined purpose (such as bouncing)
  • You can direct a specific action towards a tennis ball by hitting it with racquet or by tossing it.

What is Object Oriented Programming (OOP) ?


Object-Oriented Programming (OOP) is one of the most popular methodologies in software development. It offers a powerful model for creating computer programs. It speeds the program development process, improves maintenance and enhances reusablity of programs.

jQuery - Hello World!!!


jQuery is powerful client side scripting language. It is easy to learn language. It supports large number of browser which includes IE, Firefox, etc. It is JavaScript library of code that is already written by sine talented programmers. It simplifies most of the complex tasks that you don't need to worry. Below code display and hide Hello World!!! text using jQuery.
  


 JQuery Hello Word!!! 

 

jQuery Hello World!!!


Hello World!!!

How to get Image Preview after browsing through fileupload control using JavaScript


There are situations when you work with File Upload controls and you want to show the image preview when you hit ok in the dialog box. There are many solution but we are going to demonstrate using JavaScript. Now the below code snippet uses showImage function which first splits the complete path present in file upload text box. Later it appends 'file:///' to the complete file path.

Example:



function showImage(id,img,divName,no)
        {
            var fileUploader = id.value;            
             dots = fileUploader.split(".");
          
            //get the part AFTER the LAST period.
            fileType = "." + dots[dots.length-1];
            if(fileType=='.jpg'||fileType=='.JPG'||fileType=='.gif'||fileType=='.GIF' ||fileType=='.jpeg'||fileType=='.JPEG'||fileType=='.bmp'||fileType=='.BMP'||       fileType=='.png'||fileType=='.PNG'||fileType=='.tif'||fileType=='.TIF'||fileType=='.thm'||fileType=='.THM')
            {
               // alert('That file is OK!');
               // return true;
            }
            else
            {
                return false;
            }
            
            var filePath = fileUploader.split("\\"); 
            var path = 'file:///';
            for(var i = 1; i <  filePath.length;i++)
            {
                path += filePath[i];
                if(i != filePath.length -1)
                    path += "/";
            }  
          if(path.length > 1)
            {
                if(no==1)
                {                   
                  var ele= document.getElementById('<%= panellogo.ClientID %>');
                  ele.style.display = 'block';
                  var ele1= document.getElementById('<%= imglogo.ClientID %>');           
                }
                else if(no==2)
                {
                  var ele= document.getElementById('<%= panelheader.ClientID %>');
                  ele.style.display = 'block';
                  var ele1= document.getElementById('<%= imgheader.ClientID %>');              
                }
                else if(no==3)
                {
                  var ele= document.getElementById('<%= panelfooter.ClientID %>');
                  ele.style.display = 'block';
                  var ele1= document.getElementById('<%= imgfooter.ClientID %>');
                }
                else if(no==4)
                {
                   var ele= document.getElementById('<%= panelmiddlebar.ClientID %>');
                   ele.style.display = 'block';
                   var ele1= document.getElementById('<%= imgmiddlebar.ClientID %>');           
                }
                ele1.src =path ; 
           }
        }

How to use javascript to change values of a controls inside a gridview?


There are situations where you need to change value present in grid view dynamically. In one of my project, I need to calculate price according to the number of food items selected from a drop-down list control and this will be client site operation. To do that I have used JavaScript. Below is the ASP.NET and JavaScript which you need to past it in ASP.NET page.


       
           

               

                   

               

           

           

               

                   

                       

                       

                       

                       

                       

                   

               

           

            

               

                   

               

           

           

               

                   

               

           

           

               

                   

               

               

                   

               

           

           

               

                   

               

               

                   

               

           

       

    



Confirmation dialog box in Code Behind using C#( C-Sharp ) in ASP.NET


You can call a confirmation dialog box from code behind using c#. Copy follow the code in respective files.

Copy this is HTML

<p>
        <asp:Button id="btnSave" runat="server" Text="Save and Update 'RFFM'" OnClientClick="return UpdateRFFM();" />
    </p>

Copy this in C# code behind.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Text;
using ADI.Web;

namespace SIS
{
    public partial class update_sis : System.Web.UI.Page
    {
        SqlCommand cmd;
        SqlParameter pm;
        string strForm = "";
        StringBuilder sb;
        string strError = "";
        int UpdateStatus = -1;
        string strEmailTemplate = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/plain";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);

            if (Request["form_name"] == null)
            {
                Response.Write("");
                Response.End();
            }
            strForm = Utils.ToStringNullSafe(Request["form_name"]);
            sb = new StringBuilder();

            if (Session["ApplicationId"] == null)
            {
                Response.Write("Bad Request...");
                Response.End();
            }

            int ApplicationId = int.Parse(Session["ApplicationId"].ToString());

            switch (strForm)
            {
                case "rffm_create_user":
                    if (Session["email"] == null)
                    {
                        Response.Write("Bad Request");
                        Response.End();
                    }
                    Session["errmsg"] = "";
                    try
                    {
                        cmd = new SqlCommand("usp_SIS_PutUser");

                        // output parameter
                        pm = new SqlParameter("@UpdateStatus", SqlDbType.Int);
                        pm.Direction = ParameterDirection.Output;
                        cmd.Parameters.Add(pm);

                        // input parameters
                        cmd.Parameters.Add("Id", SqlDbType.Int).Value = 0;
                        cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 50).Value = Session["Email"].ToString();

                        string strPassword = System.Guid.NewGuid().ToString().Substring(0, 8);
                        
                        cmd.Parameters.Add("@Password", SqlDbType.VarChar, 50).Value = Utils.base64Encode(strPassword);
                        cmd.Parameters.Add("@Active", SqlDbType.Bit).Value = false;
                        int ClubId = int.Parse(Session["ClubId"].ToString());
                        if (ClubId > 0)
                        {
                            cmd.Parameters.Add("@Group_Id", SqlDbType.Int).Value = 31;
                            cmd.Parameters.Add("@Club_Id", SqlDbType.Int).Value = ClubId;
                            cmd.Parameters.Add("@NonClub_Id", SqlDbType.Int).Value = (object)DBNull.Value;
                        }
                        else
                        {
                            cmd.Parameters.Add("@Group_Id", SqlDbType.Int).Value = 32;
                            cmd.Parameters.Add("@Club_Id", SqlDbType.Int).Value = (object)DBNull.Value;
                            cmd.Parameters.Add("@NonClub_Id", SqlDbType.Int).Value = int.Parse(Session["Non_ClubId"].ToString());
                        }

                        Utils.executeSP(cmd);
                        Session.Remove("emil");
                        strError = "";

                        if (Session["errmsg"].ToString() != "") 
                            strError = "-1" + Session["errmsg"].ToString();

                        if (strError == "")
                        {
                            int UpdateStatus = int.Parse(cmd.Parameters["@UpdateStatus"].Value.ToString());
                            if (UpdateStatus < 0)
                                strError = "-1There was a problem when creating new user. Please contact Admin";
                            else
                            {
                                // send email
                                strEmailTemplate = Utils.ReadTemplate("newuser.txt");
                                strError = "00" + SIS_Site.SendEmail(UpdateStatus, strEmailTemplate);
                            }
                        }
                    } catch (Exception ex) {
                        strError = "-1" + ex.Message;
                    }
                    break;
                case "rffm_SendVerificationEmail":
                    // send email
                    if (Session["UserId"] == null)
                    {
                        Response.Write("Bad Request");
                        Response.End();
                    }
                    strError = "";
                    strEmailTemplate = Utils.ReadTemplate("newuser.txt");
                     strError = "00" + SIS_Site.SendEmail(int.Parse(Session["UserId"].ToString()), strEmailTemplate);
                    Session.Remove("UserId");
                    break;
                case "rffm_UserSetupVerify":
                    strError = "";
                    try
                    {
                        cmd = new SqlCommand("usp_SIS_UserSetupVerify");

                        // output parameter
                        pm = new SqlParameter("@UpdateStatus", SqlDbType.Int);
                        pm.Direction = ParameterDirection.Output;
                        cmd.Parameters.Add(pm);

                        SqlParameter pm2 = new SqlParameter("@EMail", SqlDbType.VarChar, 500);
                        pm2.Direction = ParameterDirection.Output;
                        cmd.Parameters.Add(pm2);

                        SqlParameter pm3 = new SqlParameter("@Updatetext", SqlDbType.VarChar, 200);
                        pm3.Direction = ParameterDirection.Output;
                        cmd.Parameters.Add(pm3);

                        SqlParameter pm4 = new SqlParameter("@UserId", SqlDbType.Int);
                        pm4.Direction = ParameterDirection.Output;
                        cmd.Parameters.Add(pm4);

                        // input parameters
                        cmd.Parameters.Add("@ApplicationId", SqlDbType.Int).Value = ApplicationId;

                        Utils.executeSP(cmd);

                        if (Session["errmsg"] != null)
                            strError = Session["errmsg"].ToString();

                        if (strError == "")
                        {
                            UpdateStatus = int.Parse(cmd.Parameters["@UpdateStatus"].Value.ToString());
                            if (UpdateStatus < 0)
                                strError = "There was an error when processing your request";
                        }

                        Session["email"] = cmd.Parameters["@EMail"].Value.ToString();
                        Session["UserId"] = cmd.Parameters["@UserId"].Value.ToString();
                        Session["Updatetext"] = cmd.Parameters["@Updatetext"].Value.ToString();

                        switch (UpdateStatus)
                        {
                           case 1:
                                strError = "1";
                                break;
                            case 2:
                                strError = "2";
                                break;
                            case 3:
                                strError = "3";
                                break;
                            case 4:
                                strError = Session["Updatetext"].ToString();
                                break;
                            case 5:
                                strError = "5" + Session["Updatetext"].ToString();
                                break;
                            default:
                                break;
                        }
                    }
                    catch (Exception ex)
                    {
                        strError = ex.Message;
                    }
                    break;

                case "rffm":
                    Session["current_tab"] = "rffm";
                    try
                    {
                        cmd = new SqlCommand("usp_SIS_PutProjectProfile");

                        // output parameter
                        pm = new SqlParameter("@UpdateStatus", SqlDbType.Int);
                        pm.Direction = ParameterDirection.Output;
                        cmd.Parameters.Add(pm);

                        // input parameters
                        cmd.Parameters.Add("@ApplicationId", SqlDbType.Int).Value = ApplicationId;
                        cmd.Parameters.Add("@LastSavedBy", SqlDbType.VarChar, 50).Value = Session["user"].ToString();

                        cmd.Parameters.Add("@FeasibilityStudyDocument", SqlDbType.VarChar, 8000).Value = Request["FeasibilityStudy"];
                        cmd.Parameters.Add("@PlanningPermissionNotRequired", SqlDbType.VarChar, 8000).Value = Request["PlanningPermissionNotRequired"];
                        cmd.Parameters.Add("@Sustainable", SqlDbType.VarChar, 8000).Value = Request["Sustainable"];

                        string strRDMRecommendation = Request["RDMRecommendation"];
                        cmd.Parameters.Add("@RDMRecommendation", SqlDbType.VarChar, 8000).Value = (strRDMRecommendation == null) ? (object)DBNull.Value : strRDMRecommendation;

                        cmd.Parameters.Add("@Risk", SqlDbType.VarChar, 10).Value = Request["Risk"];
                        cmd.Parameters.Add("@Region", SqlDbType.VarChar, 50).Value = Request["Region"];
                        cmd.Parameters.Add("@RDMName", SqlDbType.VarChar, 50).Value = Session["user"].ToString();
                        cmd.Parameters.Add("@RDMReviewDate", SqlDbType.DateTime).Value = DateTime.Now;
                        cmd.Parameters.Add("@DesignAndPlanningPermission", SqlDbType.VarChar, 8000).Value = Request["DesignAndPlanningPermission"];
                        cmd.Parameters.Add("@RecommendationOfProjectNeedAgainstSDA", SqlDbType.VarChar, 8000).Value = Request["RecommendationOfProjectNeedAgainstSportsDevelopmentActivity"];
                        cmd.Parameters.Add("@ValueForMoneyAssessment", SqlDbType.VarChar, 8000).Value = Request["ValueForMoneyAssessment"];
                        cmd.Parameters.Add("@ActionId", SqlDbType.Int).Value = int.Parse(Request["ActionId"].ToString());
                        cmd.Parameters.Add("@ActionNotes", SqlDbType.VarChar, 500).Value = "RFFM";

                        Utils.executeSP(cmd);

                        if (Session["errmsg"] != null)
                            strError = Session["errmsg"].ToString();

                        if (strError == "")
                        {
                            UpdateStatus = int.Parse(cmd.Parameters["@UpdateStatus"].Value.ToString());
                            if (UpdateStatus < 0)
                                strError = "There was an error when processing your request";
                            else
                                Session["current_tab"] = "";
                        }
                    }
                    catch (Exception ex)
                    {
                        strError = ex.Message;
                    }
                    break;

                case "check_session":
                    if (Session["ApplicationId"] != null)
                    {
                        string hfID = Request["hf_ApplicationId"].ToString();
                        string sfID = Session["ApplicationId"].ToString();

                        if (hfID != sfID)
                        {
                            strError = "-1";
                        }
                    }
                    break;
                default:
                    strError = "Bad request";
                    break;

            }
            
            Response.Write(strError);
        }
    }
} 
 
 
 
Copy this in Javascript file

function UpdateRFFM()
{
    var msg;
    var status_code;
    var rffmAction = $(".rffmAction").val();
    var Risk = $(".ddlRisk").val();
    var Region = $(".ddlRegion").val();
    var strError = "";
    
    if (rffmAction == "151") {
        if (Risk == "")
            strError = strError + "Please select a Risk\n";
        if (Region == "")
            strError = strError + "Please select a Region\n";                
    }
    
    if (strError != "") {
        alert(strError);
        return false;
    }
    
    var reply = false;

    if (rffmAction == "151") {
        $.post(getFullPath("update_sis.aspx"), 
            {form_name: 'rffm_UserSetupVerify'}, function(data) {
            if (data.length > 0)
                status_code = data.substring(0, 1);
            else
                status_code = '';
            
            switch(status_code) {
                case '0':
                    UpdateRFFM_Normal();
                    break;
                case '1':
                    $.post(getFullPath("update_sis.aspx"),
                        {form_name: 'rffm_create_user'}, function(data) {
                            status_code = data.substring(0, 2);
                            msg = data.substring(2);
                            if (status_code == "-1") 
                                alert(msg);
                            else {
                                alert('created new user account\n\n' + msg);
                                UpdateRFFM_Normal();
                            }                                    
                        });
                    break;
                case '2':
                    UpdateRFFM_Normal();
                    break;
                case '3':
                     $.post(getFullPath("update_sis.aspx"),
                        {form_name: 'rffm_SendVerificationEmail'}, function(data) {
                            status_code = data.substring(0, 2);
                            msg = data.substring(2);
                            if (status_code == "-1") 
                                alert(msg);
                            else {
                                alert('verification email sent\n\n' + msg);
                                UpdateRFFM_Normal();
                            }
                        });
                    break;
                case '4':
                    alert(data);
                    break;
                case '5':
                    msg = data.substring(1);
                    if (confirm(msg) == true) {
                      $.post(getFullPath("update_sis.aspx"),
                        {form_name: 'rffm_SendVerificationEmail'}, function(data) {
                            status_code = data.substring(0, 2);
                            msg = data.substring(2);
                            if (status_code == "-1") 
                                alert(msg);
                            else 
                                alert('verification email was sent\n\n' + msg);
                                UpdateRFFM_Normal();
                        });
                    }
                    break;                                                                                                
                default:
                    alert(data);
                    break;
            }
        });
    } else
        UpdateRFFM_Normal();

    return reply;
}
function UpdateRFFM_Normal() {
    var reply = false;         
    $.post(getFullPath("update_sis.aspx"), {form_name: 'rffm',
        FeasibilityStudy: $(".FeasibilityStudy").val(),
        PlanningPermissionNotRequired: $(".PlanningPermissionNotRequired").val(),
        Sustainable: $(".Sustainable").val(),
        RDMRecommendation: $(".RDMRecommendation").val(),
        Risk: $(".ddlRisk").val(),
        Region: $(".ddlRegion").val(),
        DesignAndPlanningPermission: $(".DesignAndPlanningPermission").val(),
        RecommendationOfProjectNeedAgainstSportsDevelopmentActivity: $(".RecommendationOfProjectNeedAgainstSportsDevelopmentActivity").val(),
        ValueForMoneyAssessment: $(".ValueForMoneyAssessment").val(),
        ActionNotes: $(".ActionNotes").val(),
        ActionId: $(".rffmAction").val()
        }, function(data) {
           if (data.length > 0) {
                alert(data);
                return false;
            } else {
                window.location = getFullPath("application_form.aspx");
                return false;
            }
        });
}

Recent Posts