Monday 10 December 2018

Different between var and Dynamic Variable in C#.

var  It is introduced  C#3.0 Version.
 dynamic It is introduced  C# 4.0 version

1).Var is statically  type of variable, where are dynamic is dynamically type of variable.

2)Errore will be occur at compile time in var, where as error will be occur at runtime
.
3)In var initialization is required at time of declaration. If you not initialize variable it will be throw error at compile time "Implicitly -typed variable must be initialized ". where as dynamic type variable initialization is not required at time of declaration.

4)var does not allow the change variable after assigned value where as dynamic type variable allow be change type after assigned .

5)var support intellisense because it arise errore at compile time where as dynamic type  variable not support intelligence because type is unknown runtime.

6)var variable can not be used for properties and return value from function .it is available only locally whereas dynamic variable can be used to create properties and return value from function





Saturday 16 June 2018

How to call function in store procedure using Sql Server 2014?


How to add auto increament with string of number and letter?


CREATE TABLE [dbo].[tbl_Product](

[Id] [int] IDENTITY(101,1) NOT NULL,

ProductId As 'PRO'+Right('000'+convert (varchar(10),Id),6)persisted,

[ProductName] [nvarchar](100) NULL,

[Quantiy] [int] NULL,

[Price] [decimal](18, 1) NULL,

[CreateOn] [datetime] NULL
) ON [PRIMARY]


 Output-

Friday 13 April 2018

Cursor In SQL SERVER

Cursor:- Cursor is  a database object to retrieve data from a result set one row at time. we use cursor when we need to update record databse table in Sigleton fashion means row wise.



  For Exampl :
   select * from Products

 know i want change  unit price of unit of each based on some condition.

Declare @UnitPrice decimal(5,2)
Declare @ProductId int
Declare UnitPriceUpdateCursore  Cursor FOR
Select ProductID From Products
open  UnitPriceUpdateCursore
Fetch Next From UnitPriceUpdateCursore into @ProductId
While (@@Fetch_Status=0)
Begin
select @UnitPrice=UnitPrice from Products

Begin Update Products set UnitPrice = case when UnitPrice between 5 And 10 then 15
                     when UnitPrice  between 11 AND 15  then 20
     else UnitPrice
                    end
Where ProductID=@ProductId
Fetch Next From UnitPriceUpdateCursore into @ProductId
END
End
Close UnitPriceUpdateCursore
Deallocate UnitPriceUpdateCursore
Set NoCount Off


Friday 6 April 2018

MVC Validation

Expressions for input fields
Alphabets and Space
[a-zA-Z ]+$
Alphabets
^[A-z]+$
Numbers
^[0-9]+$
Alphanumeric
^[a-zA-Z0-9]*$
Email
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
Mobile no.
^([7-9]{1})([0-9]{9})$
Date Format( mm/dd/yyyy | mm-dd-yyyy | mm.dd.yyyy)
/^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\\d\\d+$/
Website URL
^http(s)?://([\\w-]+.)+[\\w-]+(/[\\w- ./?%&=])?$
Credit Card Numbers
Visa
^4[0-9]{12}(?:[0-9]{3})?$
MasterCard
^5[1-5][0-9]{14}$
American Express
^3[47][0-9]{13}$
Decimal number
((\\d+)((\\.\\d{1,2})?))$


Thursday 11 January 2018

How to bind data in Drop down List from Enum usig Array in Asp.net C#

Add New Class and rename as CommonEnum.
Note:- Set location in App_Code.So it can access any in a project. 

 Add method 
nameSpace Enum
{
Public ClassCommonEnum()
{

}
Public enum Operation 
{Insert =1,
Update=2,
Delete=3,
Select=4
}
}

Add New  Web Page 
 Add Asp .Net DropDownList control in .aspx page

<asp:DropDownList Id="ddlOperation"  runat= "Server"/>

Add name Space on web Page.cs

 Array arrop=Enum.GetValues(typeof(CommonEmum.Operation));
foreach(CommonEnum.Operation opt  in arrop)
{
ddlOperation.Items.Add(new ListItem(opt.ToString(),((Int)opt).Tostring()));

How to get logged in User's Security Roles using Java Script in dynamic CRM 365.

 function GetloggedUser () {     var roles = Xrm.Utility.getGlobalContext().userSettings.roles;      if (roles === null) return false;      ...