private void btnVolver_Click(object sender, EventArgs e)
 {
     iniTable("and ref_pedido = " + pedidoDto.getId());
     restaStock();
     prin.initTable("");
     this.Dispose();
     prin.Show();
     prin.mideStock();
 }
Example #2
0
        private void btnCreaPedido_Click(object sender, EventArgs e)
        {
            Pedido o  = new Pedido();
            float  f1 = -1;

            if (!txtTotal.Text.Equals(""))
            {
                f1 = float.Parse(txtTotal.Text.Replace("'", "").Replace(".", ",").ToString());
            }
            if (check() && (f1 != -1 && f1 > 0))
            {
                String idPedidoText = o.getGestor().getUnString("select count(*) from pedidos");
                int    idPedido     = Int32.Parse(idPedidoText);
                idPedido++;
                String id_emple = o.getGestor().getUnString("select id_emple from empleados where dni = '" + cbEmples.SelectedItem.ToString().Replace("'", "") + "'");
                String id_pago  = o.getGestor().getUnString("select id_fpago from formas_pago where forma_pago = '" + cbFPago.SelectedItem.ToString().Replace("'", "") + "'");
                String sql      = "Insert into pedidos values (" + idPedido + ", " + id_emple + ", '" + txtCliente.Text.Replace("'", "") + "', " + id_pago + ", '" + f1 + "',0 , 0, sysdate)";
                o.getGestor().setData(sql);

                sql = "SELECT MAX(id_pedido_produc) FROM pedidos_productos";
                String idorderp    = o.getGestor().getUnString(sql);
                int    idorderpNum = 1;
                if (!idorderp.Equals(""))
                {
                    idorderpNum = Int32.Parse(idorderp);
                    idorderpNum++;
                }
                for (int i = 0; i < dgvNuevoPedido.RowCount; i++)
                {
                    sql = "SELECT id_producto FROM productos WHERE UPPER(nombre_producto) = '" + dgvNuevoPedido.Rows[i].Cells[0].Value.ToString().ToUpper() + "'";
                    String idp = o.getGestor().getUnString(sql);
                    sql = "Insert into pedidos_productos values ('" + idorderpNum + "', '" + idPedido + "', '" + idp + "', '" + float.Parse(dgvNuevoPedido.Rows[i].Cells[1].Value.ToString()) + "', '" + float.Parse(dgvNuevoPedido.Rows[i].Cells[2].Value.ToString()) + "')";
                    o.getGestor().setData(sql);
                    idorderpNum++;
                    int newStock = Int32.Parse(o.getGestor().getUnString("select stock from productos where id_producto = " + idp)) - Int32.Parse(dgvNuevoPedido.Rows[i].Cells[1].Value.ToString());
                    o.getGestor().setData("update productos set stock = " + newStock + " where id_producto = " + idp);
                }
                this.Dispose();
                prin.initTable("");
                prin.Show();
                prin.mideStock();
            }
            else
            {
                MessageBox.Show("Error, revise los datos para crear pedido", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #3
0
        private void btnLogar_Click_1(object sender, EventArgs e)
        {
            if (txtName.Text.Equals("") || txtSenha.Text.Equals(""))
            {
                MessageBox.Show("Por favor, preencha os campos corretamente.");
            }
            else
            {
                try
                {
                    SqlConnection con = new SqlConnection();
                    con.ConnectionString = cs;

                    String consulta = "Select email,senha from Usuario " +
                                      "where email = @email and  senha = @senha";
                    SqlCommand cmd = new SqlCommand(consulta, con); //Representa um comando ou procedimento que sera feito bd
                    cmd.Parameters.AddWithValue("@email", txtName.Text);
                    cmd.Parameters.AddWithValue("@senha", Codificar(txtSenha.Text));

                    con.Open(); //Abre a conexao com o banco de dados;

                    SqlDataAdapter data = new SqlDataAdapter(cmd);
                    DataSet        ds   = new DataSet();
                    data.Fill(ds);
                    con.Close();                      //fecha a conexao

                    if (ds.Tables[0].Rows.Count == 0) //Se não retornou nada do bd
                    {
                        MessageBox.Show("Não está cadastrado...");
                        txtName.Clear();
                        txtSenha.Clear();
                    }
                    else
                    {
                        p.Show();
                        p.setEmail(txtName.Text);
                        this.Hide();
                    }
                }
                catch (Exception erro)
                {
                    MessageBox.Show("Erro:" + erro.Message);
                }
            }
        }
 private void btnVolver_Click(object sender, EventArgs e)
 {
     this.Dispose();
     prin.Show();
 }