Exemplo n.º 1
0
        public override IForm <AddCustomerForm> BuildForm()
        {
            async Task onProcessAddCustomer(IDialogContext context, AddCustomerForm state)
            {
                GenericRepository <Customer> db = new GenericRepository <Customer>(GetDatabase.GetContext());

                Customer customer = new Customer
                {
                    Company   = state.Company,
                    FirstName = state.FirstName,
                    LastName  = state.LastName,
                    Address   = state.Address,
                    Username  = state.Username,
                    Phone     = state.Phone,
                    Status    = state.Status,
                    Email     = state.Email,
                    AddedOn   = DateTime.Now
                };

                db.Add(customer);
                db.SaveChanges();
            }

            return(new FormBuilder <AddCustomerForm>()
                   .Field(nameof(Username))
                   .Field(nameof(Company))
                   .Field(nameof(FirstName))
                   .Field(nameof(LastName))
                   .Field(nameof(Address))
                   .Field(nameof(Phone))
                   .Field(nameof(Email))
                   .Field(nameof(Status))
                   .OnCompletion(onProcessAddCustomer)
                   .Build());
        }
Exemplo n.º 2
0
        void GetCompany(string command = @"SELECT company FROM [StockDatabase].[dbo].[standard_analysis] group by company order by company")
        {
            SQL_Action    sq      = new SQL_Action("server=USER-PC\\SQLEXPRESS;database=ProssibilityDatabase;Integrated Security=SSPI");
            List <string> company = new List <string>();

            GetDatabase.GetData(command, ref _company);
        }
Exemplo n.º 3
0
        private List <Product> GetProducts(Customer customer)
        {
            var products = GetDatabase.GetContext().Customers
                           .Where(c => c.Id == customer.Id)
                           .SelectMany(c => c.SalledProducts)
                           .Select(cp => cp.Product)
                           .ToList();

            return(products);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Begin Transaction
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <IDbContextTransaction> BeginTransactionAsync(CancellationToken cancellationToken = default)
        {
            if (_currentTransaction != null)
            {
                return(null);
            }

            _currentTransaction = await GetDatabase.BeginTransactionAsync(cancellationToken);

            return(_currentTransaction);
        }
Exemplo n.º 5
0
        public override IForm <GetInfoForm> BuildForm()
        {
            async Task onProcessGetInfo(IDialogContext context, GetInfoForm state)
            {
                var customer = GetDatabase.GetContext().Customers.Where(c => c.Username == state.ClientName)
                               .FirstOrDefault();

                StringBuilder sb = new StringBuilder();

                var      id        = customer.Id;
                var      username  = customer.Username;
                var      company   = customer.Company;
                var      firstName = customer.FirstName;
                var      lastName  = customer.LastName;
                var      address   = customer.Address;
                var      phone     = customer.Phone;
                var      email     = customer.Email;
                DateTime addedOn   = customer.AddedOn;
                var      status    = customer.Status;

                sb.AppendLine($"ID: {id};  ");
                sb.AppendLine($"Username: {username};   ");
                sb.AppendLine($"Company: {company};   ");
                sb.AppendLine($"Name: {firstName + " " + lastName};   ");
                sb.AppendLine($"Address: {address};   ");
                sb.AppendLine($"Phone: {phone};  ");
                sb.AppendLine($"Email: {email};  ");
                sb.AppendLine($"Added On: {addedOn};  ");
                sb.AppendLine($"Status: {status};  ");

                var customerProducts = GetDatabase.GetContext().CustomerProducts.ToList();

                var salProd = customerProducts.Where(p => p.CustomerId == customer.Id).ToList();

                var products = GetProducts(customer);

                for (int i = 0; i < products.Count; i++)
                {
                    sb.AppendLine($"Product {i + 1}: {products[i].Name}.    ");
                }


                await context.PostAsync(sb.ToString());
            }

            return(new FormBuilder <GetInfoForm>()
                   .Field(nameof(ClientName))
                   .OnCompletion(onProcessGetInfo)
                   .Build());
        }
Exemplo n.º 6
0
        public override IForm <GetEmailForm> BuildForm()
        {
            async Task onProcessGetEmail(IDialogContext context, GetEmailForm state)
            {
                var customer = GetDatabase.GetContext().Customers.Where(c => c.Username == state.ClientName)
                               .FirstOrDefault();

                var id    = customer.Id;
                var email = customer.Email;
                await context.PostAsync($"Client with ID: {id};" + $" Email: {email}");
            }

            return(new FormBuilder <GetEmailForm>()
                   .Field(nameof(ClientName))
                   .OnCompletion(onProcessGetEmail)
                   .Build());
        }
Exemplo n.º 7
0
        void GetData()
        {
            string command;

            command = @"SELECT [Time],[_" + company + @"]
                        FROM [StockDatabase].[dbo].[technical_analysis]
  
                        where [MyIndex]=209  and [Time] between '" + startDate + "' and '" + endDate + "' order by [Time]";

            GetDatabase.GetData(command, ref ClosePrice);

            command = @"SELECT [Time],[_" + company + @"]
                        FROM [StockDatabase].[dbo].[technical_analysis]
  
                        where [MyIndex]=201  and [Time] between '" + startDate + "' and '" + endDate + "' order by [Time]";
            GetDatabase.GetData(command, ref RewardRatio);

            command = @"SELECT [Time],[_" + company + @"]
                        FROM [StockDatabase].[dbo].[technical_analysis]
  
                        where [MyIndex]=208  and [Time] between '" + startDate + "' and '" + endDate + "' order by [Time]";

            GetDatabase.GetData(command, ref Volumn);
        }
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     cbbDatabase.DataSource = GetDatabase.GetDatabaseList(txtserver.Text, null, txtUsername.Text, txtPassword.Text);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Ensures that the database for the context exists. If it exists, no action is
 /// taken. If it does not exist then the database and all its schema are created.
 /// If the database exists, then no effort is made to ensure it is compatible with
 /// the model for this context.
 /// Note that this API does not use migrations to create the database. In addition,
 /// the database that is created cannot be later updated using migrations. If you
 /// are targeting a relational database and using migrations, you can use the DbContext.Database.Migrate()
 /// method to ensure the database is created and all migrations are applied.
 /// </summary>
 /// <param name="cancellationToken"></param>
 /// <returns></returns>
 public virtual async Task <bool> EnsureCreatedAsync(CancellationToken cancellationToken = default) => await GetDatabase.EnsureCreatedAsync(cancellationToken);