public JsonResult DetailProduct(long id) { using (HutechMartDbContext db = new HutechMartDbContext()) { var info = from a in db.tbl_SanPham join b in db.tbl_XuatXu on a.id_xuatxu equals b.id into XuatXu join c in db.tbl_PhanLoai_SanPham on a.id_phanloai equals c.id into PhanLoai join d in db.tbl_DonViTinh on a.id_donvitinh equals d.id into DonVi from e in XuatXu.DefaultIfEmpty() from f in PhanLoai.DefaultIfEmpty() from g in DonVi.DefaultIfEmpty() where a.id == id select new { MaSP = a.masanpham, TenSP = a.tensanpham, HinhAnh = a.hinhanh, SL = a.soluong, GiaBan = a.giaban, GiaNhap = a.gianhap, NgayTao = a.ngaytao, GhiChu = a.ghichu, XuatXu = e.xuatxu, PhanLoai = f.tenphanloai, DonViTinh = g.donvi, }; return(Json(info.ToList(), JsonRequestBehavior.AllowGet)); } }
public List <PhanLoai> SearchPhanLoai(string mapl) { DataProvider dataP = new DataProvider(); List <PhanLoai> list = new List <PhanLoai>(); string query = "Select * From PhanLoai where MaLoai like '" + mapl + "%'"; DataTable data = dataP.ExecuteQuery(query); foreach (DataRow item in data.Rows) { PhanLoai pl = new PhanLoai(item); list.Add(pl); } return(list); }
public List <PhanLoai> GetListPhanLoai() { DataProvider dataP = new DataProvider(); List <PhanLoai> list = new List <PhanLoai>(); string query = "Select * From PhanLoai"; DataTable data = dataP.ExecuteQuery(query); foreach (DataRow item in data.Rows) { PhanLoai pl = new PhanLoai(item); list.Add(pl); } return(list); }
public PhanLoai GetListPhanLoaiByMaSach(string maSach) { DataProvider dataP = new DataProvider(); PhanLoai pl = null; string query = "Select p.MaLoai,TenLoai from PhanLoai p ,Sach s where p.MaLoai=s.MaLoai and MaSach='" + maSach + "'"; DataTable data = dataP.ExecuteQuery(query); foreach (DataRow item in data.Rows) { pl = new PhanLoai(item); return(pl); } return(pl); }
public static void LoadMon(PhanLoai phanLoai, LoadResult resultHandler) { try { new Task(() => { DAL_MonAn.StartService(); List <DTO_MonAn> monAns = DAL_MonAn.Instance.GetAllRecords(phanLoai); resultHandler(monAns); }).Start(); } catch (Exception e) { Console.WriteLine(e); } }
public QuanLy_MonAn(DTO_MonAn data) : this() { if (data != null) { Data = data; tbxGia.Text = data.Gia.ToString(); tbxTen.Text = data.Tenmon.ToString(); PhanLoai = (PhanLoai)data.Phanloai; SetPic(data.Hinhanh.ToString()); } else { ToggleInfo(); PrepareEditMode(); } }
public List <DTO_MonAn> GetAllRecords(PhanLoai phanLoai) { List <DTO_MonAn> result = new List <DTO_MonAn>(); SqlDataReader reader = null; try { SqlCommand myCmd = Connection.CreateCommand(); myCmd.CommandText = "select * from QLCH.dbo.MONAN Where phanloai = @phanloai"; myCmd.Parameters.AddWithValue("@phanloai", (int)phanLoai); reader = myCmd.ExecuteReader(); while (reader.Read()) { try { DTO_MonAn monan = new DTO_MonAn(); monan.Mamon = (int)reader["mamon"]; monan.Tenmon = reader["tenmon"] as string; monan.Gia = float.Parse(reader["gia"].ToString()); monan.Phanloai = (int)reader["phanloai"]; monan.Hinhanh = reader["hinhanh"] as string; result.Add(monan); } catch (Exception e) { Console.WriteLine(e); } } } catch (Exception e) { Console.WriteLine(e); } finally { if (reader != null && !reader.IsClosed) { reader.Close(); } } return(result); }
private void txtMaSach_TextChanged(object sender, EventArgs e) { try { string MaSach = dgvBook.SelectedCells[0].OwningRow.Cells["MaSach"].Value.ToString(); PhanLoaiDAO phanloai = new PhanLoaiDAO(); PhanLoai pl = phanloai.GetListPhanLoaiByMaSach(txtMaSach.Text); int index = -1; int i = 0; foreach (PhanLoai item in cbTheLoai.Items) { if (item.MaLoai == pl.MaLoai) { index = i; break; } i++; } cbTheLoai.SelectedIndex = index; NgonNguDAO nn = new NgonNguDAO(); NgonNgu ngonNgu = nn.GetListNgonNguByMaSach(txtMaSach.Text); int index1 = -1; int j = 0; foreach (NgonNgu item in cbNgonNgu.Items) { if (item.MaNgonNgu == ngonNgu.MaNgonNgu) { index1 = j; break; } j++; } cbNgonNgu.SelectedIndex = index1; } catch { } }