在下面的代碼中,我有一個靜態方法,其中有一個數據表的值和另一個空數據表Orderdbl
並添加3列。檢查數據表中的值並將數值添加到數據表中
現在我的目標是發送locationid,productid,quantity
到靜態方法。
現在我想檢查productid
在數據表dtGrid
如果它沒有值,並且它應該與另一個數據表Orderdbl
檢查,如果它沒有值然後將值添加到數據表Orderdbl
並將其存儲在會話中。請幫我解決這個問題。
[WebMethod(EnableSession = true)]
public static void InsertData(string LocationID, string ProductID, string Quantity)
{
MastersClient objIndent = new MastersClient();
DataTable dtGrid = (DataTable)HttpContext.Current.Session["VSOrderForm"];
// DataSet ds = objIndent.CheckForExistingOrder(Int32.Parse(LocationID), ProductID);
var DataCheck = dtGrid.Select("ProductID = '" + ProductID + "'");
if (DataCheck.Length != 0)
{
// do something...
}
//if (ds != null && ds.Tables.Count > 0)
//{
//}
else
{
DataTable Orderdbl = new DataTable();
Orderdbl.Columns.Add("LocationID", typeof(string));
Orderdbl.Columns.Add("ProductID", typeof(string));
Orderdbl.Columns.Add("Quantity", typeof(string));
DataRow row = Orderdbl.NewRow();
//if (string.IsNullOrEmpty((string)Orderdbl.Rows[i][j].value))
if (Orderdbl == null)
{
row["LocationID"] = LocationID;
row["ProductID"] = ProductID;
Orderdbl.Rows.Add(row);
HttpContext.Current.Session["OrderForm"] = Orderdbl;
}
else
{
string FilterCond1 = "ProductID=" + ProductID;
DataRow[] newrow = Orderdbl.Select(FilterCond1);
if (newrow.Length > 0)
{
for (int i = 0; i < newrow.Length; i++)
{
if (newrow[i]["ProductID"].ToString() == ProductID)
{
// YOUR CODE HERE
}
}
}
else
{
row["LocationID"] = LocationID;
row["ProductID"] = ProductID;
Orderdbl.Rows.Add(row);
HttpContext.Current.Session["OrderForm"] = Orderdbl;
}
}
}
}
對不起朋友。這裏沒有人會爲你寫代碼。如果您遇到任何奇怪的錯誤或遇到一些問題,那麼人們會幫助您解決他們的想法。 – Thangadurai 2014-12-19 11:57:31
@Thangadurai我寫的代碼請告訴我是錯誤 – Developer 2014-12-19 12:00:22
什麼是錯誤? – Mairaj 2014-12-19 12:02:26