"£{0:F2}"—112.0000 as (pundMark)112.00
You can keep it blank or any currency name replaceing “£”
Wednesday, January 7, 2009
Combo box default selected item
ddlDissection.Items.Insert(0, new ListItem("--Select Item--", "-1"));
ddlDissection.SelectedValue = "-1";
ddlDissection.SelectedValue = "-1";
Write a trigger in sql server
//Write a trigger in sql server
-- =============================================
CREATE TRIGGER [dbo].[trigUpdateDissection_Cat_Vendor]
ON [dbo].[tblProductDissection]
AFTER INSERT,DELETE
AS
BEGIN
DECLARE
@VendorId bigint,
@DissectionId bigint,
@CategoryId bigint,
@ProductId bigint
IF (SELECT Count(*) FROM INSERTED) > 0
BEGIN
SELECT
@ProductId=tblProductDissection.ProductId,
@DissectionId=tblProductDissection.DissectionId
FROM INSERTED tblProductDissection
insert into dbo.tblDissection_Cat_Vendor
(
VendorId,
DissectionId,
CategoryId
)
SELECT VendorId ,@DissectionId,CategoryId from tblProduct where tblProduct.productId=@ProductId
END
--End inserted
IF (SELECT Count(*) FROM DELETED) > 0
BEGIN
SELECT
@ProductId=tblProductDissection.ProductId,
@DissectionId=tblProductDissection.DissectionId
FROM DELETED tblProductDissection
SELECT @VendorId=VendorId from tblProduct where tblProduct.productId=@ProductId
SELECT @CategoryId=CategoryId from tblProduct where tblProduct.productId=@ProductId
DELETE from dbo.tblDissection_Cat_Vendor
WHERE DissectionId=@DissectionId and
CategoryId=@CategoryId and VendorId=@VendorId
END
END
-- =============================================
CREATE TRIGGER [dbo].[trigUpdateDissection_Cat_Vendor]
ON [dbo].[tblProductDissection]
AFTER INSERT,DELETE
AS
BEGIN
DECLARE
@VendorId bigint,
@DissectionId bigint,
@CategoryId bigint,
@ProductId bigint
IF (SELECT Count(*) FROM INSERTED) > 0
BEGIN
SELECT
@ProductId=tblProductDissection.ProductId,
@DissectionId=tblProductDissection.DissectionId
FROM INSERTED tblProductDissection
insert into dbo.tblDissection_Cat_Vendor
(
VendorId,
DissectionId,
CategoryId
)
SELECT VendorId ,@DissectionId,CategoryId from tblProduct where tblProduct.productId=@ProductId
END
--End inserted
IF (SELECT Count(*) FROM DELETED) > 0
BEGIN
SELECT
@ProductId=tblProductDissection.ProductId,
@DissectionId=tblProductDissection.DissectionId
FROM DELETED tblProductDissection
SELECT @VendorId=VendorId from tblProduct where tblProduct.productId=@ProductId
SELECT @CategoryId=CategoryId from tblProduct where tblProduct.productId=@ProductId
DELETE from dbo.tblDissection_Cat_Vendor
WHERE DissectionId=@DissectionId and
CategoryId=@CategoryId and VendorId=@VendorId
END
END
Onclient click navigation-java scrip
OnClick="btnCancel_Click" OnClientClick="location.href='OrderStatus.aspx';return false;"
Using dictionaries for the check box area includeig page
//Property
protected Dictionary DicSelectedDissections
{
get
{
if (dicSelectedDissections == null)
{
if (Session["SelectedDissectionIds"] != null)
{
dicSelectedDissections = (Dictionary)Session["SelectedDissectionIds"];
}
else
{
dicSelectedDissections = new Dictionary();
}
}
return dicSelectedDissections;
}
set
{
dicSelectedDissections = value;
Session["SelectedDissectionIds"] = value;
}
}
//Handle area
private void UpdateSeletedtoDissectionList()
{
try
{
foreach (GridViewRow row in gvDissections.Rows)
{
if (((CheckBox)row.Cells[0].Controls[1]).Checked)
{
if (!DicSelectedDissections.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicSelectedDissections.Add(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()), "");
}
if (DicSelectedDissections.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicSelectedDissections.Remove(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()));
DicSelectedDissections.Add(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()), "");
}
if (DicDeletedDissection.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicDeletedDissection.Remove(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()));
}
}
else
{
if (!DicDeletedDissection.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()))
&& DicSelectedDissections.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicDeletedDissection.Add(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()),"");
}
if (DicSelectedDissections.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicSelectedDissections.Remove(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()));
}
}
}
Session["SelectedDissectionIds"] = DicSelectedDissections;
Session["DeletedDissectionIds"] = DicDeletedDissection;
}
protected Dictionary
{
get
{
if (dicSelectedDissections == null)
{
if (Session["SelectedDissectionIds"] != null)
{
dicSelectedDissections = (Dictionary
}
else
{
dicSelectedDissections = new Dictionary
}
}
return dicSelectedDissections;
}
set
{
dicSelectedDissections = value;
Session["SelectedDissectionIds"] = value;
}
}
//Handle area
private void UpdateSeletedtoDissectionList()
{
try
{
foreach (GridViewRow row in gvDissections.Rows)
{
if (((CheckBox)row.Cells[0].Controls[1]).Checked)
{
if (!DicSelectedDissections.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicSelectedDissections.Add(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()), "");
}
if (DicSelectedDissections.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicSelectedDissections.Remove(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()));
DicSelectedDissections.Add(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()), "");
}
if (DicDeletedDissection.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicDeletedDissection.Remove(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()));
}
}
else
{
if (!DicDeletedDissection.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()))
&& DicSelectedDissections.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicDeletedDissection.Add(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()),"");
}
if (DicSelectedDissections.ContainsKey(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString())))
{
DicSelectedDissections.Remove(Int32.Parse(gvDissections.DataKeys[row.RowIndex]["DissectionId"].ToString()));
}
}
}
Session["SelectedDissectionIds"] = DicSelectedDissections;
Session["DeletedDissectionIds"] = DicDeletedDissection;
}
can increase your asp.net application session timeout
You can increase your asp.net application session timeout in below methods:
1) Include this in you web.config file:
2) in the session_start of global.asax
protected void Session_Start(Object sender, EventArgs e)
{
Session.Timeout = 540;
}
The value of session timeout is in minutes.
1) Include this in you web.config file:
2) in the session_start of global.asax
protected void Session_Start(Object sender, EventArgs e)
{
Session.Timeout = 540;
}
The value of session timeout is in minutes.
Tuesday, January 6, 2009
get the ip and find the what countre from where it comming
private void SetUserCountry(Order newOrder)
{
string strIPaddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
//strIPaddress = "220.136.40.211";
string[] arrIPNumber = strIPaddress.Split('.');
//IP Number = A x 16777216 + B x 65536 + C x 256 + D
Int64 A = Int64.Parse(arrIPNumber[0]) * 16777216;
Int64 B = Int64.Parse(arrIPNumber[1]) * 65536;
Int64 C = Int64.Parse(arrIPNumber[2]) * 256;
Int64 D = Int64.Parse(arrIPNumber[3]);
Int64 iPNumber = A + B + C + D;
//lblError.Text = "IP :" + strIPaddress + " ipnumber : " + iPNumber;
string strUserCountry = newOrder.GetUserCountry(iPNumber);
if (strUserCountry != string.Empty)
{
//ddlBillingCountry.SelectedValue = ddlBillingCountry.Items.FindByText(strUserCountry).Value;
}
}
public string GetUserCountry(Int64 IPNumber)
{
try
{
string strCountry = string.Empty;
Database db = DatabaseFactory.CreateDatabase(Constants.Database_Connection_Name);
DbCommand dbCommand = db.GetStoredProcCommand(Constants.SP_GetUserCountry);
db.AddInParameter(dbCommand, "@nIPNumber", DbType.String, IPNumber);
DataSet dsUserCountry = db.ExecuteDataSet(dbCommand);
if (dsUserCountry != null)
{
if (dsUserCountry.Tables[0].Rows.Count > 0)
{
strCountry = dsUserCountry.Tables[0].Rows[0]["Country"].ToString();
}
}
return strCountry;
}
catch (Exception ex)
{
ex.Data.Add("BusinessLayerException", GetType().ToString() + Constants.Error_Seperator + "public DataTable GetDeliveryCities()");
throw ex;
}
}
//Stored procedure
-----
ALTER PROCEDURE [dbo].[uspGetUsercountry]
@nIPNumber BIGINT
AS
BEGIN
SELECT Country
FROM dbo.tblIPToCountry
WHERE (ToIPAddress >= @nIPNumber) AND (FromIPAddress <= @nIPNumber)
END
{
string strIPaddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
//strIPaddress = "220.136.40.211";
string[] arrIPNumber = strIPaddress.Split('.');
//IP Number = A x 16777216 + B x 65536 + C x 256 + D
Int64 A = Int64.Parse(arrIPNumber[0]) * 16777216;
Int64 B = Int64.Parse(arrIPNumber[1]) * 65536;
Int64 C = Int64.Parse(arrIPNumber[2]) * 256;
Int64 D = Int64.Parse(arrIPNumber[3]);
Int64 iPNumber = A + B + C + D;
//lblError.Text = "IP :" + strIPaddress + " ipnumber : " + iPNumber;
string strUserCountry = newOrder.GetUserCountry(iPNumber);
if (strUserCountry != string.Empty)
{
//ddlBillingCountry.SelectedValue = ddlBillingCountry.Items.FindByText(strUserCountry).Value;
}
}
public string GetUserCountry(Int64 IPNumber)
{
try
{
string strCountry = string.Empty;
Database db = DatabaseFactory.CreateDatabase(Constants.Database_Connection_Name);
DbCommand dbCommand = db.GetStoredProcCommand(Constants.SP_GetUserCountry);
db.AddInParameter(dbCommand, "@nIPNumber", DbType.String, IPNumber);
DataSet dsUserCountry = db.ExecuteDataSet(dbCommand);
if (dsUserCountry != null)
{
if (dsUserCountry.Tables[0].Rows.Count > 0)
{
strCountry = dsUserCountry.Tables[0].Rows[0]["Country"].ToString();
}
}
return strCountry;
}
catch (Exception ex)
{
ex.Data.Add("BusinessLayerException", GetType().ToString() + Constants.Error_Seperator + "public DataTable GetDeliveryCities()");
throw ex;
}
}
//Stored procedure
-----
ALTER PROCEDURE [dbo].[uspGetUsercountry]
@nIPNumber BIGINT
AS
BEGIN
SELECT Country
FROM dbo.tblIPToCountry
WHERE (ToIPAddress >= @nIPNumber) AND (FromIPAddress <= @nIPNumber)
END
Function for set UploadMaximum image file size
//Function for set UploadMaximum image file size
private void SetUploadSize()
{
decimal sizeInBytes = 0;
if (hdnOrderID.Value != string.Empty)
{
string directory = Server.MapPath("PhotoPrintImages/" + hdnOrderID.Value);
DirectoryInfo dir = new DirectoryInfo(directory);
foreach (FileInfo f in dir.GetFiles())
{
sizeInBytes += f.Length;
}
imageSize = (sizeInBytes / 1048576);
if (imageSize > 0)
{
lblSize.Text = imageSize.ToString("n2");
}
else
{
lblSize.Text = "0";
}
decimal maximumSize = Decimal.Parse(Constants.CONST_PRINT_MAXIMUM_SIZE);
decimal progressSize = Math.Round((imageSize / maximumSize) * 300, 0);
if (progressSize < 1)
{
imgProgressBar.Width = 0;
}
else
{
imgProgressBar.Width = (int)progressSize;
}
}
private void SetUploadSize()
{
decimal sizeInBytes = 0;
if (hdnOrderID.Value != string.Empty)
{
string directory = Server.MapPath("PhotoPrintImages/" + hdnOrderID.Value);
DirectoryInfo dir = new DirectoryInfo(directory);
foreach (FileInfo f in dir.GetFiles())
{
sizeInBytes += f.Length;
}
imageSize = (sizeInBytes / 1048576);
if (imageSize > 0)
{
lblSize.Text = imageSize.ToString("n2");
}
else
{
lblSize.Text = "0";
}
decimal maximumSize = Decimal.Parse(Constants.CONST_PRINT_MAXIMUM_SIZE);
decimal progressSize = Math.Round((imageSize / maximumSize) * 300, 0);
if (progressSize < 1)
{
imgProgressBar.Width = 0;
}
else
{
imgProgressBar.Width = (int)progressSize;
}
}
Subscribe to:
Posts (Atom)