Exemplo n.º 1
0
        private void btnConnexion_Click(object sender, EventArgs e)
        {
            if (cbUsers.SelectedItem == null)
            {
                MessageBox.Show("Please Select User!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (cbUsers.SelectedItem is SystemUser u)
            {
                using (InputTaker taker = new InputTaker())
                {
                    taker.ShowDialog();

                    if (taker.Value != null)
                    {
                        if (taker.Value.ToLower().Equals(u.Password.ToLower()))
                        {
                            using (LiciencePlate p = new LiciencePlate(u.Username))
                            {
                                p.ShowDialog();
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Incorrect Password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void ButtonOnClick(object sender, EventArgs e)
        {
            if (sender is Button b)
            {
                using (InputTaker taker = new InputTaker(b.Text, false, "123456789<0T", false))
                {
                    taker.ShowDialog();

                    if (taker.Value != null)
                    {
                        if (taker.Value.Length < 5 || taker.Value[1] != 'T' || taker.Value.Count(x => x == 'T') != 1)
                        {
                            MessageBox.Show("Icorrect Format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }

                        int val = Convert.ToInt32(GetInt(taker.Value));

                        if (val > 50)
                        {
                            var result = MessageBox.Show("Weight is greater than 50 KG\nAre you sure to proceed?", "Vérification",
                                                         MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                            if (result != DialogResult.Yes)
                            {
                                return;
                            }
                        }

                        var lbl = new SelectedProduct()
                        {
                            Dock = DockStyle.Top, Value = b.Text + "\t     " + taker.Value
                        };
                        //lbl.AutoSize = false;
                        //lbl.DoubleClick +=LblOnDoubleClick;
                        pnlSelectedProducts.Controls.Add(lbl);
                    }
                }
                BringToFront();
            }
        }