protected void btnInitiate_Click(object sender, EventArgs e)
        {
            using (SqlConnection con = new SqlConnection(constr))
            {
                con.Open();
                string     query = "INSERT INTO ItemOrder(OrderID,MenuID,Qty) values(@OrderID,@MenuID,@Qty)";
                SqlCommand cmd3  = new SqlCommand(query, con);
                Random     rnd   = new Random();
                int        idr   = rnd.Next(99999, 1000000) + 1;
                cmd3.Parameters.AddWithValue("@OrderID", idr);
                cmd3.Parameters.AddWithValue("@MenuID", SelectedItem);
                cmd3.Parameters.AddWithValue("@Qty", 1);
                cmd3.ExecuteNonQuery();
                con.Close();
                //pricemenu
                double menuprice = 0;
                using (CreateOrder CO = new CreateOrder())
                {
                    menuprice += CO.retrieveMenuPrice(SelectedItem);
                }

                //DateTime date = DateTime.Today;
                String todaydate = date.ToString("dd-MM-yyyy");

                con.Open();
                string     query1 = "INSERT INTO ORDERTABLE(OrderID,CustID,Contact,TotalPrice,TotalQty,AddressCode,DateSend,TimeSend) values(@OrderID,@CustID,@Contact,@TotalPrice,@TotalQty,@AddressCode,@DateSend,@TimeSend)";
                SqlCommand cmd1   = new SqlCommand(query1, con);

                cmd1.Parameters.AddWithValue("@OrderID", idr);
                cmd1.Parameters.AddWithValue("@CustID", Session["Id"].ToString());
                cmd1.Parameters.AddWithValue("@Contact", txtContact.Text);
                cmd1.Parameters.AddWithValue("@TotalPrice", menuprice.ToString());
                cmd1.Parameters.AddWithValue("@TotalQty", 1);
                cmd1.Parameters.AddWithValue("@AddressCode", UsAddress);
                if (txtDate.Text == "Today")
                {
                    cmd1.Parameters.AddWithValue("@DateSend", todaydate);
                }
                else
                {
                    cmd1.Parameters.AddWithValue("@DateSend", txtDate.Text);
                }
                cmd1.Parameters.AddWithValue("@TimeSend", txtTime.Text);

                cmd1.ExecuteNonQuery();
                con.Close();


                Response.Redirect("CreateOrder.aspx?id=" + idr);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            OrderID = Request.QueryString["Id"];
            MenuID  = Request.QueryString["mn"];
            SqlConnection con = new SqlConnection(constr);

            con.Open();
            SqlCommand cmd2 = con.CreateCommand();

            cmd2.CommandType = CommandType.Text;
            cmd2.CommandText = "Select * from Menu where Id like '%" + MenuID + "%'";
            cmd2.ExecuteNonQuery();
            DataTable      dt2  = new DataTable();
            SqlDataAdapter sda2 = new SqlDataAdapter(cmd2);

            sda2.Fill(dt2);
            int a = dt2.Rows.Count;

            //btnConfirm.Text = a.ToString();
            //btnCancel.Text = MenuID;
            if (dt2.Rows.Count > 0)
            {
                StringBuilder html = new StringBuilder();
                html.Append("<div style='width:100%; height:230px;'>");
                html.Append("<img style='width:100%; height:auto' src='");
                html.Append(dt2.Rows[0][6].ToString());
                html.Append("' /></div>");
                html.Append("<h3 class='label-menu'>");
                html.Append(dt2.Rows[0][1].ToString());
                html.Append("</h3>");
                html.Append("<h3 class='label-desc' style='line-height:15px'>");
                html.Append(dt2.Rows[0][2].ToString());
                html.Append("</h3>");
                html.Append("<h5 class='widthmax label-price'>RM");
                html.Append(dt2.Rows[0][3].ToString());
                html.Append("</h5>");

                PlaceHolderItem.Controls.Add(new Literal {
                    Text = html.ToString()
                });
            }
            else
            {
                ;
            }
            con.Close();
            //Order Info

            using (CreateOrder CO = new CreateOrder())
            {
                double total = Convert.ToDouble(CO.DisplayTotalPrice(OrderID));
                double sbtl  = CO.retrieveMenuPrice(MenuID);
                lblTotal.Text    = (total + sbtl).ToString();
                lblsubtotal.Text = sbtl.ToString();
                menupr           = sbtl;
            }
            if (!IsPostBack)
            {
                using (CreateOrder CO = new CreateOrder())
                {
                    Dictionary <String, int> GetOrderedItems = CO.GetOrderedItems(OrderID);
                    foreach (KeyValuePair <String, int> item in GetOrderedItems)
                    {
                        if (item.Key.Equals(MenuID))
                        {
                            txtQty.SelectedIndex = (item.Value - 1);
                        }
                    }
                    double newprice = menupr * Convert.ToDouble(txtQty.SelectedValue);
                    lblsubtotal.Text = newprice.ToString();
                }
            }
        }