Esempio n. 1
0
        //刪除商品資料
        public ActionResult BackProdutDelect(int pr_rowid)
        {
            var model = db.product.FirstOrDefault(m => m.rowid == pr_rowid);

            db.product.Remove(model);
            db.SaveChanges();
            return(RedirectToAction("BackProdutList"));
        }
 public ActionResult EditSong([Bind(Include = "SongId,name,type,path,artist,album,posterpath")] Song Song)
 {
     if (ModelState.IsValid)
     {
         db1.Entry(Song).State = EntityState.Modified;
         db1.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(Song));
 }
Esempio n. 3
0
        public ActionResult CartDelete(int id)
        {
            var data = db.carts
                       .Where(m => m.rowid == id)
                       .FirstOrDefault();

            if (data != null)
            {
                db.carts.Remove(data);
                db.SaveChanges();
            }
            return(RedirectToAction("CartList"));
        }
Esempio n. 4
0
        public ActionResult EditProfile(users model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            using (dbcon db = new dbcon())
            {
                var user = db.users
                           .Where(m => m.rowid == model.rowid)
                           .FirstOrDefault();

                if (user != null)
                {
                    user.mname     = model.mname;
                    user.mnickname = model.mnickname;
                    user.memail    = model.memail;
                    user.birthday  = model.birthday;
                    user.remark    = model.remark;
                    db.SaveChanges();
                }

                return(RedirectToAction("MemberProfile"));
            }
        }
        public ActionResult Edit(product_typedetail_everydaystock models)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var ptype_everydaystock = db.product_typedetail_everydaystock.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (ptype_everydaystock != null)
                        {
                            ptype_everydaystock.stock      = models.stock;
                            ptype_everydaystock.stock_date = models.stock_date;
                        }
                    }
                    else
                    {
                        //Save
                        models.ptype_no = Shop.ProductTypeNo;
                        db.product_typedetail_everydaystock.Add(models);
                    }

                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 6
0
        public ActionResult Edit(shippings models)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var shippings = db.shippings.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (shippings != null)
                        {
                            shippings.shipping_no   = models.shipping_no;
                            shippings.shipping_name = models.shipping_name;
                            shippings.remark        = models.remark;
                        }
                    }
                    else
                    {
                        //Save
                        db.shippings.Add(models);
                    }
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        public ActionResult Edit(payments models)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var payments = db.payments.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (payments != null)
                        {
                            payments.payment_no = models.payment_no;
                            payments.payment    = models.payment;
                            payments.remark     = models.remark;
                        }
                    }
                    else
                    {
                        //Save
                        db.payments.Add(models);
                    }
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
 public ActionResult Upload(HttpPostedFileBase file)
 {
     if (file != null)
     {
         if (file.ContentLength > 0)
         {
             var pno = Shop.ProductNo;
             using (dbcon db = new dbcon())
             {
                 var product = db.product.Where(p => p.pno == pno).SingleOrDefault();
                 product.pimg = pno;
                 db.SaveChanges();
             }
             string str_folder      = string.Format("~/Content/images/product/{0}", pno);
             string str_folder_path = Server.MapPath(str_folder);
             if (!Directory.Exists(str_folder_path))
             {
                 Directory.CreateDirectory(str_folder_path);
             }
             string str_file_name = pno + ".jpg";
             var    path          = Path.Combine(str_folder_path, str_file_name);
             if (System.IO.File.Exists(path))
             {
                 System.IO.File.Delete(path);
             }
             file.SaveAs(path);
         }
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 9
0
 //登入購物車
 public static void LoginCart()        //已經登入
 {
     if (!string.IsNullOrEmpty(LotNo)) //訪客時的批號不是空
     {
         int int_qty = 0;
         using (dbcon db = new dbcon())
         {
             var datas = db.carts
                         .Where(m => m.lot_no == LotNo) //訪客時的批號
                         .ToList();
             if (datas != null)                         //若有找到
             {
                 foreach (var item in datas)
                 {
                     int_qty = item.ptype_qty.GetValueOrDefault();               //拿到商品數量
                     AddCart(item.pno, item.ptype_no, item.ptype_spec, int_qty); //加入購物車資料庫(驗證該會員帳戶)
                     db.carts.Remove(item);                                      //刪除訪客資料
                 }
                 db.SaveChanges();
             }
         }
         LotNo = "";
     }
     ClearCustomerLotNo();
 }
Esempio n. 10
0
        public ActionResult Edit(users models)
        {
            bool status = false;

            ModelState.Remove("Password"); //忽略 Password 驗證
            ModelState.Remove("role_no");  //忽略 role_no 驗證
            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var users = db.users.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (users != null)
                        {
                            users.isvarify = Shop.BoolToInteger(models.bool_isvarify);
                            users.mno      = models.mno;
                            users.mname    = models.mname;
                            users.memail   = models.memail;
                            users.birthday = models.birthday;
                            users.remark   = models.remark;
                        }
                    }
                    else
                    {
                        //Save
                        models.role_no     = UserAccount.UserRoleNo;
                        models.varify_code = UserAccount.GetNewVarifyCode(); //產生驗證碼
                        if (UserAccount.UserStatus < 2)
                        {
                            models.isvarify = UserAccount.UserStatus;
                        }
                        else
                        {
                            models.isvarify = Shop.BoolToInteger(models.bool_isvarify);
                        }

                        db.users.Add(models);
                    }
                    try
                    {
                        db.Configuration.ValidateOnSaveEnabled = false;
                        db.SaveChanges();
                        db.Configuration.ValidateOnSaveEnabled = true;
                        status = true;
                    }
                    catch (Exception ex)
                    {
                        string str_message = ex.Message;
                        status = false;
                    }
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 11
0
        public ActionResult createPlaylist(Playlists p)
        {
            if (ModelState.IsValid == false)
            {
                return(View());
            }
            var addnew = new Playlists
            {
                UserName     = User.Identity.GetUserName(),
                PlaylistName = p.PlaylistName
            };

            var ex = db.playlists.Where(x => x.UserName == addnew.UserName && x.PlaylistName == addnew.PlaylistName).Select(x => x).FirstOrDefault();

            db.playlists.Add(addnew);
            db.SaveChanges();
            return(View());
        }
Esempio n. 12
0
        //將資料加入到購物車
        public static void AddCart(string pno, string ptype_no, string day_spec, int buyQty)
        {
            using (dbcon db = new dbcon())
            {
                //先在購物車搜尋,看有沒有加入過購物車
                if (UserAccount.IsLogin)
                {
                    LotNo = "";
                }
                var datas = db.carts.Where(m => m.lot_no == LotNo)
                            .Where(m => m.mno == UserAccount.UserNo)
                            .Where(m => m.pno == pno)
                            .Where(m => m.ptype_no == ptype_no)
                            .Where(m => m.ptype_spec == day_spec)
                            .FirstOrDefault();
                //沒有:新增一筆資料,加入商品
                int int_price  = Shop.GetProductPrice(ptype_no);
                int int_amount = (buyQty * int_price);
                if (datas == null)
                {
                    carts models = new carts();
                    models.lot_no      = LotNo;
                    models.mno         = UserAccount.UserNo;
                    models.crete_time  = LotCreateTime;
                    models.pno         = pno;
                    models.pname       = Shop.GetProductName(pno);
                    models.ptype_no    = ptype_no;
                    models.ptype_name  = Shop.GetProductTypeName(ptype_no);
                    models.ptype_spec  = day_spec;
                    models.ptype_qty   = buyQty;
                    models.ptype_price = int_price;
                    models.amount      = int_amount;

                    db.carts.Add(models);
                    db.SaveChanges();
                }
                else//有:將數量加總,總計重新計算
                {
                    datas.ptype_qty += buyQty;
                    datas.amount     = int_amount;
                    db.SaveChanges();
                }
            }
        }
Esempio n. 13
0
        private static string CreateNewOrderNo(cvmOrder model)
        {
            Shop.OrderID = 0;
            Shop.OrderNo = "0";
            string str_order_no = "";
            string str_guid     = Guid.NewGuid().ToString().Substring(0, 25).ToUpper();

            using (dbcon db = new dbcon())
            {
                order order = new order();
                order.order_closed    = 0;
                order.order_validate  = 0;
                order.order_no        = "";
                order.order_date      = DateTime.Now;
                order.mno             = UserAccount.UserNo;
                order.order_status    = "ON";
                order.order_guid      = str_guid;
                order.payment_no      = model.payment_no;
                order.payment_name    = Shop.GetPaymentName(model.payment_no);
                order.receive_name    = model.receive_name;
                order.receive_phone   = model.receive_phone;
                order.receive_email   = model.receive_memail;
                order.receive_address = model.receive_address;
                order.remark          = model.remark;
                db.order.Add(order);
                db.SaveChanges();


                //此時order_no還沒編號,待寫入guid後,再拿出來對比,使用rowid進行 +0 取8位 得出 str_order_no
                var neword = db.order.Where(m => m.order_guid == str_guid).FirstOrDefault();
                if (neword != null)
                {
                    str_order_no    = neword.rowid.ToString().PadLeft(8, '0');
                    neword.order_no = str_order_no;
                    Shop.OrderID    = neword.rowid;
                    Shop.OrderNo    = str_order_no;
                    db.SaveChanges();
                }
            }
            return(str_order_no);
        }
Esempio n. 14
0
        public int AddToFavourite(FavouriteSong fs)
        {
            FavouriteSong f = new FavouriteSong();

            f.SongName = fs.SongName;
            f.SongId   = fs.SongId;
            f.user     = User.Identity.GetUserName();

            var f1 = db.favouritesong.Where(x => x.SongId == f.SongId && x.user == f.user).FirstOrDefault();

            Console.WriteLine(f1);
            if (f1 == null)
            {
                db.favouritesong.Add(f);
                db.SaveChanges();
                return(f.SongId);
            }

            return(0);



            //return RedirectToAction("/Account/Login");
        }
Esempio n. 15
0
 public ActionResult UnConfirm(int id = 0)
 {
     using (dbcon db = new dbcon())
     {
         var model = db.users.Where(m => m.rowid == id).FirstOrDefault();
         if (model != null)
         {
             model.isvarify = 0;
             db.SaveChanges();
             return(RedirectToAction("Index", "Member", new { area = "Admin", id = UserAccount.UserStatus }));
         }
         else
         {
             return(HttpNotFound());
         }
     }
 }
Esempio n. 16
0
 public ActionResult ReturnProduct(int id = 0)
 {
     using (dbcon db = new dbcon())
     {
         var model = db.order.Where(m => m.rowid == id).FirstOrDefault();
         if (model != null)
         {
             if (Shop.IsUnCloseOrder(model.order_status))
             {
                 model.order_status = "RT";
                 model.order_closed = 1;
                 db.SaveChanges();
             }
         }
     }
     return(RedirectToAction("Index", "order", new { area = "Member", id = UserAccount.UserStatus, code = UserAccount.UserCode }));
 }
Esempio n. 17
0
 private static void ClearCustomerLotNo()
 {
     using (dbcon db = new dbcon())
     {
         var datas = db.carts
                     .Where(m => m.mno == UserAccount.UserNo)
                     .ToList();
         if (datas != null)
         {
             foreach (var data in datas)
             {
                 data.lot_no = "";
             }
             db.SaveChanges();
         }
     }
 }
Esempio n. 18
0
        public ActionResult DeleteData(int id)
        {
            bool status = false;

            using (dbcon db = new dbcon())
            {
                var model = db.payments.Where(m => m.rowid == id).FirstOrDefault();
                if (model != null)
                {
                    db.payments.Remove(model);
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 19
0
        public ActionResult Pdescription(product_typedetail product_Typedetail)
        {
            bool status = false;

            using (dbcon db = new dbcon())
            {
                var model = db.product_typedetail.Where(m => m.rowid == product_Typedetail.rowid).FirstOrDefault();
                if (model != null)
                {
                    model.ptype_dep = product_Typedetail.ptype_dep;
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 20
0
 public ActionResult ChangeStatus(order model)
 {
     using (dbcon db = new dbcon())
     {
         bool status = false;
         var  order  = db.order.Where(m => m.order_no == model.order_no).FirstOrDefault();
         if (order != null)
         {
             order.order_status   = model.order_status;
             order.order_closed   = Shop.GetOrderClosed(model.order_status);
             order.order_validate = Shop.GetOrderValidate(model.order_status);
             db.SaveChanges();
             status = true;
         }
         return(new JsonResult {
             Data = new { status = status }
         });
     }
 }
Esempio n. 21
0
 public ActionResult CancelOrder(int order_rowid = 0)
 {
     using (dbcon db = new dbcon())
     {
         var model = db.order.Where(m => m.rowid == order_rowid).FirstOrDefault();
         if (model != null)
         {
             if (Shop.IsUnCloseOrder(model.order_status))
             {
                 if (model.order_status == "ON" || model.order_status == "PP" || model.order_status == "PN" || model.order_status == "OP")
                 {
                     model.order_status = "OR";
                     model.order_closed = 1;
                     db.SaveChanges();
                 }
             }
         }
     }
     return(RedirectToAction("GetDataList", "Members", new { isclose = 0 }));
 }
Esempio n. 22
0
        public ActionResult ResetPassword(int id)
        {
            bool status = false;

            using (dbcon db = new dbcon())
            {
                var model = db.users.Where(m => m.rowid == id).FirstOrDefault();
                if (model != null)
                {
                    using (Cryptographys crpy = new Cryptographys())
                    {
                        model.mpassword = crpy.SHA256Encode(model.mno);
                        db.SaveChanges();
                    }
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 23
0
        public ActionResult Edit(categorys models)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var categorys = db.categorys.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (categorys != null)
                        {
                            categorys.category_no   = models.category_no;
                            categorys.category_name = models.category_name;
                        }
                    }
                    else
                    {
                        //新增嗎????
                        //Save
                        if (Session["CategoryID"] == null)
                        {
                            models.parentid = 0;
                        }
                        else
                        {
                            models.parentid = int.Parse(Session["CategoryID"].ToString());
                        }
                        db.categorys.Add(models);
                    }
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
 public ActionResult Create(string id)
 {
     using (dbcon db = new dbcon())
     {
         bool   added           = false;
         string DayValueListStr = Request.Form["day_value_list"];
         if (!string.IsNullOrEmpty(DayValueListStr))
         {
             var DayValueList = DayValueListStr.Split(',');
             foreach (var dvPair in DayValueList)
             {
                 DateTime date     = Convert.ToDateTime(dvPair.Split(':')[0]);
                 int      num      = Convert.ToInt32(dvPair.Split(':')[1]);
                 bool     hasStock = db.product_typedetail_everydaystock.Count(e => e.ptype_no == id && e.stock_date == date) != 0;
                 if (hasStock)
                 {
                     db.product_typedetail_everydaystock.SingleOrDefault(e => e.ptype_no == id && e.stock_date == date).stock = num;
                 }
                 else
                 {
                     product_typedetail_everydaystock record = new product_typedetail_everydaystock()
                     {
                         ptype_no   = id,
                         stock_date = date,
                         stock      = num
                     };
                     db.product_typedetail_everydaystock.Add(record);
                 }
             }
             db.SaveChanges();
             added = true;
         }
         return(new JsonResult {
             Data = new { status = added }
         });
     }
 }
Esempio n. 25
0
        public ActionResult Edit(product_typedetail models)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    if (models.rowid > 0)
                    {
                        //Edit
                        var product_typedetail = db.product_typedetail.Where(m => m.ptype_no == models.ptype_no).FirstOrDefault();
                        if (product_typedetail != null)
                        {
                            product_typedetail.pno         = Shop.Pno;
                            product_typedetail.parea_name  = models.parea_name;
                            product_typedetail.ptype_no    = models.ptype_no;
                            product_typedetail.ptype_name  = models.ptype_name;
                            product_typedetail.ptype_price = models.ptype_price;
                            product_typedetail.remark      = models.remark;
                        }
                    }
                    else
                    {
                        //Save
                        models.pno = Shop.Pno;
                        db.product_typedetail.Add(models);
                    }

                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        public ActionResult Edit(product models)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                using (dbcon db = new dbcon())
                {
                    int int_cate_id = 0;
                    if (models.rowid > 0)
                    {
                        //Edit
                        var product = db.product.Where(m => m.rowid == models.rowid).FirstOrDefault();
                        if (product != null)
                        {
                            int_cate_id           = models.categoryid.GetValueOrDefault();
                            product.pno           = models.pno;   //有疑慮
                            product.pname         = models.pname; //有疑慮
                            product.categoryid    = int_cate_id;
                            product.category_name = Shop.GetCategoryNameByid(int_cate_id);
                            product.istop         = (models.bool_istop) ? 1 : 0;
                            product.issale        = (models.bool_issale) ? 1 : 0;
                            product.start_count   = models.start_count;
                            product.browse_count  = models.browse_count;
                            product.plocation     = models.plocation;
                            product.pmapurl       = models.pmapurl;
                            product.vendor_no     = UserAccount.UserOfAccount;
                            product.remark        = models.remark;
                            var feature = db.product_features.Where(f => f.pno == models.pno).FirstOrDefault();
                            if (feature != null)
                            {
                                feature.location_type          = models.product_features.location_type;
                                feature.near_river             = models.product_features.near_river;
                                feature.near_sea               = models.product_features.near_sea;
                                feature.no_tent                = models.product_features.no_tent;
                                feature.have_canopy            = models.product_features.have_canopy;
                                feature.have_clouds            = models.product_features.have_clouds;
                                feature.have_firefly           = models.product_features.have_firefly;
                                feature.could_book_all         = models.product_features.could_book_all;
                                feature.have_rental_equipment  = models.product_features.have_rental_equipment;
                                feature.have_game_area         = models.product_features.have_game_area;
                                feature.elevation_under_300m   = models.product_features.elevation_under_300m;
                                feature.elevation_301m_to_500m = models.product_features.elevation_301m_to_500m;
                                feature.elevation_over_501m    = models.product_features.elevation_over_501m;
                            }
                            else
                            {
                                db.product_features.Add(models.product_features);
                            }
                        }
                    }
                    else
                    {
                        //Save
                        models.vendor_no                = UserAccount.UserOfAccount;
                        int_cate_id                     = models.categoryid.GetValueOrDefault();
                        models.category_name            = Shop.GetCategoryNameByid(int_cate_id);
                        models.istop                    = (models.bool_istop) ? 1 : 0;
                        models.issale                   = (models.bool_issale) ? 1 : 0;
                        models.product_features.pno     = models.pno;
                        models.product_features.product = models;
                        db.product.Add(models);
                        db.product_features.Add(models.product_features);
                    }
                    db.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Esempio n. 27
0
        public ActionResult Register(cvmRegister model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //自定義檢查
            bool bln_error = false;
            var  user      = db.users.Where(m => m.maccount == model.maccount).FirstOrDefault();

            if (user != null)
            {
                ModelState.AddModelError("", "帳號重複註冊!"); bln_error = true;
            }
            user = db.users.Where(m => m.memail == model.memail).FirstOrDefault();
            if (user != null)
            {
                ModelState.AddModelError("", "電子信箱重複註冊!"); bln_error = true;
            }
            if (bln_error)
            {
                return(View(model));
            }

            //密碼加密
            using (Cryptographys cryp = new Cryptographys())
            {
                model.mpassword       = cryp.SHA256Encode(model.mpassword);
                model.ConfirmPassword = model.mpassword;
            }

            users new_user = new users();

            new_user.maccount    = model.maccount;
            new_user.mname       = model.mname;
            new_user.mpassword   = model.mpassword;
            new_user.memail      = model.memail;
            new_user.birthday    = model.birthday;
            new_user.remark      = model.remark;
            new_user.role_no     = "Member";                       //設定角色代號為 Member
            new_user.varify_code = UserAccount.GetNewVarifyCode(); //產生驗證碼
            new_user.isvarify    = 0;

            //寫入資料庫
            try
            {
                db.Configuration.ValidateOnSaveEnabled = false;
                db.users.Add(new_user);
                db.SaveChanges();
                db.Configuration.ValidateOnSaveEnabled = true;
            }
            catch (Exception ex)
            {
                string str_message = ex.Message;
            }

            //寄出驗證信
            SendVerifyMail(model.memail, new_user.varify_code);
            return(RedirectToAction("SendEmailResult"));
        }
Esempio n. 28
0
        public static bool CartPayment(cvmOrder model)
        {
            OrderNo = CreateNewOrderNo(model);
            using (dbcon db = new dbcon())
            {
                var datas = db.carts
                            .Where(m => m.mno == UserAccount.UserNo)
                            .ToList();
                if (datas != null)
                {
                    //將同會員購買的所有品項加總 為什麼不用CartTotal??
                    int int_amount = datas.Sum(m => m.amount).GetValueOrDefault();
                    //加上稅金
                    decimal dec_tax = 0;
                    if (int_amount > 0)
                    {
                        dec_tax = Math.Round((decimal)(int_amount * 5 / 100), 0);
                    }
                    int int_total = int_amount + (int)dec_tax;
                    var data      = db.order.Where(m => m.order_no == OrderNo).FirstOrDefault();
                    if (data != null)
                    {
                        data.amounts = int_amount;
                        data.taxs    = (int)dec_tax;
                        data.totals  = int_total;
                    }

                    foreach (var item in datas)
                    {
                        var stock_date_list = item.ptype_spec.Trim().Split(' ').ToList();
                        stock_date_list.RemoveAt(stock_date_list.Count - 1);
                        foreach (var d in stock_date_list)
                        {
                            DateTime date     = Convert.ToDateTime(d);
                            var      hasStock = db.product_typedetail_everydaystock.Count(e => e.ptype_no == item.ptype_no && e.stock_date == date && e.stock >= item.ptype_qty) > 0;
                            if (!hasStock)
                            {
                                return(false);
                            }
                        }
                        order_detail detail = new order_detail();
                        detail.order_no      = OrderNo;
                        detail.pno           = item.pno;
                        detail.pname         = item.pname;
                        detail.ptype_no      = item.ptype_no;
                        detail.ptype_name    = item.ptype_name;
                        detail.vendor_no     = Shop.GetVendorNoByProduct(item.pno);
                        detail.category_name = Shop.GetCategoryName(item.pno);
                        detail.ptype_spec    = item.ptype_spec;
                        detail.qty           = item.ptype_qty;
                        detail.price         = item.ptype_price;
                        detail.amount        = item.amount;
                        detail.remark        = "";
                        db.order_detail.Add(detail);

                        db.carts.Remove(item);
                    }
                    db.SaveChanges();
                }
            }
            return(true);
        }