Beispiel #1
0
    private static void Main()
    {
        var output = new StringBuilder();

        string[] line;
        char[,] shopGrid = new char[25, 25];
        while ((line = Console.ReadLine().Split())[0] != "0")
        {
            int height = int.Parse(line[1]);
            int width  = int.Parse(line[0]);

            for (int r = 0; r < height; ++r)
            {
                string row = Console.ReadLine();
                for (int c = 0; c < width; ++c)
                {
                    shopGrid[r, c] = row[c];
                }
            }
            Console.ReadLine();

            var solver = new SHOP(height, width, shopGrid);

            output.Append(
                solver.Solve());
            output.AppendLine();
        }

        Console.Write(output);
    }
Beispiel #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            SHOP sHOP = db.SHOPs.Find(id);

            db.SHOPs.Remove(sHOP);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ShopID,ShopName,ShopType")] SHOP sHOP)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sHOP).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sHOP));
 }
Beispiel #4
0
        public ActionResult Create(ShopViewModel vmodel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //if no image, assign default image
                    string logo = vmodel.LogoShop;
                    if (logo == null)
                    {
                        logo = "~/Content/image/logo_noImage.png";
                    }
                    SHOP shop = new SHOP
                    {
                        logoShop = logo,
                        phone    = vmodel.Phone,
                        email    = vmodel.Email,
                        zipCode  = vmodel.ZipCode
                    };
                    db.SHOPs.Add(shop);
                    db.SaveChanges();

                    //Add Translation
                    int id = shop.idShop;
                    IList <SHOP_TRANSLATION> shopsT = TranslationBL.VerifyIsUniversal(vmodel.ShopsTrans, id);

                    db.SHOP_TRANSLATIONs.AddRange(shopsT);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (DbEntityValidationException ex)
                {
                    // to do insert to log file
                    var e1 = ex.GetBaseException(); // --> log
                    var e4 = ex.Message;            // --> log
                    var e5 = ex.Source;             // --> log
                    var e8 = ex.GetType();          // --> log
                    var e9 = ex.GetType().Name;     // --> log
                    return(View("Error"));
                }
                catch (Exception ex)
                {
                    //to do insert to log file
                    var e1 = ex.GetBaseException(); // --> log
                    var e4 = ex.Message;            // --> log
                    var e5 = ex.Source;             // --> log
                    var e8 = ex.GetType();          // --> log
                    var e9 = ex.GetType().Name;     // --> log
                    return(View("Error"));
                }
            }
            vmodel.ListLang = LanguageBL.FindLanguageListWithoutUniversal();
            return(View(vmodel));
        }
        public ActionResult Create([Bind(Include = "ShopID,ShopName,ShopType")] SHOP sHOP)
        {
            if (ModelState.IsValid)
            {
                db.SHOPS.Add(sHOP);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sHOP));
        }
Beispiel #6
0
 public ActionResult Edit([Bind(Include = "shno,empno,shthepic,shname,shclassno,shaccount,shpwd,shboss,shcontact,shaddress,shtel,shemail,shabout,shlogopic,shurl,shadstate,shadtitle,shadpic,shpopshop,shcheckstate,shstartdate,shenddate,shcheckdate,shpwdstate,shstoprightstartdate,shstoprightenddate,shopguid")] SHOP sHOP)
 {
     if (ModelState.IsValid)
     {
         Service.Update(sHOP);
         return(RedirectToAction("Index"));
     }
     ViewBag.empno     = new SelectList(EmpService.Get(), "empno", "empname", sHOP.empno);
     ViewBag.shclassno = new SelectList(ShClassService.Get(), "shclassno", "shclassname", sHOP.shclassno);
     return(View(sHOP));
 }
Beispiel #7
0
        // GET: Shops/Delete/5
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SHOP sHOP = db.SHOPs.Find(id);

            if (sHOP == null)
            {
                return(HttpNotFound());
            }
            return(View(sHOP));
        }
Beispiel #8
0
        // GET: Admin/Shop/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SHOP sHOP = Service.FindOne(id);

            if (sHOP == null)
            {
                return(HttpNotFound());
            }
            return(View(sHOP));
        }
Beispiel #9
0
        // GET: Admin/Shop/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SHOP sHOP = Service.FindOne(id);

            if (sHOP == null)
            {
                return(HttpNotFound());
            }
            ViewBag.empno     = new SelectList(EmpService.Get(), "empno", "empname", sHOP.empno);
            ViewBag.shclassno = new SelectList(ShClassService.Get(), "shclassno", "shclassname", sHOP.shclassno);
            return(View(sHOP));
        }
Beispiel #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="emp"></param>
 /// <returns></returns>
 public int Update(SHOP obj)
 {
     try
     {
         using (AllShowEntities db = new AllShowEntities())
         {
             db.Entry(obj).State = EntityState.Modified;
             return(db.SaveChanges());
         }
     }
     catch (DbEntityValidationException)
     {
         throw;
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="emp"></param>
 /// <returns></returns>
 public int Create(SHOP obj)
 {
     try
     {
         using (AllShowEntities db = new AllShowEntities())
         {
             db.SHOP.Add(obj);
             return(db.SaveChanges());
         }
     }
     catch (DbEntityValidationException)
     {
         throw;
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="emp"></param>
 /// <returns></returns>
 public int Delete(int id)
 {
     try
     {
         using (AllShowEntities db = new AllShowEntities())
         {
             SHOP target = db.SHOP.Where(m => m.shno == id).FirstOrDefault();
             db.SHOP.Remove(target);
             return(db.SaveChanges());
         }
     }
     catch (DbEntityValidationException)
     {
         throw;
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #13
0
        // GET: Shops/Edit/5
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SHOP sHOP = db.SHOPs.Find(id);

            if (sHOP == null)
            {
                return(HttpNotFound());
            }
            var           translation = db.SHOP_TRANSLATIONs.Where(st => st.shopId == id).ToList();
            var           lang        = db.LANGUAGESs.Count();
            ShopViewModel vm          = new ShopViewModel();
            bool          isUniversal = false;

            if (translation.Count() == 1)
            {
                isUniversal = true;
                SHOP_TRANSLATION empty = new SHOP_TRANSLATION
                {
                    shopId     = 0,
                    languageId = 0,
                    nameShop   = "",
                    street     = "",
                    city       = "",
                    opening    = ""
                };
                for (int i = 0; i < (lang - 2); i++)
                {
                    translation.Add(empty);
                }
            }
            ViewBag.isUniversal = isUniversal;
            vm.ListLang         = LanguageBL.FindLanguageListWithoutUniversal();
            vm.Shop             = sHOP;
            vm.ShopsTrans       = translation;
            return(View(vm));
        }
Beispiel #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="emp"></param>
 /// <returns></returns>
 public int Update(SHOP obj)
 {
     return(dao.Update(obj));
 }
Beispiel #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="emp"></param>
 /// <returns></returns>
 public int Create(SHOP obj)
 {
     return(dao.Create(obj));
 }
Beispiel #16
0
        public bool AddShop(JToken jt)
        {
            using (var db = new OrderDB())
            {
                db.BeginTransaction();
                try
                {
                    if (!IS_ADMIN)
                    {
                        throw new Exception("当前用户无管理员权限!");
                    }
                    var name       = jt["NAME"]?.ToString();
                    var address    = jt["ADDRESS"]?.ToString();
                    var account    = jt["ACCOUNT"]?.ToString();
                    var password   = jt["PASSWORD"]?.ToString();
                    var tel        = jt["TEL"]?.ToString();
                    var printer    = jt["PRINTER"]?.ToString();
                    var urls       = new List <IMAGE>();
                    var CAPITATION = jt["CAPITATION"]?.ToString();
                    var COST       = Convert.ToInt32(string.IsNullOrEmpty(jt["COST"]?.ToString()) ? 0 : jt["COST"].ToString());
                    if (jt["URLS"]?.ToString() != null)
                    {
                        urls = JsonConvert.DeserializeObject <List <IMAGE> >(jt["URLS"].ToString());
                    }
                    if (string.IsNullOrEmpty(name))
                    {
                        throw new Exception("商店名称不能为空!");
                    }
                    if (string.IsNullOrEmpty(account) || string.IsNullOrEmpty(password))
                    {
                        throw new Exception("账号、密码不能为空");
                    }
                    if (LoginDomain.Current.UserIsExsist(name))
                    {
                        throw new Exception("名称已存在!");
                    }
                    var m = new SHOP();
                    m.ID              = Guid.NewGuid().ToString("N").ToUpper();
                    m.UserCreated     = ACCOUNT;
                    m.DatetimeCreated = DateTime.Now;
                    m.STATE           = 'A';
                    m.NAME            = name;
                    m.ACCOUNT         = account;
                    m.ADDRESS         = address;
                    m.PASSWORD        = password;
                    m.TEL             = tel;
                    m.PrinterCode     = printer;
                    m.IsAdmin         = "N";
                    m.CAPITATION      = CAPITATION;
                    m.COST            = COST;
                    foreach (var url in urls)
                    {
                        var u = new IMAGE
                        {
                            ID              = Guid.NewGuid().ToString("N").ToUpper(),
                            UserCreated     = ACCOUNT,
                            DatetimeCreated = DateTime.Now,
                            STATE           = 'A',
                            URL             = url.URL,
                            ConnectId       = m.ID
                        };
                        db.Insert(u);
                    }
                    db.Insert(m);
                    db.CommitTransaction();
                }
                catch (Exception ex)
                {
                    db.RollbackTransaction();
                    throw ex;
                }

                return(true);
            }
        }