MyBllDemo bllDemo = new MyBllDemo(); //定义一个BLL层的类 private void btnAdd_Click(object sender, EventArgs e) { #region 面向过程:任务逐语句执行 //if(bllDemo.Operate(pName.Text, Age.Text, Sex.Text) > 0) //{ // MessageBox.Show("添加成功"); // pName.Clear(); // Age.Clear(); // Sex.Clear(); //} #endregion //面向对象:逐过程 InitData(); MyModelDemo model = new MyModelDemo(); if (bllDemo.Operate() > 0) { MessageBox.Show("添加成功"); pName.Clear(); Age.Clear(); Sex.Clear(); } Update(); }
private void btnModify_Click(object sender, EventArgs e) { if (txtID.Text.Length <= 0) { MessageBox.Show("请输入要修改的编号"); return; } else { if (mysql.Show("update Person set Name='" + Name.Text + "', Age = '" + Age.Text + "',Sex = '" + Sex.Text + "' where ID='" + txtID.Text + "' ") > 0) { MessageBox.Show("修改成功"); Name.Clear(); txtID.Clear(); Age.Clear(); Sex.Clear(); readContent.Items.Clear(); read(); } else { MessageBox.Show("没有该内容"); } } }
public void Clear() { Sex.Clear(); Status.Clear(); Country.Clear(); City.Clear(); Birth.Clear(); Interest.Clear(); Like.Clear(); Joined.Clear(); Limit = 0; Order = false; Keys = 0; KeyOrder.Clear(); }
MyVar mysql = new MyVar(); //定义一个myVar类 private void btnAdd_Click(object sender, EventArgs e) { if (Name.Text.Length <= 0) { MessageBox.Show("请输入下面相关信息"); return; } else { if (mysql.Show("insert into Person(Name, Age, Sex) values('" + Name.Text + "', '" + Age.Text + "', '" + Sex.Text + "')") > 0) { MessageBox.Show("添加成功"); Name.Clear(); Age.Clear(); Sex.Clear(); readContent.Items.Clear(); read(); } else { MessageBox.Show("添加失败"); } } }
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"; } }); }