Exemplo n.º 1
0
        private void btn_cadastrarcliente_Click(object sender, EventArgs e)
        {
            if (tb_NomeCliente.Text != "" && mtb_CpfCliente.Text != "")
            {
                Cliente cliente = new Cliente();
                cliente.Nome = tb_NomeCliente.Text.Trim();
                string cpf = mtb_CpfCliente.Text.Trim();
                string[] split = cpf.Split(new Char[] { ',', '-' });
                cpf = string.Join("", split);
                cliente.Cpf = cpf;
                string dt = string.Format("{0}-{1}-{2} {3}:{4}:{5}", dtp_DataCadastroCliente.Value.Year, dtp_DataCadastroCliente.Value.Month, dtp_DataCadastroCliente.Value.Day, dtp_DataCadastroCliente.Value.Hour, dtp_DataCadastroCliente.Value.Minute, dtp_DataCadastroCliente.Value.Second);
                cliente.dtCadastro = dt;

                long id = cliente.Cadastrar();

                tb_Codigo.Text = Convert.ToString(id + 1);
                tb_NomeCliente.Text = "";
                mtb_CpfCliente.Text = "";
                dtp_DataCadastroCliente.Value = DateTime.Now;
            }
            else
            {
                MessageBox.Show(this, "Este campo precisa ser preenchido para que o cadastro seja efetuado!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 2
0
        public void TirarPedido(List<PedidoProduto> produtos)
        {
            if (this.Clientes == null)
            {
                Cliente clientes = new Cliente();
                clientes.Codigo = 1;
                this.Clientes = clientes;
            }
            TConnect p = new TConnect();
            p.Sql = "insert into pedido(cod_cliente,cod_funcionario)values(" + this.Clientes.Codigo + "," + this.Funcionarios.Codigo + ")";
            long id = p.Inserir();

            for (int i = 0; i < produtos.Count(); i++)
            {
                TConnect pp = new TConnect();
                string dateTimeFormat = "{0}-{1}-{2} {3}:{4}:{5}";
                string dtvendas = string.Format(dateTimeFormat, this.DtVenda.Year, this.DtVenda.Month, this.DtVenda.Day, this.DtVenda.Hour, this.DtVenda.Minute, this.DtVenda.Second);
                pp.Sql = "insert into pedidoproduto(dtvenda,cod_produto,quantidade,valortotal,cod_pedido)values('" + dtvendas + "','" + produtos[i].CodigoPedidoProduto + "','" + produtos[i].Quantidade + "','" + produtos[i].ValorTotalProduto + "','" + id + "')";
                pp.Inserir();
                this.BaixaEstoque(produtos[i].Quantidade, produtos[i].CodigoPedidoProduto);
            }
        }
Exemplo n.º 3
0
 public TelaUpdateCliente(Cliente cliente)
 {
     InitializeComponent();
     this.Cliente = cliente;
 }