Beispiel #1
0
        private async void btnAdd_Click(object sender, EventArgs e)
        {
            Packet packet = new Packet()
            {
                DateWeek = txtDate.Text,
                Price    = nmrcPrice.Value,
                Name     = txtName.Text,
                Date     = txtDate.Text
            };

            db.Packets.Add(packet);
            await db.SaveChangesAsync();

            foreach (var item in flowLayoutPanel1.Controls)
            {
                CheckBox checkBox = (CheckBox)item;

                if (checkBox.Checked)
                {
                    ServicesToPacket serviceToPackage = new ServicesToPacket()
                    {
                        ServicesId = Convert.ToInt32(checkBox.Tag),
                        PacketId   = packet.Id
                    };

                    db.ServicesToPackets.Add(serviceToPackage);
                }
            }

            await db.SaveChangesAsync();

            this.Close();
            MessageBox.Show("You add new packet");
        }
Beispiel #2
0
        private async void btnAdd_Click(object sender, EventArgs e)
        {
            Pac.Name     = txtName.Text;
            Pac.Date     = txtDate.Text;
            Pac.DateWeek = txtDateWeek.Text;
            Pac.Price    = nmrcPrice.Value;

            foreach (var item in _contex2.ServicesToPackets.Where(x => x.PacketId == Pac.Id))
            {
                _contex2.ServicesToPackets.Remove(item);
            }

            await _contex2.SaveChangesAsync();

            foreach (var item in flowLayoutPanel1.Controls)
            {
                CheckBox checkbox = (CheckBox)item;
                if (checkbox.Checked)
                {
                    ServicesToPacket servicesToPackage = new ServicesToPacket()
                    {
                        ServicesId = Convert.ToInt32(checkbox.Tag),
                        PacketId   = Pac.Id
                    };
                    _contex2.ServicesToPackets.Add(servicesToPackage);
                }
            }
            await _contex2.SaveChangesAsync();

            dgt.DataSource = _contex2.Packets.ToList();
            this.Close();
            MessageBox.Show("You Edited");
        }
Beispiel #3
0
        private async void btnAdd_Click(object sender, EventArgs e)
        {
            Role role = new Role()
            {
                Name = txtName.Text
            };

            _contex2.Roles.Add(role);
            await _contex2.SaveChangesAsync();

            cmbRole.DataSource = _contex2.Roles.Where(r => r.Id != 1).ToList();

            txtName.Text = " ";
        }
Beispiel #4
0
        private async void btnAddCustomer_Click(object sender, EventArgs e)
        {
            string firstname = txtCustomerName.Text;
            string lastname  = txtCustomerLastName.Text;
            string email     = txtEmail.Text;

            if (firstname == " " || lastname == " " || email == " ")
            {
                ShowMessage("Your Username or Password is not valid ", "Eror");
                return;
            }

            Customer customer = new Customer()
            {
                Firstname = firstname,
                Lastname  = lastname,
                Email     = email
            };

            _contex.Customers.Add(customer);
            await _contex.SaveChangesAsync();

            cmb.DataSource = _contex.Customers.ToList();

            txtCustomerName.Text     = string.Empty;
            txtCustomerLastName.Text = string.Empty;
            txtEmail.Text            = string.Empty;


            this.Close();
        }
Beispiel #5
0
        private async void button1_Click(object sender, EventArgs e)
        {
            Service  selectedService  = cmbservices.SelectedItem as Service;
            Packet   selectedPacket   = cmbPacket.SelectedItem as Packet;
            Customer selectedCustomer = cmbCustoemrs.SelectedItem as Customer;

            Order order = new Order()
            {
                Date       = dateTimePicker1.Value,
                EmployeeId = emp.Id,
                Price      = Convert.ToDecimal(txtPrices.Text)
            };

            _contex.Orders.Add(order);
            await _contex.SaveChangesAsync();

            if (cmbservices.SelectedIndex >= 0 && cmbPacket.SelectedIndex == -1)
            {
                OrderDetail orderDetail = _contex.OrderDetails.Add(new OrderDetail
                {
                    CustomerId = selectedCustomer.Id,
                    ServicesId = selectedService.Id,
                    PacketId   = null,
                    OrdersId   = order.Id
                });

                _contex.OrderDetails.Add(orderDetail);
                await _contex.SaveChangesAsync();
            }

            if (cmbservices.SelectedIndex == -1 && cmbPacket.SelectedIndex >= 0)
            {
                OrderDetail orderDetail = _contex.OrderDetails.Add(new OrderDetail
                {
                    CustomerId = selectedCustomer.Id,
                    ServicesId = null,
                    PacketId   = selectedPacket.Id,
                    OrdersId   = order.Id
                });

                _contex.OrderDetails.Add(orderDetail);
                await _contex.SaveChangesAsync();
            }

            dataGridView1.DataSource = _contex.OrderDetails.ToList();
            MessageBox.Show("Order is accepted");
        }
Beispiel #6
0
        private async void btnAdd_Click(object sender, EventArgs e)
        {
            service.Name  = txtName.Text;
            service.Date  = Convert.ToInt32(txtDate.Text);
            service.Price = numericUpDown1.Value;

            await _contex2.SaveChangesAsync();

            dgt.DataSource = _contex2.Services.ToList();
            this.Close();
        }
        private async void btnLogIn_Click(object sender, EventArgs e)
        {
            string defaultPassword = txtDefault.Text;
            string newPassword     = txtNewPassword.Text;
            string confirmPassword = txtConfirmPassword.Text;

            if (defaultPassword == string.Empty || newPassword == string.Empty || confirmPassword == string.Empty)
            {
                ShowMessage("Please fill all fields", "Error");
                return;
            }

            if (!CheckHashCode(loggedEmployee.Password, defaultPassword))
            {
                ShowMessage("Current password is not  invalid.", "Error");
                return;
            }

            if (newPassword != confirmPassword)
            {
                ShowMessage("New password and confirm password don't match.", "Error");
                return;
            }

            Employee UpdateEmployee = await _contex.Employees.FindAsync(loggedEmployee.Id);

            UpdateEmployee.Password    = GetHash(newPassword);
            UpdateEmployee.HasVerified = true;
            await _contex.SaveChangesAsync();

            if (UpdateEmployee.Role.Name == Roles.Employee.ToString())
            {
                this.Close();
                new Employees(employee).ShowDialog();
            }
        }