Пример #1
0
        private void Eventos()
        {
            KeyDown   += KeyDowns;
            KeyPreview = true;
            Masks.SetToUpper(this);

            Shown += (s, e) =>
            {
                txtQtdItens.Text = @"0";
                txtValor.Text    = @"R$ 00,00";

                SetHeadersTableItens(GridLista);
                SetHeadersTableSelecionados(GridListaSelecionados);
                LoadItens();
            };

            txtDinheiro.KeyPress += (s, e) => Masks.MaskDouble(s, e);

            txtDinheiro.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);

                var troco = Validation.ConvertToDouble(txtDinheiro.Text) -
                            Validation.ConvertToDouble(txtValor.Text.Replace("R$ ", ""));
                label6.Text = Validation.FormatPrice(troco, true);
            };

            btnContinuar.Click += (s, e) =>
            {
                Itens.Clear();

                if (GridLista.Rows.Count > 0)
                {
                    foreach (DataGridViewRow row in GridLista.Rows)
                    {
                        Itens.Add(new
                        {
                            Id         = row.Cells[0].Value,
                            CProd      = row.Cells[1].Value,
                            xProd      = row.Cells[2].Value,
                            Quantidade = row.Cells[3].Value,
                            Total      = Validation.ConvertToDouble(row.Cells[4].Value.ToString().Replace("R$ ", ""))
                        });
                    }
                }

                DialogResult = DialogResult.OK;
                Close();
            };

            #region Table Itens

            GridLista.CellClick += (s, e) =>
            {
                if (GridLista.Columns[e.ColumnIndex].Name == "Dividir")
                {
                    ModalDividirValor.Valor = Validation.ConvertToDouble(GridLista.SelectedRows[0].Cells["Valor"].Value
                                                                         .ToString().Replace("R$ ", ""));
                    var form = new ModalDividirValor {
                        TopMost = true
                    };
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        GridListaSelecionados.Rows.Add(
                            GridLista.SelectedRows[0].Cells["ID"].Value,
                            GridLista.SelectedRows[0].Cells["Referência"].Value,
                            GridLista.SelectedRows[0].Cells["Item"].Value,
                            GridLista.SelectedRows[0].Cells["Qtd."].Value,
                            Validation.FormatPrice(ModalDividirValor.ValorDivido, true),
                            Resources.error20x
                            );

                        RefreshTotal();

                        if (ModalDividirValor.ValorRestante <= 0)
                        {
                            GridLista.Rows.RemoveAt(e.RowIndex);
                        }
                        else
                        {
                            GridLista.Rows[e.RowIndex].Cells[4].Value =
                                Validation.FormatPrice(ModalDividirValor.ValorRestante, true);
                        }

                        Alert.Message("Pronto", "Item adicionado.", Alert.AlertType.success);
                    }
                }

                if (GridLista.Columns[e.ColumnIndex].Name == "Adicionar")
                {
                    GridListaSelecionados.Rows.Add(
                        GridLista.SelectedRows[0].Cells["ID"].Value,
                        GridLista.SelectedRows[0].Cells["Referência"].Value,
                        GridLista.SelectedRows[0].Cells["Item"].Value,
                        GridLista.SelectedRows[0].Cells["Qtd."].Value,
                        GridLista.SelectedRows[0].Cells["Valor"].Value,
                        Resources.error20x
                        );

                    RefreshTotal();

                    GridLista.Rows.RemoveAt(e.RowIndex);

                    Alert.Message("Pronto", "Item adicionado.", Alert.AlertType.success);
                }
            };

            GridLista.CellMouseEnter += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridLista.Columns[e.ColumnIndex].Name == "Adicionar" ||
                    GridLista.Columns[e.ColumnIndex].Name == "Dividir")
                {
                    dataGridView.Cursor = Cursors.Hand;
                }
            };

            GridLista.CellMouseLeave += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridLista.Columns[e.ColumnIndex].Name == "Adicionar" ||
                    GridLista.Columns[e.ColumnIndex].Name == "Dividir")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };

            #endregion

            #region Itens Selecionados

            GridListaSelecionados.CellClick += (s, e) =>
            {
                if (GridListaSelecionados.Columns[e.ColumnIndex].Name == "Remover")
                {
                    var notFound = true;
                    foreach (DataGridViewRow row in GridLista.Rows)
                    {
                        if (row.Cells[0].Value.ToString() ==
                            GridListaSelecionados.Rows[e.RowIndex].Cells[0].Value.ToString())
                        {
                            var valor    = Validation.ConvertToDouble(row.Cells[4].Value.ToString().Replace("R$ ", ""));
                            var addValor = Validation.ConvertToDouble(GridListaSelecionados.Rows[e.RowIndex].Cells[4]
                                                                      .Value.ToString().Replace("R$ ", ""));
                            row.Cells[4].Value = Validation.FormatPrice(valor + addValor, true);
                            notFound           = false;
                            break;
                        }
                    }

                    if (notFound)
                    {
                        GridLista.Rows.Add(
                            GridListaSelecionados.SelectedRows[0].Cells["ID"].Value,
                            GridListaSelecionados.SelectedRows[0].Cells["Referência"].Value,
                            GridListaSelecionados.SelectedRows[0].Cells["Item"].Value,
                            GridListaSelecionados.SelectedRows[0].Cells["Qtd."].Value,
                            GridListaSelecionados.SelectedRows[0].Cells["Valor"].Value,
                            Resources.divide20x,
                            Resources.plus20x
                            );
                    }

                    GridListaSelecionados.Rows.RemoveAt(e.RowIndex);

                    RefreshTotal();
                }
            };

            GridListaSelecionados.CellMouseEnter += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridListaSelecionados.Columns[e.ColumnIndex].Name == "Remover")
                {
                    dataGridView.Cursor = Cursors.Hand;
                }
            };

            GridListaSelecionados.CellMouseLeave += (s, e) =>
            {
                if (e.ColumnIndex < 0 || e.RowIndex < 0)
                {
                    return;
                }

                var dataGridView = s as DataGridView;
                if (GridListaSelecionados.Columns[e.ColumnIndex].Name == "Remover")
                {
                    dataGridView.Cursor = Cursors.Default;
                }
            };

            #endregion
        }
Пример #2
0
        public void Eventos()
        {
            ToolHelp.Show(
                "Atribua um limite para lançar descontos a este item. O Valor irá influenciar nos descontos em reais e porcentagens.",
                pictureBox11, ToolHelp.ToolTipIcon.Info, "Ajuda!");
            ToolHelp.Show("Essa opção ativa o controle do estoque, não permitindo vender itens com o estoque zerado.",
                          pictureBox1, ToolHelp.ToolTipIcon.Info, "Ajuda!");
            ToolHelp.Show("Ative essa opção para utilizar as mesas predefinidas no sistema.", pictureBox5,
                          ToolHelp.ToolTipIcon.Info, "Ajuda!");

            Shown += (s, e) =>
            {
                if (!string.IsNullOrEmpty(IniFile.Read("RetomarVenda", "Comercial")))
                {
                    retomarVendaInicio.Toggled = IniFile.Read("RetomarVenda", "Comercial") == "True";
                }

                if (!string.IsNullOrEmpty(IniFile.Read("ControlarEstoque", "Comercial")))
                {
                    btnControlarEstoque.Toggled = IniFile.Read("ControlarEstoque", "Comercial") == "True";
                }

                if (!string.IsNullOrEmpty(IniFile.Read("LimiteDesconto", "Comercial")))
                {
                    txtLimiteDesconto.Text =
                        Validation.Price(Validation.ConvertToDouble(IniFile.Read("LimiteDesconto", "Comercial")));
                }

                if (!string.IsNullOrEmpty(IniFile.Read("TrocasCliente", "Comercial")))
                {
                    Trocas_01.Toggled = IniFile.Read("TrocasCliente", "Comercial") == "True";
                }

                if (!string.IsNullOrEmpty(IniFile.Read("UserNoDocument", "Comercial")))
                {
                    UserNoDocument.Toggled = IniFile.Read("UserNoDocument", "Comercial") == "True";
                }

                if (!string.IsNullOrEmpty(IniFile.Read("ShowImagePDV", "Comercial")))
                {
                    imgPDV.Toggled = IniFile.Read("ShowImagePDV", "Comercial") == "True";
                }

                if (!string.IsNullOrEmpty(IniFile.Read("Alimentacao", "Comercial")))
                {
                    btnAlimentacao.Toggled = IniFile.Read("Alimentacao", "Comercial") == "True";
                }

                if (!string.IsNullOrEmpty(IniFile.Read("MesasPreCadastrada", "Comercial")))
                {
                    btnMesasPreCadastrada.Toggled = IniFile.Read("MesasPreCadastrada", "Comercial") == "True";
                }

                if (!string.IsNullOrEmpty(IniFile.Read("BaixarEstoqueRemessas", "Comercial")))
                {
                    btnBaixarEstoqueRemessas.Toggled = IniFile.Read("BaixarEstoqueRemessas", "Comercial") == "True";
                }
            };

            retomarVendaInicio.Click += (s, e) =>
            {
                IniFile.Write("RetomarVenda", retomarVendaInicio.Toggled ? "False" : "True", "Comercial");
            };

            btnControlarEstoque.Click += (s, e) =>
            {
                IniFile.Write("ControlarEstoque", btnControlarEstoque.Toggled ? "False" : "True", "Comercial");
            };

            Trocas_01.Click += (s, e) =>
            {
                IniFile.Write("TrocasCliente", Trocas_01.Toggled ? "False" : "True", "Comercial");
            };

            UserNoDocument.Click += (s, e) =>
            {
                IniFile.Write("UserNoDocument", UserNoDocument.Toggled ? "False" : "True", "Comercial");
            };

            imgPDV.Click += (s, e) =>
            {
                IniFile.Write("ShowImagePDV", imgPDV.Toggled ? "False" : "True", "Comercial");
            };

            btnAlimentacao.Click += (s, e) =>
            {
                IniFile.Write("Alimentacao", btnAlimentacao.Toggled ? "False" : "True", "Comercial");
            };

            btnMesasPreCadastrada.Click += (s, e) =>
            {
                IniFile.Write("MesasPreCadastrada", btnMesasPreCadastrada.Toggled ? "False" : "True", "Comercial");
            };

            btnBaixarEstoqueRemessas.Click += (s, e) =>
            {
                IniFile.Write("BaixarEstoqueRemessas", btnBaixarEstoqueRemessas.Toggled ? "False" : "True", "Comercial");
            };

            txtLimiteDesconto.Leave += (s, e) => IniFile.Write("LimiteDesconto",
                                                               Validation.ConvertToDouble(txtLimiteDesconto.Text).ToString(), "Comercial");
            txtLimiteDesconto.TextChanged += (s, e) =>
            {
                var txt = (TextBox)s;
                Masks.MaskPrice(ref txt);
            };

            btnExit.Click += (s, e) => Close();
        }