Friday, November 10, 2017

Using "OUT" Parameter With Stored Procedure in MVC

Creating Table in SQL Server Database
Now create a table named UserDetail with the columns UserName, Email and Country. The table looks as below.


Creating a Stored Procedure with Out parameter
Now create a stored procedure with an out parameter to insert data into the table. We create an error out parameter.
===================================
USE [TEST]
GO
/****** Object:  StoredProcedure [dbo].[spuserdetail]    Script Date: 01/25/2012 01:37:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spuserdetail]
@UserName varchar(50),
@Password varchar(50),
@Email varchar(50),
@Country varchar(50),
@ERROR VARCHAR(100) OUT
AS
BEGIN   
         
SET NOCOUNT ON;

IF NOT EXISTS(SELECT * FROM UserDetail WHERE UserName=@UserName) //  To Check UserName is exits or not
BEGIN
INSERT INTO UserDetail(
UserName,
[Password],
Email,
Country
)
VALUES
(
@UserName,
@Password,
@Email,
@Country
)
SET @ERROR=@UserName+' Registered Successfully'
END
ELSE
BEGIN
SET @ERROR=@UserName + ' Already Exists'
END
END
In the above stored procedure, error is the out parameter and other are the input parameter. In this stored procedure we check UserName; if the UserName exists in the table then it will return the message as an Output Parameter.
SET @ERROR=@UserName + ' Already Exists'
If the UserName does not exist in the table then it will return the message as an Output Parameter.
SET @ERROR=@UserName+' Registered Successfully'
====================================
Codebehind
=======================================
  
      string message = string.Empty;
        SqlConnection con = new SqlConnection("Data Source=.; uid=sa; pwd=*****;database=Mehedi;");
     if (conn.State == 0)
            {
                conn.Open();
            }
        SqlCommand cmd = new SqlCommand("USP_GETUSER", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@UserName", UserName);
        cmd.Parameters.AddWithValue("@Password", Password);
        cmd.Parameters.AddWithValue("@Email", Email);
        cmd.Parameters.AddWithValue("@Country", Country);
        cmd.Parameters.Add("@ERROR"SqlDbType.Char, 500);
        cmd.Parameters["@ERROR"].Direction = ParameterDirection.Output;
        cmd.ExecuteNonQuery();
        message = (string)cmd.Parameters["@ERROR"].Value;
    
    

   

Monday, November 6, 2017

How to remove all rows of the table but keep the header

 
  $('#table_Item_Search tr').not(function () { return !!$(this).has('th').length; }).remove();

Thursday, November 2, 2017

ওয়েব থেকে গুগোলক্রম দিয়ে আরডিএলসি (RDLC) পিডিএফ (PDF) ডাইরেক্ট প্রিন্ট

ওয়েব থেকে গুগোলক্রম দিয়ে আরডিএলসি (RDLC) পিডিএফ (PDF) ডাইরেক্ট প্রিন্ট করবার জন্য আনেক গুলো ধাপ আনুসারে কাজ করতে হবে, যা আমরা নিচে আলোচনা করবো।



প্রথম ধাপঃ

রিপোর্ট ভিউয়ার দিয়ে ফাইল তৈরি করা।






Tuesday, October 31, 2017

কি বোর্ড এর আপ ডাউন বাটন ক্লিক করে জাভাস্ক্রিপ্ট দিয়ে টেবিলের রো সিলেক্ট

(function () {
    var trows = document.getElementById('table_Return').rows, t = trows.length, trow, nextrow,
        //  rownum = document.getElementById('rownum'),
        addEvent = (function () {
            return window.addEventListener ? function (el, ev, f) {
                el.addEventListener(ev, f, false); //modern browsers
            } : window.attachEvent ? function (el, ev, f) {
                el.attachEvent('on' + ev, function (e) { f.apply(el, [e]); }); //IE 8 and less
            } : function () { return; }; //a very old browser (IE 4 or less, or Mozilla, others, before Netscape 6), so let's skip those
        })();

    // rownum.value = rownum.defaultValue; //reset for browsers that remember input values on reload

    while (--t > -1) {
        trow = trows[t];
        trow.className = 'normal';
        addEvent(trow, 'click', highlightRow);
    }//end while

    function highlightRow(gethighlight) { //now dual use - either set or get the highlighted row
        gethighlight = gethighlight === true;
        var t = trows.length;
        while (--t > -1) {
            trow = trows[t];
            if (gethighlight && trow.className === 'highlighted') { return t; }
            else if (!gethighlight) {
                if (trow !== this) { trow.className = 'normal'; }
                else if (this.className === 'normal') {
                    //rownum.value = t;
                }
                else {
                    //rownum.value = rownum.defaultValue;
                }
            }
        }//end while

        return gethighlight ? null : this.className = this.className === 'highlighted' ? 'normal' : 'highlighted';
    }//end function

    function movehighlight(way, e) {
        e.preventDefault && e.preventDefault();
        e.returnValue = false;
        var idx = highlightRow(true); //gets current index or null if none highlighted
        if (typeof idx === 'number') {//there was a highlighted row
            idx += way; //increment\decrement the index value
            if (idx && (nextrow = trows[idx])) { return highlightRow.apply(nextrow); } //index is > 0 and a row exists at that index
            else if (idx) { return highlightRow.apply(trows[1]); } //index is out of range high, go to first row
            return highlightRow.apply(trows[trows.length - 1]); //index is out of range low, go to last row
        }
        return highlightRow.apply(trows[way > 0 ? 1 : trows.length - 1]); //none was highlighted - go to 1st if down arrow, last if up arrow
    }//end function

    function processkey(e) {
        switch (e.keyCode) {
            case 38: {//up arrow
                return movehighlight(-1, e)
            }
            case 40: {//down arrow
                return movehighlight(1, e);
            }
            default: {
                return true;
            }
        }
    }//end function

    addEvent(document, 'keydown', processkey);
    addEvent(window, 'unload', function () { }); //optional, resets the page for browsers that remember the script state on back and forward buttons

}/* end function */)();//execute function and end script

Saturday, October 21, 2017

জাভা স্ক্রিপ্ট দিয়ে অনেক গুলো টেক্সট বক্সের ভ্যালু যোগ করা।

জাভা স্ক্রিপ্ট দিয়ে খুব সহজেই অনেক গুলো টেক্সট বক্সের ভ্যালু যোগ করা যায়,
 নিম্নের পদ্ধতিতে ঃ

//--------------------------------------------
var TotalAmount = 0,
  Amount = document.querySelectorAll('.C_Amount');

 for (i = 0; i < C_Amount.length; i++) {
                    TotalAmount += parseFloat(C_Amount[i].value || 0);
                }
alert (TotalAmount );
//--------------------------------------------

জাভা-স্ক্রিপ্ট দিয়ে কি-বোর্ড বাটন প্রেস ধরা।

জাভা-স্ক্রিপ্ট দিয়ে আমরা খুব সহজে  কি-বোর্ড বাটন প্রেস ধরতে পারি। 

নিম্ন পদ্ধতিতে ঃ

$(document).ready(function () {
      document.addEventListener("keydown", keyPress, false);
)
});
function keyPress(e) {
 var keyCode = e.keyCode;
// এই কি কোড ভালু ধরে অ্যাকশান  ধরা যায়।

 if (keyCode === 13) {
        alert("You Press Enter");
    }

 if (keyCode === 113) {
        alert("You Press F2");
    }
 if (keyCode === 114) {
        alert("You Press F3");
    }
 if (keyCode === 115) {
        alert("You Press F4");
    }

 if (keyCode === 117) {
        alert("You Press F6");
    }
 if (keyCode === 119) {
        alert("You Press F8");
    }
 if (keyCode === 120) {
        alert("You Press F9");
    }

}