Showing posts with label C# Developer. Show all posts
Showing posts with label C# Developer. Show all posts

All the Operation of Getdate()


Friday, July 15, 2011

Hello developers,

Please find all the operation done on particular getdate() function,



--Get today date
select getdate()

--Get Day
select DATENAME (DW,GETDATE())

--Get date of sundays in month
declare @d1 datetime, @d2 datetime
--select @d1 = '5/1/2009'
--,@d2= '5/31/2009'

select @d1 = CONVERT(datetime, DATEADD(dd,-(DAY(DATEADD(mm,1,GETDATE()))-1),DATEADD(mm,0,GETDATE())), 103)
,@d2= CONVERT(datetime, DATEADD(d, -DAY(DATEADD(m,1,getdate())),DATEADD(m,1,getdate())), 103)

;with dates ( date )
as
(
select @d1
union all
select dateadd(d,1,date)
from dates
where date < @d2
)
select day(date) as sundaydate from dates where datename(dw,date) = 'Sunday'


--Get total number of days in month
select datepart(dd,dateadd(dd,-1,dateadd(mm,1,cast(cast(year(getdate()) as varchar)+'-'+cast(month(getdate()) as varchar)+'-01' as datetime))))

--First Day of month
SELECT DAY(DATEADD(dd,-(DAY(DATEADD(mm,1,GETDATE()))-1),DATEADD(mm,0,GETDATE())))

--Last Day of month
SELECT DAY(DATEADD(d, -DAY(DATEADD(m,1,getdate())),DATEADD(m,1,getdate())))


--First Date of month
SELECT CONVERT(VARCHAR(10), DATEADD(dd,-(DAY(DATEADD(mm,1,GETDATE()))-1),DATEADD(mm,0,GETDATE())), 103)

--Last Date of month
SELECT CONVERT(VARCHAR(10), DATEADD(d, -DAY(DATEADD(m,1,getdate())),DATEADD(m,1,getdate())), 103)

--Get date of date
select DAY(getdate())



Thanks
Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer
Email: raj143svmit@gmail.com

e-Procurement Technologies Ltd (India)
www.abcprocure.com

How to define Global Variable in Windows Forms with C#


Thursday, March 25, 2010

Create one Static class and declare static member/property into that class.

Now you can access that variable from any form in your windows application. Also you can able to set and get variable values.

GlobalModule Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class GlobalModule
{

private static string _GlobalVar = "";
public static string GlobalVar
{
get { return _GlobalVar; }
set { _GlobalVar = value; }
}

public static string FirstName = "Rajesh";
}



How to use global variables in application:


//Set the value to static variable
GlobalModule.GlobalVar = "VB.Net C#";

//Get the value from static variable
string CheckVal = GlobalModule.GlobalVar;
string FirstName = GlobalModule.FirstName;



Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com


.

Delete all image file from Perticular folder in C#


Friday, March 19, 2010

Hello DotNet Developer,

Please find below code, which will help to find all file in perticular folder and delete all the file and make folder blank.

Explaination of the code : Delete all image file from Perticular folder in C#

Here, i have find the folder path using Server.MapPath, then stored all the file in the array, i have named it imglist.

Then i have used forloop to get all the files name one by one and delete it,
Here i have taken DateTime.Now.AddMinutes, because if the file is added just before 3 minutes from the current time, then it should not be delete, you can change the time according to your need.

Code :

protected void CleanImageFolder()
{
string imgFolder = Server.MapPath("~/lab/maskemail/img/");
string[] imgList = Directory.GetFiles(imgFolder, "*.jpg");
foreach (string img in imgList)
{
FileInfo imgInfo = new FileInfo(img);
if (imgInfo.LastWriteTime < DateTime.Now.AddMinutes(-3))
{
imgInfo.Delete();
}
}
}



Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

How to integrate Nochex Payment Gateway in C# ?


Wednesday, December 16, 2009

Solution :

Step 1 : Create one project in visual studio, and add below code in the HTML code of default.aspx page.



<table class="productholder" border="0" cellpadding="10" cellspacing="0" width="600">
<tbody>
<tr>
<td valign="top">
<h1>
Micro Helicopter</h1>
<h2>
Super Cool remote control copter!</h2>
<p>
An absolute must for all gadget heads - this amazing remote control copter is the
business. Just like what Nochex does for your business – this beauty will take you
to another level. Be a chopper pilot!
</p>
</td>
<td valign="top">
<img src="http://www.ukgadgetsrus.com/images/productimage-copter.gif" alt="Helecopter"
height="138" width="137" /></td>
<td valign="top">
<span class="stock">In stock</span><br />
<span class="prices">RRP £59.99</span><br />
<span class="prices2">Our Price £39.99 </span>
<form action="https://www.nochex.com/nochex.dll/checkout" method="post">
<div align="center">
<input type="hidden" name="email" size="64" value="xyz@xyz.com">
<input type="hidden" name="amount" size="8" value="39.99">
<br>
<input type="hidden" name="logo" size="64">
<br>
<input type="hidden" name="returnurl" value="http://localhost:1856/Nochex%20Payment%20Gateway%20Example/default.aspx" />
<input name="image" type="image" src="http://support.nochex.com/web/images/cardsboth2.gif"
alt="I accept payment using NOCHEX" />
</div>
</form>
</td>
</tr>
</tbody>
</table>



Step 2 : In the code you need to change the email value to your account email id, please replace that.

Step 3 : Set value of amount, logo and returnurl according to your product details.

Step 4 : thats it, you have done with payment integration.

Step 5 : Just select visa option for example and carry on with this credit card : 4111111111111111 and set issue number to 12 and Security number to 123.

Step 6 : Continue with the payment, after doing payment successfull, nochex website will return you to your return url.

Step 7 : Such a simple way to integrate Nochex payment gateway.

Step 8 : if you are satisfied with my explaination above, please put comment for me or if you feel any difficulties please put question as comment, i will reply to your question.

Please find Demo below

Merchant Payment Demo
http://www.ukgadgetsrus.com/merchant-payment-page.html

Seller Payment Demo
http://www.ukgadgetsrus.com/seller-payment-page.html


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

Get variables from web.config and global.asax


Saturday, December 5, 2009


There are two methods, you can assign variable at one place and call it from through out the website.

The first is, Declare the variable in web.config and call it in any aspx.cs page and the second is, Declare the variable in global.asax and call it in any aspx.cs page.

The first one is very usefull because you can edit it directly form the FTP editor.

Please find explanation and code of both method below,


First Method:
web.config
<appSettings>
<add key="siteurl" value="www.indianic.com"/>
<add key="TempDir" value="./uploads"/>
</appSettings>

Default.aspx.cs
ConfigurationSettings.AppSettings["siteurl"].ToString();
ConfigurationSettings.AppSettings["TempDir"].ToString();


Second Method:
global.asax
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Application["siteurl"] = "www.indianic.com";
Application["TempDir"] = "./uploads";
}

Default.aspx.cs
string smtphost = Application["siteurl"].ToString();
string userid = Application["TempDir"].ToString();


Please use any of the above method which is needed in your application.

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

How to upload zip file on blogger ?


Monday, October 26, 2009

Answer :

you can't upload any file directly to your blog.but you can achive this by indirectly, Please

read to find simple and free method to upload zip file on blogger.


Create account in this site :

http://www.4shared.com/signup.jsp


Just enter your email address and click on signup with FREE account

Then a virtual directory will be appered in front of you

http://www.4shared.com/account/dir/22327988/fd9c2607/sharing.html?rnd=46


Below you can see, upload file option, you can use that and upload your zip,image or any file
which you wanted, the user should download from your blog.

After uploading that file, you will see that file will appeared in the virtual directory.
then to get download link, you just click on download icon shown at the end of your file in

that virtual directory.

After clicking on that link, you will find this page

http://www.4shared.com/file/143676923/93c0c852/paypal_credit_card_processing_payment_gateway.html?signout=1


click on download, dont worry, the download will not start, this is to get download link.

after clicking on download button, you will see this page, counting download time in

decremently..

http://www.4shared.com/get/143676923/93c0c852/paypal_credit_card_processing_payment_gateway.html


then right click on this link "Click here to download this file" and click on "copy link

location".

open notepad and paste copied link.

i.e copied link ->


http://dc170.4shared.com/download/143676923/93c0c852/paypal_credit_card_processing_payment_gateway.zip?tsid=20091026-010849-1eccccca



How to use this download link in your blog

use this HTML code in your blog

&lt;a id="downloadid" src="http://dc170.4shared.com/download/143676923/93c0c852/paypal_credit_card_processing_payment_gateway.zip?tsid=20091026-010849-1eccccca" &gt;Download Source Code&lt;/a&gt;


when the user will click on this download link, the download will start from your blog without

visiting to other site.

Click here to see Demo


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

List of Test Credit Card Numbers


Thursday, October 22, 2009




credit cards images

Card Type

Card Number

American Express

378282246310005

American Express

371449635398431

American Express Corporate

378734493671000

Australian BankCard

5610591081018250

Diners Club

30569309025904

Diners Club

38520000023237

Discover

6011111111111117

Discover

6011000990139424

JCB

3530111333300000

JCB

3566002020360505

MasterCard

5555555555554444

MasterCard

5105105105105100

Visa

4111111111111111

Visa

4012888888881881

Visa

4222222222222

Note : Even though this number has a different character count than the other test numbers, it is the correct and functional number.

Processor-specific Cards

Dankort (PBS)

76009244561

Dankort (PBS)

5019717010103742

Switch/Solo (Paymentech)

6331101999990016




Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com