Ejemplo n.º 1
0
        private void ConfirmPurchase_Click(object sender, RoutedEventArgs e)
        {
            DatabaseManipulation dataMani = new DatabaseManipulation();

            vmvo.OrderList = orderList;

            if (dataMani.AddOrdersFromList() == true)
            {
                vmvo.OnPropertyChanged();

                // Find the frame.
                Frame            frame  = null;
                DependencyObject parent = VisualTreeHelper.GetParent(this);

                // Cycles through to MainWindow frame
                while (parent != null && frame == null)
                {
                    frame  = parent as Frame;
                    parent = VisualTreeHelper.GetParent(parent);
                }

                // Change the page of the frame.
                if (frame != null)
                {
                    frame.Navigate(new SalesRecordPage());
                }
                //Code Courtesy of Shmuel Zang in codeprojects.com https://www.codeproject.com/Questions/281551/frame-navigation-in-WPF
            }
            else
            {
                MessageBox.Show("Could Not Complete All Orders.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 2
0
        private void Refund_Click(object sender, RoutedEventArgs e)
        {
            var dbMani = new DatabaseManipulation();
            int custID;

            if (-1 != (custID = dbMani.FindCustomer()))
            {
                vmvo.CurrentCustomer.CustomerID = custID;
                vmvo.CurrentCustomer.FirstName  = vmvo.FirstName;
                vmvo.CurrentCustomer.LastName   = vmvo.LastName;
                vmvo.CurrentCustomer.Phone      = vmvo.Phone;

                // Find the frame.
                Frame            frame  = null;
                DependencyObject parent = VisualTreeHelper.GetParent(this);

                // Cycles through to MainWindow frame
                while (parent != null && frame == null)
                {
                    frame  = parent as Frame;
                    parent = VisualTreeHelper.GetParent(parent);
                }

                // Change the page of the frame.
                if (frame != null)
                {
                    frame.Navigate(new RefundOrder());
                }
                //Code Courtesy of Shmuel Zang in codeprojects.com https://www.codeproject.com/Questions/281551/frame-navigation-in-WPF
            }
            else
            {
                MessageBox.Show("Could Not Find Specific Customer.", "Alert!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 3
0
        private void Find_Click(object sender, RoutedEventArgs e)
        {
            DatabaseManipulation dataMani = new DatabaseManipulation();

            if (!dataMani.LoadOrder())
            {
                MessageBox.Show("Could Not Find the Specified Order.", "Alert!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 4
0
        public Home()
        {
            InitializeComponent();
            List <ConfigMqtt> itens = DatabaseManipulation.DBConfigMqtt();

            mqttConnectionShutter            = new MQTTConnection();
            mqttConnectionAH                 = new MQTTConnection();
            mqttConnectionH                  = new MQTTConnection();
            mqttConnectionAzm                = new MQTTConnection();
            mqttConnectionSinc               = new MQTTConnection();
            mqttConnectionCmdExterno         = new MQTTConnection();
            mqttConnectioninfoTrapeira       = new MQTTConnection();
            mqttConnectioninfoAzmDomo        = new MQTTConnection();
            mqttConnectioninfoPosHome        = new MQTTConnection();
            mqttConnectioninfoPosPark        = new MQTTConnection();
            mqttConnectioninfoResolucao      = new MQTTConnection();
            mqttConnectioninfoSincTelescopio = new MQTTConnection();
            mqttConnectioninfoPosTelescopio  = new MQTTConnection();
            mqttConnectioninfoVelDomo        = new MQTTConnection();



            brokerConfig = itens[0].valor;
            mqttPort     = int.Parse(itens[1].valor);

            strCfgShutter     = itens[2].valor;
            strCfgAH          = itens[3].valor;
            strCfgH           = itens[4].valor;
            strCfgAzm         = itens[5].valor;
            strCfgSinc        = itens[6].valor;
            strCfgCmdExterno  = itens[7].valor;
            strCfgInfoTpr     = itens[8].valor;
            strCfgInfoAzm     = itens[9].valor;
            strCfgInfoHome    = itens[10].valor;
            strCfgInfoPark    = itens[11].valor;
            strCfgInfoResol   = itens[12].valor;
            strCfgInfoSinc    = itens[13].valor;
            strCfgInfoPos     = itens[14].valor;
            strCfgInfoVelDomo = itens[15].valor;


            mqttConnectionShutter.StartConnection(brokerConfig, mqttPort, strCfgShutter);
            mqttConnectionAH.StartConnection(brokerConfig, mqttPort, strCfgAH);
            mqttConnectionH.StartConnection(brokerConfig, mqttPort, strCfgH);
            mqttConnectionAzm.StartConnection(brokerConfig, mqttPort, strCfgAzm);
            mqttConnectionSinc.StartConnection(brokerConfig, mqttPort, strCfgSinc);

            mqttConnectionCmdExterno.StartConnection(brokerConfig, mqttPort, strCfgCmdExterno);
            mqttConnectioninfoTrapeira.StartConnection(brokerConfig, mqttPort, strCfgInfoTpr);
            mqttConnectioninfoAzmDomo.StartConnection(brokerConfig, mqttPort, strCfgInfoAzm);
            mqttConnectioninfoPosHome.StartConnection(brokerConfig, mqttPort, strCfgInfoHome);
            mqttConnectioninfoPosPark.StartConnection(brokerConfig, mqttPort, strCfgInfoPark);
            mqttConnectioninfoResolucao.StartConnection(brokerConfig, mqttPort, strCfgInfoResol);
            mqttConnectioninfoSincTelescopio.StartConnection(brokerConfig, mqttPort, strCfgInfoSinc);
            mqttConnectioninfoPosTelescopio.StartConnection(brokerConfig, mqttPort, strCfgInfoPos);
            mqttConnectioninfoVelDomo.StartConnection(brokerConfig, mqttPort, strCfgInfoVelDomo);
        }
Ejemplo n.º 5
0
        private void botaoLogin_Click(object sender, EventArgs e)
        {
            List <Usuario> dataUsers;

            if (BoxSenha.Text.Equals("Senha") || BoxNome.Text.Length.Equals("Nome do usuário") || BoxNome.Text.Length == 0 || BoxSenha.Text.Length == 0)
            {
                AtualizarEstadoMsgBox();
            }
            else
            {
                dataUsers = DatabaseManipulation.DBUsers();

                MD5    md5 = MD5.Create();
                byte[] hashSenha;

                hashSenha = md5.ComputeHash(Encoding.ASCII.GetBytes(BoxSenha.Text));

                StringBuilder sBuilder = new StringBuilder();
                foreach (byte item in hashSenha)
                {
                    sBuilder.Append(item.ToString("x2"));
                }

                foreach (Usuario user in dataUsers)
                {
                    if (user.Nome.Equals(BoxNome.Text) && user.Senha.Equals(sBuilder.ToString()))
                    {
                        //Vai para a outra tela
                        Program.setUserLogged(user);
                        this.Hide();

                        if (user.TipoUsuario == TiposDeUsuarios.Usuario)
                        {
                            telaHome = new Home();


                            telaHome.ShowDialog();
                        }

                        else
                        {
                            cfgMqtt = new ConfiguracaoAttrMQTT();
                            cfgMqtt.ShowDialog();
                        }

                        logginState = true;
                        this.Close();
                    }
                }
                if (!logginState)
                {
                    //indica ao usuário que não há um cadastro com os dados passados
                    MessageBox.Show("Não há um usuário cadastrado com esses dados", "Erro no acesso", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    AtualizarEstadoMsgBox();
                }
            }
        }
Ejemplo n.º 6
0
        private void ConfirmRefund_Click(object sender, RoutedEventArgs e)
        {
            //Database Command class
            DatabaseManipulation dataMani = new DatabaseManipulation();

            if (vmvo.Order.Quantity > vmvo.ProductQuantity && vmvo.ProductQuantity > 0)
            {
                //Adjust Order's Quantity and set order to refund
                vmvo.Order.Quantity = vmvo.ProductQuantity;
                vmvo.Order.Status   = "RFND";

                //Moving over the Static order to a local order
                ord                = vmvo.Order;
                ord.OrderDate      = DateTime.Now;
                ord.SalesPrice     = 0.0;
                vmvo.CurrentBranch = ord.Branch;
                orderList          = new List <Orders>();

                //Clearing the OrderList just in case and Adding order to order list
                orderList.Add(ord);
                vmvo.OrderList = orderList;

                //Clear Static Order
                vmvo.Order = new Orders();

                if (dataMani.AddOrdersFromList() == true)
                {
                    // Find the frame.
                    Frame            frame  = null;
                    DependencyObject parent = VisualTreeHelper.GetParent(this);

                    // Cycles through to MainWindow frame
                    while (parent != null && frame == null)
                    {
                        frame  = parent as Frame;
                        parent = VisualTreeHelper.GetParent(parent);
                    }

                    // Change the page of the frame.
                    if (frame != null)
                    {
                        frame.Navigate(new SalesRecordPage());
                    }
                    //Code Courtesy of Shmuel Zang in codeprojects.com https://www.codeproject.com/Questions/281551/frame-navigation-in-WPF
                }
                else
                {
                    MessageBox.Show("Could Not Return Your Order", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Quantity of Products Returned Cannot Be More Than What Was Ordered.", "Alert!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 7
0
        private void OnBranchSelected(object sender, EventArgs e)
        {
            var dataMani = new DatabaseManipulation();

            if (dataMani.GetAllProductsInBranch() == false)
            {
                MessageBox.Show("Could Not Find Any Products For The Selected Branch", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            vmvo.OnPropertyChanged("ProductList");
        }
Ejemplo n.º 8
0
        private void Vmvo_NewOrderID(object sender, EventArgs e)
        {
            DatabaseManipulation dataMani = new DatabaseManipulation();

            if (!dataMani.LoadOrder())
            {
                MessageBox.Show("Could Not Find the Specified Order.", "Alert!", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            vmvo.ProductQuantity = vmvo.Order.Quantity;

            vmvo.OnPropertyChanged("ProductQuantity");
            vmvo.OnPropertyChanged("Order");
        }
Ejemplo n.º 9
0
        private void InventoryLevels_Loaded(object sender, RoutedEventArgs e)
        {
            //Variables
            var dataMani = new DatabaseManipulation();

            //Load Viewmodel into dataContext
            vmvo        = new ViewModelValueOriented();
            DataContext = vmvo;

            vmvo.CurrentBranchSelected += OnBranchSelected;

            //Check if all branches are loaded into view
            if (dataMani.GetAllBranches() == false)
            {
                MessageBox.Show("Could Not Load Branches", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 10
0
        private void ConfirmCust_Click(object sender, RoutedEventArgs e)
        {
            DatabaseManipulation dataMani = new DatabaseManipulation();
            int custID;

            if ((custID = dataMani.FindCustomer()) == -1)
            {
                if ((custID = dataMani.AddCustomer()) != -1)
                {
                    vmvo.CurrentCustomer.CustomerID = custID;
                    vmvo.CurrentCustomer.FirstName  = vmvo.FirstName;
                    vmvo.CurrentCustomer.LastName   = vmvo.LastName;
                    vmvo.CurrentCustomer.Phone      = vmvo.Phone;

                    // Find the frame.
                    Frame            frame  = null;
                    DependencyObject parent = VisualTreeHelper.GetParent(this);

                    // Cycles through to MainWindow frame
                    while (parent != null && frame == null)
                    {
                        frame  = parent as Frame;
                        parent = VisualTreeHelper.GetParent(parent);
                    }

                    // Change the page of the frame.
                    if (frame != null)
                    {
                        frame.Navigate(new PurchaseOrder());
                    }
                    //Code Courtesy of Shmuel Zang in codeprojects.com https://www.codeproject.com/Questions/281551/frame-navigation-in-WPF
                }
                else
                {
                    MessageBox.Show("Error: Could Not Add Customer To Database", "Alert!", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Customer Already Exists", "Alert!", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Ejemplo n.º 11
0
        private void accept_Click(object sender, EventArgs e)
        {
            TiposDeUsuarios novoCadastro;
            Usuario         newUser;

            if (checkBoxUser.Checked || checkBoxAdm.Checked || Program.getUserLogged().TipoUsuario == TiposDeUsuarios.Usuario)
            {
                if (textBox1.Text.Length > 0 && textBox3.Text.Length > 0)
                {
                    if (checkBoxUser.Checked || (Program.getUserLogged().TipoUsuario == TiposDeUsuarios.Usuario))
                    {
                        newUser = new Usuario(textBox1.Text, textBox3.Text, TiposDeUsuarios.Usuario);
                    }
                    else
                    {
                        newUser = new Usuario(textBox1.Text, textBox3.Text, TiposDeUsuarios.Administrador);
                    }

                    if (DatabaseManipulation.userRegister(newUser))              //se retornar true o usuario ja esta cadastrado
                    {
                        MessageBox.Show("Usuário já consta no sistema", "Mensagem cadastro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        textBox1.Text = "\0";
                        textBox3.Text = "\0";
                    }
                    else
                    {
                        MessageBox.Show("Cadastro efetuado", "Mensagem cadastro", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        returnInversorScreen();
                    }
                }
                else
                {
                    MessageBox.Show("Número de caracteres deve ser maior que zero", "Mensagem cadastro", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    returnInversorScreen();
                }
            }
        }
        public ConfiguracaoAttrMQTT()
        {
            InitializeComponent();

            atual_config = DatabaseManipulation.DBConfigMqtt();
        }
        private void btnMudar_Click(object sender, EventArgs e)
        {
            if (novoTopico.Text.Length > 0)
            {
                switch (lastSelect)
                {
                case 0:
                    atual_config[0].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[0].idconfig, atual_config[0].valor);
                    break;

                case 1:
                    atual_config[1].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[1].idconfig, atual_config[1].valor);
                    break;

                case 2:
                    atual_config[2].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[2].idconfig, atual_config[2].valor);
                    break;

                case 3:
                    atual_config[3].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[3].idconfig, atual_config[3].valor);
                    break;

                case 4:
                    atual_config[4].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[4].idconfig, atual_config[4].valor);
                    break;

                case 5:
                    atual_config[5].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[5].idconfig, atual_config[5].valor);
                    break;

                case 6:
                    atual_config[6].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[6].idconfig, atual_config[6].valor);
                    break;

                case 7:
                    atual_config[7].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[7].idconfig, atual_config[7].valor);
                    break;

                case 8:
                    atual_config[8].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[8].idconfig, atual_config[8].valor);
                    break;

                case 9:
                    atual_config[9].valor = novoTopico.Text;
                    textoTopicoAtual.Text = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[9].idconfig, atual_config[9].valor);
                    break;

                case 10:
                    atual_config[10].valor = novoTopico.Text;
                    textoTopicoAtual.Text  = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[10].idconfig, atual_config[10].valor);
                    break;

                case 11:
                    atual_config[11].valor = novoTopico.Text;
                    textoTopicoAtual.Text  = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[11].idconfig, atual_config[11].valor);
                    break;

                case 12:
                    atual_config[12].valor = novoTopico.Text;
                    textoTopicoAtual.Text  = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[12].idconfig, atual_config[12].valor);
                    break;

                case 13:
                    atual_config[13].valor = novoTopico.Text;
                    textoTopicoAtual.Text  = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[13].idconfig, atual_config[13].valor);
                    break;

                case 14:
                    atual_config[14].valor = novoTopico.Text;
                    textoTopicoAtual.Text  = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[14].idconfig, atual_config[14].valor);
                    break;

                case 15:
                    atual_config[15].valor = novoTopico.Text;
                    textoTopicoAtual.Text  = novoTopico.Text;
                    DatabaseManipulation.changeConfigMqtt(atual_config[15].idconfig, atual_config[15].valor);
                    break;
                }
                lastSelect = -1;
            }
        }