/// <summary> /// Guarda un nuevo mercado /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGuardarMercado_Click(object sender, EventArgs e) { if (tbCuotaOver.Text.Contains('.')) { string conComa = tbCuotaOver.Text.Replace('.', ','); tbCuotaOver.Text = conComa; } if (tbCuotaUnder.Text.Contains('.')) { string conComa = tbCuotaUnder.Text.Replace('.', ','); tbCuotaUnder.Text = conComa; } if (tbDineroOver.Text.Contains('.')) { string conComa = tbDineroOver.Text.Replace('.', ','); tbDineroOver.Text = conComa; } if (tbDineroUnder.Text.Contains('.')) { string conComa = tbDineroUnder.Text.Replace('.', ','); tbDineroUnder.Text = conComa; } if (!Edita) { if (rb15.Checked == false && rb25.Checked == false && rb35.Checked == false) { MessageBox.Show("Campo 'Tipo Mercado' obligatorio", "Place My Bet", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (tbCuotaOver.Text == "" || tbCuotaUnder.Text == "" || tbDineroOver.Text == "" || tbDineroUnder.Text == "") { MessageBox.Show("Los campos de 'Cuotas' y 'Dineros' tienes que estar rellenos", "Place My Bet", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { DialogResult res = MessageBox.Show("¿Estás seguro que quieres añadir el mercado?", "Confirmación nuevo evento", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { double tipoMercado = 0; if (rb15.Checked == true) { tipoMercado = 1.5; } else if (rb25.Checked == true) { tipoMercado = 2.5; } else if (rb35.Checked == true) { tipoMercado = 3.5; } float a = (float)tipoMercado; Mercado m = new Mercado(Int32.Parse(tbId.Text), a, 1.9F, 1.9F, 100, 100, Int32.Parse(tbIdEvento.Text)); MercadoDAO.InsertMercado(m); this.Close(); } } } else { Mercado m = MercadoDAO.GetMercadoById(IdMercado); if (m.CuotaOver.ToString() == tbCuotaOver.Text && m.CuotaUnder.ToString() == tbCuotaUnder.Text && m.DineroOver.ToString() == tbDineroOver.Text && m.DineroUnder.ToString() == tbDineroUnder.Text) { MessageBox.Show("No se han producido cambios", "Place My Bet", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (tbCuotaOver.Text == "" || tbCuotaUnder.Text == "" || tbDineroOver.Text == "" || tbDineroUnder.Text == "") { MessageBox.Show("Los campos de 'Cuotas' y 'Dineros' tienes que estar rellenos", "Place My Bet", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { DialogResult res = MessageBox.Show("¿Quieres guardar los cambios realizados?", "Confirmación edición evento", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res == DialogResult.Yes) { m.Tipo = m.Tipo; m.CuotaOver = float.Parse(tbCuotaOver.Text); m.CuotaUnder = float.Parse(tbCuotaUnder.Text); m.DineroOver = Int32.Parse(tbDineroOver.Text); m.DineroUnder = Int32.Parse(tbDineroUnder.Text); m.ID_Evento = m.ID_Evento; MercadoDAO.Update(m); this.Close(); } } } }