private int AttemptCapture(MonsterObj monster) { // Algo is from g3/4. float a = (3 * monster.MaxHp - 2 * monster.CurrentHp) * monster.Base.CatchRate * ConditionDB.GetStatusBonus(monster.Status) / (3 * monster.MaxHp); if (a >= 255) { return(4); } float b = 1048560 / Mathf.Sqrt(Mathf.Sqrt(16711680 / a)); var beamCount = 0; while (beamCount < 4) { if (UnityEngine.Random.Range(0, 65535) >= b) { break; } ++beamCount; } return(beamCount); }
protected void FillGrid() { DataTable dt = ConditionDB.GetDataTable(chkShowDeleted.Checked); Session["condition_data"] = dt; if (dt.Rows.Count > 0) { GrdCondition.DataSource = dt; try { GrdCondition.DataBind(); } catch (Exception ex) { SetErrorMessage("", ex.ToString()); } //Sort("parent_descr", "ASC"); } else { dt.Rows.Add(dt.NewRow()); GrdCondition.DataSource = dt; GrdCondition.DataBind(); int TotalColumns = GrdCondition.Rows[0].Cells.Count; GrdCondition.Rows[0].Cells.Clear(); GrdCondition.Rows[0].Cells.Add(new TableCell()); GrdCondition.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdCondition.Rows[0].Cells[0].Text = "No Conditions Found"; } }
public static Hashtable GetHashtable(bool inc_deleted = false) { Hashtable hash = new Hashtable(); foreach (Condition condition in ConditionDB.GetAll(inc_deleted)) { hash[condition.ConditionID] = condition; } return(hash); }
public static PatientCondition LoadAll(DataRow row) { PatientCondition patientCondition = Load(row, "patient_condition_"); patientCondition.Condition = ConditionDB.Load(row, "condition_"); patientCondition.Patient = PatientDB.Load(row, "patient_"); patientCondition.Patient.Person = PersonDB.Load(row, "person_", "entity_id"); patientCondition.Patient.Person.Title = IDandDescrDB.Load(row, "title_title_id", "title_descr"); return(patientCondition); }
public static Condition[] GetAll(bool inc_deleted = false) { DataTable tbl = GetDataTable(inc_deleted); Condition[] list = new Condition[tbl.Rows.Count]; for (int i = 0; i < tbl.Rows.Count; i++) { list[i] = ConditionDB.Load(tbl.Rows[i], "condition_"); } return(list); }
protected void GrdCondition_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label lblId = (Label)GrdCondition.Rows[e.RowIndex].FindControl("lblId"); TextBox txtDescr = (TextBox)GrdCondition.Rows[e.RowIndex].FindControl("txtDescr"); DropDownList ddlDisplayOrder = (DropDownList)GrdCondition.Rows[e.RowIndex].FindControl("ddlDisplayOrder"); CheckBox chkShowDate = (CheckBox)GrdCondition.Rows[e.RowIndex].FindControl("chkShowDate"); CheckBox chkShowNWeeksDue = (CheckBox)GrdCondition.Rows[e.RowIndex].FindControl("chkShowNWeeksDue"); CheckBox chkShowText = (CheckBox)GrdCondition.Rows[e.RowIndex].FindControl("chkShowText"); Condition condition = ConditionDB.GetByID(Convert.ToInt32(lblId.Text)); ConditionDB.Update(Convert.ToInt32(lblId.Text), txtDescr.Text, chkShowDate.Checked, chkShowNWeeksDue.Checked, chkShowText.Checked, Convert.ToInt32(ddlDisplayOrder.SelectedValue), condition.IsDeleted); GrdCondition.EditIndex = -1; FillGrid(); }
protected void GrdCondition_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Insert")) { DropDownList ddlParent = (DropDownList)GrdCondition.FooterRow.FindControl("ddlNewParent"); TextBox txtDescr = (TextBox)GrdCondition.FooterRow.FindControl("txtNewDescr"); DropDownList ddlDisplayOrder = (DropDownList)GrdCondition.FooterRow.FindControl("ddlNewDisplayOrder"); CheckBox chkShowDate = (CheckBox)GrdCondition.FooterRow.FindControl("chkNewShowDate"); CheckBox chkShowNWeeksDue = (CheckBox)GrdCondition.FooterRow.FindControl("chkNewShowNWeeksDue"); CheckBox chkShowText = (CheckBox)GrdCondition.FooterRow.FindControl("chkNewShowText"); ConditionDB.Insert(txtDescr.Text, chkShowDate.Checked, chkShowNWeeksDue.Checked, chkShowText.Checked, Convert.ToInt32(ddlDisplayOrder.SelectedValue), false); FillGrid(); } if (e.CommandName.Equals("_Delete") || e.CommandName.Equals("_UnDelete")) { int id = Convert.ToInt32(e.CommandArgument); try { if (e.CommandName.Equals("_Delete")) { ConditionDB.UpdateInactive(id); } else { ConditionDB.UpdateActive(id); } } catch (ForeignKeyConstraintException fkcEx) { if (Utilities.IsDev()) { SetErrorMessage("Can not delete because other records depend on this : " + fkcEx.Message); } else { SetErrorMessage("Can not delete because other records depend on this"); } } FillGrid(); } }
private void Awake() { Instance = this; menuController = GetComponent <MenuController>(); // Disables Mouse /* * Cursor.lockState = CursorLockMode.Locked; * Cursor.visible = false; */ PieceDB.Init(); AbilityDB.Init(); ConditionDB.Init(); }
private void Awake() { Instance = this; ConditionDB.Init(); }
protected void lbSubtractOneDisplayOrderToAll_Click(object sender, EventArgs e) { ConditionDB.UpdateDisplayOrderAll(-1); FillGrid(); }
protected void FillGrdCondition(Patient patient = null) { if (patient == null) { patient = PatientDB.GetByID(GetFormPatientID()); } DataTable dt = ConditionDB.GetDataTable(false); Hashtable conditionHash = ConditionDB.GetHashtable(false); Session["patientcondition_data"] = dt; if (dt.Rows.Count > 0) { GrdCondition.DataSource = dt; try { GrdCondition.DataBind(); Hashtable selectedConditions = PatientConditionDB.GetHashtable_ByPatientID(patient.PatientID, false); foreach (GridViewRow row in GrdCondition.Rows) { Label lblId = row.FindControl("lblId") as Label; CheckBox chkSelect = row.FindControl("chkSelect") as CheckBox; DropDownList ddlDate_Day = (DropDownList)row.FindControl("ddlDate_Day"); DropDownList ddlDate_Month = (DropDownList)row.FindControl("ddlDate_Month"); DropDownList ddlDate_Year = (DropDownList)row.FindControl("ddlDate_Year"); DropDownList ddlNbrWeeksDue = (DropDownList)row.FindControl("ddlNbrWeeksDue"); Label lblNextDue = row.FindControl("lblNextDue") as Label; Label lblWeeksLater = row.FindControl("lblWeeksLater") as Label; Label lblAdditionalInfo = row.FindControl("lblAdditionalInfo") as Label; System.Web.UI.HtmlControls.HtmlControl br_date = (System.Web.UI.HtmlControls.HtmlControl)row.FindControl("br_date"); System.Web.UI.HtmlControls.HtmlControl br_nweeksdue = (System.Web.UI.HtmlControls.HtmlControl)row.FindControl("br_nweeksdue"); System.Web.UI.HtmlControls.HtmlControl br_text = (System.Web.UI.HtmlControls.HtmlControl)row.FindControl("br_text"); TextBox txtText = (TextBox)row.FindControl("txtText"); if (lblId == null || chkSelect == null) { continue; } Condition condition = (Condition)conditionHash[Convert.ToInt32(lblId.Text)]; br_date.Visible = condition.ShowDate; ddlDate_Day.Visible = condition.ShowDate; ddlDate_Month.Visible = condition.ShowDate; ddlDate_Year.Visible = condition.ShowDate; br_nweeksdue.Visible = condition.ShowNWeeksDue; ddlNbrWeeksDue.Visible = condition.ShowNWeeksDue; lblNextDue.Visible = condition.ShowNWeeksDue; lblWeeksLater.Visible = condition.ShowNWeeksDue; br_text.Visible = condition.ShowText; txtText.Visible = condition.ShowText; lblAdditionalInfo.Visible = condition.ShowText; if (selectedConditions[Convert.ToInt32(lblId.Text)] != null) { PatientCondition ptCondition = (PatientCondition)selectedConditions[Convert.ToInt32(lblId.Text)]; chkSelect.Checked = selectedConditions[Convert.ToInt32(lblId.Text)] != null; if (condition.ShowDate) { if (ptCondition.Date != DateTime.MinValue) { ddlDate_Day.SelectedValue = ptCondition.Date.Day.ToString(); ddlDate_Month.SelectedValue = ptCondition.Date.Month.ToString(); ddlDate_Year.SelectedValue = ptCondition.Date.Year.ToString(); } } if (condition.ShowNWeeksDue) { ddlNbrWeeksDue.SelectedValue = ptCondition.NWeeksDue.ToString(); } if (condition.ShowText) { txtText.Text = ptCondition.Text; } } } } catch (Exception ex) { SetErrorMessage("", ex.ToString()); } //Sort("parent_descr", "ASC"); } else { dt.Rows.Add(dt.NewRow()); GrdCondition.DataSource = dt; GrdCondition.DataBind(); int TotalColumns = GrdCondition.Rows[0].Cells.Count; GrdCondition.Rows[0].Cells.Clear(); GrdCondition.Rows[0].Cells.Add(new TableCell()); GrdCondition.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdCondition.Rows[0].Cells[0].Text = "No Record Found"; } }
protected void FillGrdConditionView(Patient patient = null) { if (patient == null) { patient = PatientDB.GetByID(GetFormPatientID()); } DataTable dt = ConditionDB.GetDataTable(false); Hashtable conditionHash = ConditionDB.GetHashtable(false); Session["patientconditionview_data"] = dt; if (dt.Rows.Count > 0) { GrdConditionView.DataSource = dt; try { GrdConditionView.DataBind(); Hashtable selectedConditions = PatientConditionDB.GetHashtable_ByPatientID(patient.PatientID, false); for (int i = GrdConditionView.Rows.Count - 1; i >= 0; i--) { Label lblId = GrdConditionView.Rows[i].FindControl("lblId") as Label; Label lblDate = GrdConditionView.Rows[i].FindControl("lblDate") as Label; Label lblNextDue = GrdConditionView.Rows[i].FindControl("lblNextDue") as Label; Label lblDateDue = GrdConditionView.Rows[i].FindControl("lblDateDue") as Label; Label lblAdditionalInfo = GrdConditionView.Rows[i].FindControl("lblAdditionalInfo") as Label; Label lblText = GrdConditionView.Rows[i].FindControl("lblText") as Label; System.Web.UI.HtmlControls.HtmlControl br_date = (System.Web.UI.HtmlControls.HtmlControl)GrdConditionView.Rows[i].FindControl("br_date"); System.Web.UI.HtmlControls.HtmlControl br_nweeksdue = (System.Web.UI.HtmlControls.HtmlControl)GrdConditionView.Rows[i].FindControl("br_nweeksdue"); System.Web.UI.HtmlControls.HtmlControl br_text = (System.Web.UI.HtmlControls.HtmlControl)GrdConditionView.Rows[i].FindControl("br_text"); if (lblId == null) { continue; } Condition condition = (Condition)conditionHash[Convert.ToInt32(lblId.Text)]; br_date.Visible = condition.ShowDate; lblDate.Visible = condition.ShowDate; br_nweeksdue.Visible = condition.ShowNWeeksDue; lblNextDue.Visible = condition.ShowNWeeksDue; lblDateDue.Visible = condition.ShowNWeeksDue; br_text.Visible = condition.ShowText; lblText.Visible = condition.ShowText; lblAdditionalInfo.Visible = condition.ShowText; if (selectedConditions[Convert.ToInt32(lblId.Text)] != null) { PatientCondition ptCondition = (PatientCondition)selectedConditions[Convert.ToInt32(lblId.Text)]; if (condition.ShowDate) { lblDate.Text = ptCondition.Date == DateTime.MinValue ? "[Date Not Set]" : ptCondition.Date.ToString("d MMM, yyyy"); } if (condition.ShowNWeeksDue) { bool expired = ptCondition.Date != DateTime.MinValue && ptCondition.Date.AddDays(7 * ptCondition.NWeeksDue) < DateTime.Today; lblDateDue.Text = ptCondition.Date == DateTime.MinValue ? "[Date Not Set]" : (expired ? "<font color=\"red\">" : "") + ptCondition.Date.AddDays(7 * ptCondition.NWeeksDue).ToString("d MMM, yyyy") + (expired ? "</font>" : ""); } if (condition.ShowText) { lblText.Text = ptCondition.Text.Length == 0 ? "[Blank]" : ptCondition.Text; } } else { GrdConditionView.Rows[i].Visible = false; } } } catch (Exception ex) { SetErrorMessage("", ex.ToString()); } //Sort("parent_descr", "ASC"); } else { dt.Rows.Add(dt.NewRow()); GrdConditionView.DataSource = dt; GrdConditionView.DataBind(); int TotalColumns = GrdConditionView.Rows[0].Cells.Count; GrdConditionView.Rows[0].Cells.Clear(); GrdConditionView.Rows[0].Cells.Add(new TableCell()); GrdConditionView.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdConditionView.Rows[0].Cells[0].Text = "No Record Found"; } }