// POS PAGE
        public static void CreateOrder(CsOrder neworder)
        {
            string aQuery = string.Format(@"INSERT INTO tblOrder(orderNO, orderCustomerNO, orderDate) 
            VALUES (NEXT VALUE FOR SQOrderNum,'{0}',getdate());", neworder.CustomerNumber);

            string bQuery = string.Format(@"SELECT current_value FROM sys.sequences WHERE name = 'SQOrderNum'; ");



            cmdStringA = new SqlCommand(aQuery, cntString);
            cmdStringB = new SqlCommand(bQuery, cntString);

            try
            {
                // ORDER INSERT
                cntString.Open();
                cmdStringA.ExecuteNonQuery();

                // GET ORDERNUMBER (CURVAL)
                SqlDataAdapter da = new SqlDataAdapter(cmdStringB);
                DataTable      dt = new DataTable();
                DataSet        ds = new DataSet();
                da.Fill(dt);
                ds.Tables.Add(dt);


                neworder.OrderNumber = dt.Rows[0]["current_value"].ToString();
            }

            finally
            {
                cntString.Close();
            }
        }
Beispiel #2
0
        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 = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    //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
                {
                }
            }
        }