private DataRow GetFormRuleRow(Action <DataTable> tableAction = null) { var table = new DataTable("testTable"); table.Columns.Add("region"); table.Columns.Add("CostName"); var rules = new FormRule(); var fields = typeof(FormRules).GetFields().Select(fieldInfo => fieldInfo.GetValue(rules)); foreach (var name in fields) { table.Columns.Add(name.ToString()); } if (tableAction != null) { tableAction(table); } var row = table.NewRow(); foreach (var name in fields) { row[name.ToString()] = 0; } table.Rows.Add(row); row[FormRules.colFormByCode] = false; return(row); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRule_Click(object sender, EventArgs e) { using (FormRule formRule = new FormRule(txtRule.Text)) { formRule.ShowDialog(this); } }
/// <summary> /// /// </summary> private void ShowSignatureWindow() { if (listEvents.SelectedObjects.Count != 1) { return; } Event temp = (Event)listEvents.SelectedObjects[0]; if (temp == null) { UserInterface.DisplayErrorMessageBox(this, "Unable to locate event"); return; } using (FormRule form = new FormRule(controlEventInfo.Signature)) { form.ShowDialog(this); } }
/// <summary> /// al apretar Jugar en este form se abrira un form ruleta y se armara la partida y los nuevos datos del jugador /// segun si el random perdio o gano. solo se podra abrir un form de ruleta si no existe uno ya corriendo y /// si todos los datos son correctos /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnJugar_Click(object sender, EventArgs e) { if (!invoked) { try { if ((this.victima = Casino.BuscarJugador(this.ca, txtBoxIDAJugar.Text)) != null) { try { int cantidadJ; cantidadJ = int.Parse(txtCantidadAJugar.Text); if (cantidadJ < 0) { throw new FormatException(); } ETipoMoneda money = (ETipoMoneda)cmbBoxAJugar.SelectedItem; int ganancia = Moneda.SacarGanancia(money); if (this.victima.CantidadMonedasSegunTipo(money) >= cantidadJ) { if ((rdoButtonBoleto.Checked && this.victima.Boletos.Cantidad > 0) || rdoButtonBoleto.Checked == false) { /*base del form*/ this.ruleta = new FormRule(); this.ruleta.frenacion += spinStop; this.invoked = true;//si ya se abrio una ruleta y no se cerro de ninguna forma no se puede generar otro form ruleta.Show(); this.InicioThread(); /**/ if ((rdoButtonBoleto.Checked && this.victima.Boletos.Cantidad > 0)) { BoletoChances apuesto = new BoletoChances(1); this.victima -= apuesto; } Moneda apostada = new Moneda(Moneda.SacarPrecio(money), cantidadJ, money, ganancia); this.segunda = new Jugada(this.victima); this.winLo = ganoperdio.Next(0, 50); if (this.winLo > 35)/*15 veces mas de perder que de ganar*/ { this.segunda.Varianza = Jugada.CalcularVarianza(apostada, cantidadJ, ETipoTransaccion.gana); apostada.Cantidad = apostada.Cantidad * ganancia; this.victima += apostada; this.segunda.Movimiento = ETipoTransaccion.gana; } else { this.segunda.Movimiento = ETipoTransaccion.pierde; this.segunda.Varianza = Jugada.CalcularVarianza(apostada, cantidadJ, ETipoTransaccion.pierde); this.victima -= apostada; } this.victima.Saldo = this.victima.SacarSaldo(this.victima.Billetera); } else { MessageBox.Show("No le alcanzan los boletos"); } } else { MessageBox.Show("No tiene las monedas suficientes para jugar"); } } catch (FormatException) { throw new cantidadInvalidaException(); } } else { MessageBox.Show("No se encuentra ese dni en la lista de jugadores disponibles"); } }
/// <summary> /// Applies the business rule on form set. /// </summary> /// <param name="theForms">The forms.</param> /// <param name="theRules">The rules.</param> /// <param name="patientAge">The patient age.</param> /// <param name="patientSex">The patient sex.</param> DataTable ApplyBusinessRuleOnFormSet(ref DataTable theForms, ref List <FormRule> theRules, double patientAge, string patientSex) { theForms.Columns.Add(new DataColumn("Deleted", Type.GetType("System.Int32"))); theForms.Columns["Deleted"].DefaultValue = 0; theForms.AcceptChanges(); foreach (DataRow row in theForms.Rows) { row["Deleted"] = 0; int formId = Convert.ToInt32(row["FormId"]); FormRule setOneAge = theRules.Where(r => r.RuleSet == 1 && r.RuleReferenceId == "ACTIVE_AGE_RANGE_YEARS" && r.FormId == formId).FirstOrDefault(); List <FormRule> setOneFemale = theRules.Where(r => r.RuleSet == 1 && r.RuleReferenceId == "ACTIVE_FEMALE" && r.FormId == formId).ToList(); List <FormRule> setOneMale = theRules.Where(r => r.RuleSet == 1 && r.RuleReferenceId == "ACTIVE_MALE" && r.FormId == formId).ToList(); bool setOneFlag = true; bool setTwoFlag = true; if (setOneAge != null) { if (setOneAge.MinValue != "0" || setOneAge.MaxValue != "0") { if (patientAge >= Convert.ToDouble(setOneAge.MinValue) && patientAge <= Convert.ToDouble(setOneAge.MaxValue)) { //setOneFlag = true; } else { setOneFlag = false; } //rowFilter = string.Format("{0} Age >= {1} And Age <= {2} ", rowFilter, Convert.ToDecimal(setOneAge.MinValue), Convert.ToDecimal(setOneAge.MaxValue)); } } if (setOneFemale != null && setOneFemale.Count > 0 && setOneMale != null && setOneMale.Count > 0) { } else { if (setOneFemale.Count > 0 && patientSex == "Male") { setOneFlag = false; } else if (setOneMale.Count > 0 && patientSex == "Female") { setOneFlag = false; } } FormRule set2Age = theRules.Where(r => r.RuleSet == 2 && r.RuleReferenceId == "ACTIVE_AGE_RANGE_YEARS" && r.FormId == formId).FirstOrDefault(); List <FormRule> set2Female = theRules.Where(r => r.RuleSet == 2 && r.RuleReferenceId == "ACTIVE_FEMALE" && r.FormId == formId).ToList(); List <FormRule> set2Male = theRules.Where(r => r.RuleSet == 2 && r.RuleReferenceId == "ACTIVE_MALE" && r.FormId == formId).ToList(); if (set2Age != null) { if (patientAge >= Convert.ToDouble(set2Age.MinValue) && patientAge <= Convert.ToDouble(set2Age.MaxValue)) { } else { setTwoFlag = false; } } if (set2Female != null && set2Female.Count > 0 && set2Male != null && set2Male.Count > 0) { } else { if (set2Female.Count > 0 && patientSex == "Male") { setTwoFlag = false; } else if (set2Male.Count > 0 && patientSex == "Female") { setTwoFlag = false; } } if (!setTwoFlag || !setOneFlag) { row["Deleted"] = 1; row.AcceptChanges(); } theForms.AcceptChanges(); } theForms.DefaultView.RowFilter = "Deleted <> 1"; return(theForms.DefaultView.ToTable()); }