private bool Save()
        {
            EtPurchase purchase;

            if (-1 == CmbOperator.SelectedIndex)
            {
                MsgBoxUtil.ErrMsgBox("经办人不能为空!");
                return(false);
            }
            int staffId = StaffDao.QueryByStaffName(CmbOperator.SelectedItem.ToString())[0].StaffID;
            int res     = 0;

            foreach (ClsGood good in Goods)
            {
                purchase = new EtPurchase {
                    PurchaseID   = int.Parse(LblPurchaseID.Text),
                    Category     = good.Good.Category,
                    PurchaseDate = DtpPurchaseDate.Value.ToString("yyyyMMdd"),
                    Quantity     = good.Count,
                    Cost         = good.Good.Cost,
                    StaffID      = staffId
                };
                res += PurchaseDao.InsertPurchase(purchase);
                EtGood g = new EtGood {
                    Category       = good.Good.Category,
                    ProductionDate = good.Good.ProductionDate,
                    PurchaseDate   = purchase.PurchaseDate,
                    Cost           = good.Good.Cost,
                    Price          = good.Good.Price,
                    State          = good.Good.State
                };
                for (int i = 0; i < good.Count; i++)
                {
                    GoodDao.InsertGood(g);
                }
            }
            if (res == Goods.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public ActionResult Checkout()
        {
            int userId = System.Convert.ToInt32(Request.Cookies["userId"].Value);
            HttpCookieCollection        cookies = Request.Cookies;
            Dictionary <string, string> kV      = Utility.CookieUtility.getProductKeyValues(cookies);

            //make product id and no of item key value pair
            string[] arr = cookies.AllKeys;
            //persist in DB
            PurchaseDao.InsertPurchase(userId, kV);
            //remove items in the cart
            foreach (string k in arr)
            {
                if (k != "userId" && k != "name")
                {
                    HttpCookie cookie = new HttpCookie(k);
                    cookie.Expires = DateTime.Now.AddDays(-1);
                    Response.Cookies.Add(cookie);
                }
            }

            return(RedirectToAction("Index", "Purchase"));
        }