Exemple #1
0
        public async Task <bool> AddSupplier(Supplier supplier)
        {
            long nextMax    = 0;
            var  connection = dbContext.Database.GetDbConnection();

            if (connection.State == System.Data.ConnectionState.Closed)
            {
                connection.Open();
            }
            var command = connection.CreateCommand();

            command.CommandText = "SELECT nextval('Supplierserial');";
            nextMax             = (long)command.ExecuteScalar();

            supplier.SupplierNumber = $"S{nextMax}";
            await dbContext.Suppliers.AddAsync(supplier);

            var recordsAffected = await dbContext.SaveChangesAsync();

            return((recordsAffected > 0) ? true : false);
        }
Exemple #2
0
        public async Task <bool> AddItem(Item item)
        {
            long nextMax    = 0;
            var  connection = dbContext.Database.GetDbConnection();

            if (connection.State == System.Data.ConnectionState.Closed)
            {
                connection.Open();
            }
            var command = connection.CreateCommand();

            command.CommandText = "SELECT nextval('Itemserial');";
            nextMax             = (long)command.ExecuteScalar();

            item.ItemCode = $"I{nextMax}";
            await dbContext.Items.AddAsync(item);

            var recordsAffected = await dbContext.SaveChangesAsync();

            return((recordsAffected > 0) ? true : false);
        }