62,271
社区成员
发帖
与我相关
我的任务
分享
protected void odsOrderList_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
if (e.ReturnValue != null)
{
DataSet ds = (DataSet)e.ReturnValue;
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
bool existsCheckAddress =ds.Tables[0].Columns.Contains("CheckAddress");
if (existsCheckAddress)
{
BoundField colCheckAddress = new BoundField();
colCheckAddress.DataField = "CheckAddress";
colCheckAddress.HeaderText = "联系地址";
colCheckAddress.ItemStyle.Width = 200;
this.gdvInfoList.Columns.Add(colCheckAddress);
}
}
}
}

[DataObjectMethod(DataObjectMethodType.Select)]
public DataSet GetOrderInfoForShoper(int productid, string ownerName, string orderNum, string tel, string coupon)
{
DataSet ds=dal.GetOrderInfoForShoper(productid,ownerName,orderNum,tel,coupon);
if(ds!=null&& ds.Tables[0].Rows.Count>0)
{
bool existsCheckAddress = false;
bool existsCouponNum = false;
foreach (DataRow row in ds.Tables[0].Rows)
{
if (string.IsNullOrEmpty(row["UseStatus"].ToString()))
{
row["UseStatus"] = 0;
}
if (!string.IsNullOrEmpty(row["LogisticsStatus"].ToString()))
{
int status = Convert.ToInt32(row["LogisticsStatus"]);
switch (status)
{
case 0:
row["UseStatus"] = 3;
break;
case 1:
row["UseStatus"] = 4;
break;
default:
break;
}
}
if (!existsCheckAddress && !string.IsNullOrEmpty(row["CheckAddress"].ToString()))
{
existsCheckAddress = true;
}
if (!existsCouponNum && !string.IsNullOrEmpty("CouponNum"))
{
existsCouponNum = true;
}
}
if (!existsCheckAddress)
{
ds.Tables[0].Columns.Remove("CheckAddress");
ds.Tables[0].Columns.Remove("CompanyName");
ds.Tables[0].Columns.Remove("LogisticsNumber");
}
if (!existsCouponNum)
{
ds.Tables[0].Columns.Remove("CouponNum");
}
}
return ds;
}
protected void gdvInfoList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView row = (DataRowView)e.Row.DataItem;
string oid = row["OrderID"].ToString();
if (row.DataView.Table.Columns.Contains("CouponNum"))
{
LinkButton b = (LinkButton)e.Row.FindControl("lnkbtnCoupon");
string couponNum = row["CouponNum"].ToString();
b.Text = couponNum;
b.OnClientClick = "showCoupon('" + oid + "');return false;";
}
LinkButton a = (LinkButton)e.Row.FindControl("lbtnStatus");
a.OnClientClick = "showDiv('" + oid + "',this);return false";
int useStatus = Convert.ToInt32(row["UseStatus"]);
switch (useStatus)
{
case 1:
a.Text = "未使用";
break;
case 2:
a.Text = "已使用";
break;
case 3:
a.Text = "未发货";
break;
case 4:
a.Text = "已发货";
break;
case 5:
a.Text = "已过时";
break;
default:
a.Text = "未修改";
break;
}
}
}