Archive for September, 2008

Passing variables for a image between Javascript and PHP for web2

Try a javascript image object:

var myImage = new Image();
myImage.src = “http://mydomain.xxx/myfile.php?x=” +x+ “&y=” +y”;

then you can use $_GET[x]  in myfile.php to take the variable

Advertisements

September 22, 2008 at 7:55 am Leave a comment

Janus gridEX click event c#

Useful query c# adonet

private void gridEX1_Click(object sender, EventArgs e)
{

//get position

int i = this.gridEX1.SelectedItems[0].Position;

//get id from column(0) and row position  ( dataset)

string id=  gridEX1.GetRow(i).Cells[0].Text;

}

September 22, 2008 at 7:43 am Leave a comment

Function field value is egual in .net c#

private static bool fieldValuesAreEqual(object[] lastValues, DataRow currentRow, string[] fieldNames)
{
bool areEqual = true;

for (int i = 0; i < fieldNames.Length; i++)
{
if (lastValues[i] == null || !lastValues[i].Equals(currentRow[fieldNames[i]]))
{
areEqual = false;
break;
}
}

return areEqual;
}

September 22, 2008 at 7:38 am Leave a comment

SQL create a procedure with update and insert a other table

CREATE PROCEDURE dbo.sp_UpdateLibList
@TableId     as numeric(18,0),
@descr1     as nvarchar(2048),
@descr2    as nvarchar(2048) = ‘ ‘,
@reftableid     as numeric(18,0),
@seealso     as nvarchar(2048),
@newsee    as numeric(18,0),
@UserID     as numeric(18,0)
AS
BEGIN
DECLARE    @Event_ID as Numeric(18,0),
@Table_Code     as nvarchar(50)

SET NOCOUNT ON
select @Table_Code = ( select Top 1 Table_Code from LibTables where Field_Code = ( select fieldcode from liblist where tableid = @tableid) )
if @Table_Code is not null
begin
UPDATE LibList
SET     descr1         = @descr1 ,
descr2         = @descr2 ,
reftableid     = @reftableid,
seealso        = @seealso,
newsee        = @newsee
WHERE tableid        = @tableid

INSERT INTO LibEvent ( Event_Type, TableId, Table_Code)
VALUES ( ‘U’, @TableId, @Table_Code )
SELECT @Event_ID = @@IDENTITY

INSERT INTO UserEvents ( [User_ID], Event_ID )
VALUES ( @UserID, @Event_ID )
end
END

September 22, 2008 at 7:35 am Leave a comment

Function Crop image

static Image Crop(Image imgPhoto, int Width, int Height, AnchorPosition Anchor)
{
int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height;
int sourceX = 0;
int sourceY = 0;
int destX = 0;
int destY = 0;

float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;

nPercentW = ((float)Width/(float)sourceWidth);
nPercentH = ((float)Height/(float)sourceHeight);

if(nPercentH < nPercentW)
{
nPercent = nPercentW;
switch(Anchor)
{
case AnchorPosition.Top:
destY = 0;
break;
case AnchorPosition.Bottom:
destY = (int)(Height – (sourceHeight * nPercent));
break;
default:
destY = (int)((Height – (sourceHeight * nPercent))/2);
break;
}
}
else
{
nPercent = nPercentH;
switch(Anchor)
{
case AnchorPosition.Left:
destX = 0;
break;
case AnchorPosition.Right:
destX = (int)(Width – (sourceWidth * nPercent));
break;
default:
destX = (int)((Width – (sourceWidth * nPercent))/2);
break;
}
}

int destWidth  = (int)(sourceWidth * nPercent);
int destHeight = (int)(sourceHeight * nPercent);

Bitmap bmPhoto = new Bitmap(Width, Height, PixelFormat.Format24bppRgb);
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);

Graphics grPhoto = Graphics.FromImage(bmPhoto);
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;

grPhoto.DrawImage(imgPhoto,
new Rectangle(destX,destY,destWidth,destHeight),
new Rectangle(sourceX,sourceY,sourceWidth,sourceHeight),
GraphicsUnit.Pixel);

grPhoto.Dispose();
return bmPhoto;
}

September 14, 2008 at 9:51 am Leave a comment

Function fix size image

public Image FixedSize(Image imgPhoto, int Width, int Height)
{
int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height;
int sourceX = 0;
int sourceY = 0;
int destX = 0;
int destY = 0;

float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;

nPercentW = ((float)Width/(float)sourceWidth);
nPercentH = ((float)Height/(float)sourceHeight);

//if we have to pad the height pad both the top and the bottom
//with the difference between the scaled height and the desired height
if(nPercentH < nPercentW)
{
nPercent = nPercentH;
destX = (int)((Width – (sourceWidth * nPercent))/2);
}
else
{
nPercent = nPercentW;
destY = (int)((Height – (sourceHeight * nPercent))/2);
}

int destWidth  = (int)(sourceWidth * nPercent);
int destHeight = (int)(sourceHeight * nPercent);

Bitmap bmPhoto = new Bitmap(Width, Height, PixelFormat.Format24bppRgb);
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);

Graphics grPhoto = Graphics.FromImage(bmPhoto);
grPhoto.Clear(Color.Red);
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;

grPhoto.DrawImage(imgPhoto,
new Rectangle(destX,destY,destWidth,destHeight),
new Rectangle(sourceX,sourceY,sourceWidth,sourceHeight),
GraphicsUnit.Pixel);

grPhoto.Dispose();
return bmPhoto;
}

September 14, 2008 at 9:50 am Leave a comment

Function for resize image with proportion

public  Image ConstrainProportions(Image imgPhoto, int Size, Dimensions Dimension)
{
int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height;
int sourceX = 0;
int sourceY = 0;
int destX = 0;
int destY = 0;
float nPercent = 0;

switch(Dimension)
{
case Dimensions.Width:
nPercent = ((float)Size/(float)sourceWidth);
break;
default:
nPercent = ((float)Size/(float)sourceHeight);
break;
}

int destWidth  = (int)(sourceWidth * nPercent);
int destHeight = (int)(sourceHeight * nPercent);

Bitmap bmPhoto = new Bitmap(destWidth, destHeight, PixelFormat.Format24bppRgb);
bmPhoto.SetResolution(imgPhoto.HorizontalResolution, imgPhoto.VerticalResolution);

Graphics grPhoto = Graphics.FromImage(bmPhoto);
grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;

grPhoto.DrawImage(imgPhoto,
new Rectangle(destX,destY,destWidth,destHeight),
new Rectangle(sourceX,sourceY,sourceWidth,sourceHeight),
GraphicsUnit.Pixel);

grPhoto.Dispose();
return bmPhoto;
}

September 14, 2008 at 9:48 am Leave a comment

Older Posts


September 2008
M T W T F S S
« Aug   Oct »
1234567
891011121314
15161718192021
22232425262728
2930