public async Task <ActionResult <ThanhPho> > PostThanhPho(ThanhPho thanhPho) { _context.thanhPhos.Add(thanhPho); await _context.SaveChangesAsync(); return(CreatedAtAction("GetThanhPho", new { id = thanhPho.MaTp }, thanhPho)); }
public async Task <IActionResult> PutThanhPho(int id, ThanhPho thanhPho) { if (id != thanhPho.MaTp) { return(BadRequest()); } _context.Entry(thanhPho).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThanhPhoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult ImportExcel(ImportExcel importExcel) { if (ModelState.IsValid) { string path = Server.MapPath("~/Content/Upload/" + importExcel.file.FileName); importExcel.file.SaveAs(path); using (var stream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read)) { using (var reader = ExcelReaderFactory.CreateReader(stream)) { var result = reader.AsDataSet(); DataTable dt = result.Tables[0]; List <string> lstTinhThanh = new List <string>(); foreach (DataRow row in dt.Rows) { string CityName = row[0].ToString(); ThanhPho city = new ThanhPho(); city.TenThanhPho = CityName; city.ID = StringConverter.toUnsignedString(CityName); InsertCity(city); } } } } return(RedirectToAction("Index")); }
public List <ThanhPho> xoaThanhPho(int tp) { ThanhPho tp_db = ctx.ThanhPhos.Where(x => x.MaThanhPho == tp).SingleOrDefault(); ctx.ThanhPhos.Remove(tp_db); ctx.SaveChanges(); return(ctx.ThanhPhos.ToList()); }
public ActionResult DeleteConfirmed(string id) { ThanhPho thanhPho = db.ThanhPhoes.Find(id); db.ThanhPhoes.Remove(thanhPho); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "ID,TenThanhPho")] ThanhPho thanhPho) { if (ModelState.IsValid) { db.Entry(thanhPho).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(thanhPho)); }
public ThanhPho suaThanhPho(ThanhPho tp) { ThanhPho tp_db = ctx.ThanhPhos.Where(x => x.MaThanhPho == tp.MaThanhPho).SingleOrDefault(); //MaPhanHoi, NoiDungPhanHoi, TinhTrang, NgayPhanHoi, TieuDe, Email, HoTen tp_db.TenThanhPho = tp.TenThanhPho; ctx.SaveChanges(); return(tp); }
public bool AddCity(string cityID, string cityName, ref string err) { QLBHDataContext qLBH = new QLBHDataContext(); ThanhPho city = new ThanhPho(); city.ThanhPho1 = cityID.Trim(); city.TenThanhPho = cityName.Trim(); qLBH.ThanhPhos.InsertOnSubmit(city); qLBH.ThanhPhos.Context.SubmitChanges(); return(true); }
public ActionResult Create([Bind(Include = "Ten,ID,MoTa")] ThanhPho thanhpho) { if (ModelState.IsValid) { db.ThanhPhoes.Add(thanhpho); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(thanhpho)); }
public bool AddCity(string cityID, string cityName, ref string err) { QuanLyBanHangEntities qLBH = new QuanLyBanHangEntities(); ThanhPho city = new ThanhPho(); city.ThanhPho1 = cityID.Trim(); city.TenThanhPho = cityName.Trim(); qLBH.ThanhPhoes.Add(city); qLBH.SaveChanges(); return(true); }
public bool ThemThanhPho(string MaThanhPho, string TenThanhPho, ref string err) { QLKHDataContext qlKH = new QLKHDataContext(); ThanhPho tp = new ThanhPho(); tp.ThanhPho1 = MaThanhPho; tp.TenThanhPho = TenThanhPho; qlKH.ThanhPhos.InsertOnSubmit(tp); qlKH.ThanhPhos.Context.SubmitChanges(); return(true); }
public ActionResult Create([Bind(Exclude = "ID")] ThanhPho thanhPho) { thanhPho.ID = StringConverter.toUnsignedString(thanhPho.TenThanhPho); if (ModelState.IsValid) { db.ThanhPhoes.Add(thanhPho); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(thanhPho)); }
public bool RemoveCity(string cityID, ref string err) { QuanLyBanHangEntities qLBH = new QuanLyBanHangEntities(); ThanhPho tp = new ThanhPho(); tp.ThanhPho1 = cityID; qLBH.ThanhPhoes.Attach(tp); qLBH.ThanhPhoes.Remove(tp); qLBH.SaveChanges(); return(true); }
private void InitThanhPho() { ThanhPho firstItem = new ThanhPho { idThanhPho = 0, maTP = "All", tenTP = "Tất Cả", ThongTinNhanVIens = null }; List <ThanhPho> listThanhPho = new List <ThanhPho>(); listThanhPho.Add(firstItem); listThanhPho.AddRange(thanhPhoServices.GetAllThanhPho()); comboNoiO.DataSource = listThanhPho; comboNoiO.DisplayMember = "tenTP"; comboNoiO.ValueMember = "idThanhPho"; }
// GET: Admin/City/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ThanhPho thanhPho = db.ThanhPhoes.Find(id); if (thanhPho == null) { return(HttpNotFound()); } return(View(thanhPho)); }
public bool SuaThanhPho(ThanhPho thanhPho) { try { var kq = db.ThanhPhoes.Find(thanhPho.ID_ThanhPho); kq.TenThanhPho = thanhPho.TenThanhPho; kq.ID_Vung = thanhPho.ID_Vung; db.SaveChanges(); return(true); } catch (Exception) { return(false); } }
public static ThanhPho GetInfo(string MaThanhPho) { DataTable dt = ShipBookingData.FillDataTable("spThanhPho_SelectByID", "@MaThanhPho", MaThanhPho); ThanhPho TP = new ThanhPho(); if (dt.Rows.Count > 0) { TP.MaThanhPho = dt.Rows[0]["MaThanhPho"].ToString(); TP.Ten = dt.Rows[0]["Ten"].ToString(); } else { TP = null; } return TP; }
public static double TimDuongDiNganNhatNN() { double DuongDiNN = 0; HanhTrinhNN = new List <ThanhPho>(); HanhTrinhTinhBangNN = new List <ThanhPho>(); HanhTrinhNN.Add(BanDo.DanhSachThanhPho[0]); ThanhPho GanNhat = BanDo.DanhSachThanhPho[1]; ThanhPho TPHienTai = BanDo.DanhSachThanhPho[0]; double KC = 0; double KCNganNhat = KCSieuLon;//TPHienTai.KhoangCach(GanNhat); for (int i = 1; i < BanDo.SoThanhPho; i++) { KCNganNhat = KCSieuLon; for (int j = 0; j < BanDo.SoThanhPho; j++) { if (i != j && !HanhTrinhNN.Contains(BanDo.DanhSachThanhPho[j])) { KC = BanDo.DanhSachThanhPho[j].KhoangCach(TPHienTai); if (KC < KCNganNhat) { KCNganNhat = KC; GanNhat = BanDo.DanhSachThanhPho[j]; } } } TPHienTai = GanNhat; HanhTrinhNN.Add(TPHienTai); DuongDiNN += KCNganNhat; } DuongDiNN += TPHienTai.KhoangCach(BanDo.DanhSachThanhPho[0]); TPHienTai = BanDo.DanhSachThanhPho[0]; HanhTrinhNN.Add(TPHienTai); Snn = DuongDiNN; HanhTrinhTinhBangNN = HanhTrinhNN; return(DuongDiNN); }
public ThanhPho themThanhPho(ThanhPho tp) { ctx.ThanhPhos.Add(tp); ctx.SaveChanges(); return(tp); }
public Messenger SendMailImg(KhachHang kh, DonBan dh) { var listShopCart = Session["ShopCart"] as List <ShopCart>; List <ShopCart> listShop = GetListCart(); try { MailMessage message = new MailMessage(new MailAddress("*****@*****.**", "RuouPlaza.com"), new MailAddress(kh.Gmail)); message.Subject = "Thông tin đơn hàng từ RuouPlaza.com"; message.IsBodyHtml = true; #region Gửi mail int i = 1; CultureInfo cul = CultureInfo.GetCultureInfo("vi-VN"); double TT = Convert.ToDouble(listShopCart.Sum(n => n.ThanhTien)) + dh.PhiShip; string PhiShip = dh.PhiShip.ToString("#,###", cul.NumberFormat); string TongTien = TT.ToString("#,###", cul.NumberFormat); //TongTien = TongTien.Replace(".", ","); ThanhPho TP = db.ThanhPhos.Find(kh.MaThanhPho); Huyen huyen = db.Huyens.Find(kh.MaHuyen); var inlineLogo = new LinkedResource(Server.MapPath("~/Img/1469936020.png"), "image/png"); var Body = ""; Body += " <html>"; Body += "<body>"; Body += "<p style='font-weight:bold'>Họ và tên:" + "<span style='font-weight:lighter;'>" + " " + kh.TenKH + "</span>" + "</p>"; Body += "<p style='font-weight:bold'>Địa chỉ:" + "<span style='font-weight:lighter;'>" + " " + kh.DiaChi + " - " + huyen.TenHuyen + " - " + TP.TenThanhPho + "</span>" + "</p>"; Body += "<p style='font-weight:bold'>Số điện thoại:" + "<span style='font-weight:lighter;'>" + " " + 0 + "" + kh.SDT + "</span>" + "</p>"; Body += "<table border='1' width='1000' class='table table-striped table-bordered table-hover'>"; Body += "<tr style='text-align:center' class='success'>"; Body += "<td colspan='6'><h3>Đơn hàng của bạn từ Rượu plaza</h3> </td>"; Body += "</tr>"; Body += "<tr style='text-align:center'>"; Body += "<td>STT</td> <td>Hình ảnh</td> <td> Tên sản phẩm </td><td> Số lượng </td><td> Đơn giá </td> <td> Thành tiền</td>"; Body += "<tr >"; foreach (var item in listShop) { inlineLogo = new LinkedResource(Server.MapPath("~/Img/" + item.iHinhAnh), "image/png"); inlineLogo.ContentId = Guid.NewGuid().ToString(); inlineLogo.ContentType.MediaType = "image/png"; string body1 = string.Format(@"<img src='cid:{0}' width='50'/>", inlineLogo.ContentId); string GiaBan = item.iGiaBan.ToString("#,###", cul.NumberFormat); string Monney = (item.iSoLuongBan * item.iGiaBan).ToString("#,###", cul.NumberFormat); Body += "<tr >"; Body += "<td style='text-align:center;'> " + (i++) + "</td>" + "<td style='text-align:center;'> " + body1 + "</td>" + "<td style='text-align:left;'> " + "<p style='margin-left:20px;'>" + item.iTenSP + "</p>" + "</td>" + "<td style='text-align:center;color:red'> " + item.iSoLuongBan + "</td>" + "<td style='text-align:center;color:red'> " + GiaBan + "</td>" + "<td style='text-align:center;color:red'> " + Monney + "</td>"; Body += "<tr >"; } Body += "</table>"; Body += "<p style='font-weight:bold'>Phí ship:" + "<span style='font-weight:lighter;color:red'>" + " " + PhiShip + " " + "₫" + "</span>" + "</p>"; Body += "<p style='font-weight:bold'>Tổng tiền:" + "<span style='font-weight:lighter;color:red'>" + " " + TongTien + " " + "₫" + "</span>" + "</p>"; Body += "<p>Đơn hàng của bạn đã được xử lý.Trong vòng 1 tuần đơn hàng sẽ đến địa chỉ của bạn mong bạn hãy kiểm tra sản phẩm trước khi thanh toán.Cảm ơn bạn rất nhiều chúc bạn có một ngày mới vui vẻ <3 !!!</p>"; Body += "</body>"; Body += "</html>"; #endregion var view = AlternateView.CreateAlternateViewFromString(Body, null, "text/html"); view.LinkedResources.Add(inlineLogo); message.AlternateViews.Add(view); SmtpClient smtp = new SmtpClient(); smtp.UseDefaultCredentials = false; smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address smtp.Credentials = new NetworkCredential("*****@*****.**", "tranlam123"); //client.UseDefaultCredentials = true; smtp.DeliveryMethod = SmtpDeliveryMethod.Network; smtp.EnableSsl = true; smtp.Port = 587; smtp.Send(message); messenger.Message = "Gửi mail thành công"; messenger.IsSuccess = false; return(messenger); } catch (Exception e) { messenger.Message = "Gửi mail thất bại"; messenger.IsSuccess = false; return(messenger); } }
public ActionResult ConvertListDH(int[] data, int TrangThai, bool TrangThaiThanhToan) { bool Check = Permission("DonHang", "Submit"); if (Check == true) { for (int i = 0; i < data.Length; i++) { int MaDB = data[i]; DonBan dh = db.DonBans.Find(MaDB); int MaKH = dh.MaKH; dh.TrangThai = TrangThai; dh.TrangThaiThanhToan = TrangThaiThanhToan; db.Entry(dh).State = EntityState.Modified; var ListCTDH = db.ChiTietDonBans.Where(s => s.MaDB == MaDB).ToList(); if (ListCTDH != null) { foreach (var item in ListCTDH) { ChiTietDonBan CTDB = db.ChiTietDonBans.Find(item.MaCTDB); CTDB.TrangThai = TrangThai; CTDB.TrangThaiThanhToan = TrangThaiThanhToan; db.Entry(CTDB).State = EntityState.Modified; } } if (TrangThai == 1) { #region Gửi mail int j = 1; CultureInfo cul = CultureInfo.GetCultureInfo("vi-VN"); string TongTien = dh.TongTien.Value.ToString("#,###", cul.NumberFormat); string PhiShip = dh.PhiShip.ToString("#,###", cul.NumberFormat); KhachHang kh = db.KhachHangs.Find(MaKH); ThanhPho TP = db.ThanhPhos.Find(kh.MaThanhPho); Huyen huyen = db.Huyens.Find(kh.MaHuyen); var ListCTDB1 = db.ChiTietDonBans.Include(s => s.SANPHAM).Where(s => s.MaDB == MaDB).ToList(); var Body = ""; Body += " <html>"; Body += "<body>"; Body += "<p style='font-weight:bold'>Họ và tên:" + "<span style='font-weight:lighter;'>" + " " + kh.TenKH + "</span>" + "</p>"; Body += "<p style='font-weight:bold'>Địa chỉ:" + "<span style='font-weight:lighter;'>" + " " + kh.DiaChi + " - " + huyen.TenHuyen + " - " + TP.TenThanhPho + "</span>" + "</p>"; Body += "<p style='font-weight:bold'>Số điện thoại:" + "<span style='font-weight:lighter;'>" + " " + 0 + "" + kh.SDT + "</span>" + "</p>"; Body += "<table border='1' width='1000' class='table table-striped table-bordered table-hover'>"; Body += "<tr style='text-align:center' class='success'>"; Body += "<td colspan='5'><h3>Đơn hàng của bạn từ Rượu plaza</h3> </td>"; Body += "</tr>"; Body += "<tr style='text-align:center'>"; Body += "<td>STT</td> <td> Tên sản phẩm </td><td> Số lượng </td><td> Đơn giá </td> <td> Thành tiền</td>"; Body += "<tr >"; foreach (var item in ListCTDB1) { string GiaBan = item.SANPHAM.GiaBan.Value.ToString("#,###", cul.NumberFormat); string Monney = (item.SoLuong.Value * item.SANPHAM.GiaBan.Value).ToString("#,###", cul.NumberFormat); Body += "<tr >"; Body += "<td style='text-align:center;'> " + (j++) + "</td>" + "<td style='text-align:left;'> " + "<p style='margin-left:20px;font-weight:bold'>" + item.SANPHAM.TenSP + "</p>" + "</td>" + "<td style='text-align:center;color:red'> " + item.SoLuong + "</td>" + "<td style='text-align:center;color:red'> " + GiaBan + "</td>" + "<td style='text-align:center;color:red'> " + Monney + "</td>"; Body += "<tr >"; } Body += "</table>"; Body += "<p style='font-weight:bold'>Phí ship:" + "<span style='font-weight:lighter;color:red'>" + " " + PhiShip + " " + "₫" + "</span>" + "</p>"; Body += "<p style='font-weight:bold'>Tổng tiền:" + "<span style='font-weight:lighter;color:red'>" + " " + TongTien + " " + "₫" + "</span>" + "</p>"; Body += "<p>Đơn hàng của bạn đã được xử lý.Trong vòng 1 tuần đơn hàng sẽ đến địa chỉ của bạn mong bạn hãy kiểm tra sản phẩm trước khi thanh toán.Cảm ơn bạn rất nhiều chúc bạn có một ngày mới vui vẻ <3 !!!</p>"; Body += "</body>"; Body += "</html>"; #endregion var Mail = SendMail(Body, kh.Gmail); } } db.SaveChanges(); messenger.IsSuccess = true; messenger.Message = "Cập nhập thành công!!!"; return(Content(JsonConvert.SerializeObject(new { messenger, }))); } else { messenger.IsSuccess = false; messenger.RedirectToAction = true; messenger.Message = "Thêm sản phẩm thất bại!!!"; return(Content(JsonConvert.SerializeObject(new { messenger, }))); } }
public IActionResult themThanhPho(ThanhPho tp) { _thanhphoRepository.themThanhPho(tp); return(RedirectToAction("ThanhPhoInformation")); }
public static void Update(ThanhPho TP) { string[] parameters = new string[] { "@MaThanhPho", "@Ten" }; string[] values = new string[] { TP.MaThanhPho, TP.Ten }; ExecuteData("spThanhPho_UpdateByID", parameters, values); }
public bool InsertCity(ThanhPho city) { db.ThanhPhoes.Add(city); db.SaveChanges(); return(true); }
public List <TabOject> Encode(string Ma) { List <TabOject> result = new List <TabOject>(); if (Ma == null || Ma == "") { return(result); } List <string> list = Ma.Split(',').ToList(); foreach (string s in list) { TabOject tag = new TabOject(); Char key = s[0]; string ID = ""; for (int i = 1; i < s.Length; i++) { ID += s[i]; } switch (key) { //Ngành case 'N': Nganh nganh = db.Nganhs.SingleOrDefault(t => t.MaNganh == ID); if (nganh != null) { tag.ID = nganh.MaNganh; tag.Ten = nganh.Ten; tag.Loai = "N"; } break; // Trường case 'T': Truong truong = db.Truongs.SingleOrDefault(t => t.MaTruong == ID); if (truong != null) { tag.ID = truong.MaTruong; tag.Loai = "T"; tag.Ten = truong.Ten; } break; //Thành phố case 'P': int id = Int16.Parse(ID); ThanhPho tinh = db.ThanhPhoes.SingleOrDefault(t => t.ID == id); if (tinh != null) { tag.ID = ID; tag.Loai = "P"; tag.Ten = tinh.Ten; } break; } if (tag.ID != "") { result.Add(tag); } } return(result); }
public bool LuuTP(ThanhPho thanhPho) { db.ThanhPhoes.Add(thanhPho); db.SaveChanges(); return(true); }