Пример #1
0
        public static void PayOutSalaryHandler(ShowObject sender, EventArgs e)
        {
            List <Worker> workerList = DatabaseMethods.SelectWorkers();

            if (workerList.Count() > 0)
            {
                Worker worker = null;
                int    number = Convert.ToInt32(sender.objectBox.SelectedItem.ToString().Split('.').First());
                worker = workerList.Where(x => x.WorkerNumber == number).First();

                if (Budget.Balance - worker.Salary > Convert.ToDouble(Program.ReadSetting("Limit of bankrupt", "App.config")))
                {
                    MessageBox.Show("Paid out €" + worker.Salary + " to " + worker.Name + " " + worker.LastName, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    worker.PaySalary();
                    sender.Dispose();
                }
                else
                {
                    worker.PaySalary();
                    sender.Dispose();
                }
            }
            else
            {
                MessageBox.Show("No workers!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        public static void SendEmailClientHandler(ShowObject sender, EventArgs e)
        {
            Client client = null;
            int    number = Convert.ToInt32(sender.objectBox.SelectedItem.ToString().Split(' ').Last().Remove(sender.objectBox.SelectedItem.ToString().Split(' ').Last().Length - 1));

            client = DatabaseMethods.SelectClientFromQuery("SELECT * FROM Clients WHERE ClientNumber = '" + number.ToString() + "'");
            Task.Run(() => EmailSender.SendIt(client, client.Email, client.RegisterDate, "Client information"));
            MessageBox.Show("E-mail sent to " + client.Email, "E-mail sent", MessageBoxButtons.OK, MessageBoxIcon.Information);
            sender.Dispose();
        }
Пример #3
0
        public static void SendEmailOrderHandler(ShowObject sender, EventArgs e)
        {
            Order order  = null;
            int   number = Convert.ToInt32(sender.objectBox.SelectedItem.ToString().Split('.').First());

            order = DatabaseMethods.SelectOrderFromQuery("SELECT * FROM Orders WHERE OrderNumber = '" + number.ToString() + "'");
            string email = DatabaseMethods.SelectClients().Where(x => x.ClientNumber == order.OrderClientNumber).First().Email;

            Task.Run(() => EmailSender.SendIt(order, email, order.OrderRegisterDate, "Order information"));
            MessageBox.Show("E-mail sent to " + email, "E-mail sent", MessageBoxButtons.OK, MessageBoxIcon.Information);
            sender.Dispose();
        }
Пример #4
0
        private void ShowClientsButton_Click(object sender, EventArgs e)
        {
            List <Client> clientList = DatabaseMethods.SelectClients();

            if (clientList.Count() > 0)
            {
                List <string> list       = clientList.Select(i => i.Name + " " + i.LastName + " [Client number: " + i.ClientNumber + "]").ToList();
                ShowObject    showObject = new ShowObject(new BindingSource(list, null), typeof(Client), this);
                showObject.Text = "Show clients";
                showObject.ShowDialog();
            }
            else
            {
                MessageBox.Show("No clients!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
        private void ShowWorkersButton_Click(object sender, EventArgs e)
        {
            List <Worker> workerList = DatabaseMethods.SelectWorkers();

            if (workerList.Count() > 0)
            {
                List <string> list       = workerList.Select(i => i.WorkerNumber + ". " + i.Name + " " + i.LastName + ", " + i.Position).ToList();
                ShowObject    showObject = new ShowObject(new BindingSource(list, null), typeof(Worker), this);
                showObject.Text = "Show workers";
                showObject.ShowDialog();
            }
            else
            {
                MessageBox.Show("No workers!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #6
0
        private void ShowOrdersButton_Click(object sender, EventArgs e)
        {
            List <Order> orderList = DatabaseMethods.SelectOrders();

            if (orderList.Count() > 0)
            {
                List <string> list       = orderList.Select(i => i.OrderNumber + ". " + DatabaseMethods.SelectClients().Where(x => x.ClientNumber == i.OrderClientNumber).First().Name + " " + DatabaseMethods.SelectClients().Where(x => x.ClientNumber == i.OrderClientNumber).First().LastName + " " + DatabaseMethods.SelectOffers().Where(x => x.OfferNumber == i.TravelOfferNumber).First().TravelDestination).ToList();
                ShowObject    showObject = new ShowObject(new BindingSource(list, null), typeof(Order), this);
                showObject.Text = "Show orders";
                showObject.ShowDialog();
            }
            else
            {
                MessageBox.Show("No orders!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #7
0
        private void ShowOffersButton_Click(object sender, EventArgs e)
        {
            List <Offer> offerList = DatabaseMethods.SelectOffers();

            if (offerList.Count() > 0)
            {
                List <string> list       = offerList.Select(i => i.OfferNumber + ". " + i.TravelDestination + ", " + i.HotelRanking + ", " + i.Feeding + ", €" + i.Price).ToList();
                ShowObject    showObject = new ShowObject(new BindingSource(list, null), typeof(Offer), this);
                showObject.Text = "Show offers";
                showObject.ShowDialog();
            }
            else
            {
                MessageBox.Show("No offers!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #8
0
        private void PayOutSalaryButton_Click(object sender, EventArgs e)
        {
            List <Worker> workerList = DatabaseMethods.SelectWorkers();

            if (workerList.Count() > 0)
            {
                List <string> list       = workerList.Select(i => i.WorkerNumber + ". " + i.Name + " " + i.LastName + ", " + i.Position).ToList();
                ShowObject    showObject = new ShowObject(new BindingSource(list, null), typeof(Worker), this);
                showObject.Text                 = "Pay out salary";
                showObject.showButton.Text      = "Pay out salary";
                showObject.showButton.Size      = new Size(564, 51);
                showObject.deleteButton.Visible = false;
                showObject.ShowDialog();
            }
            else
            {
                MessageBox.Show("No workers!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #9
0
        private void AboutClientButton_Click(object sender, EventArgs e)
        {
            List <Client> clientList = DatabaseMethods.SelectClients();

            if (clientList.Count() > 0)
            {
                List <string> list       = clientList.Select(i => i.Name + " " + i.LastName + " [Client number: " + i.ClientNumber + "]").ToList();
                ShowObject    showObject = new ShowObject(new BindingSource(list, null), typeof(Client));
                showObject.Text                 = "Show clients";
                showObject.showButton.Text      = "Send information to E-mail";
                showObject.showButton.Size      = new Size(564, 51);
                showObject.deleteButton.Visible = false;
                showObject.ShowDialog();
            }
            else
            {
                MessageBox.Show("No clients!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }