Thursday, March 13, 2008

Declaring Global Variables

A global variable is a variable that is accessible in every scope

New Class with Class Name: GlobalVars

public class GlobalVars
{
private static string cstmAccId;
public static string strcstmAccountId
{
get { return cstmAccId; }
set { cstmAccId = value; }
}
}

Assigning value to Global variable
GlobalVars. strcstmAccountId=”10”;

Accessing value of Global variable
String strId= GlobalVars. strcstmAccountId;

Monday, March 10, 2008

Convert RGB to CMYK in Delphi script

uses Math;

function RGBtoCMYK(const rgbColor : TRGBColor) : TCMYKColor;
begin
with Result do
begin
Cyan := 1 - rgbColor.Red;
Magenta := 1 - rgbColor.Green;
Yellow := 1 - rgbColor.Blue;

KeyPlate := Min(Min(Cyan, Magenta), Yellow) ;

Cyan := Cyan - KeyPlate;
Magenta := Magenta - KeyPlate;
Yellow := Yellow - KeyPlate;
end;
end;

var
rgbColor : TRGBColor;
cmykColor : TCMYKColor;

begin
rgbColor.Red := 128;
rgbColor.Green := 64;
rgbColor.Blue := 192;

cmykColor := RGBtoCMYK(rgbColor) ;

Caption := Format('%d-%d-%d-%d',[cmykColor.Cyan, cmykColor.Magenta, cmykColor.Yellow, cmykColor.KeyPlate])
end;

export datatable to excel

public static void ExportToSpreadsheet(DataTable table, string name)
{
HttpContext context = HttpContext.Current;
context.Response.Clear();
foreach (DataColumn column in table.Columns)
{
context.Response.Write(column.ColumnName + ";");
}
context.Response.Write(Environment.NewLine);
foreach (DataRow row in table.Rows)
{
for (int i = 0; i < table.Columns.Count; i++)
{
context.Response.Write(row[i].ToString().Replace(";", string.Empty) + ";");
}
context.Response.Write(Environment.NewLine);
}
context.Response.ContentType = "text/csv";
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name + ".csv");
context.Response.End();
}

Merge 2 datatset

''here ds1 in one dataset
''and ds2 as second dataset

here we want to merge the ds2 to ds1

ds1.Merge(ds2, False, MissingSchemaAction.Add)

Creating a ProgressBar with ASP.NET

http://aspalliance.com/760
http://forums.asp.net/p/1048429/1502684.aspx#1502684
http://forums.asp.net/p/1040649/1449185.aspx
http://msdn.microsoft.com/msdnmag/issues/03/12/DesignPatterns/
http://www.aspdotnetcodes.com/GridView_Insert_Edit_Update_Delete.aspx
http://msdn2.microsoft.com/en-us/library/ms972940.aspx
http://aspalliance.com/1125_Dynamically_Templated_GridView