public DataTable ChiTietByMaNX(string manx) { try { using (QLCuaHangDataContext cuahang = new QLCuaHangDataContext()) { DataTable dt = new DataTable(); dt.Columns.Add("STT"); dt.Columns["STT"].DataType = typeof(Int64); dt.Columns.Add("MaHang"); dt.Columns.Add("TenHang"); dt.Columns.Add("SoLuong"); dt.Columns["STT"].DataType = typeof(Int64); dt.Columns.Add("DonGia"); dt.Columns["DonGia"].DataType = typeof(double); dt.Columns.Add("ThanhTien"); dt.Columns["ThanhTien"].DataType = typeof(double); DataRow dr; foreach (var ct in cuahang.SP_XemCTNX(manx)) { dr = dt.NewRow(); dr["STT"] = ct.STT; dr["MaHang"] = ct.MaHang; dr["TenHang"] = ct.TenHang; dr["SoLuong"] = ct.SoLuong; dr["DonGia"] = ct.DonGia; dr["ThanhTien"] = ct.ThanhTien; dt.Rows.Add(dr); } return(dt); } } catch (Exception ex) { myme.ShowError(ex); return(null); } }
public void LoadGridViewCT(DataGridView dgv, string ma) { try { using (QLCuaHangDataContext cuahang = new QLCuaHangDataContext()) { dgv.DataSource = cuahang.SP_XemCTNX(ma).ToList(); } } catch (Exception ex) { myme.ShowError(ex); } }