Monday, January 13, 2014

String was not recognized as a valid DateTime



if you getting this error .

You can set the culture in the web.config via the globalization tag.


under the  <configuration> 

 <system.web>
      <globalization culture="en-GB"/>
   </system.web>

WYSIWYG Text Editor in asp.net using jquery


Use the script in head tag
  <script src="http://js.nicedit.com/nicEdit-latest.js" type="text/javascript"></script>
In the <head> tag of design page  create JavaScript function as:

 <script type="text/javascript">
        bkLib.onDomLoaded(function () {
            new nicEditor({ fullPanel: true }).panelInstance('txtName');
        });    
    </script>
                                               OR
if you use master page then you have to use this script
   <script type="text/javascript">
        bkLib.onDomLoaded(function () {
            new nicEditor({ fullPanel: true }).panelInstance('ctl00_ContentPlaceHolder1_txtName');
        });
   
    </script>
In the <body> Tag place a Textarea

<textarea id="txtName" type="text" class="input_txt" runat="server" style="width: 420px;
                                        height: 60px;"></textarea>

reference link
Click here read article

Monday, June 10, 2013

Tips for Happy Life for software developers..


  1. Drink at least 8 glasses of Water each day.
  2. Eat a good breakfast.
  3. Eat more natural food than packed and processed food. 
  4. Live life with Passion and Energy.
  5. Each day, spend 5 minutes reflecting on your day and see what did GOOD or BAD did you do today.
  6. Your Heart and Soul are your best friends. Always listen to them.
  7. Exercise at least 3 days a week. 1-2 hrs a day.
  8. Sleep well. At least 7 hours a day.  
  9. Don't compare your life to others. You have no idea what their journey is all about.
  10. Don't have negative thoughts or things you cannot control. Instead invest your energy in the positive present moment.
  11. Don't blame others for what you are today. People are in worst situations.
  12. Time is precious. No one knows how much you have. Don't waste it.
  13. Everyone has a positive and a negative side. Look for positive sides in others. Look for negative side in yourself and try to change it.
  14. Make peace with your past so it won't spoil the present.
  15. No one is in charge of your happiness but you.
  16. Just do what you supposed to do. Everything will be just fine.
  17. It takes 43 muscles to frown and 17 to smile. Just smile.
  18. Brush your teeth before you go to bed. Good teeth = Good smile.
  19. Don't delay calling your family and friends.
  20. When you are sick, your family and friends are the one you will need. Stay close to them.
  21. Each day, try to help one person in any way.
  22. Don't judge people by their work. If cleaners don't clean, you will be dirty too.
  23. Don't worry about that you cannot control.
  24. What other people think of you, it's their problem. Why do you care?
  25. Forgiveness is a high road. Adapt it.
  26. In an argument or fight, on one wins. Avoid it. Let you be the little fellow.
  27. For all good things, time is NOW. Do not delay them.
  28. For all bad things, there is always tomorrow. Leave them to tomorrow. Tomorrow never comes.
  29. Great people are same in both good and bad situations.
  30. Don't hate your boss. He has a job to do. If he is being unrealistic, let him know nicely.
  31. In business, no one is enemy. Everybody is trying to do their job. Don't take it personal.
  32. When you don't know what to do, take a break. Meet your good friends.
  33. Writing a good habit. Make a daily to do list J
  34. Do as much as you can do. If you can't, don't stress about it.
  35. Don't blame your parents for anything. You're here because of them.
  36. Before judging anyone, put yourself in their shoes.
  37. When you are down, look at people who are in worse situations.
  38. When you are up, look at people who are higher than you.
  39. Adapt good things from others.
  40. If you have any question, just ask. No question is stupid question.

Thursday, May 2, 2013

How to find total salary of each employee IN SQL??


I have a department table and i find out to total salary of each employee by department Id.

DeptId       Name      Salary
1            AA        2000 
1            AA       3000 
2            BB       1000
3            cc        1000
3            cc        4000
 
 sql query


SELECT E.DeptId,ISNULL(SUM(ES.Salary),0) AS Amt FROM Employee E
LEFT OUTER JOIN Employee ES ON E.DeptId=ES.DeptId
GROUP BY E.DeptId


 Output

DeptId             Salary
1                   5000 
2                   1000
3                   5000

How to Convert Indian Rupee to Word format

In this Articles ,I would like to show  simple function to Convert  Indian Money to word format in Indian money .
Pass the input string in function and get the value in word according to Indian rupee.

For example the input value 9,00,000  (Indian Money)  The output as follow:

Input value: 9,00,000

Output : 9 Lacs
Source Code
CREATE FUNCTION [dbo].[AmountToWords]
(
@TOTALAMOUNT varchar(max)

)

RETURNS
VARCHAR(500)
AS

BEGIN

DECLARE @AMOUNTWORD varchar(500)

DECLARE @LENGTH VARCHAR(200)=0

DECLARE
@SECONDWORD VARCHAR(200)
SET @LENGTH=(SELECT LEN(@TOTALAMOUNT))

IF
(@LENGTH=4)
BEGIN

SET
@SECONDWORD=(SELECT SUBSTRING(@TOTALAMOUNT,2,2))
IF
(@SECONDWORD!=00 )
SET @AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,1))+'.'+@SECONDWORD + ' Thousand'

ELSE

SET
@AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,1)) + ' Thousand'
END

ELSE
IF(@LENGTH=5)
BEGIN

SET
@SECONDWORD=(SELECT SUBSTRING(@TOTALAMOUNT,2,2))
IF
(@SECONDWORD!=00 )
SET
@AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,2))+'.'+(SELECT SUBSTRING(@TOTALAMOUNT,3,2)) + 'Thousand'
ELSE

SET
@AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,2)) + ' Thousand'
END

ELSE
IF(@LENGTH=6)
BEGIN

SET @SECONDWORD=(SELECT SUBSTRING(@TOTALAMOUNT,2,2))

IF
(@SECONDWORD!=00 )
SET
@AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,1))+'.'+@SECONDWORD + ' Lacs'
ELSE

SET @AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,1)) + ' Lacs'

END

IF(@LENGTH=7)

BEGIN

SET
@SECONDWORD=(SELECT SUBSTRING(@TOTALAMOUNT,2,2))
IF
(@SECONDWORD!=00 )
SET
@AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,2))+'.'+(SELECT SUBSTRING(@TOTALAMOUNT,3,2)) + ' Lacs'
ELSE

SET @AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,2)) + ' Lacs'

END

ELSE
IF(@LENGTH=8)
BEGIN

SET @SECONDWORD=(SELECT SUBSTRING(@TOTALAMOUNT,2,2))

IF
(@SECONDWORD!=00)
SET @AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,1))+'.'+@SECONDWORD + ' Crore'

ELSE

SET @AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,1)) + ' Crore'

END

ELSE IF(@LENGTH=9)

BEGIN

SET
@SECONDWORD=(SELECT SUBSTRING(@TOTALAMOUNT,2,2))
IF
(@SECONDWORD!=00 )
SET @AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,2))+'.'+(SELECT SUBSTRING(@TOTALAMOUNT,3,2)) + ' Crore'

ELSE

SET
@AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,2)) + ' Crore'  
END

ELSE
IF(@LENGTH=10)
BEGIN

SET @SECONDWORD=(SELECT SUBSTRING(@TOTALAMOUNT,2,2))

IF(@SECONDWORD!=00)

SET @AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,1))+'.'+@SECONDWORD + ' Arab'

ELSE

SET
@AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,1)) + ' Arab'  
END

ELSE IF(@LENGTH=11)

BEGIN

SET @SECONDWORD=(SELECT SUBSTRING(@TOTALAMOUNT,2,2))

IF
(@SECONDWORD!=00 )
SET @AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,2))+'.'+(SELECT SUBSTRING(@TOTALAMOUNT,3,2)) + ' Arab'

ELSE

SET @AMOUNTWORD=(SELECT SUBSTRING(@TOTALAMOUNT,1,2)) + ' Arab'

END

RETURN @AMOUNTWORD

END

Output
Select dbo.AmountToWords('900000') as Money
Output : 9 Lacs