コード例 #1
0
ファイル: TestImport.cs プロジェクト: amitdumka/eStore
        public DataTable TestImportExcel(eStoreDbContext db, string fileName)
        {
            Console.WriteLine(fileName);
            XSReader xS = new XSReader(fileName);

            var ws = xS.GetWS("Employees");
            var dt = XSReader.ReadSheetToDt(ws, 6);
            int c  = dt.Columns.IndexOf("UserName");

            dt.Columns[c].ColumnName = "UserId";
            dt.Columns.Add("EntryStatus");
            dt.Columns.Add("IsReadOnly");
            int c1 = 101;

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["EntryStatus"] = EntryStatus.Added;
                dt.Rows[i]["IsReadOnly"]  = true;
                dt.Rows[i][0]             = ((i + 1 * 201) * c1 / 3) * i;
                c1 = c1 + new Random(c1).Next();
            }
            dt.AcceptChanges();
            //JsonConvert.SerializeObject(dt);
            //
            var lst = CommonMethod.ConvertToList <Employee>(dt);

            //var lst = DAL.CreateListFromTable<Employee>(dt);
            db.Employees.AddRange(lst);
            Console.WriteLine(JsonConvert.SerializeObject(dt));
            Console.WriteLine("Save: " + db.SaveChanges());
            return(dt);
        }
コード例 #2
0
        public async Task ReadDueAsync(XSReader ixs)
        {
            xS = ixs;

            if (xS.WorkBookName == "Daily Sales")
            {
                await AddEDCTranscationAsync();
                await AddDueRecoveredListAsync(await SaleDetailsAsync());
            }
            else
            {
                throw new Exception();
            }
        }
コード例 #3
0
        public async System.Threading.Tasks.Task <bool> ImportDataAsync(string fileName)
        {
            XSReader xS = new XSReader(fileName);

            switch (xS.WorkBookName)
            {
            case "PayRoll":
                xS = null;
                ImportPayroll ip = new ImportPayroll(Db, _userManager);
                await ip.ReadPayRollAsync(fileName);

                break;

            case "Stores":
                StoreInfoImport sii = new StoreInfoImport(Db);
                await sii.ReadAsync(xS);

                break;

            case "Expenses":
                ImportExpenses ie = new ImportExpenses(Db);
                await ie.ReadAsync(xS);

                break;

            case "Tailoring":
                TailoringImport ti = new TailoringImport(Db);
                await ti.ReadAsync(xS);

                break;

            case "Daily Sales":
                DailySaleImport dsi = new DailySaleImport(Db);
                await dsi.ReadAsync(xS);

                break;

            default:
                break;
            }

            return(true);
        }
コード例 #4
0
        public async System.Threading.Tasks.Task ReadAsync(string fileName)
        {
            xS = new XSReader(fileName);

            if (xS.WorkBookName == "Daily Sales")
            {
                await AddEDCAsync();

                var sm = GetSaleman();
                var ds = await AddDailySalesAsync(sm);

                var dl = await AddDueListsAsync(ds);
                await AddDueRecoveredListAsync(dl);
                await AddEDCTranscationAsync();
            }
            else
            {
                throw new Exception();
            }
        }
コード例 #5
0
ファイル: ImportPayroll.cs プロジェクト: amitdumka/eStore
        public async System.Threading.Tasks.Task ReadPayRollAsync(string fileName)
        {
            xS = new XSReader(fileName);

            if (xS.WorkBookName == "PayRoll")
            {
                db.Attendances.RemoveRange(db.Attendances);
                db.SalaryPayments.RemoveRange(db.SalaryPayments);
                db.Salesmen.RemoveRange(db.Salesmen);
                db.Employees.RemoveRange(db.Employees);

                db.SaveChanges();


                await AddEmployeesAsync(xS.GetWS("Employees"));

                // await AddAllSheetAsync();
                // await AddCurrentSalarAsync(xS.GetWS("CurrentSalaries"));
            }
            else
            {
                throw new Exception();
            }
        }