private void btnAdd_Click(object sender, EventArgs e)
        {
            var customerRepository = new SqlCustomerRepository(frmGymManager.connectionString);
            var customer           = new Customer();

            if (dgvAddCustomer.CurrentRow.Cells[0].Value != null && dgvAddCustomer.CurrentRow.Cells[1].Value != null &&
                dgvAddCustomer.CurrentRow.Cells[2].Value != null && dgvAddCustomer.CurrentRow.Cells[3].Value != null)
            {
                customer.Name        = dgvAddCustomer.CurrentRow.Cells[0].Value.ToString();
                customer.Surname     = dgvAddCustomer.CurrentRow.Cells[1].Value.ToString();
                customer.Street      = dgvAddCustomer.CurrentRow.Cells[2].Value.ToString();
                customer.HouseNumber = Convert.ToInt32(dgvAddCustomer.CurrentRow.Cells[3].Value);
                customer.PhoneNumber = dgvAddCustomer.CurrentRow.Cells[4].Value.ToString();
                customer.Email       = dgvAddCustomer.CurrentRow.Cells[5].Value.ToString();
                customer.Validaty    = Convert.ToInt32(dgvAddCustomer.CurrentRow.Cells[7].Value);
                customer.Price       = Convert.ToInt32(dgvAddCustomer.CurrentRow.Cells[8].Value);
                customer.CardType    = dgvAddCustomer.CurrentRow.Cells[6].Value.ToString();
                customer.AdminId     = ActiveAdmin.Id;

                if (customerRepository.AddNewCustomer(customer) > 0)
                {
                    MessageBox.Show("Successfull operation", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Try Again", "Allert", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Enter data!");
            }
        }
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(txtLogin.Text))
            {
                MessageBox.Show("Please input login.");
                return;
            }

            string login = txtLogin.Text;

            if (String.IsNullOrEmpty(pasPassword.Password))
            {
                MessageBox.Show("Please input password.");
                return;
            }

            string password = pasPassword.Password;

            string connectionString = ConfigurationManager.ConnectionStrings["PTS"].ConnectionString;

            SqlCustomerRepository customerRepository = new SqlCustomerRepository(connectionString);

            _customer = customerRepository.LogIn(login, password) ?? _customer;

            if (_customer == null)
            {
                MessageBox.Show("Customer with this login and password doesn't exist.", "Wrong login or password", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                DialogResult = true;
            }
        }
        private void btShowAllCustomers_Click(object sender, EventArgs e)
        {
            var customerRepository = new SqlCustomerRepository(Globals.connectionString);
            var customerList       = customerRepository.SelectAllCustomers();

            dgvCustomers.DataSource = customerList;
        }
    static void Main(string[] args)
    {
        // Dependency injection, usually done via a DI container
        var customerRepository = new SqlCustomerRepository();
        var form = new CustomerForm(customerRepository);

        form.PersistCustomer();
    }
Example #5
0
 public BuyTicketForm(int showtimeId, string filmName)
 {
     _connectionString  = ConfigurationManager.ConnectionStrings["CinemaTicketingSystem_ConnectionString"].ConnectionString;
     _showtimeId        = showtimeId;
     seatRepository     = new SqlSeatRepository(_connectionString);
     customerRepository = new SqlCustomerRepository(_connectionString);
     salesRepository    = new SqlSalesRepository(_connectionString);
     InitializeComponent();
     filmNameLabel.Text = filmName;
 }
Example #6
0
        public Customer GetCustomer(int id)
        {
            Customer cust = null;

            using (var db = new BikesAndBrewsContext())
            {
                ICustomerRepository repo = new SqlCustomerRepository(db);
                cust = repo.GetAsync(id).Result;
            }

            return(cust);
        }
Example #7
0
        public int DeleteCustomer(List <int> idList)
        {
            int result = 0;

            using (var db = new BikesAndBrewsContext())
            {
                ICustomerRepository repo = new SqlCustomerRepository(db);
                result = repo.DeleteRangeAsync(idList).Result;
            }

            return(result);
        }
Example #8
0
        public bool DeleteCustomer(int id)
        {
            bool result = false;

            using (var db = new BikesAndBrewsContext())
            {
                ICustomerRepository repo = new SqlCustomerRepository(db);
                result = repo.DeleteAsync(id).Result;
            }

            return(result);
        }
Example #9
0
        public int AddCustomer(Customer customer)
        {
            int id = 0;

            using (var db = new BikesAndBrewsContext())
            {
                ICustomerRepository repo = new SqlCustomerRepository(db);
                id = repo.InsertAsync(customer).Result.Id;
            }

            return(id);
        }
 private void btAdd_Click(object sender, EventArgs e)
 {
     //checks inputs for length and isempty
     if (tbName.Text.Length <= 50 && !String.IsNullOrWhiteSpace(tbName.Text) &&
         tbSurname.Text.Length <= 50 && !String.IsNullOrWhiteSpace(tbSurname.Text) &&
         tbContactPhone.Text.Length <= 50 && !String.IsNullOrWhiteSpace(tbContactPhone.Text) &&
         tbAdress.Text.Length <= 50 && !String.IsNullOrWhiteSpace(tbAdress.Text))
     {
         var customerRepository = new SqlCustomerRepository(Globals.connectionString);
         customerRepository.AddNewCustomer(new Customer()
         {
             Adress       = tbAdress.Text,
             ContactPhone = tbContactPhone.Text,
             Name         = tbName.Text,
             Surname      = tbSurname.Text
         });
         this.Close();
     }
     else
     {
         MessageBox.Show("Plesae verify input data", "Input error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }