protected void CheckOut(object sender, EventArgs e) { if (subTotal.Text == "0" && lblCustomerNumber.Text == "-") { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Please Choose Item and Customer');</script>"); } else if (lblCustomerNumber.Text == "-" && subTotal.Text != "0") { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Please Select Customer (Use Search box above)');</script>"); } else if (lblCustomerNumber.Text != "-" && subTotal.Text == "0") { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Please Add Items to Cart');</script>"); } else { // CUSTOMER NUMBER FROM SEARCH WINDOW CustomerNum = lblCustomerNumber.Text; try { CsOrder newOrder = new CsOrder(OrderNum, CustomerNum, OrderDate); // INSERT ORDER + GET ORDER NUMBER ConnectionClass.CreateOrder(newOrder); // INSERT ORDER NUMBER INTO ORDERITEM TABLE (ITABLE) for (int a = 0; a < iTable.Rows.Count; a++) { iTable.Rows[a]["orderno"] = newOrder.OrderNumber; } // REBUILD GRIDVIEW //GridView1.DataSource = iTable; //GridView1.DataBind(); // UPLOAD ORDERITEM TABLE (ITABLE) ConnectionClass.UploadOrderItem(iTable); // PASS SESSION VALUE (ORDER NUMBER) Session["ONUM"] = newOrder.OrderNumber; Session["CNAME"] = lblCustomerName.Text; Session["CNUM"] = lblCustomerNumber.Text; // EMPTY ITABLE //Session["iTable"] = null; iTable.Clear(); //subTotal.Text = "0"; //grandTotal.Text = "0"; //GridView1.DataSource = iTable; //GridView1.DataBind(); //lblCustomerName.Text = " "; //lblCustomerNumber.Text = "-"; //SUCCESS MESSAGE ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Order Confirmed');</script>"); ClientScript.RegisterStartupScript(this.Page.GetType(), "", "window.open('012pos_seeOrderReceipt.aspx','window','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,height=350,width=700,left=130,top=220');", true); Page.ClientScript.RegisterStartupScript(this.GetType(), "refresh", "window.location.href=window.location;", true); } catch { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Error Occured,Please try again later. ');</script>"); } finally { } } }