在下面的代码中,我有一个静态方法,其中有一个数据表的值和另一个空数据表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