コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["itemNum"] != null && !IsPostBack)
            {
                inumlbl.Text = Session["itemNum"].ToString();

                // update 이전: 텍스트박스+ 드롭다운리스트 disabled, 업로드버튼 invisible
                btnUpload.Visible = false;
                DisableTextBoxes(Page);

                iID = inumlbl.Text;


                try
                {
                    CsItem theitem = new CsItem(iID, iCategory, iName, iPPrice, iRPrice, iNote, iImage, iQuantity, iRday);

                    ConnectionClass.GetItemDetails(theitem); //  NO CURRENCY DISPLAY (FOR EASILY UPDATING)

                    CategoryList.SelectedItem.Text = theitem.itemCategory;
                    iNameBox.Text             = theitem.itemName;
                    qtyList.SelectedItem.Text = theitem.itemQuantity;
                    notebox.Text = theitem.itemNote;

                    pPriceBox.Text   = theitem.itemPPrice;
                    rPriceBox.Text   = theitem.itemRPrice;
                    testimg.ImageUrl = theitem.itemImage;
                    imgURL.Text      = theitem.itemImage;
                }

                catch
                {
                    ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('error');</script>");
                }
                finally
                {
                }
            }
        }
コード例 #2
0
        // SELECT ITEM (BY CLICK ITEM IMAGE)
        protected void SelectItem(object sender, EventArgs e)
        {
            if (Session["ii"] == null)
            {
                ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Please select quantity ');</script>");
            }

            else
            {
                ImageButton ibtn = (ImageButton)(sender);

                string itemNo = Convert.ToString(ibtn.CommandArgument);

                CsItem theitem = new CsItem(itemNo, iCategory, iName, iPPrice, iRPrice, iNote, iImage, iQuantity, iRday);

                ConnectionClass.GetItemDetails(theitem);

                bool found = false;

                if (iTable.Rows.Count > 0) // IF CART IS NOT EMPTY,
                {
                    foreach (DataRow iRow in iTable.Rows)
                    {
                        if (Convert.ToString(iRow["No"]) == itemNo) // IF THE ITEM IS ALREADY IN THE CART LIST, UPDATE QTY
                        {
                            //double temp = Convert.ToDouble(iRow["qty"]);

                            double temp = Convert.ToDouble(iRow["qty"]);


                            // double uptemp = Convert.ToDouble(Session["ii"]) + temp;

                            double uptemp = Convert.ToDouble(Session["ii"]) + temp;

                            if (uptemp > Convert.ToDouble(theitem.itemQuantity))                                                                                  // IF USER TRY TO ADD ITEM MORE THAN AVAILABLE NUMBER (=QUANTITY)
                            {
                                ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('You cannot add more than available stock ');</script>"); // ALERT MESSSAGE
                            }


                            else
                            {
                                iRow["qty"] = Convert.ToDouble(Session["ii"]) + temp; // UPDATE QUANTITY

                                // iRow["amount"] = Math.Round(Convert.ToDouble(iRow["qty"]) * Convert.ToDouble(iRow["unitprice"]),2);
                                iRow["amount"] = Math.Round(Convert.ToDouble(iRow["qty"]) * Convert.ToDouble(iRow["unitprice"]), 2);
                                //iRow["tax"] = Convert.ToDouble(iRow["amount"]) * 0.13;
                                iRow["tax"] = Math.Round(Convert.ToDouble(iRow["amount"]) * 0.13, 2);
                            }
                            found = true;
                        }
                    }

                    if (!found) // IF ITEM IS NOT IN THE CART LIST, ADD ROW
                    {
                        iTable.Rows.Add("", itemNo, theitem.itemName,
                                        Math.Round(Convert.ToDouble(theitem.itemRPrice), 2),
                                        Convert.ToDouble(Session["ii"]),
                                        Math.Round(Convert.ToDouble(theitem.itemRPrice) * Convert.ToDouble(Session["ii"]), 2),
                                        Math.Round(Convert.ToDouble(theitem.itemRPrice) * Convert.ToDouble(Session["ii"]) * 0.13, 2));
                    }
                }

                else // IF CART IS EMPTY,
                {
                    iTable.Rows.Add("", itemNo, theitem.itemName,
                                    Math.Round(Convert.ToDouble(theitem.itemRPrice), 2),
                                    Convert.ToDouble(Session["ii"]),
                                    Math.Round(Convert.ToDouble(theitem.itemRPrice) * Convert.ToDouble(Session["ii"]), 2),
                                    Math.Round(Convert.ToDouble(theitem.itemRPrice) * Convert.ToDouble(Session["ii"]) * 0.13, 2));
                }
                GridView1.DataSource = iTable;    //
                GridView1.DataBind();



                object Sum        = iTable.Compute(" SUM(amount) ", "");
                double NetTotal   = Math.Round(Double.Parse(Sum.ToString()), 2);
                double GrandTotal = Math.Round(NetTotal * 1.13, 2);

                subTotal.Text   = NetTotal.ToString();
                grandTotal.Text = GrandTotal.ToString();
                Session["ii"]   = null;
            }
        }