using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class Admin_Controls_OrderStatus : WebBlockUserControl
{
string ImagePath
{
get { return (Session["ImagePath"] == null ? "" : Session["ImagePath"].ToString()); }
set { Session["ImagePath"] = value; }
}
private int _OrderID = 0;
public int OrderID
{
get { return _OrderID; }
set { _OrderID = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
BindData();
}
private void BindData()
{
// use session variables to prevent URL hacking
ImagePath = ("~/Resources/Orders/" + OrderID.ToString() + "/UPSshippinglabel.gif");
hypDelay.NavigateUrl += _OrderID.ToString();
hypReauthorize.NavigateUrl += _OrderID.ToString();
hypCancel.NavigateUrl += _OrderID.ToString();
hypReverseCancel.NavigateUrl += _OrderID.ToString();
hypRefund.NavigateUrl += _OrderID.ToString();
hypCapture.NavigateUrl += _OrderID.ToString();
hypShip.NavigateUrl += _OrderID.ToString();
hypVoidShipment.NavigateUrl += _OrderID.ToString();
DataRow dr = Database.Orders_GetByOrderID(_OrderID);
litStatus.Text = (string)dr["StatusName"];
litAuthorized.Text = ((bool)dr["IsAuthorized"] ? "Yes" : "No");
litSettled.Text = ((bool)dr["IsCaptured"] ? "Yes" : "No");
bool isShipped = (bool)dr["IsShipped"];
litShipped.Text = (isShipped ? "Yes" : "No");
if (isShipped)
{
string labelPath = Server.MapPath("~/Resources/Orders/" + OrderID.ToString());
string[] shippingLabels = Directory.GetFiles(labelPath, "UPSshippinglabel*");
for(int i = 0; i < shippingLabels.Length; i++)
{
string str = shippingLabels[i];
str = str.Substring(str.IndexOf("Resources"));
litPrintShippingLabel.Text += "Print Shipping Label (" + (i + 1) + ")
";
}
pnlShipped.Visible = true;
}
if (System.IO.File.Exists(Server.MapPath("~/Resources/Orders/" + OrderID.ToString() + "/HighValueReport.html")))
{
lnkHighValueReport.NavigateUrl = "~/Resources/Orders/" + OrderID.ToString() + "/HighValueReport.html";
pnlHighValueReport.Visible = true;
}
switch ((int)dr["OrderStatusID"])
{
case 1: // Received
{
if ((bool)dr["IsAuthorized"])
hypCapture.Visible = true;
if (isShipped)
hypVoidShipment.Visible = true;
else
hypShip.Visible = true;
hypDelay.Visible = true;
hypReauthorize.Visible = true;
hypCancel.Visible = true;
break;
}
case 3: // Shipped
{
hypVoidShipment.Visible = true;
if (!(bool)dr["IsCaptured"])
hypCapture.Visible = true;
else
hypRefund.Visible = true;
break;
}
case 4: // Cancelled
{
hypReverseCancel.Visible = true;
break;
}
case 5: // Refunded
{
if (isShipped)
{
hypVoidShipment.Visible = true;
}
hypReauthorize.Visible = true;
break;
}
case 6: // Delayed
{
if (isShipped)
hypVoidShipment.Visible = true;
else
hypShip.Visible = true;
hypCapture.Visible = true;
hypReauthorize.Visible = true;
hypCancel.Visible = true;
break;
}
case 8: // Billing Error
{
if (isShipped)
hypVoidShipment.Visible = true;
else
hypShip.Visible = true;
hypDelay.Visible = true;
hypReauthorize.Visible = true;
hypCancel.Visible = true;
break;
}
case 13: // Completed
{
hypVoidShipment.Visible = true;
hypRefund.Visible = true;
break;
}
case 14: // Captured
{
if (isShipped)
hypVoidShipment.Visible = true;
else
hypShip.Visible = true;
hypRefund.Visible = true;
break;
}
default: //unspecified
break;
}
}
}