コード例 #1
0
        private void btn_voltar_Click(object sender, EventArgs e)
        {
            PedidoView p = new PedidoView();

            p.Show();
            this.Hide();
        }
コード例 #2
0
        private void btn_salvar_Click(object sender, EventArgs e)
        {
            try {
                if (cb_tipoPedido.SelectedItem.ToString() == "Retirada")
                {
                    validaPedido();

                    if (this.pedido.Tipo_pedido == "Entrega")
                    {
                        this.pedidoController.deletarEndereco(this.idPedido);
                    }

                    this.pedidoController.atualizarPedido(populaPedido(), this.produtos);
                    enviaMsg("Pedido Atualizado!", "check");
                }
                else
                {
                    validaPedidoEntrega();

                    if (this.pedido.Tipo_pedido == "Retirada")
                    {
                        this.pedidoController.inserirEndereco(populaPedidoEntrega(), this.idPedido);
                    }

                    this.pedidoController.atualizarPedido(populaPedidoEntrega(), this.produtos);
                    enviaMsg("Pedido Atualizado!", "check");
                }

                PedidoView p = new PedidoView();
                p.Show();
                this.Hide();
            }catch (Exception e1) {
                enviaMsg(e1.Message, "erro");
            }
        }
        private void btn_cadastrar_Click(object sender, EventArgs e)
        {
            try {
                this.pedidoController.inserirPedido(this.pedido, this.produtos);
                enviaMsg("Pedido Cadastrado!", "check");

                PedidoView p = new PedidoView();
                p.Show();
                this.Hide();
            }catch (Exception e1) {
                enviaMsg(e1.Message, "erro");
            }
        }
        public PedidoCadastrarView()
        {
            InitializeComponent();

            try {
                clientes            = new List <Cliente>();
                produtos            = new List <ProdutoPesquisa>();
                produtosCadastrados = new List <Produto>();

                pedidoController  = new PedidoController();
                clienteController = new ClienteController();
                produtoController = new ProdutoController();

                cliente = new Cliente();
                pedido  = new dto.Pedido();

                this.produtosCadastrados = this.produtoController.pesquisarProdutos();
                this.clientes            = this.clienteController.pesquisaClientes();

                preencheComboBox();

                txt_dataEntrega.Value = DateTime.Now;


                txt_dataEntrega.MaxDate = DateTime.Now.AddDays(60);
                txt_dataEntrega.MinDate = DateTime.Now.AddDays(-60);

                txt_dataPag.Value = txt_dataEntrega.Value;

                txt_dataPag.MinDate = txt_dataEntrega.MinDate;
                txt_dataPag.MaxDate = txt_dataEntrega.MaxDate;
            }catch (Exception e) {
                enviaMsg(e.Message, "erro");

                PedidoView p = new PedidoView();
                p.Show();
                this.Hide();
            }
        }