Friday, October 27, 2017

Access Camera HTML 5

Access camera and video, the INPUT element with a type of file is necessary:
<input type="file" accept="image/*">
To isolate only a photos as the type to be uploaded, the accept attribute must match the pattern above.
HTML 5 CAPTURE MEDIA DEVICE

<p>Capture Image: <input type="file" accept="image/*" id="capture" capture="camera"> 

<p>Capture Audio: <input type="file" accept="audio/*" id="capture" capture="microphone"> 

<p>Capture Video: <input type="file" accept="video/*" id="capture" capture="camcorder"> 

Friday, December 4, 2015

Bootstrap basic stuff

creating bootstrap breadcurmb using twitter bootstrap
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
  <li><a tabindex="-1" href="#">Action</a></li>
  <li><a tabindex="-1" href="#">Another action</a></li>
  <li><a tabindex="-1" href="#">Something else here</a></li>
  <li class="divider"></li>
  <li><a tabindex="-1" href="#">Separated link</a></li>
</ul>
creating bootstrap pagination and use .disabled for unclickable links and .active to indicate the current page.
  1. <div class="pagination">
  2. <ul>
  3. <li><a href="#">Prev</a></li>
  4. <li><a href="#">1</a></li>
  5. <li><a href="#">2</a></li>
  6. <li><a href="#">3</a></li>
  7. <li><a href="#">4</a></li>
  8. <li><a href="#">5</a></li>
  9. <li><a href="#">Next</a></li>
  10. </ul>
  11. </div>

Monday, January 5, 2015

Datediff Function Sql Server

DateDiff function returns the  difference between to dates

Suppose we have employee table and it has following rows and columns
Id
Name
Description
JoiningDate
1
Test1
Executive
10/5/2013 0:00
2
Test2
S.Executive
10/5/2012 0:00
3
Test3
Team Lead
10/5/2012 0:00
4
Test4
Jr Engineer
10/11/2014 0:00


Calculate the Employee joining Year, month and days
  select name, datediff(year,JoiningDate,getdate()) Year  , datediff(year,JoiningDate,getdate()) month ,datediff(DAY,JoiningDate,getdate()) day from Employee  where joiningdate is not null

Calculate the age   Sql server in years-month and days

  Declare @dateofbirth datetime
  Declare @years int
  declare @months int
  declare @days int
  declare @temp date
  set @dateofbirth='1983-04-27';
  set @temp  =@dateofbirth

  set @years = (select DATEDIFF(yy, @temp, GETDATE())- CASE WHEN (MONTH(@dateofbirth) > MONTH(GETDATE())) OR (MONTH(@dateofbirth) = MONTH(GETDATE()) AND DAY(@dateofbirth) > DAY(GETDATE())) THEN 1 ELSE 0 END)

SET @temp = DATEADD(yy, @years, @temp)

SET @months = DATEDIFF(m, @temp, GETDATE()) - CASE WHEN DAY(@dateofbirth) > DAY(GETDATE()) THEN 1 ELSE 0 END

SET @temp = DATEADD(m, @months, @temp)
SET @days = DATEDIFF(d, @temp, GETDATE())

select @years as TotalYear ,@months as M

Sql server Get the Day of week

Suppose we have employee table and it has following rows and columns
Id
Name
Description
JoiningDate
1
Test1
Executive
10/5/2013 0:00
2
Test2
S.Executive
10/5/2012 0:00
3
Test3
Team Lead
10/5/2012 0:00
4
Test4
Jr Engineer
10/11/2014 0:00

select  case   DATEPART(DW,getdate())+@@DATEFIRST %WHEN 1 THEN 'SUNDAY'
    WHEN 2 THEN 'MONDAY'
    WHEN 3 THEN 'TUESDAY'
    WHEN 4 THEN 'WENSDAY'
    WHEN 5 THEN 'THURSDAY'
    WHEN 6 THEN 'FRIDAY'
    WHEN 7 THEN 'SATURDAY'
END

DATEPART() Function in Sql Server

DATPART function is used to return single part such as date, time, year, hour, minute seconds. It’s very useful function
datepart(datepartstring,date)
Here is common queries we have used in sql server day by day operations
Suppose we have employee table and it has following rows and columns
Id
Name
Description
JoiningDate
1
Test1
Executive
10/5/2013 0:00
2
Test2
S.Executive
10/5/2012 0:00
3
Test3
Team Lead
10/5/2012 0:00
4
Test4
Jr Engineer
10/11/2014 0:00

1)  Get Year from joining date of employee
    select name, DATEPART(year,joiningDate)  from employee

2)  Get Month from joining date of employee

select name ,DATEPART(month,joiningDate) from Employee


3)  Count employees based upon year
  select name ,DATEPART(YEAR,joiningDate) from Employee where DATEPART(YEAR,joiningDate)='2013'


4)  Get joining day of Employee
   select name , case   DATEPART(DW,JoiningDate)+@@DATEFIRST %WHEN 1 THEN 'SUNDAY'
    WHEN 2 THEN 'MONDAY'
    WHEN 3 THEN 'TUESDAY'
    WHEN 4 THEN 'WENSDAY'
    WHEN 5 THEN 'THURSDAY'
    WHEN 6 THEN 'FRIDAY'
    WHEN 7 THEN 'SATURDAY'
END  from Employee where JoiningDate is not null

Saturday, December 27, 2014

Difference beteween stuff and replace function in sql server

STUFF function is used to overwrite existing characters. Here is the syntax of stuff function
stuff (Expression, start, length, replace),
Expression is the string that will have characters substituted
start is the starting position
length is the number of characters in the string that are substituted
replace are the new characters interjected into the string
Here is the   example of stuff function
SELECT STUFF('anil kumar', 1, 2, 'sun');
Output this query = sunil kumar

REPLACE function to replace existing characters of all occurrences.
Using the syntax REPLACE (string_expression, search_string, replacement_string), where every incidence of search_string found in the string_expression will be replaced with replacement_string.
Here  is the example
select REPLACE('Sunil Kumar asp.net devloper','Sunil','Anil' )

output of this query is: Anil Kumar asp.net devloper

ORDER BY Clause using Variable in store Procedure

Let’s create the table with sample data:

CREATE TABLE [dbo].[Product] (
    [Id]          INT            IDENTITY (1, 1) NOT NULL,
    [Name]        NVARCHAR (256) NULL,
    [CategoryId]  INT            NULL,
    [Description] NVARCHAR (512) NULL,
    [IsActive]    BIT            NULL,
    [Price]       DECIMAL (18)   NOT NULL,
    CONSTRAINT [PK_Product] PRIMARY KEY CLUSTERED ([Id] ASC),
    CONSTRAINT [FK_Product_Category] FOREIGN KEY ([CategoryId]) REFERENCES [dbo].[Category]([Id]) ON DELETE CASCADE ON UPDATE CASCADE
);


//Insert Data

SET IDENTITY_INSERT [dbo].[Product] ON
INSERT INTO [dbo].[Product] ([Id], [Name], [CategoryId], [Description], [IsActive], [Price])VALUES (1, N'Htc on', 1, NULL, 1, CAST(34 AS Decimal(18, 0)))
INSERT INTO [dbo].[Product] ([Id], [Name], [CategoryId], [Description], [IsActive], [Price])VALUES (2, N'Samsung  galaxy', 1, N' Thids jsdfhns kndfksd', 1, CAST(45 AS Decimal(18, 0)))
INSERT INTO [dbo].[Product] ([Id], [Name], [CategoryId], [Description], [IsActive], [Price])VALUES (3, N'Lumia 1320', 1, N'test test', 1, CAST(45 AS Decimal(18, 0)))
INSERT INTO [dbo].[Product] ([Id], [Name], [CategoryId], [Description], [IsActive], [Price])VALUES (4, N'Ramond', 2, N' theisbdf ', 1, CAST(45 AS Decimal(18, 0)))
INSERT INTO [dbo].[Product] ([Id], [Name], [CategoryId], [Description], [IsActive], [Price])VALUES (5, N'Peter England trouser', 2, N'sdfj', 1, CAST(AS Decimal(18, 0)))
INSERT INTO [dbo].[Product] ([Id], [Name], [CategoryId], [Description], [IsActive], [Price])VALUES (6, N'Niva', 3, N'dhfdh', 1, CAST(34 AS Decimal(18, 0)))
INSERT INTO [dbo].[Product] ([Id], [Name], [CategoryId], [Description], [IsActive], [Price])VALUES (7, N'Ponds', 3, NULL, 1, CAST(45 AS Decimal(18, 0)))
SET IDENTITY_INSERT [dbo].[Product] OFF

//Store Procedure
create PROCEDURE [dbo].[Sorting]
      
       @SortByCloumnName varchar(128),
       @SortByDirection  varchar(4)
AS
    

       select *  from  Product   order by 
          case when @SortByCloumnName='Name' and  LOWER( @SortByDirection)= 'asc'  thenName   end asc,
           case when @SortByCloumnName='Name' and LOWER(@SortByDirection) = 'desc'  thenName   end Desc

      
         
         RETURN 0

Access Camera HTML 5

Access camera and video, the  INPUT  element with a type of  file  is necessary: < input type = " file " accept = " i...

buy cloth