public JsonResult XoaSanPhamDaMua(string id) { /* * 1 Hệ Thống Bị Lỗi * 2 dang van chuyen khong the huy * 3 thanh cong */ string Trave = ""; try { var madamua = Convert.ToInt32(id); if (db.daMuas.Where(n => n.idDM == madamua).FirstOrDefault().dangVanChuyen == true) { Trave = "2"; } else { var gf = db.daMuas.Where(n => n.idDM == madamua).FirstOrDefault(); gf.daxoa = true; db.SaveChanges(); Trave = "3"; } } catch (Exception) { Trave = "1"; } return(Json(Trave)); }
public JsonResult addProduct(string idGioHang, string soluong) { /* * 1 loi he thong * 2 gio hang tim ko thay na pham cos tai khoan va ma hang nhu tren * 3 tai khoan chua dang nhap * 4 la thanh cong chuyen den trang da mua */ string trave = ""; if (save.taikhoan == "" || save.taikhoan == null) { trave = "3"; } else { try { int concac = Convert.ToInt32(idGioHang); var bcg = db.dangMuas.Where(n => n.taikhoan == save.taikhoan && n.idDM == concac); if (bcg.Count() == 0) { trave = "2"; } else { daMua dam = new daMua(); dam.soluong = Convert.ToInt32(soluong); dam.gia = bcg.FirstOrDefault().gia; dam.sophantram = bcg.FirstOrDefault().sophantram; dam.dangChuanBi = true; dam.ngaymua = DateTime.Now; dam.ngayLapDat = DateTime.Now.Add(new TimeSpan(1, 0, 0, 0)); dam.dangVanChuyen = false; dam.daxoa = false; dam.idSP = bcg.FirstOrDefault().idSP; dam.taikhoan = save.taikhoan; db.daMuas.Add(dam); db.SaveChanges(); bcg.FirstOrDefault().daxoa = true; db.SaveChanges(); trave = "4"; } } catch (Exception) { trave = "1"; } } return(Json(trave)); }
public JsonResult laymk(string taikhoan, string gmail) { string trave = ""; if (taikhoan == null || taikhoan == "" || gmail == null || gmail == "") { trave = "3"; } else { try { Ran a = new Ran(); int songaunhien = a.songaunhien(); guiMail g = new guiMail(); var taiKhoanLayDuoc = db.accs.Where(n => n.taikhoan == taikhoan.Trim() && n.email == gmail.Trim()); if (taiKhoanLayDuoc.Count() == 1) { if (g.ToguiMail(gmail, Convert.ToString(songaunhien).Trim()) == true) { taiKhoanLayDuoc.FirstOrDefault().matkhau = MD5.ToMD5(Convert.ToString(songaunhien).Trim()); db.SaveChanges(); trave = "1"; } else { //gui mail den tai khoan cua ban trave = "2"; } } else { trave = "0"; } } catch (Exception) { trave = "2"; } } return(Json(trave)); }
public JsonResult themtaikhoan(string a, string b, string c, string d, string e, string g) { string avg = ""; if (KyTu.kiemtra(a) == true || KyTu.kiemtra(b) == true || KyTu.kiemtra(c) == true || KyTu.kiemtra(d) == true || KyTu.kiemtra(e) == true) { avg = "Không được nhập Ký tự đặc biệt chỉ có thể nhập a-z 0-9"; } else { //tim so dien thoai try { if (db.infoes.Where(n => n.number_phone == a).Count() != 0) { avg = "Số điện thoại đã được sử dụng"; } else { if (db.accs.Where(n => n.taikhoan == a).Count() != 0) { avg = "sdt đã có tài khoản đăng ký"; } else { try { acc ac = new acc(); ac.taikhoan = a; ac.matkhau = MD5.ToMD5(b.Trim()); ac.daxoa = false; ac.email = g; ac.chucvu = 3; ac.taikhoanquanly = "ADminVip"; info inf = new info(); inf.nameFull = d; inf.age = Convert.ToInt32(e.Trim()); inf.adress = c; inf.number_phone = a; inf.taikhoan = a; db.accs.Add(ac); db.infoes.Add(inf); db.SaveChanges(); avg = "Cảm Ơn Bạn Đã sử dụng dịch vụ của chúng tôi"; } catch (Exception) { avg = "đã có lỗi sảy ra "; } } } } catch { avg = "404"; } } return(Json(avg)); }
//ket thuc sua san pham/////////////////////////////////////////////////////////////////////////////////// //them san pham vao ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public JsonResult Add_product(string name_product, string length_product, string with_product, string height_product, string title_product, string number_product, string core_product, string producttion_product, string speed_product, string technology_product, string pump_product, string price_product, string brand_product, string quality_product, string where_production, string free_product, string number_free_product, string Imgchinh, string Img1, string Img2, string Img3, string Img4) { string trave = ""; //tim kiem nha cung cap theo tai khoan hien co /* * 1 là tài khoản hiện tại rỗng * 2 là nha cung cấp chưa đăng ký * 3 là đã gặp vấn đề về dữ liệu * 4 laf hoàn thành */ if (save.taikhoan == null || save.taikhoan == "") { trave = "1"; } else { var manhacungcap = db.NhaCungCaps.Where(n => n.taikhoan == save.taikhoan).FirstOrDefault().idIfncc; if (manhacungcap == null) { trave = "2"; } else { try { sanpham sp = new sanpham(); sp.tensp = name_product; sp.dai = Convert.ToInt32(length_product); sp.rong = Convert.ToInt32(with_product); sp.cao = Convert.ToInt32(height_product); sp.tieude = title_product; sp.soluong = Convert.ToInt32(number_product); sp.soLoiLoc = Convert.ToInt32(core_product); sp.congxuat = producttion_product; sp.tocdoloc = speed_product; sp.congnghekhangkhuan = technology_product; sp.congXuatBom = pump_product; sp.gia = Convert.ToInt32(price_product); sp.thuongHieu = brand_product; sp.chatluong = quality_product; sp.noisanxuat = where_production; sp.magiamgia = free_product; sp.sophantram = Convert.ToInt32(number_free_product); sp.anhsanpham1 = Imgchinh; sp.anhsanpham2 = Img1; sp.anhsanpham3 = Img2; sp.anhsanpham4 = Img3; sp.anhsanpham5 = Img4; sp.daxoa = false; sp.hethang = false; sp.idIfncc = manhacungcap; sp.soluongdaban = 0; db.sanphams.Add(sp); db.SaveChanges(); var xyz = db.sanphams.Where(n => n.idIfncc == manhacungcap && n.tensp == name_product && n.anhsanpham2 == Img1 && n.anhsanpham3 == Img2 && n.anhsanpham4 == Img3 && n.anhsanpham5 == Img4 && n.anhsanpham1 == Imgchinh ).FirstOrDefault(); trave = "kd" + xyz.idSP; } catch (Exception) { trave = "3"; } } } return(Json(trave)); }