コード例 #1
0
        public void addAdjVoucher(List <WCFAdjustmentVoucherItem> adjItemList)
        {
            List <AdjustmentVoucherItemcart> adjItemCart = new List <AdjustmentVoucherItemcart>();

            foreach (WCFAdjustmentVoucherItem wcfAI in adjItemList)
            {
                AdjustmentVoucherItemcart cartItem = new AdjustmentVoucherItemcart();
                cartItem.ItemID = wcfAI.ItemID;
                cartItem.Qty    = wcfAI.Qty;
                cartItem.Record = wcfAI.Record;

                adjItemCart.Add(cartItem);
            }
            adjDAO.addAdjV(adjItemCart);
        }
コード例 #2
0
        public int addAdjVoucher(WCFCart_Json cartList, string staffID)
        {
            AdjustmentVoucherDAO                adjDAO       = new AdjustmentVoucherDAO();
            List <AdjustmentVoucherItemcart>    adjItemCart  = new List <AdjustmentVoucherItemcart>();
            List <WCFAdjustmentVoucherCartItem> adjVItemList = cartList.CartList;

            foreach (WCFAdjustmentVoucherCartItem wcfCI in adjVItemList)
            {
                AdjustmentVoucherItemcart cartItem = new AdjustmentVoucherItemcart();
                cartItem.ItemID = wcfCI.ItemID;
                cartItem.Qty    = wcfCI.Qty;
                cartItem.Record = wcfCI.Record;
                adjItemCart.Add(cartItem);
            }
            try
            {
                adjDAO.addAdjustmentVoucher(staffID, adjItemCart);
            }catch (Exception e)
            {
                return(0);
            }

            return(1);
        }
コード例 #3
0
        protected void GridView_CatalogList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int number = 0;

            if (e.CommandName == "Add")
            {
                List <AdjustmentVoucherItemcart> lac = new List <AdjustmentVoucherItemcart>();
                lac = (List <AdjustmentVoucherItemcart>)Session["adjvcart"];//get cart from Session
                string name   = this.staffID;
                string itemid = e.CommandArgument.ToString();
                int    alert  = 0;

                foreach (Control i in cartRepeater.Items)                                     //get Quantity from the cart
                {
                    LinkButton deletebtn  = i.FindControl("cart_deleteButton") as LinkButton; //get itemID
                    TextBox    cartqty    = i.FindControl("cart_qtyTextBox") as TextBox;      //get currrent quantity
                    TextBox    cartrecord = i.FindControl("cart_recordTextBox") as TextBox;   //get record
                    string     a          = cartqty.Text;
                    if (a.Trim() == "")
                    {
                        a = "1";
                    }
                    if (lac[number].Qty % 1 != 0)
                    {
                        ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Input must be integer!');</script>");
                        break;
                    }
                    string b = cartrecord.Text;
                    foreach (var k in lac)
                    {
                        if (k.ItemID == deletebtn.CommandArgument.ToString())
                        {
                            k.Record = b;
                            k.Qty    = Int32.Parse(a);
                        }
                    }
                    if (deletebtn.CommandArgument.ToString() == itemid) //Just get the corresponding itemID
                    {
                        foreach (var j in lac)                          //find in cart
                        {
                            if (j.ItemID == itemid)                     //only for banning add repeated items
                            {
                                j.Qty    = Int32.Parse(a);              //store current quantity into session
                                j.Record = b;
                                alert    = 1;
                                break;
                            }
                        }
                    }
                }

                //If this item was in the cart ,then alert!!!!
                if (alert == 1)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Already in your cart')", true);
                    return;
                }
                //If this item not in the cart ,then add it to the cart
                AdjustmentVoucherItemcart c = new AdjustmentVoucherItemcart
                {
                    Name   = name,
                    ItemID = itemid,
                    Qty    = 1//default
                };
                lac.Add(c);
                Session["adjvcart"] = lac;
                cartUpdatePanel.Update();
                updateCart(lac);
                ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>win.alert('Notice', 'Invalid input!!!');</script>");
            }

            if (e.CommandName == "go")
            {
                tb = (TextBox)GridView_CatalogList.BottomPagerRow.FindControl("inPageNum");
            }

            try
            {
                int num = Int32.Parse(tb.Text);
                GridViewPageEventArgs ea = new GridViewPageEventArgs(num - 1);
                GridView_CatalogList_PageIndexChanging(null, ea);
            }
            catch
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Invalid Page Number')", true);
            }
        }