public partial class Shipment : System.Web.UI.Page
{
MembershipUser mu;
SiteMaster ms = new SiteMaster();
Data obj = new Data();
public string userEmail = "";
public string adr = "";
DataTable cartdetail = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (User.Identity.IsAuthenticated)
{
if (!Page.IsPostBack)
{
try
{
if (Session["tempcartid"].ToString() != null)
{
BindGridview(Session["tempcartid"].ToString());
Session["tempcartid"] = Session["tempcartid"];
}
BindAddressList();
}
catch (Exception ex)
{
}
if (Session["user"].ToString() != null)
{
Session["user"] = Session["user"].ToString();
mu = Membership.GetUser(Session["user"].ToString());
userEmail = mu.Email.ToString();
}
else
Response.Redirect("~/Login.aspx", false);
if (Session["tempcartid"].ToString() != null)
{
Session["tempcartid"] = Session["tempcartid"].ToString();
}
}
}
else
{
Response.Redirect("~/Login.aspx", false);
}
}
catch (Exception ex)
{
}
try
{
if (Session["tempcartid"].ToString() != null)
{
DataTable itemscount = new DataTable();
itemscount = obj.carttotalprice(Session["tempcartid"].ToString());
if (itemscount.Rows.Count > 0)
{
lbl_subtotal.Text = itemscount.Rows[0]["total"].ToString();
lbl_total.Text = lbl_subtotal.Text;
}
else
{
lbl_subtotal.Text = "0.00";
lbl_total.Text = lbl_subtotal.Text;
}
}
else
{
lbl_subtotal.Text = "0.00";
lbl_total.Text = lbl_subtotal.Text;
}
if (Session["tempcartid"].ToString() != null)
{
Session["tempcartid"] = Session["tempcartid"].ToString();
}
}
catch (Exception ex)
{
}
}
protected void lnkCheckout_Click(object sender, EventArgs e)
{
try
{
if (Session["tempcartid"].ToString() != null)
{
cartdetail = obj.web_Getcartdetail(Session["tempcartid"].ToString());
if (cartdetail.Rows.Count > 0)
{
Recvorder(Convert.ToInt32(cartdetail.Rows[0]["CompID"].ToString()), Session["user"].ToString(), DateTime.Now.ToString(), cartdetail.Rows[0]["Comments"].ToString(), "0", "25", "0", cartdetail.Rows[0]["total"].ToString(), "Cash on Home Delivery", "", "", lbl_SelectedAddress.Text);
}
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Your Cart is Empty');", true);
}
}
catch (Exception ex)
{
Response.Write(ex.ToString());
Page.ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Error Occured Please contact Support!!');" + ex.ToString(), true);
}
}
public void Recvorder(int CompID, string Customer_ID, string ordertime, string Recvorder_comments, string Recvorder_Totaldiscount, string Recvorder_Servicecharges, string Recvorder_promotioncode, string Recvorder_Totalamount, string Recvorder_Paymentmethod, string Recvorder_Paymentrecvstatus, string Recvorder_VoucherNo, string Recvorder_ShipmentAddress)
{
DataTable dtorderid = new DataTable();
Random rand = new Random();
string invoice = "web" + rand.Next(10000).ToString();
cartdetail = obj.web_Getcartdetail(Session["tempcartid"].ToString());
try
{
DateTime orderdatetime = DateTime.Parse(ordertime);
obj.web_Recvorder(orderdatetime, CompID, Customer_ID, "Open", orderdatetime, Recvorder_comments, "", Recvorder_Totaldiscount, Recvorder_Servicecharges, Recvorder_promotioncode, Recvorder_Totalamount, Recvorder_Paymentmethod, "Not-Received", Recvorder_VoucherNo, "web", "both", 0, invoice, Recvorder_ShipmentAddress);
foreach (DataRow dr in cartdetail.Rows)
{
obj.web_Recvorderdetail(invoice, Convert.ToInt32(dr["product_id"].ToString()), Convert.ToInt32(dr["quantity"].ToString()), float.Parse(dr["price"].ToString()), dr["SubMenuDetail"].ToString(), dr["Comments"].ToString());
}
Response.Redirect("order_done.aspx", false);
}
catch (Exception ex)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Error Occured Please contact Support!!');", true);
}
}
}