private void dtAddict_CellEndEdit(object sender, DataGridViewCellEventArgs e) { string updateID = dtAddict.Rows[e.RowIndex].Cells[0].Value.ToString(); _addiction = new Addiction(updateID, dtAddict.Rows[e.RowIndex].Cells[1].Value.ToString(), dtAddict.Rows[e.RowIndex].Cells[2].Value.ToString(), PatientID, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID); DBConnect.Update(_addiction, updateID); }
public void CalculateTest(double firstValue, double secondValue, double expected) { var calculator = new Addiction(); var actualResult = calculator.Calculate(firstValue, secondValue); Assert.AreEqual(expected, actualResult, 0.001); }
private void saveBtn_Click(object sender, EventArgs e) { if (nameTxt.Text == "") { nameTxt.BackColor = Color.Red; return; } string id = Guid.NewGuid().ToString(); if (chronicBtn.Checked == true) { _chronic = new Chronic(id, nameTxt.Text, descriptionTxt.Text, PatientID, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID); DBConnect.Insert(_chronic); } if (allergyBtn.Checked == true) { _allergy = new Allergy(id, nameTxt.Text, descriptionTxt.Text, PatientID, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID); DBConnect.Insert(_allergy); } if (additBtn.Checked == true) { _addiction = new Addiction(id, nameTxt.Text, descriptionTxt.Text, PatientID, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID); DBConnect.Insert(_addiction); } nameTxt.Text = ""; descriptionTxt.Text = ""; MessageBox.Show("Information Saved"); LoadAddiction(PatientID); LoadAllergy(PatientID); LoadChronic(PatientID); }
public Addiction(Addiction addiction) { _addictionType = addiction._addictionType; _addictionChance = addiction._addictionChance; _withdrawDelay = addiction._withdrawDelay; _withdrawDelayLength = addiction._withdrawDelayLength; _addictWithdraw = addiction._addictWithdraw; _withdrawLength = addiction._withdrawLength; _effects = addiction._effects; }
private static bool AddictionMatchesType(Addiction addiction, Effect.DelayLength length) { var info = addiction.GetWithdrawInfo; if (!info.nowInWithdraw) { return(addiction.WithdrawDelayLength == length); } else { return(addiction.WithdrawLength == length); } }
private void LoadAddiction(string patID) { _addictions = Addiction.ListAddiction(patID); tr = new DataTable(); // create and execute query tr.Columns.Add("id"); //2 tr.Columns.Add("Name"); //2 tr.Columns.Add("Description"); // tr.Columns.Add("Created"); // tr.Columns.Add("Delete"); // foreach (Addiction r in _addictions) { tr.Rows.Add(new object[] { r.Id, r.Name, r.Description, r.Created, "Delete" }); } dtAddict.DataSource = tr; dtAddict.AllowUserToAddRows = false; dtAddict.Columns[0].Visible = false; dtAddict.Columns[4].DefaultCellStyle.BackColor = Color.Aquamarine; }
public void SetValues(Addiction newAddiction) { _withdrawDelay = newAddiction._withdrawDelay; _addictWithdraw = newAddiction._addictWithdraw; _withdrawStarted = newAddiction._withdrawStarted; }
public async void UpdateGraphView() { List <String> diseaseListRepeatedValues = new List <string>(); List <String> allergyListRepeatedValues = new List <string>(); List <String> addictionListRepeatedValues = new List <string>(); List <String> vaccinationListRepeatedValues = new List <string>(); List <String> operationListRepeatedValues = new List <string>(); List <String> cityListRepeatedValues = new List <string>(); Sex.Clear(); City.Clear(); Blood.Clear(); Married.Clear(); Addiction.Clear(); Allergy.Clear(); Operation.Clear(); Vaccine.Clear(); Disease.Clear(); foreach (var i in resultList) { diseaseListRepeatedValues.AddRange(i.Diseases.Values.ToList()); allergyListRepeatedValues.AddRange(i.Allergy); operationListRepeatedValues.AddRange(i.Operation); addictionListRepeatedValues.AddRange(i.Addiction); vaccinationListRepeatedValues.AddRange(i.Vaccines.Values.ToList()); cityListRepeatedValues.Add(i.City); } //displaying sex pie chart int x = resultList.Count(i => i.Sex == 'M'); window = CoreWindow.GetForCurrentThread(); window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate { if (resultList.Count() != 0) { Sex.Add(new TestClass() { Category = "Male", Number = (int)Math.Round((double)x * 100 / resultList.Count()) }); Sex.Add(new TestClass() { Category = "Female", Number = (int)Math.Round((double)100 * (resultList.Count() - x) / resultList.Count()) }); } else { sexGraph.ChartSubTitle = "No results found"; } }); //display married pie chart int y = resultList.Count(i => i.Married == true); window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate { if (resultList.Count() != 0) { Married.Add(new TestClass() { Category = "Married", Number = (int)Math.Round((double)y * 100 / resultList.Count()) }); Married.Add(new TestClass() { Category = "Unmarried", Number = (int)Math.Round(((double)resultList.Count() - y) * 100 / resultList.Count()) }); } else { marriedGraph.ChartSubTitle = "No results found"; } }); window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate { //display cities graph foreach (var i in cityListRepeatedValues.Distinct()) { City.Add(new TestClass() { Category = i, Number = cityListRepeatedValues.Count(j => j.Equals(i)) }); } if (City.Count == 0) { cityGraph.ChartSubTitle = "No results found"; } }); window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate { //display blood group chart List <String> bloodgrp = new List <string>(); foreach (var i in resultList) { bloodgrp.Add(i.BloodGroup); } foreach (var i in bloodgrp.Distinct()) { Blood.Add(new TestClass() { Category = i.ToString(), Number = resultList.Count(j => j.BloodGroup.Equals(i.ToString())) }); } if (Blood.Count == 0) { bloodGraph.ChartSubTitle = "No results found"; } }); window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate { //display disease graph foreach (var i in diseaseListRepeatedValues.Distinct()) { Disease.Add(new TestClass() { Category = i.ToString(), Number = diseaseListRepeatedValues.Count(j => j.Equals(i)) }); } if (Disease.Count == 0) { diseaseGraph.ChartSubTitle = "No diseases found"; } }); window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate { //display addictions graph foreach (var i in addictionListRepeatedValues.Distinct()) { Addiction.Add(new TestClass() { Category = i.ToString(), Number = addictionListRepeatedValues.Count(j => j.Equals(i)) }); } if (Addiction.Count == 0) { addictionGraph.ChartSubTitle = "No addictions found"; } }); window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate { //display addictions graph //display operations graph foreach (var i in operationListRepeatedValues.Distinct()) { Operation.Add(new TestClass() { Category = i.ToString(), Number = operationListRepeatedValues.Count(j => j.Equals(i.ToString())) }); } if (Operation.Count == 0) { operationGraph.ChartSubTitle = "No operations found"; } }); window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate { foreach (var i in allergyListRepeatedValues.Distinct()) { Allergy.Add(new TestClass() { Category = i.ToString(), Number = allergyListRepeatedValues.Count(j => j.Equals(i.ToString())) }); } if (Allergy.Count == 0) { allergyGraph.ChartSubTitle = "No allergies found"; } }); window.Dispatcher.RunAsync(CoreDispatcherPriority.Low, delegate { //display vaccine graph foreach (var i in vaccinationListRepeatedValues.Distinct()) { Vaccine.Add(new TestClass() { Category = i.ToString(), Number = vaccinationListRepeatedValues.Count(j => j.Equals(i.ToString())) }); } if (Vaccine.Count == 0) { vaccineGraph.ChartSubTitle = "No vaccinations found"; } }); }
private void TriggerAddiction(Addiction addiction) { _activeAddictions.Add(new Addiction(addiction)); //TODO finish this logic }
private static void ResetAddiction(Addiction existingAddiction, Addiction newAddiction) { existingAddiction.SetValues(newAddiction); }