Exemplo n.º 1
0
        public void ExportItem(string url)
        {
            System.Data.DataSet ds = new System.Data.DataSet();
            _OnImportExport(String.Format("Đọc dữ liệu..."), false);
            var listItem = (from a in mKaraokeEntities.MENUNHOMs
                            join b in mKaraokeEntities.MENUMONs on a.NhomID equals b.NhomID
                            join c in mKaraokeEntities.MENUKICHTHUOCMONs on b.MonID equals c.MonID
                            where a.Deleted == false && b.Deleted == false && c.Deleted == false
                            select new ImportExportItem
            {
                TenNhom = a.TenNgan,
                TenMon = b.TenNgan,
                DonGia = c.GiaBanMacDinh,
                ChiTietMon = c.TenLoaiBan,
                SoLuongBanMacDinh = c.SoLuongBanBan
            }).ToList();

            _OnImportExport(String.Format("Khởi tạo dữ liệu..."), false);
            System.Data.DataTable tbl = CreateExcelFile.ListToDataTable(listItem);
            tbl.TableName = MON;
            ds.Tables.Add(tbl);
            _OnImportExport("Lưu tập tin..." + url, false);
            CreateExcelFile.CreateExcelDocument(ds, url);
            _OnImportExport("Lưu tập tin thành công..." + url, false);
        }
Exemplo n.º 2
0
        public static System.Data.DataTable GetTableData(List <TEntity> list, string tableName)
        {
            var tbl = CreateExcelFile.ListToDataTable(list);

            tbl.TableName = tableName;
            return(tbl);
        }
Exemplo n.º 3
0
 public static void Coppy(TEntity source, TEntity desc)
 {
     foreach (var item in typeof(TEntity).GetProperties())
     {
         if (CreateExcelFile.CheckType(item.PropertyType) && item.CanWrite && item.CanRead)
         {
             item.SetValue(desc, item.GetValue(source, null), null);
         }
     }
 }
Exemplo n.º 4
0
 public static void GetValue(TEntity data, IList <string> rowData, IList <string> columnNames)
 {
     foreach (var item in typeof(TEntity).GetProperties())
     {
         if (CreateExcelFile.CheckType(item.PropertyType))
         {
             item.SetValue(data, ConvertType(item.PropertyType, rowData[columnNames.IndexOf(item.Name.ToLower())]), null);
         }
         //MaMayIn = Convert.ToInt32(),
     }
 }
Exemplo n.º 5
0
        public void Export(string url)
        {
            try
            {
                System.Data.DataSet ds = new System.Data.DataSet();
                _OnImportExport(String.Format("Đọc {0}...", LOAINHOM), false);
                ds.Tables.Add(ObjectConvert <Data.MENULOAINHOM> .GetTableData(mKaraokeEntities.MENULOAINHOMs.ToList(), LOAINHOM));

                _OnImportExport(String.Format("Đọc {0}...", MAYIN), false);
                ds.Tables.Add(ObjectConvert <Data.MAYIN> .GetTableData(mKaraokeEntities.MAYINs.Where(o => o.Deleted == false).ToList(), MAYIN));

                _OnImportExport(String.Format("Đọc {0}...", LOAIGIA), false);
                ds.Tables.Add(ObjectConvert <Data.MENULOAIGIA> .GetTableData(mKaraokeEntities.MENULOAIGIAs.Where(o => o.Deleted == false).ToList(), LOAIGIA));

                _OnImportExport(String.Format("Đọc {0}...", DONVI), false);
                ds.Tables.Add(ObjectConvert <Data.DONVI> .GetTableData(mKaraokeEntities.DONVIs.Where(o => o.Deleted == false).ToList(), DONVI));

                _OnImportExport(String.Format("Đọc {0}...", LOAIDONVIBAN), false);
                ds.Tables.Add(ObjectConvert <Data.LOAIBAN> .GetTableData(mKaraokeEntities.LOAIBANs.Where(o => o.Deleted == false).ToList(), LOAIDONVIBAN));

                _OnImportExport(String.Format("Đọc {0}...", NHOM), false);
                ds.Tables.Add(ObjectConvert <Data.MENUNHOM> .GetTableData(mKaraokeEntities.MENUNHOMs.Where(o => o.Deleted == false).ToList(), NHOM));

                _OnImportExport(String.Format("Đọc {0}...", MON), false);
                ds.Tables.Add(ObjectConvert <Data.MENUMON> .GetTableData(mKaraokeEntities.MENUMONs.Where(o => o.Deleted == false).ToList(), MON));

                _OnImportExport(String.Format("Đọc {0}...", CHITIETMON), false);
                ds.Tables.Add(ObjectConvert <Data.MENUKICHTHUOCMON> .GetTableData(mKaraokeEntities.MENUKICHTHUOCMONs.Where(o => o.Deleted == false).ToList(), CHITIETMON));

                _OnImportExport(String.Format("Đọc {0}...", CHITIETGIA), false);
                ds.Tables.Add(ObjectConvert <Data.MENUGIA> .GetTableData(mKaraokeEntities.MENUGIAs.ToList(), CHITIETGIA));

                _OnImportExport(String.Format("Đọc {0}...", MONMAYIN), false);
                ds.Tables.Add(ObjectConvert <Data.MENUITEMMAYIN> .GetTableData(mKaraokeEntities.MENUITEMMAYINs.Where(o => o.Deleted == false).ToList(), MONMAYIN));

                _OnImportExport("Lưu tập tin..." + url, false);
                CreateExcelFile.CreateExcelDocument(ds, url);

                _OnImportExport("Xuất dữ liệu thành công...", false);
            }
            catch (Exception ex)
            {
                _OnImportExport("Lỗi..." + ex.Message, true);
            }
        }