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")); } }
public ActionResult AdvertiseEdit(FormCollection collection, onsoft.Models.Advertise advertise) { if (Request.Cookies["Username"] != null) { advertise.Name = collection["Name"]; advertise.Image = collection["Image"]; advertise.Height = Convert.ToInt32(collection["Height"]); advertise.Width = Convert.ToInt32(collection["Width"]); advertise.Position = Convert.ToInt32(collection["sllPossition"]); advertise.Link = collection["Link"]; advertise.Target = collection["sllTarget"]; advertise.Orders = Convert.ToInt32(collection["Order"]); advertise.Active = (collection["Active"] == "false") ? false : true; advertise.Description = collection["Description"]; advertise.Lang = Session["Lang"] != null ? Session["Lang"].ToString() : "vi"; string groid = collection["Cat"]; if (groid != null && groid != "") { advertise.GrpID = int.Parse(groid); } else { advertise.GrpID = 0; } db.Entry(advertise).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("AdvertiseIndex")); } else { return(Redirect("/Admins/admins")); } }
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")); } }
public ActionResult ChangeActive(int id) { var news = db.News.Find(id); if (news != null) { news.Active = news.Active == true ? false : true; } db.Entry(news).State = EntityState.Modified; db.SaveChanges(); var results = "Trạng thái kích hoạt đã được thay đổi."; return(Json(results)); }
public ActionResult ChangeStatus(int id) { var customer = db.Customers.Find(id); if (customer != null) { customer.Status = customer.Status == true ? false : true; } db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); var results = "Trạng thái đã được thay đổi."; return(Json(results)); }
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)); }
public ActionResult UpdateDirect(int id, string order, string link) { var menu = db.Menus.Find(id); var result = string.Empty; if (menu != null) { if (order != null) { menu.Ord = Convert.ToInt32(order); result = "Thứ tự đã được thay đổi."; } else if (link != null) { menu.Link = link; result = "Link Menu đã được thay đổi."; } else { menu.Active = menu.Active == true ? false : true; result = "Trạng thái Menu đã được thay đổi."; } } db.Entry(menu).State = System.Data.EntityState.Modified; db.SaveChanges(); //var result = "Dữ liệu đã được thay đổi.";// userModule.Active; return(Json(result)); }
public ActionResult ChangeSupport(int id, string ord, string name, string nick, string tel) { var results = ""; var vSize = db.Supports.Find(id); if (vSize != null) { if (ord != null) { vSize.Ord = Int32.Parse(ord); results = "Thứ tự đã được thay đổi."; } if (name != null) { vSize.Name = name; results = "Tên Support đã được thay đổi."; } if (nick != null) { vSize.Nick = nick; results = "Nick Support đã được thay đổi."; } if (tel != null) { vSize.Tel = tel; results = "Điện thoại Support đã được thay đổi."; } } db.Entry(vSize).State = EntityState.Modified; db.SaveChanges(); return(Json(results)); }
public ActionResult UserModuleEdit(FormCollection collection, UserModule userModule) { if (Request.Cookies["Username"] != null) { userModule.Name = collection["Name"]; userModule.Order = Convert.ToInt32(collection["Order"]); userModule.Description = collection["Description"]; userModule.Active = (collection["Active"] == "false") ? false : true; db.Entry(userModule).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("UserModuleIndex")); } else { return(Redirect("/Admins/admins")); } }
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")); } }
public ActionResult ChangeProvince(int id, string ord, string price, string time, string Price1, string Time1, string Price2, string Time2, string Name) { var results = ""; var Province = db.Provinces.Find(id); if (Province != null) { if (ord != null) { Province.Ord = Int32.Parse(ord); results = "Thứ tự đã được thay đổi."; } else if (price != null) { Province.Price = int.Parse(price); results = "Cước CPN đã được thay đổi!"; } else if (Price1 != null) { Province.Price1 = double.Parse(Price1); results = "Cước CP thường đã được thay đổi!"; } else if (Price2 != null) { Province.Price2 = double.Parse(Price2); results = "Cước CP ô tô đã được thay đổi!"; } else if (time != null) { Province.Time = time; results = "Thời gian CPN đã được thay đổi!"; } else if (Time1 != null) { Province.Time1 = Time1; results = "Thời gian CP thường đã được thay đổi!"; } else if (Time2 != null) { Province.Time2 = Time2; results = "Thời gian CP ô tô đã được thay đổi!"; } else if (Name != null) { Province.Name = Name; results = "Tên tỉnh thành phố đã được thay đổi!"; } } db.Entry(Province).State = EntityState.Modified; db.SaveChanges(); return(Json(results)); }
public ActionResult MultiCommand(FormCollection collect) { if (Request.Cookies["Username"] != null) { if (collect["btnDeleteAll"] != null) { foreach (string key in Request.Form) { var checkbox = ""; if (key.StartsWith("chk")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { Int32 id = Convert.ToInt32(key.Remove(0, 3)); var Del = (from emp in db.GroupSupports where emp.Id == id select emp).SingleOrDefault(); db.GroupSupports.Remove(Del); db.SaveChanges(); } } } } else { foreach (string key in Request.Form) { if (key.StartsWith("Ord")) { Int32 id = Convert.ToInt32(key.Remove(0, 3)); var Up = db.GroupSupports.Where(e => e.Id == id).FirstOrDefault(); if (Up != null) { if (!collect["Ord" + id].Equals("")) { Up.Ord = int.Parse(collect["Ord" + id]); } db.Entry(Up).State = System.Data.EntityState.Modified; //db.ObjectStateManager.ChangeObjectState(provider, EntityState.Modified); db.SaveChanges(); } } } //return RedirectToAction("ProductIndexot", new { page = m }); } return(RedirectToAction("GroupSupportIndex")); } else { return(Redirect("/Admins/admins")); } }
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")); } }
public ActionResult UserEdit(int id, FormCollection collection) { if (Request.Cookies["Username"] != null) { var catego = db.Users.Find(id); // Lấy dữ liệu từ view string name = collection["Name"]; catego.UserName = collection["UserName"]; catego.Email = collection["Email"]; catego.Password = collection["Password"]; catego.FullName = collection["FullName"]; var data = collection["UserModule"]; catego.UserModuleID = data; catego.Active = (collection["Active"] == "false") ? false : true; db.Entry(catego).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("UserIndex")); } else { return(Redirect("/Admins/admins")); } }
public ActionResult ChangeOrder(int id, string postcode) { var results = ""; var order = db.Ords.Find(id); if (order != null) { if (postcode != null) { order.PostCode = postcode; results = "Mã bưu điện đã được cập nhật."; } } db.Entry(order).State = EntityState.Modified; db.SaveChanges(); return(Json(results)); }
public ActionResult ChangeProvince_Price(int id, string From, string To, string PriceN, string PriceC, string PriceO) { var results = ""; var Province = db.Province_Price.Find(id); if (Province != null) { if (From != null) { Province.From = double.Parse(From); results = "Trọng lượng từ đã được thay đổi."; } else if (To != null) { Province.To = double.Parse(To); results = "Trọng lượng đến đã được thay đổi!"; } else if (PriceN != null) { Province.PriceN = double.Parse(PriceN); results = "Cước CP nhanh đã được thay đổi!"; } else if (PriceC != null) { Province.PriceC = double.Parse(PriceC); results = "Cước CP thường đã được thay đổi!"; } else if (PriceO != null) { Province.PriceO = double.Parse(PriceO); results = "Cước chuyển Ô tô đã được thay đổi!"; } } db.Entry(Province).State = EntityState.Modified; db.SaveChanges(); return(Json(results)); }
public ActionResult ChangeMember(int id, string Username, string Password, string Tel, string Email, string Name) { var results = ""; var vMember = db.Members.Find(id); if (vMember != null) { if (Username != null) { vMember.Username = Username; results = "UserName đã được thay đổi."; } else if (Password != null) { vMember.Password = Password; results = "Mật khẩu đã được thay đổi."; } else if (Tel != null) { vMember.Tel = Tel; results = "Số điện thoại đã được thay đổi."; } else if (Email != null) { vMember.Email = Email; results = "Địa chỉ Email đã được thay đổi."; } else if (Name != null) { vMember.Name = Name; results = "Tên thành viên đã được thay đổi."; } } db.Entry(vMember).State = EntityState.Modified; db.SaveChanges(); return(Json(results)); }
public ActionResult ChangeSize(int id, string ord, string name) { var results = ""; var vSize = db.Sizes.Find(id); if (vSize != null) { if (ord != null) { vSize.Ord = Int32.Parse(ord); results = "Thứ tự đã được thay đổi."; } if (name != null) { vSize.Name = name; results = "Tên kích thước đã được thay đổi."; } } db.Entry(vSize).State = EntityState.Modified; db.SaveChanges(); return(Json(results)); }
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")); } }
public ActionResult ChangeColor(int id, string ord, string name) { var results = ""; var vColor = db.Colors.Find(id); if (vColor != null) { if (ord != null) { vColor.Ord = Int32.Parse(ord); results = "Thứ tự đã được thay đổi."; } if (name != null) { vColor.Name = name; results = "Tên màu sắc đã được thay đổi."; } } db.Entry(vColor).State = EntityState.Modified; db.SaveChanges(); return(Json(results)); }
public ActionResult ChangePriceCity(int id, string ord, string priceship) { var results = ""; var pricecity = db.PriceCities.Find(id); if (pricecity != null) { if (ord != null) { pricecity.Ord = Int32.Parse(ord); results = "Thứ tự đã được thay đổi."; } if (priceship != null) { pricecity.Price_ship = float.Parse(priceship); results = "Cước vận chuyển đã được thay đổi."; } } db.Entry(pricecity).State = EntityState.Modified; db.SaveChanges(); return(Json(results)); }
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")); } }
public ActionResult MultiCommand(FormCollection collect) { int m = int.Parse(collect["mPage"]); int pagesize = int.Parse(collect["PageSize"]); List <CatPermission> catpermissions = db.CatPermissions.ToList(); int lastpage = catpermissions.Count / pagesize; if (catpermissions.Count % pagesize > 0) { lastpage++; } //int lastPage = int.Parse(collect["LastPage"]); if (Request.Cookies["Username"] != null) { if (collect["btnDelete"] != null) { //string str = ""; foreach (string key in Request.Form) { var checkbox = ""; if (key.Contains("chk")) { checkbox = Request.Form["" + key]; if (checkbox != "false") { int id = Convert.ToInt32(key.Remove(0, 3)); var Del = (from del in db.CatPermissions where del.ID == id select del).SingleOrDefault(); db.CatPermissions.Remove(Del); db.SaveChanges(); } } } if (collect["checkAll"] != null) { if (m == 1) { return(RedirectToAction("CatPermissionIndex")); } if (m == lastpage) { m--; } } return(RedirectToAction("CatPermissionIndex", new { page = m })); } else if (collect["Users"] != null) { if (collect["Users"].Length > 0) { Session["Users"] = collect["Users"]; } return(RedirectToAction("CatPermissionIndex")); } else { foreach (string key in Request.Form) { if (key.StartsWith("View")) { Int32 id = Convert.ToInt32(key.Remove(0, 3)); var Up = db.CatPermissions.Where(e => e.ID == id).FirstOrDefault(); if (Up != null) { if (!collect["ID" + id].Equals("")) { Up.ID = Int32.Parse(collect["ID" + id]); } db.Entry(Up).State = System.Data.EntityState.Modified; db.SaveChanges(); } } } return(RedirectToAction("CatPermissionIndex", new { page = m })); } } else { return(Redirect("/Admins/admins")); } }
public ActionResult BuyNow(string Name, string Email, string Phone, string Address) { string chuoi = ""; if (Session["ShoppingCart"] != null) { Customer mem = new Customer(); Province provi = new Province(); if (Name != "" && Email != "" && Phone != "" && Address != "") { #region [Lưu vào dababase theo tình huống có địa chỉ giao hàng là Địa chỉ mới] int provid = 0; float tongdiem = 0; float tongtien = 0; float diem = 0; float tien = 0; int w = 0; int ship = 0; int tienship = 0; string sTypePay = ""; string email = Email; #region [Lưu vào bảng khách hàng] //onsoft.Models.Customer customer = new onsoft.Models.Customer(); //customer.Name = Name; //customer.Email = Email; //customer.Password = Email; //customer.Address = Address; //customer.Tel = Phone; //customer.SDate = DateTime.Now; //customer.Status = false; //customer.P_xa = Address; //customer.Provice = 0; //customer.Diem = 0; //customer.Si = false; //customer.Vip = 0; //customer.Avarta = ""; //customer.cPriceNT = 0; //customer.cNongthon = 0; data.sp_Customer_Insert(Name, Email, Email, Phone, Address, DateTime.Now, false, Address, 0, 0, false, 0, "", 0, 0, true); //data.Entry(mem).State = EntityState.Modified; data.SaveChanges(); #endregion mem = data.Customers.Where(m => m.Email == email).FirstOrDefault(); if (mem != null) { provid = 0; tongdiem = float.Parse(mem.Diem.ToString()); var cart = (ShoppingCartViewModel)Session["ShoppingCart"]; ShoppingCartViewModel shoppCart = (ShoppingCartViewModel)Session["ShoppingCart"]; #region [Lưu dữ liệu vào bảng đơn hàng] onsoft.Models.Ord ord = new onsoft.Models.Ord(); ord.IdCus = mem.Id; ord.Amount = shoppCart.CartTotal; ord.SDate = DateTime.Now; ord.TypePay = sTypePay; ord.Status = "1"; ord.PriceVC = 0; ord.Name = Name; ord.Address = Address; ord.Tel = Phone; ord.ProviceId = provid; ord.Nongthon = 0; data.Ords.Add(ord); diem = shoppCart.CartTotal / 1000; tongdiem = tongdiem + diem; mem.Diem = tongdiem; data.Entry(mem).State = EntityState.Modified; data.SaveChanges(); #endregion #region [Lưu vào bảng chi tiết đơn hàng] var listbillcus = data.Ords.OrderByDescending(m => m.Id).FirstOrDefault(); foreach (var item in shoppCart.CartItems) { var pro = data.Products.Where(m => m.Id == item.productId).FirstOrDefault(); OrderDetail billdetail = new OrderDetail(); billdetail.IdOr = listbillcus.Id; billdetail.IdPro = item.productId; billdetail.IdSize = item.idsize; billdetail.IdColor = item.idcolor; billdetail.Number = item.count; w = (w + item.proweight * item.count); //if (mem.Si == true) //{ billdetail.Price = double.Parse(pro.PricePromotion.ToString()); tien = float.Parse(item.count.ToString()) * float.Parse(pro.PricePromotion.ToString()); //} //else //{ // billdetail.Price = double.Parse(pro.PriceRetail.ToString()); // tien = float.Parse(item.count.ToString()) * float.Parse(pro.PriceRetail.ToString()); //} tongtien = tongtien + tien; billdetail.Total = double.Parse(item.total.ToString()); //data.sp_OrderDetail_Insert(); data.OrderDetails.Add(billdetail); pro.Num = pro.Num - int.Parse(item.count.ToString()); data.Entry(pro).State = EntityState.Modified; data.SaveChanges(); } #endregion #region [Update lại tổng tiền, tiền ship] tienship = ship; listbillcus.PriceNT = 0; listbillcus.PriceVC = tienship; listbillcus.Amount = tongtien + tienship; data.Entry(listbillcus).State = EntityState.Modified; data.SaveChanges(); RemoveFromCartAll(); #endregion } #endregion return(RedirectToAction("order_success", "Pages")); } return(View()); } else { return(RedirectToAction("/")); } }