Esempio n. 1
0
        public int Load(string file)
        {
            int           rows         = 0;
            EProductType  eProductType = null;
            BProductType  bProductType = new BProductType();
            List <string> columns      = new List <string>();
            DataTable     table        = Epplus.ToDataTable(file);

            if (table != null)
            {
                table.Columns["Código"].ColumnName       = "CodeProductType";
                table.Columns["Descripción"].ColumnName  = "Description";
                table.Columns["Código Sunat"].ColumnName = "CodeSunatExistence";
                table.Columns["Estado"].ColumnName       = "State";

                columns = table.GetColumns();

                using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    foreach (DataRow datarow in table.Rows)
                    {
                        eProductType = new EProductType(datarow, columns);
                        eProductType.Audit.UserRegister = "User Load";
                        bProductType.Insert(eProductType);

                        rows++;
                    }
                    ts.Complete();
                }
            }
            return(rows);
        }
Esempio n. 2
0
        public void ToDataTable()
        {
            string    file  = @"D:\Miguel\Escritorio\Apps Load\ProductType.xlsx";
            DataTable table = null;

            table = Epplus.ToDataTable(file);
            if (table != null &&
                table.Columns.Count > 0 &&
                table.Rows.Count > 0)
            {
                Assert.IsTrue(true);
            }
        }