Exemple #1
0
        public TB_STORE getStoreById(int id)
        {
            object[] sqlParams =
            {
                new SqlParameter("@N_ID", id)
            };
            TB_STORE storeResult = context.Database.SqlQuery <TB_STORE>("Usp_GetStoreById @N_ID", sqlParams).SingleOrDefault();

            return(storeResult);
        }
Exemple #2
0
        public ActionResult AddShop(string name, string type)
        {
            decimal cur_user = (Session["UserMessage"] as UserMessage).id;                                 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            TB_MANAGE     tb_manage     = new TB_MANAGE();
            TB_STORE      tb_store      = new TB_STORE();
            TB_STORE_TYPE tb_store_type = new TB_STORE_TYPE();



            name = Request.Form[("NAME")];
            type = Request.Form[("TYPE")];

            if (ModelState.IsValid)
            {
                foreach (TB_STORE myStore in db2.TB_STORE)
                {
                    if (myStore.NAME == name)
                    {
                        return(View());
                    }
                }
                foreach (TB_MANAGE myMag in db1.TB_MANAGE)
                {
                    if (myMag.U_ID == cur_user && myMag.AUTHORITY == true)
                    {
                        return(View());
                    }
                }
                tb_store.NAME           = name;
                tb_store.QUALITY_RATING = 0;
                db2.TB_STORE.Add(tb_store);
                db2.SaveChanges();
                foreach (TB_STORE myStore in db2.TB_STORE)
                {
                    if (myStore.NAME == name)
                    {
                        tb_manage.U_ID      = cur_user;
                        tb_manage.S_ID      = myStore.ID;
                        tb_manage.AUTHORITY = true;
                        db1.TB_MANAGE.Add(tb_manage);
                        db1.SaveChanges();
                        tb_store_type.ID   = myStore.ID;
                        tb_store_type.TYPE = type;
                        db3.TB_STORE_TYPE.Add(tb_store_type);
                        db3.SaveChanges();
                        return(RedirectToAction("Myshop"));
                    }
                }
            }
            return(View());
        }
Exemple #3
0
        public object createStore(TB_STORE store)
        {
            object[] sqlParams =
            {
                new SqlParameter("@S_NAME",    store.S_NAME),
                new SqlParameter("@S_ADDRESS", store.S_ADDRESS),
                new SqlParameter("@S_CONTACT", store.S_CONTACT)
            };
            var result = context.Database.SqlQuery <object>("Usp_InsertStore @S_NAME,@S_ADDRESS,@S_CONTACT", sqlParams).SingleOrDefault();

            return(result);
        }
Exemple #4
0
        public ActionResult Create(StoreModel storeModel)
        {
            try
            {
                var      storeDBModel = new StoreDBModel();
                TB_STORE store        = new TB_STORE();
                store.S_NAME    = storeModel.storeName;
                store.S_CONTACT = storeModel.contact;
                store.S_ADDRESS = storeModel.address;
                storeDBModel.createStore(store);

                return(RedirectToAction("List"));
            }
            catch
            {
                return(View());
            }
        }
        // GET: ProductDetails/Details/5
        public ActionResult Details(decimal?product_id, decimal?store_id)          //此处有默认值!!!!!!!!!!!!!!
        {
            if (product_id == null && store_id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            string            sql         = "select * from TB_PRODUCT WHERE ID = " + product_id + " and S_ID = " + store_id;
            List <TB_PRODUCT> list_tb_pro = dbPro.Database.SqlQuery <TB_PRODUCT>(sql).ToList();

            if (list_tb_pro.Count() != 0)
            {
                productMes.id   = list_tb_pro.First().ID;
                productMes.s_id = list_tb_pro.First().S_ID;
                productMes.name = list_tb_pro.First().NAME;
                TB_STORE store = dbSto.TB_STORE.Find(store_id);
                productMes.store_name   = store.NAME;
                productMes.price        = list_tb_pro.First().PRICE;
                productMes.discount     = (1 - list_tb_pro.First().DISCOUNT_RATE) * 100;
                productMes.new_price    = productMes.price * (100 - productMes.discount) / 100;
                productMes.description  = list_tb_pro.First().DESCRIPTION;
                productMes.num          = list_tb_pro.First().NUM;
                productMes.comment_list = new List <Comment>();
                foreach (TB_COMMENT mycomment in dbCom.TB_COMMENT)
                {
                    if (mycomment.S_ID == productMes.s_id && mycomment.P_ID == productMes.id)
                    {
                        Comment new_comment = new Comment();
                        new_comment.comment   = mycomment;
                        new_comment.user_name = dbUsr.TB_USER.Find(mycomment.U_ID).NAME;
                        productMes.comment_list.Add(new_comment);
                    }
                }
            }
            if (string.IsNullOrEmpty(Request.Form["AddToCart"]) == false)
            {
                return(AddToCart());
            }
            if (string.IsNullOrEmpty(Request.Form["BuyNow"]) == false)
            {
                return(BuyNow());
            }
            return(View(productMes));
        }