Search

Tuesday, April 7, 2009

Globlization Localization Date

"public DateTime CultureDate(string dat)
{
DateTime condate;
string[] dt = dat.Split('/');
CultureInfo cul = CultureInfo.CurrentCulture;
if (cul.ToString() == 'en-US')
{
return condate = Convert.ToDateTime(dt[1] + '/' + dt[0] + '/' + dt[2]);
}
else if (cul.ToString() == 'en-UK')
{
return condate = Convert.ToDateTime(dt[0] + '/' + dt[1] + '/' + dt[2]);
}
else
{
return condate = Convert.ToDateTime(dt[0] + '/' + dt[1] + '/' + dt[2]);
}
}"

Thursday, March 19, 2009

Case Statement in Ms-SQL Server

SELECT Partys.PartyId, Partys.PartyName, GRN.ChallanNo, GRNDetail.GrnId, GRNDetail.ChallanQty,
GRNDetail.AcceptQty,
CASE
WHEN challanqty = Acceptqty THEN '55%'
WHEN ((Acceptqty / challanqty) * 100) > 90 THEN '50%'
WHEN ((Acceptqty / challanqty) * 100) > 90 AND ((Acceptqty / challanqty) * 100) < 70 THEN '40%'
WHEN ((Acceptqty / challanqty) * 100) > 70 AND ((Acceptqty / challanqty) * 100) < 50 THEN '25%'
ELSE '0%'
END AS 'Quality',

GRN.PoNo,

Convert(nvarchar,PurchaseOrders.DeliverbyDate,103) as DeliverbyDate,convert(nvarchar,grn.GrnDate,103)AS GrnDate,
Case

when (datediff(day,DeliverbyDate,GrnDate))<= 3 then '45%'
when (datediff(day,DeliverbyDate,GrnDate))> 3 and (datediff(day,DeliverbyDate,GrnDate)) <= 7 then '35%'
when (datediff(day,DeliverbyDate,GrnDate))> 7 and (datediff(day,DeliverbyDate,GrnDate)) <= 10 then '20%'
else
'0%'

end as 'delivery'
FROM GRNDetail

Thursday, March 5, 2009

Monday, March 2, 2009

Print Crystal Report Programatically with Parameter




Print Report On Click Button Or Programatically with Parameter using Below Code

CrystalReportViewer1_Load
{
'Define Report Document

crReportDocument = New ReportDocument()

'Find Current Printer in Local Machine

Dim printDocument As New System.Drawing.Printing.PrintDocument()
crReportDocument.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName

'find path of report

Path = Application.StartupPath
Path = Mid(Path, 1, Len(Path) - 9)


'load printer

crReportDocument.Load(Path & "\test2.rpt")

'pass Peramter

crReportDocument.SetParameterValue("@invoiceid", invoiceno)
CrystalReportViewer1.ReportSource = crReportDocument

'Assign User name and database name for avoid error Answer
'Incorrect Log on Parameters

crReportDocument.SetDatabaseLogon("sa", "pass#word1", ".\sqlexpress","TATA")

'Print report using Printer

crReportDocument.PrintToPrinter(1, True, 1, 1)

}
End Sub

Saturday, February 7, 2009

Crystalt Report in Asp.net(C#)

//Display Crystal Report Using Asp.net with No Perameter

//Assembly to add
using CrystalDecisions.Shared;
using CrystalDecisions;
using CrystalDecisions.CrystalReports.Engine;

protected void Page_Load(object sender, EventArgs e)
{
CrystalReportViewer1.ReportSource = "~/Reports/Reportname.rpt";

configureCRYSTALREPORT();
}

private void configureCRYSTALREPORT()
{
ConnectionInfo myConnectionInfo = new ConnectionInfo();

myConnectionInfo.DatabaseName = "databasename";
myConnectionInfo.UserID = "sa";
myConnectionInfo.Password = "sa";
setDBLOGONforREPORT(myConnectionInfo);
}

private void setDBLOGONforREPORT(ConnectionInfo myconnectioninfo)
{
TableLogOnInfos mytableloginfos = new TableLogOnInfos();
mytableloginfos = CrystalReportViewer1.LogOnInfo;
foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
{
myTableLogOnInfo.ConnectionInfo = myconnectioninfo;
}

}


//Now Crystal report With Perameter
protected void Page_Load(object sender, EventArgs e)
{
CrystalReportViewer1.ReportSource = "~/Reports/Reportname.rpt";


//First Perameter

ParameterFields paramFields_pFrmDate = CrystalReportViewer1.ParameterFieldInfo;
ParameterField paramField_pFrmDate = paramFields_pFrmDate["@fromdate"];
ParameterValues curValues_pFrmDate = paramField_pFrmDate.CurrentValues;
ParameterDiscreteValue discreteValue_pFrmDate = new ParameterDiscreteValue();
discreteValue_pFrmDate.Value = Session["item_maingroup_fromdate"] ;
curValues_pFrmDate.Add(discreteValue_pFrmDate);
CrystalReportViewer1.ParameterFieldInfo = paramFields_pFrmDate;

//Second Perameter

ParameterFields paramFields_pToDate = CrystalReportViewer1.ParameterFieldInfo;
ParameterField paramField_pToDate = paramFields_pToDate["@todate"];
ParameterValues curValues_pToDate = paramField_pToDate.CurrentValues;
ParameterDiscreteValue discreteValue_pToDate = new ParameterDiscreteValue();
discreteValue_pToDate.Value = Session["item_maingroup_todate"];
curValues_pToDate.Add(discreteValue_pToDate);
CrystalReportViewer1.ParameterFieldInfo = paramFields_pToDate;

configureCRYSTALREPORT();
}

private void configureCRYSTALREPORT()
{
ConnectionInfo myConnectionInfo = new ConnectionInfo();

myConnectionInfo.DatabaseName = "DatabaseName";
myConnectionInfo.UserID = "sa";
myConnectionInfo.Password = "sa";
setDBLOGONforREPORT(myConnectionInfo);
}

private void setDBLOGONforREPORT(ConnectionInfo myconnectioninfo)
{
TableLogOnInfos mytableloginfos = new TableLogOnInfos();
mytableloginfos = CrystalReportViewer1.LogOnInfo;
foreach (TableLogOnInfo myTableLogOnInfo in mytableloginfos)
{
myTableLogOnInfo.ConnectionInfo = myconnectioninfo;
}

}

Saturday, January 24, 2009

Web.confing Connection String Encrypted Decrypted



Web.config Encyrpted and Decrypted






protected void Page_Load(object sender, EventArgs e)

{

// load web.config into TextBox on first page visit...

if (!Page.IsPostBack)

{

RefreshWebConfig();

}

}



private void RefreshWebConfig()

{

// Read in the value of Web.config into the TextBox...

using (StreamReader reader = File.OpenText(Server.MapPath("~/Web.config")))

{

webConfig.Text = reader.ReadToEnd();

}



// Programmatically read in the value of the connection string

PlainTextConnectionString.Text =
ConfigurationManager.ConnectionStrings["MembershipConnectionString"].ConnectionString;

}



protected void btnRefreshWebConfig_Click(object sender, EventArgs e)

{

RefreshWebConfig();

}



protected void btnEncrypt_Click(object sender, EventArgs e)

{

ProtectSection("connectionStrings", "DataProtectionConfigurationProvider");

RefreshWebConfig();

}



protected void btnDescrypt_Click(object sender, EventArgs e)

{

UnProtectSection("connectionStrings");

RefreshWebConfig();

}



protected void btnEncAuthentication_Click(object sender, EventArgs e)

{

ProtectSection("system.web/authentication", "DataProtectionConfigurationProvider");

RefreshWebConfig();

}



protected void btnDecAuthentication_Click(object sender, EventArgs e)

{

UnProtectSection("system.web/authentication");

RefreshWebConfig();

}



private void ProtectSection(string sectionName,

string provider)

{

Configuration config =

WebConfigurationManager.

OpenWebConfiguration(Request.ApplicationPath);



ConfigurationSection section =

config.GetSection(sectionName);



if (section != null &&

!section.SectionInformation.IsProtected)

{

section.SectionInformation.ProtectSection(provider);

config.Save();

}

}



private void UnProtectSection(string sectionName)

{

Configuration config =

WebConfigurationManager.

OpenWebConfiguration(Request.ApplicationPath);



ConfigurationSection section =

config.GetSection(sectionName);



if (section != null &&

section.SectionInformation.IsProtected)

{

section.SectionInformation.UnprotectSection();

config.Save();

}

}






Friday, July 18, 2008

Upload Multiple Folder On FTP




In Asp.net we have to upload multiple folder in FTP then using Below Code we can upload Multiple folder

FtpWebRequest ftpReq = WebRequest.Create("ftp://URL" + Name.Substring(0, 5)) as FtpWebRequest;
ftpReq.Method = WebRequestMethods.Ftp.MakeDirectory;
ftpReq.Credentials = new NetworkCredential("Username", "password");


FtpWebResponse ftpResp = ftpReq.GetResponse() as FtpWebResponse;

Blog Archive

Contributors