Esempio n. 1
0
 public ActionResult ShopCreate(FormCollection collec, Shop shop)
 {
     if (Request.Cookies["Username"] != null)
     {
         shop.Name        = collec["Name"];
         shop.Address     = collec["Address"];
         shop.Tel         = collec["Tel"];
         shop.Description = collec["Description"];
         if (collec["SDate"] == "")
         {
             shop.EDate = null;
         }
         else
         {
             shop.EDate = DateTime.Parse(collec["SDate"]);
         }
         if (collec["EDate"] == "")
         {
             shop.EDate = null;
         }
         else
         {
             shop.EDate = DateTime.Parse(collec["EDate"]);
         }
         data.Shops.Add(shop);
         data.SaveChanges();
         return(RedirectToAction("ShopIndex"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 2
0
        public ActionResult ConfigEdit(FormCollection collection)
        {
            if (Request.Cookies["Username"] != null)
            {
                var config = db.Configs.FirstOrDefault();

                var Mail_Smtp     = collection["Mail_Smtp"];
                var Mail_Port     = collection["Mail_Port"];
                var Mail_Info     = collection["Mail_Info"];
                var Mail_Noreply  = collection["Mail_Noreply"];
                var Mail_Password = collection["Mail_Password"];

                var Copyright   = collection["Copyright"];
                var Thanhtoan   = collection["Thanhtoan"];
                var Canhbao     = collection["Canhbao"];
                var Title       = collection["Title"];
                var Description = collection["Description"];
                var Keyword     = collection["Keyword"];

                if (config != null)
                {
                    config.Mail_Smtp     = Mail_Smtp;
                    config.Mail_Port     = short.Parse(Mail_Port);
                    config.Mail_Info     = Mail_Info;
                    config.Mail_Noreply  = Mail_Noreply;
                    config.Mail_Password = Mail_Password;
                    config.Copyright     = Copyright;
                    config.Title         = Title;
                    config.Description   = Description;
                    config.Keyword       = Keyword;
                    UpdateModel(config);
                    db.SaveChanges();
                    return(RedirectToAction("ConfigEditot", "Admins"));
                }
                else
                {
                    config               = new Config();
                    config.Mail_Smtp     = Mail_Smtp;
                    config.Mail_Port     = short.Parse(Mail_Port);
                    config.Mail_Info     = Mail_Info;
                    config.Mail_Noreply  = Mail_Noreply;
                    config.Mail_Password = Mail_Password;
                    config.Copyright     = Copyright;
                    config.Title         = Title;
                    config.Description   = Description;
                    config.Keyword       = Keyword;

                    db.Entry(config).State = EntityState.Added;
                    db.SaveChanges();
                    return(RedirectToAction("Default", "Admins"));
                }
            }
            else
            {
                return(RedirectToAction("admins"));
            }
        }
Esempio n. 3
0
        public ActionResult MemberDelete(int id)
        {
            var del = db.Members.First(p => p.Id == id);

            db.Members.Remove(del);
            db.SaveChanges();

            return(RedirectToAction("MemberIndex", "Member"));
        }
Esempio n. 4
0
        public ActionResult Province_PriceDelete(int id)
        {
            var del = db.Province_Price.First(p => p.Id == id);

            db.Province_Price.Remove(del);
            db.SaveChanges();

            return(RedirectToAction("Province_PriceIndex", "Province_Price"));
        }
Esempio n. 5
0
        public ActionResult PriceCityDelete(int id)
        {
            var del = db.PriceCities.First(p => p.Id == id);

            db.PriceCities.Remove(del);
            db.SaveChanges();

            return(RedirectToAction("PriceCityIndex", "PriceCity"));
        }
Esempio n. 6
0
        public ActionResult SizeDelete(int id)
        {
            var del = db.Sizes.First(p => p.Id == id);

            db.Sizes.Remove(del);
            db.SaveChanges();

            return(RedirectToAction("SizeIndex", "Size"));
        }
Esempio n. 7
0
        public ActionResult SupportCreate(FormCollection collection, onsoft.Models.Support supports)
        {
            if (Request.Cookies["Username"] != null)
            {
                var Name   = collection["Name"];
                var Link   = "";
                var Tel    = collection["Phone"];
                var Type   = collection["Type"];
                var Nick   = collection["Nick"];
                var Ord    = collection["Order"];
                var Target = "";
                //var Location = collection["Location"];
                var GroupSupport = collection["GroupSupport"];



                supports.IdGroupSupport = Convert.ToInt32(GroupSupport);
                supports.Name           = Name;
                supports.Link           = Link;
                supports.Tel            = Tel;
                supports.Type           = int.Parse(Type);
                supports.Nick           = Nick;
                supports.Ord            = Convert.ToInt32(Ord);
                supports.Target         = Target;
                supports.Active         = (collection["Active"] == "false") ? false : true;
                db.Supports.Add(supports);
                db.SaveChanges();
                return(RedirectToAction("SupportIndex"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }
Esempio n. 8
0
        public ActionResult Register(string email, string password, string name, string tel, string address)
        {
            var cus    = db.Customers.Where(c => c.Email.Equals(email)).ToList();
            var result = "";

            if (cus.Count > 0)
            {
                result = "E-mail đã tồn tại..";
            }
            else
            {
                Customer customer = new Customer();
                customer.Email    = email;
                customer.Password = StringClass.Encrypt(password);
                customer.Name     = name;
                if (tel != null)
                {
                    customer.Tel = tel;
                }
                if (address != null)
                {
                    customer.Address = address;
                }
                customer.SDate = DateTime.Now;

                db.Entry(customer).State = System.Data.EntityState.Added;
                db.SaveChanges();

                Session["User-Email"] = email;
                result = "success";
            }

            return(Json(result));
        }
        //[HttpPost]
        public string dkkm(string gt, string mail)
        {
            if (mail != null && mail != "")
            {
                var list = db.Customers.Where(m => m.Email == mail).ToList();
                if (list.Count > 0)
                {
                    return("Email của bạn đã được đăng ký!");
                }
                else
                {
                    string gtinh    = "";
                    bool   gioitinh = true;
                    if (gt == "nam")
                    {
                        gioitinh = true;
                    }
                    else
                    {
                        gioitinh = false;
                    }

                    string ten = "";
                    db.sp_Customer_Insert("Đăng ký nhận thông tin KM", mail, mail, "", mail, DateTime.Now, true, "", 0, 1, false, 1, "", 0, 0, gioitinh);
                    db.SaveChanges();
                    return("Bạn đã đăng ký thông tin thành công!");
                }
            }
            else
            {
                return("Bạn chưa nhập Email!");
            }
        }
Esempio n. 10
0
 public ActionResult GroupMemberCreate(FormCollection collect, GroupMember grMem)
 {
     if (Request.Cookies["Username"] != null)
     {
         grMem.Name = collect["Name"];
         Boolean Active = (collect["Active"] == "false") ? false : true;
         grMem.Active = Active;
         db.GroupMembers.Add(grMem);
         db.SaveChanges();
         return(RedirectToAction("GroupMemberIndex"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 11
0
 public ActionResult WareHouseCreate(FormCollection collec, WareHouse wh)
 {
     if (Request.Cookies["Username"] != null)
     {
         wh.Name        = collec["Name"];
         wh.Address     = collec["Address"];
         wh.Tel         = collec["Tel"];
         wh.Description = collec["Description"];
         if (collec["SDate"] == "")
         {
             wh.SDate = null;
         }
         else
         {
             wh.SDate = DateTime.Parse(collec["SDate"]);
         }
         if (collec["EDate"] == "")
         {
             wh.EDate = null;
         }
         else
         {
             wh.EDate = DateTime.Parse(collec["EDate"]);
         }
         var u = collec["MemId"];
         db.WareHouses.Add(wh);
         db.SaveChanges();
         var           list    = db.WareHouses.OrderByDescending(m => m.Id).ToList();
         List <Member> members = db.Members.ToList();
         Member        user    = null;
         foreach (Member item in members)
         {
             if (item.Id == int.Parse(u))
             {
                 user = item;
                 break;
             }
         }
         MemberWareHouse userWh = new MemberWareHouse();
         userWh.IdMember    = user.Id;
         userWh.IdWareHouse = list[0].Id;
         userWh.SDate       = DateTime.Now;
         userWh.EDate       = null;
         db.sp_MemberWareHouse_Insert(user.Id, list[0].Id, wh.SDate, null, 1);
         db.SaveChanges();
         return(RedirectToAction("WareHouseIndex"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 12
0
        public ActionResult LibraryCreate(FormCollection collection, Models.Library news, HttpPostedFileBase fileImg)
        {
            int idmem = 0;

            if (Session["uId"] != null)
            {
                idmem = int.Parse(Session["uId"].ToString());
            }
            if (Request.Cookies["Username"] != null)
            {
                news.Name  = collection["Name"];
                news.Image = collection["Image"];
                int GroupLibrary = Convert.ToInt32(collection["GroupLibrary"]);
                news.GroupLibraryID  = GroupLibrary;
                news.Keyword         = collection["Keyword"];
                news.Description     = collection["Description"];
                news.Title           = collection["Title"];
                news.Ord             = Convert.ToInt32(collection["Ord"]);
                news.Action          = (collection["Action"] == "false") ? false : true;
                news.Lang            = Session["Lang"] != null ? Session["Lang"].ToString() : "vi";
                news.Views           = 0;//so luot xem
                news.CreateDate      = DateTime.Now;
                db.Entry(news).State = EntityState.Added;
                //db.sp_News_Insert(news.Name, news.Tag, news.Title, news.Keyword, news.Description, news.Image, news.SDate, news.Content, news.Detail, news.Index, news.View, news.IdGroup, news.Ord, news.Active, news.Lang);
                db.SaveChanges();
                return(RedirectToAction("LibraryIndexot"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }
Esempio n. 13
0
        public ActionResult NewsCreate(FormCollection collection, News news, HttpPostedFileBase fileImg)
        {
            int idmem = 0;

            if (Session["uId"] != null)
            {
                idmem = int.Parse(Session["uId"].ToString());
            }
            if (Request.Cookies["Username"] != null)
            {
                news.Name    = collection["Name"];
                news.Tag     = StringClass.NameToTag(collection["Name"]);
                news.Image   = collection["Image"];
                news.Content = collection["Content"];
                news.Detail  = collection["Detail"];
                int GroupNews = Convert.ToInt32(collection["GroupNews"]);
                news.IdGroup     = GroupNews;
                news.Keyword     = collection["Keyword"];
                news.Description = collection["Description"];
                news.Title       = collection["Title"];
                news.Ord         = Convert.ToInt32(collection["Ord"]);
                news.Index       = (collection["Index"] == "false") ? false : true;
                news.Active      = (collection["Active"] == "false") ? false : true;
                news.Lang        = Session["Lang"] != null ? Session["Lang"].ToString() : "vi";
                news.View        = 0;//so luot xem
                news.SDate       = DateTime.Now;
                db.sp_News_Insert(news.Name, news.Tag, news.Title, news.Keyword, news.Description, news.Image, news.SDate, news.Content, news.Detail, news.Index, news.View, news.IdGroup, news.Ord, news.Active, news.Lang);
                db.SaveChanges();
                return(RedirectToAction("NewsIndexot"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }
Esempio n. 14
0
        public ActionResult UserModuleCreate(FormCollection collection, UserModule userModule)
        {
            if (Request.Cookies["Username"] != null)
            {
                var Name        = collection["Name"];
                var Ord         = collection["Order"];
                var description = collection["Description"];
                var Active      = collection["Active"];

                userModule.Name        = Name;
                userModule.Order       = Convert.ToInt32(Ord);
                userModule.Description = description;
                userModule.Active      = (collection["Active"] == "false") ? false : true;

                db.UserModules.Add(userModule);
                db.SaveChanges();



                return(RedirectToAction("UserModuleIndex"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }
Esempio n. 15
0
 public ActionResult GroupNewCreateot(FormCollection collection, GroupNew catego)
 {
     if (Request.Cookies["Username"] != null)
     {
         // Lấy dữ liệu từ view
         int    parentId = 0;
         string level    = "00000";
         if (collection["GroupNew"] != "0")
         {
             if (collection["GroupNew"] != "")
             {
                 parentId = Int32.Parse(collection["GroupNew"]);
                 string parentLevel = db.GroupNews.Where(g => g.Id == parentId).SingleOrDefault().Level;
                 level = parentLevel + "00000";
             }
         }
         catego.Level       = level;
         catego.Name        = collection["Name"];
         catego.Title       = collection["Title"];
         catego.Description = collection["Description"];
         catego.Keyword     = collection["Keyword"];
         catego.Ord         = Convert.ToInt32(collection["Ord"]);
         catego.Tag         = StringClass.NameToTag(collection["Name"]);
         catego.Priority    = (collection["Priority"] == "false") ? false : true;
         catego.Index       = (collection["Index"] == "false") ? false : true;
         catego.Active      = (collection["Active"] == "false") ? false : true;
         catego.Lang        = Session["Lang"] != null ? Session["Lang"].ToString() : "vi";
         string groid = collection["Cat"];
         if (groid != null && groid != "")
         {
             catego.GrpID = int.Parse(groid);
         }
         else
         {
             catego.GrpID = 0;
         }
         db.Entry(catego).State = EntityState.Added;
         db.SaveChanges();
         return(RedirectToAction("GroupNewIndexot"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 16
0
 public ActionResult BankCreate(FormCollection collection, Bank bak)
 {
     if (Request.Cookies["Username"] != null)
     {
         var Name = collection["Name"];
         var Img  = collection["Image"];
         bak.Name   = Name;
         bak.Image  = Img;
         bak.Active = (collection["Active"] == "false") ? false : true;
         db.Banks.Add(bak);
         db.SaveChanges();
         return(RedirectToAction("BankIndex"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 17
0
        public ActionResult OrderUpdateStatus(int id, string status)
        {
            var results = "";
            //if (Request.Cookies["Username"] != null)
            //{
            var up = db.Ords.First(m => m.Id == id);

            if (status != null)
            {
                if (status == "1")
                {
                    up.Status = "2";
                    results   = "Đã nhận tiền";
                }

                if (status == "2")
                {
                    up.Status = "3";
                    results   = "Đã gửi hàng";
                }

                if (status == "4")
                {
                    var detail = db.OrderDetails.Where(m => m.IdOr == up.Id).ToList();
                    for (int k = 0; k < detail.Count; k++)
                    {
                        int idPro = detail[k].IdPro;
                        var sp    = db.Products.Where(m => m.Id == idPro).FirstOrDefault();
                        sp.Count = (sp.Count - detail[k].Number);
                        db.SaveChanges();
                    }
                    up.Status = "4";
                    results   = "Đã hủy đơn hàng";
                }
            }
            db.SaveChanges();

            return(Json(results));
            //}
            //else
            //{
            //    return Redirect("/Admins/admins");
            //}
        }
Esempio n. 18
0
 public ActionResult SupplierCreate(FormCollection collect, Supplier sup)
 {
     if (Request.Cookies["Username"] != null)
     {
         sup.Name      = collect["Name"];
         sup.Tel       = collect["Tel"];
         sup.Email     = collect["Email"];
         sup.Website   = collect["Website"];
         sup.Address   = collect["Address"];
         sup.IdCountry = int.Parse(collect["IdCountry"]);
         db.Suppliers.Add(sup);
         db.SaveChanges();
         return(RedirectToAction("SupplierIndex"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 19
0
        public ActionResult GroupProductCreateot(FormCollection collection, GroupProduct catego)
        {
            if (Request.Cookies["Username"] != null)
            {
                // Lấy dữ liệu từ view
                int    parentId = 0;
                string level    = "00000";
                if (collection["GroupProduct"] != "0")
                {
                    if (collection["GroupProduct"] != "")
                    {
                        parentId = Int32.Parse(collection["GroupProduct"]);
                        string parentLevel = db.GroupProducts.Where(g => g.Id == parentId).SingleOrDefault().Level;
                        level = parentLevel + "00000";
                    }
                }
                catego.Level       = level;
                catego.ParentId    = parentId;
                catego.Name        = collection["Name"];
                catego.Title       = collection["Title"];
                catego.Description = collection["Description"];
                catego.Keyword     = collection["Keyword"];
                catego.Ord         = Convert.ToInt32(collection["Ord"]);
                catego.Tag         = StringClass.NameToTag(collection["Name"]);
                catego.Priority    = (collection["Priority"] == "false") ? false : true;
                catego.Index       = (collection["Index"] == "false") ? false : true;
                catego.Active      = (collection["Active"] == "false") ? false : true;
                catego.Icon        = collection["Icon"];
                catego.Images      = collection["Images"];
                catego.BaoHanh     = collection["Baohanh"];
                catego.Detail      = collection["Detail"];

                db.Entry(catego).State = EntityState.Added;
                db.SaveChanges();
                return(RedirectToAction("GroupProductIndexot"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }
Esempio n. 20
0
 public ActionResult CountryCreate(FormCollection collection, Country pro)
 {
     if (Request.Cookies["Username"] != null)
     {
         pro.Name = collection["Name"];
         if (!collection["Ord"].Equals(""))
         {
             pro.Ord = int.Parse(collection["Ord"]);
         }
         pro.Active      = (collection["Active"] == "false") ? false : true;
         pro.Logo        = collection["Logo"];
         pro.Description = collection["Description"];
         db.Countries.Add(pro);
         db.SaveChanges();
         return(RedirectToAction("CountryIndex"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 21
0
        public ActionResult CatPermissionCreate(FormCollection collection, CatPermission catpermission)
        {
            if (Request.Cookies["Username"] != null)
            {
                catpermission.UserID = Int32.Parse(collection["UserID"]);
                catpermission.CatID  = Int32.Parse(collection["CatID"]);
                catpermission.View   = (collection["View"] == "false") ? false : true;
                catpermission.Full   = (collection["Full"] == "false") ? false : true;

                db.CatPermissions.Add(catpermission);
                db.SaveChanges();
                return(RedirectToAction("CatPermissionIndex"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }
Esempio n. 22
0
 public ActionResult GroupSupportCreate(FormCollection collection, onsoft.Models.GroupSupport groupsp)
 {
     if (Request.Cookies["Username"] != null)
     {
         var Name = collection["Name"];
         var Ord  = collection["Ord"];
         groupsp.Name   = Name;
         groupsp.Ord    = int.Parse(Ord);
         groupsp.Active = (collection["Active"] == "false") ? false : true;
         db.GroupSupports.Add(groupsp);
         db.SaveChanges();
         return(RedirectToAction("GroupSupportIndex"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 23
0
        public ActionResult LanguageCreateot(FormCollection collection, Models.Language catego)
        {
            if (Request.Cookies["Username"] != null)
            {
                // Lấy dữ liệu từ view
                catego.Name = collection["Name"];
                catego.Code = collection["Code"];

                catego.Images = collection["Images"];
                catego.Active = (collection["Action"] == "false") ? false : true;

                db.Entry(catego).State = EntityState.Added;
                db.SaveChanges();
                return(RedirectToAction("LanguageIndexot"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }
Esempio n. 24
0
 public ActionResult CustomerEdit(FormCollection collection, int id)
 {
     if (Request.Cookies["Username"] != null)
     {
         var cus = db.Customers.First(m => m.Id == id);
         cus.Name     = collection["Name"];
         cus.Email    = collection["Email"];
         cus.Password = StringClass.Encrypt(collection["Password"]);
         cus.Tel      = collection["Tel"];
         cus.Address  = collection["Address"];
         cus.SDate    = DateTime.Now;
         cus.Status   = (collection["Status"] == "false") ? false : true;
         db.SaveChanges();
         return(RedirectToAction("CustomerIndex"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 25
0
        public ActionResult PermisstionActiveAll(bool status)
        {
            //var pStatus = db.UserModules.Find(id);

            if (status == true)
            {
                foreach (var item in db.UserModules.ToList())
                {
                    item.Active = true;
                }
            }
            else
            {
                foreach (var item in db.UserModules.ToList())
                {
                    item.Active = false;
                }
            }
            db.SaveChanges();
            var result = "Trạng thái đã được cập nhật.";// userModule.Active;

            return(Json(result));
        }
Esempio n. 26
0
 public ActionResult GroupLibraryCreateot(FormCollection collection, Models.GroupLibrary catego)
 {
     if (Request.Cookies["Username"] != null)
     {
         // Lấy dữ liệu từ view
         catego.Name            = collection["Name"];
         catego.Code            = collection["Code"];
         catego.Description     = collection["Description"];
         catego.Keyword         = collection["Keyword"];
         catego.Ord             = Convert.ToInt32(collection["Ord"]);
         catego.Image           = collection["Image"];
         catego.Active          = (collection["Active"] == "false") ? false : true;
         catego.Lang            = Session["Lang"] != null ? Session["Lang"].ToString() : "vi";
         db.Entry(catego).State = EntityState.Added;
         db.SaveChanges();
         return(RedirectToAction("GroupLibraryIndexot"));
     }
     else
     {
         return(Redirect("/Admins/admins"));
     }
 }
Esempio n. 27
0
        public ActionResult MenuCreate(FormCollection collection, onsoft.Models.Menu page)
        {
            if (Request.Cookies["Username"] != null)
            {
                page.Name   = collection["Name"];
                page.Images = collection["Images"];
                if (collection["PageTypeDDL"] == "0")
                {
                    //Lien ket
                    if (collection["LinkDDL"] == "0")
                    {
                        page.Link = collection["Link"];
                    }
                    else if (collection["LinkDDL"] == "1")
                    {
                        page.Link = collection["LinkModule"];
                    }
                    else if (collection["LinkDDL"] == "2")
                    {
                        page.Link = "/san-pham";
                    }
                    else
                    {
                        page.Link = "/tin-tuc";
                    }
                    page.IdCategory = null;
                }
                else
                {
                    //Noi dung
                    page.Link       = "/gioi-thieu/" + StringClass.NameToTag(collection["Name"].ToString()) + "";
                    page.IdCategory = 0;
                }

                page.Target      = collection["Target"];
                page.Position    = Convert.ToInt32(collection["Position"]);
                page.Content     = collection["Content"];
                page.Detail      = collection["Detail"];
                page.Title       = collection["Title"];
                page.Lang        = Session["Lang"].ToString();
                page.Description = collection["Description"];
                page.Keyword     = collection["Keyword"];
                string le = collection["lstMenu"];
                if (le.Length > 0)
                {
                    page.Level = le + "00000";
                }
                else
                {
                    page.Level = "00000";
                }
                page.Ord    = Convert.ToInt32(collection["Order"]);
                page.Active = (collection["Active"] == "false") ? false : true;

                page.Tag = onsoft.Models.StringClass.NameToTag(collection["Name"]);

                //StringClass.ShowNameLevel(collection["Name"], Model[i].Level);

                db.Menus.Add(page);
                db.SaveChanges();
                return(RedirectToAction("MenuIndex"));
            }
            else
            {
                return(RedirectToAction("admins"));
            }
        }
Esempio n. 28
0
        public ActionResult UserCreate(FormCollection collection, User user)
        {
            if (Request.Cookies["Username"] != null)
            {
                user.FullName     = collection["FullName"];
                user.UserName     = collection["UserName"];
                user.Password     = collection["Password"];
                user.Email        = collection["Email"];
                user.UserModuleID = collection["permissions"];
                //user.Permission = short.Parse(collection["Permission"]);
                user.Active = (collection["Active"] == "false") ? false : true;

                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("UserIndex"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }
Esempio n. 29
0
        public ActionResult AdvertiseCreate(FormCollection collection, onsoft.Models.Advertise advertise)
        {
            if (Request.Cookies["Username"] != null)
            {
                advertise.Name   = collection["Name"];;
                advertise.Image  = collection["Picture"];
                advertise.Width  = Convert.ToInt32(collection["Width"]);
                advertise.Height = Convert.ToInt32(collection["Height"]);
                advertise.Orders = Convert.ToInt32(collection["Order"]);
                advertise.Link   = collection["Link"];
                advertise.Click  = Convert.ToInt32(collection["Click"]);

                advertise.Active      = (collection["Active"] == "false") ? false : true;
                advertise.Lang        = Session["Lang"] != null ?  Session["Lang"].ToString() : "vi";
                advertise.Position    = Convert.ToInt32(collection["sllPossition"]);
                advertise.Description = collection["Description"];
                if (collection["FromDate"] != null)
                {
                    advertise.FromDate = Convert.ToDateTime(collection["FromDate"]);
                }
                if (collection["ToDate"] != null)
                {
                    advertise.ToDate = Convert.ToDateTime(collection["ToDate"]);
                }

                string groid = collection["Cat"];
                if (groid != null && groid != "")
                {
                    advertise.GrpID = int.Parse(groid);
                }
                else
                {
                    advertise.GrpID = 0;
                }
                if (Convert.ToInt32(collection["sllTarget"]) == 0)
                {
                    advertise.Target = "_blank";
                }
                else if (Convert.ToInt32(collection["sllTarget"]) == 1)
                {
                    advertise.Target = "_self";
                }
                else if (Convert.ToInt32(collection["sllTarget"]) == 2)
                {
                    advertise.Target = "_Parient";
                }
                else if (Convert.ToInt32(collection["sllTarget"]) == 3)
                {
                    advertise.Target = "_top";
                }

                advertise.Click = 0;

                db.Advertises.Add(advertise);
                db.SaveChanges();
                return(RedirectToAction("AdvertiseIndex"));
            }
            else
            {
                return(Redirect("/Admins/admins"));
            }
        }
Esempio n. 30
0
        public ActionResult Detail(string tag)
        {
            string chuoi      = "";
            string chuoilink  = "";
            string image      = "";
            string imagethumb = "";
            string Cart       = "";
            int    category   = 0;
            int    proId      = 0;
            string baohanh    = "";
            string noibat     = "";
            string chitiet    = "";
            string thanhtoan  = "";
            string canhbao    = "";
            string khuyenmai  = "";
            string fb         = "";
            var    pro        = (from p in data.Products where p.Tag == tag select p).ToList();

            if (pro.Count > 0)
            {
                proId = pro[0].Id;
                data.sp_Product_Update(proId, pro[0].Name, pro[0].Tag, pro[0].Image, pro[0].Description, pro[0].Weight, pro[0].ChatLieu, pro[0].Status, pro[0].Detail, pro[0].SpTon, pro[0].Count, (pro[0].View + 1), pro[0].Like, pro[0].IdCategory, pro[0].Date, pro[0].Index, pro[0].Priority, pro[0].Keyword, pro[0].Title, pro[0].Content, pro[0].Ord, pro[0].Active, pro[0].PriceRetail, pro[0].PricePromotion, pro[0].Num, pro[0].Noibat, pro[0].Baohanh, pro[0].Giamgia);
                data.SaveChanges();

                category = pro[0].IdCategory;
                var cate = (from p in data.GroupProducts where p.Id == category select p).ToList();
                if (cate.Count > 0)
                {
                    chuoilink = "<li class='Last'><a href='/danh-muc/" + cate[0].Tag + "'>" + cate[0].Name + "</a></li>";
                }
                cate.Clear();
                cate         = null;
                ViewBag.link = chuoilink;
                int g = 0;
                if (pro[0].Num != null)
                {
                    g = int.Parse(pro[0].Num.ToString());
                }
                chuoi      += "<input type=\"hidden\" id=\"item_id\" value=\"" + pro[0].Id + "\">";
                imagethumb += "<li class='active' rel='1'><img src=\"" + pro[0].Image + "\" alt=\"" + pro[0].Name + "\" title=\"Click to enlarge\" /></li>";
                //if (g == 0)
                //{
                image += "<a href=\"" + pro[0].Image + "\" class=\"highslide\" rel=\"position: 'inside' , showTitle: false\" id=\"zoom1\" style=\"position: relative; display: block;\" onclick=\"return hs.expand(this)\"><img src=\"" + pro[0].Image + "\" alt=\"" + pro[0].Name + "\" /></a>";
                //}
                //else
                //{
                //    image += "<a href=\"" + pro[0].Image + "\" class=\"highslide\" rel=\"position: 'inside' , showTitle: false\" id=\"zoom1\" style=\"position: relative; display: block;\" onclick=\"return hs.expand(this)\"><img src=\"" + pro[0].Image + "\" alt=\"" + pro[0].Name + "\" /></a>";
                //}
                chuoi += "<input type=\"hidden\" id=\"item_id\" value=\"" + pro[0].Id + "\" />";
                chuoi += "<p id=\"titPro\">" + pro[0].Name + "</p>";
                chuoi += "<p>Mã SP: <span class=\"value\">" + pro[0].Code + "</span></p>";
                chuoi += "<div class=\"divInfo\">";
                if (g > 0)
                {
                    //chuoi += "<p><span class=\"txtw80\">Tình trạng:</span><span class=\"stock\">Còn hàng</span></p>";
                    if ((pro[0].PricePromotion / pro[0].PriceRetail) * 100 < 100)
                    {
                        chuoi += "<p><span id=\"valBanle-cu\">Giá cũ: " + StringClass.Format_Price(pro[0].PriceRetail.ToString()) + "đ</span></p>";
                        chuoi += "<p>Giá bán: <span id=\"valBanle\"> " + StringClass.Format_Price(pro[0].PricePromotion.ToString()) + "đ</span></p>";
                    }
                    else
                    {
                        chuoi += "<p>Giá: <span id=\"valBanle\"> " + StringClass.Format_Price(pro[0].PricePromotion.ToString()) + "đ</span></p>";
                    }
                }
                else
                {
                    //chuoi += "<p><span class=\"txtw80\">Tình trạng:</span><span class=\"nostock\">Hết hàng</span></p>";
                    chuoi += "<p>Giá bán: <span id=\"valBanle\">" + StringClass.Format_Price(pro[0].PricePromotion.ToString()) + "đ</span></p>";
                }
                //chuoi += "<span class=\"lblProduct\">&nbsp;</span>";
                chuoi += "</div>";
                int pid       = pro[0].Id;
                var proimages = (from im in data.ProImages where im.IdPro == pid select im).ToList();
                int k         = 2;
                for (int j = 0; j < proimages.Count; j++)
                {
                    if (proimages.Count > 1)
                    {
                        imagethumb += "<li class='active' rel='" + (k + j) + "'><img src=\"" + proimages[j].Image + "\" alt=\"" + pro[0].Name + "\" /></li>";
                    }
                    image += "<a href=\"" + proimages[j].Image + "\" class=\"highslide\" onclick=\"return hs.expand(this)\"><img src=\"" + proimages[j].Image + "\" alt=\"" + pro[0].Name + "\" /></a>";
                }
                if (g > 0)
                {
                    Cart += "<p id=\"Cart\"><a id=\"btnAddCart\" href=\"javascript:;\" class=\"btnBuyNow add-to-cart\" title=\"Thêm sản phẩm này vào giỏ hàng\"><span id=\"txt\"></span></a><a id=\"btnAddCart\" title=\"Mua ngay\" href=\"javascript:;\" class=\"btnAddCart\" rel=\"/Home/checkout\"><span id=\"txt1\">Mua ngay</span></a></p>";
                }
                else
                {
                    Cart += "<p id=\"Cart\"><a id=\"btnAddCart\" href=\"javascript:;\" class=\"btnBuyNow Disabled\" title=\"Thêm sản phẩm này vào giỏ hàng\"><span id=\"txt\"></span></a><a id=\"btnAddCart\" title=\"Mua ngay\" href=\"javascript:;\" class=\"btnAddCart Disabled\" rel=\"/Home/checkout\"><span id=\"txt1\">Mua ngay</span></a></p>";
                }
                chitiet = pro[0].Content;
                noibat  = pro[0].Noibat;
                int idcate = pro[0].IdCategory;
                var bh     = data.GroupProducts.Find(idcate);
                baohanh = bh.BaoHanh; // bao hanh


                #region [Title, Keyword, Deskription]
                string t   = pro[0].Title;
                string tt  = pro[0].Description;
                string ttt = pro[0].Keyword;
                if (pro[0].Title != null && pro[0].Title.Length > 0)
                {
                    ViewBag.tit = pro[0].Title;
                }
                else
                {
                    ViewBag.tit = pro[0].Name;
                }
                if (pro[0].Description != null && pro[0].Description.Length > 0)
                {
                    ViewBag.des = pro[0].Description;
                }
                else
                {
                    ViewBag.des = pro[0].Name;
                }
                if (pro[0].Keyword != null && pro[0].Keyword.Length > 0)
                {
                    ViewBag.key = pro[0].Keyword;
                }
                else
                {
                    ViewBag.key = pro[0].Name;
                }
                #endregion
                ViewBag.cart = Cart;
                proimages.Clear();
                proimages = null;

                fb += "<div class=\"fb-like\" style=\"margin-top: 15px; padding-bottom: 3px\" data-href=\"" + Request.Url.ToString() + "\" data-send=\"true\" data-max-width=\"950\" data-show-faces=\"true\"></div>";
                fb += "<div class=\"fb-comments\" style=\"margin-top: 15px\" data-href=\"" + Request.Url.ToString() + "\" data-max-width=\"950\" data-num-posts=\"5\"></div>";

                #region [Sản phẩm cùng loại]
                string chuoicungloai = "";
                var    list          = (from p in data.Products where p.Active == true && p.IdCategory == category && p.Tag != tag orderby p.Ord ascending select p).Take(21).ToList();
                for (int i = 0; i < list.Count; i++)
                {
                    //if (i % 3 != 0)
                    //{
                    //    chuoicungloai += "<li class=\"other\">";
                    //}
                    //else
                    //{
                    //    chuoicungloai += "<li class=\"right\">";
                    //}
                    //chuoicungloai += "<div class=\"imagespro\"><a href=\"/thong-tin/" + list[i].Tag + "\" title=\"" + list[i].Name + "\"><img src=\"" + list[i].Image + "\" alt=\"" + list[i].Name + "\" title=\"" + list[i].Name + "\"/></a></div>";
                    //    chuoicungloai += "<div>";
                    //    if (list[i].Code != null && list[i].Code != "")
                    //    {
                    //        chuoicungloai += "<p class=\"gia_cu\">" + list[i].Code + " đ</p>";
                    //    }
                    //    else
                    //    {
                    //        chuoicungloai += "<p class=\"gia_cu\">No size</p>";
                    //    }
                    //    if (list[i].PricePromotion == 0)
                    //    {
                    //        chuoicungloai += "<p class=\"gia_sp\">Giá: Vui lòng liên hệ</p>";
                    //    }
                    //    else
                    //    {
                    //        chuoicungloai += "<p class=\"gia_sp\">Giá: " + os.os.Format_Price(list[i].PricePromotion.ToString()) + " đ</p>";
                    //    }
                    //    chuoicungloai += "</div>";
                    //    chuoicungloai += "<p class=\"sp_code\"><a href=\"/thong-tin/" + list[i].Tag + "\">" + list[i].Name + "</a></p>";
                    //chuoicungloai += "</li>";



                    if (i % 3 != 0)
                    {
                        chuoicungloai += "<li class=\"other\">";
                        chuoicungloai += "<div class=\"imagespro\"><a href=\"/thong-tin/" + list[i].Tag + "\" title=\"" + list[i].Name + "\"><img src=\"" + list[i].Image + "\" alt=\"" + list[i].Name + "\"  title=\"" + list[i].Name + "\"/></a></div>";
                        if ((list[i].PricePromotion / list[i].PriceRetail) * 100 < 100)
                        {
                            chuoicungloai += "<div>";
                            if (list[i].Code != null && list[i].Code != "")
                            {
                                chuoicungloai += "<p class=\"sp_code\">Mã SP: " + list[i].Code + "</p>";
                            }
                            else
                            {
                                chuoicungloai += "<p class=\"sp_code\">No size</p>";
                            }
                            if (list[i].PricePromotion == 0)
                            {
                                chuoicungloai += "<p class=\"gia_sp\">Giá: Vui lòng liên hệ</p>";
                            }
                            else
                            {
                                chuoicungloai += "<p class=\"gia_cu\">Giá cũ: " + os.os.Format_Price(list[i].PriceRetail.ToString()) + "đ</p>";
                                chuoicungloai += "<p class=\"gia_sp\">Giá bán: " + os.os.Format_Price(list[i].PricePromotion.ToString()) + "đ</p>";
                            }
                            chuoicungloai += "</div>";
                            chuoicungloai += "<p class=\"sp_name\"><a href=\"/thong-tin/" + list[i].Tag + "\"> " + list[i].Name + "</a></p>";
                            chuoicungloai += "<div class=\"giamgia\">";
                            chuoicungloai += "<span class=\"discount-label\">Giảm</span>";
                            chuoicungloai += "<span class=\"discount-value\">" + onsoft.Models.StringClass.Round(double.Parse((100 - (list[i].PricePromotion / list[i].PriceRetail) * 100).ToString()), 2) + "%</span>";
                            chuoicungloai += "</div>";
                        }
                        else
                        {
                            chuoicungloai += "<div>";
                            if (list[i].Code != null && list[i].Code != "")
                            {
                                chuoicungloai += "<p class=\"sp_code\">Mã SP: " + list[i].Code + "</p>";
                            }
                            else
                            {
                                chuoicungloai += "<p class=\"sp_code\">No size</p>";
                            }
                            if (list[i].PricePromotion == 0)
                            {
                                chuoicungloai += "<p class=\"gia_sp\">Giá: Vui lòng liên hệ</p>";
                            }
                            else
                            {
                                chuoicungloai += "<p class=\"gia_sp\">Giá bán: " + os.os.Format_Price(list[i].PricePromotion.ToString()) + "đ</p>";
                            }
                            chuoicungloai += "</div>";
                            chuoicungloai += "<p class=\"sp_name\"><a href=\"/thong-tin/" + list[i].Tag + "\">" + list[i].Name + "</a></p>";
                        }
                        chuoicungloai += "</li>";
                    }
                    else
                    {
                        chuoicungloai += "<li class=\"right\">";
                        chuoicungloai += "<div class=\"imagespro\"><a href=\"/thong-tin/" + list[i].Tag + "\" title=\"list[i].Name\"><img src=\"" + list[i].Image + "\" alt=\"" + list[i].Name + "\"  title=\"" + list[i].Name + "\"/></a></div>";
                        chuoicungloai += "<div>";
                        if (list[i].Code != null && list[i].Code != "")
                        {
                            chuoicungloai += "<p class=\"sp_code\">Mã SP: " + list[i].Code + "</p>";
                        }
                        else
                        {
                            chuoicungloai += "<p class=\"sp_code\">No size</p>";
                        }
                        if (list[i].PricePromotion == 0)
                        {
                            chuoicungloai += "<p class=\"gia_sp\">Giá: Vui lòng liên hệ</p>";
                        }
                        else
                        {
                            chuoicungloai += "<p class=\"gia_sp\">Giá bán: " + os.os.Format_Price(list[i].PricePromotion.ToString()) + "đ</p>";
                        }
                        chuoicungloai += "</div>";
                        chuoicungloai += "<p class=\"sp_name\"><a href=\"/thong-tin/" + list[i].Tag + "\">" + list[i].Name + "</a></p>";
                        chuoicungloai += "</li>";
                    }
                }
                ViewBag.cungloai = chuoicungloai;
                list.Clear();
                list = null;
                #endregion
                #region [Sản phẩm nhiều người mua]
                string chuoinhieu = "";
                var    listnn     = (from p in data.v_Product_DescTotalNumber select p).Take(20).ToList();
                for (int e = 0; e < listnn.Count; e++)
                {
                    chuoinhieu += "<li>";
                    chuoinhieu += "<a href=\"/dong-ho/" + listnn[e].Tag + "\"><img src=\"" + listnn[e].Image + "\" /></a>";
                    chuoinhieu += "<a href=\"/dong-ho/" + listnn[e].Tag + "\">" + listnn[e].Name + "</a>";
                    if ((listnn[e].PricePromotion / listnn[e].PriceRetail) * 100 < 100)
                    {
                        chuoinhieu += "<p><span>" + os.os.Format_Price(listnn[e].PriceRetail.ToString()) + "đ</span></p>";
                        chuoinhieu += "<p>" + os.os.Format_Price(listnn[e].PricePromotion.ToString()) + "đ</p>";
                    }
                    else
                    {
                        chuoinhieu += "<p>" + os.os.Format_Price(listnn[e].PricePromotion.ToString()) + "đ</p>";
                    }
                    chuoinhieu += "</li>";
                }
                ViewBag.nhieu = chuoinhieu;
                listnn.Clear();
                listnn = null;
                #endregion
            }
            ViewBag.images     = image;
            ViewBag.imagethumb = imagethumb;
            ViewBag.pro        = chuoi;
            pro.Clear();
            pro = null;
            #region [Hiển thị thông tin các Tab]
            var listconf = data.Configs.ToList();
            if (listconf.Count > 0)
            {
                thanhtoan = listconf[0].Thanhtoan;
                canhbao   = listconf[0].Canhbao;
                khuyenmai = listconf[0].Helpsize;
            }
            listconf.Clear();
            listconf = null;
            string chuoitab_head    = "";
            string chuoitab_content = "";
            if (chitiet != null && chitiet != "")
            {
                chuoitab_head    += "<li><a href=\"#tabs-1\">Thông tin sản phẩm</a></li>";
                chuoitab_content += "<div id=\"tabs-1\"><p>" + chitiet + " " + canhbao + "</p></div>";
            }
            if (noibat != null && noibat != "")
            {
                chuoitab_head    += "<li><a href=\"#tabs-2\">Ưu điểm nổi bật</a></li>";
                chuoitab_content += "<div id=\"tabs-2\"><p>" + noibat + "</p></div>";
            }
            if (baohanh != null && baohanh != "")
            {
                chuoitab_head    += "<li><a href=\"#tabs-3\">Thông tin bảo hành</a></li>";
                chuoitab_content += "<div id=\"tabs-3\"><p>" + baohanh + "</p></div>";
            }
            if (thanhtoan != null && thanhtoan != "")
            {
                chuoitab_head    += "<li><a href=\"#tabs-4\">Phương thức thanh toán</a></li>";
                chuoitab_content += "<div id=\"tabs-4\"><p>" + thanhtoan + "</p></div>";
            }
            //if (canhbao != null && canhbao != "")
            //{
            //    chuoitab_head += "<li><a href=\"#tabs-5\">Cảnh báo</a></li>";
            //    chuoitab_content += "<div id=\"tabs-5\"><p>" + canhbao + "</p></div>";
            //}
            if (khuyenmai != null && khuyenmai != "")
            {
                chuoitab_head    += "<li><a href=\"#tabs-6\">Khuyến mại</a></li>";
                chuoitab_content += "<div id=\"tabs-6\"><p>" + khuyenmai + "</p></div>";
            }
            chuoitab_head     += "<li><a href=\"#tabs-7\">Bình luận đánh giá</a></li>";
            chuoitab_content  += "<div id=\"tabs-7\"><p>" + fb + "</p></div>";
            ViewBag.tabhead    = chuoitab_head;
            ViewBag.tabcontent = chuoitab_content;
            #endregion
            #region [Hỗ trợ trực tuyến]
            string chuoisp       = "";
            string chuoi_tel     = "";
            string chuoi_hotline = "";
            string chuoi_mobile  = "";
            var    listsp        = data.Supports.ToList();
            if (listsp.Count > 0)
            {
                for (int i = 0; i < listsp.Count; i++)
                {
                    if (listsp[i].Type == 0)
                    {
                        chuoisp += "<p><a href=\"ymsgr:sendim?" + listsp[i].Nick + "\" title=\"" + listsp[i].Name + "\"><img alt=\"" + listsp[i].Name + "\" src=\"http://opi.yahoo.com/online?u=" + listsp[i].Nick + "&amp;m=g&amp;t=1\" border=\"0\" align=\"middle\"></a></p>";
                    }
                    else if (listsp[i].Type == 1)
                    {
                        chuoisp += "<p><a href=\"skype:" + listsp[i].Nick + "?chat\"><img src=\"HTTP://MYSTATUS.SKYPE.COM/smallclassic/" + listsp[i].Nick + "\" title=\"" + listsp[i].Name + "\"></a></p>";
                    }
                    else if (listsp[i].Type == 2)
                    {
                        chuoi_hotline += "<p><a href=\"#\" class=\"hl\" title=\"" + listsp[i].Name + "\"></a><span>HOTLINE: " + listsp[i].Tel + "</span></p>";
                    }
                    else if (listsp[i].Type == 3)
                    {
                        chuoi_tel += "<p><a href=\"#\" class=\"cel\" title=\"" + listsp[i].Name + "\"></a>" + listsp[i].Tel + "</p>";
                    }
                    else if (listsp[i].Type == 4)
                    {
                        chuoi_mobile += "<p><a href=\"#\" class=\"mob\" title=\"" + listsp[i].Name + "\"></a>" + listsp[i].Tel + "</p>";
                    }
                }
                chuoisp = chuoisp + chuoi_tel + chuoi_mobile + chuoi_hotline;
            }
            ViewBag.support = chuoisp;
            #endregion
            //#region[view drop Colors]
            //var procolor = data.ProColors.Where(n => n.IdPro == proId).ToList();
            //List<DropDownList> listcolor = new List<DropDownList>();
            //listcolor.Add(new DropDownList { value = "0", text = "Như ảnh" });
            //if (procolor.Count > 0)
            //{
            //    List<DropDownList> listcolor1 = new List<DropDownList>();
            //    for (int k = 0; k < procolor.Count; k++)
            //    {
            //        int clId=procolor[k].IdColor;
            //        var color = data.Colors.Where(n => n.Id == clId).ToList();
            //        for (int i = 0; i < color.Count; i++)
            //        {
            //            string sid=color[i].Id.ToString();
            //            string sname=color[i].Name.ToString();
            //            listcolor1.Add(new DropDownList { value = "" + sid + "", text = "" + sname + "" });
            //            //ViewBag.color = new SelectList(color, "Id", "Name");
            //        }
            //    }
            //    ViewBag.color = new SelectList(listcolor1, "value", "text");
            //}
            //else
            //{
            //    ViewBag.color = new SelectList(listcolor, "value", "text");
            //}
            //#endregion
            //#region[view drop Sizes]
            //var prosize = data.ProSizes.Where(n => n.IdPro == proId).ToList();
            //List<DropDownList> listsize = new List<DropDownList>();
            //listsize.Add(new DropDownList { value = "0", text = "Freesize" });
            //if (prosize.Count > 0)
            //{
            //    List<DropDownList> listsize1 = new List<DropDownList>();
            //    for (int s = 0; s < prosize.Count; s++)
            //    {
            //        int szId = prosize[s].IdSize;
            //        var size = data.Sizes.Where(n => n.Id == szId).ToList();
            //        for (int i = 0; i < size.Count; i++)
            //        {
            //            string sid = size[i].Id.ToString();
            //            string sname = size[i].Name.ToString();
            //            listsize1.Add(new DropDownList { value = "" + sid + "", text = "" + sname + "" });
            //            //ViewBag.sizes = new SelectList(size, "Id", "Name");
            //        }
            //    }
            //    ViewBag.size = new SelectList(listsize1, "value", "text");
            //}
            //else
            //{
            //    ViewBag.size = new SelectList(listsize, "value", "text");
            //}
            //#endregion

            return(View());
        }