private void button1_Click(object sender, EventArgs e) { try { int RowAnalyzes = DB.DataTable("select celendarRAid,price, Analysisname from Analyzes A,celendarRA CRA ,RequiredAnalysis RA where A.Analysisnumber = RA.Analysisnumber and RA.RequiredAnalysisid = CRA.RequiredAnalysisid and RA.Admissionid = @Admissionid ", new SqlParameter("@Admissionid", int.Parse(textBox1.Text))).Rows.Count; int RowPictures = DB.DataTable("select celendarRPid,price,picturesname from pictures P,Requiredpictures RP,celendarRP CRP where P.picturesid=RP.picturesid and RP.Requiredpicturesid=CRP.Requiredpicturesid and RP.Admissionid=@Admissionid ", new SqlParameter("@Admissionid", int.Parse(textBox1.Text))).Rows.Count; if (RowAnalyzes != 0) { dataGridView1.DataSource = DB.DataTable("select celendarRAid,price, Analysisname from Analyzes A,celendarRA CRA ,RequiredAnalysis RA where A.Analysisnumber = RA.Analysisnumber and RA.RequiredAnalysisid = CRA.RequiredAnalysisid and RA.Admissionid = @Admissionid ", new SqlParameter("@Admissionid", int.Parse(textBox1.Text))); } if (RowPictures != 0) { dataGridView2.DataSource = DB.DataTable("select celendarRPid,price,picturesname from pictures P,Requiredpictures RP,celendarRP CRP where P.picturesid=RP.picturesid and RP.Requiredpicturesid=CRP.Requiredpicturesid and RP.Admissionid=@Admissionid ", new SqlParameter("@Admissionid", int.Parse(textBox1.Text))); } //جلب مجموع اسعار التحاليل com = new SqlCommand("select sum(price) from Analyzes A,celendarRA CRA ,RequiredAnalysis RA where A.Analysisnumber = RA.Analysisnumber and RA.RequiredAnalysisid = CRA.RequiredAnalysisid and RA.Admissionid = @Admissionid ", con); com.Parameters.AddWithValue("@Admissionid", int.Parse(textBox1.Text)); //لجلب مجموع اسعار الصور SqlCommand comm = new SqlCommand("select sum(price) from pictures P,Requiredpictures RP,celendarRP CRP where P.picturesid=RP.picturesid and RP.Requiredpicturesid=CRP.Requiredpicturesid and RP.Admissionid=@Admissionid ", con); comm.Parameters.AddWithValue("@Admissionid", int.Parse(textBox1.Text)); con.Open(); int A = 0; if (RowAnalyzes != 0) { A = Convert.ToInt32(com.ExecuteScalar()); } int P = 0; if (RowPictures != 0) { P = Convert.ToInt32(comm.ExecuteScalar()); } //لجمع حق الصور والتحاليل وتكاليف المتربة AP = A + P + (Convert.ToDouble(textBox2.Text)); label8.Text = AP.ToString(); con.Close(); //لجلب الدفعة الاولية SqlCommand ccom = new SqlCommand("select DownPayment from patientAdmission where Admissionid=@Admissionid ", con); ccom.Parameters.AddWithValue("@Admissionid", int.Parse(textBox1.Text)); con.Open(); q = Convert.ToDouble(ccom.ExecuteScalar()); label10.Text = q.ToString(); con.Close(); //التأمين t = AP * (Convert.ToDouble(textBox3.Text) / 100); //الضرائب da = (Convert.ToDouble(textBox4.Text)); //مجموع الاخير AP = AP - t; //شرائح نسبة الحسم if (AP < 15000) { ma = (AP + da) - (q); label15.Text = ma.ToString(); label16.Text = "0"; return; } if (AP >= 15000 && AP <= 20000) { ma = (AP + da) - (q + 1000); label15.Text = ma.ToString(); label16.Text = "1000"; return; } if (AP > 20000 && AP <= 30000) { ma = (AP + da) - (q + 2000); label15.Text = ma.ToString(); label16.Text = "2000"; return; } if (AP > 30000 && AP <= 50000) { ma = (AP + da) - (q + 4000); label15.Text = ma.ToString(); label16.Text = "4000"; return; } else { ma = (AP + da) - (q + 5000); label15.Text = ma.ToString(); label16.Text = "5000"; return; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
static void Main(string[] args) { List <List <int> > RPs = new List <List <int> >(); List <int> N = new List <int> { }; List <int> M = new List <int> { }; List <int> F = new List <int> { }; RPs.Add(N); //RPs[0] is Near Set RPs.Add(M); //RPs[1] is Medium Set RPs.Add(F); //RPs[2] is Far Set List <data_all> DataRes = new List <data_all>(); List <fuzzy_label> LabelRes = new List <fuzzy_label>(); fuzzy_membership_created uploadData = new fuzzy_membership_created(); foreach (int AP in APs) { //N LabelRes.Clear(); LabelRes = Get_fuzzy_label_N(AP); foreach (var data in LabelRes) { RPs[0].Add(data.Position); } //RPs[0].ForEach(Console.Write); foreach (int Position in RPs[0]) { DataRes.Clear(); DataRes = Get_data_all_PosMinor(Position, AP); foreach (var data in DataRes) { if (data.RSS <= 0) { allData.Add(data.RSS); } } } updateValue(); Console.WriteLine("AP:" + AP.ToString() + " N"); Console.WriteLine(" S: " + allData.Count + " S.D: " + sd + " Mean: " + mean); uploadData.BeaconMinor = AP; uploadData.Label = "N"; uploadData.Samples = allData.Count; uploadData.Max = (int)Max; uploadData.Min = (int)Min; uploadData.Mean = mean; uploadData.SD = sd; UploadMembership(uploadData); dataClear(); RPs[0].Clear(); Console.WriteLine(); //M LabelRes.Clear(); LabelRes = Get_fuzzy_label_M(AP); foreach (var data in LabelRes) { RPs[1].Add(data.Position); } //RPs[1].ForEach(Console.Write); foreach (int Position in RPs[1]) { DataRes.Clear(); DataRes = Get_data_all_PosMinor(Position, AP); foreach (var data in DataRes) { if (data.RSS <= 0) { allData.Add(data.RSS); } } } updateValue(); Console.WriteLine("AP:" + AP.ToString() + " M"); Console.WriteLine(" S: " + allData.Count + " S.D: " + sd + " Mean: " + mean); uploadData.BeaconMinor = AP; uploadData.Label = "M"; uploadData.Samples = allData.Count; uploadData.Max = (int)Max; uploadData.Min = (int)Min; uploadData.Mean = mean; uploadData.SD = sd; UploadMembership(uploadData); dataClear(); RPs[1].Clear(); Console.WriteLine(); //F LabelRes.Clear(); LabelRes = Get_fuzzy_label_F(AP); foreach (var data in LabelRes) { RPs[2].Add(data.Position); } RPs[2].ForEach(Console.Write); foreach (int Position in RPs[2]) { DataRes.Clear(); DataRes = Get_data_all_PosMinor(Position, AP); foreach (var data in DataRes) { if (data.RSS <= 0) { allData.Add(data.RSS); } } } updateValue(); Console.WriteLine("AP:" + AP.ToString() + " F"); Console.WriteLine(" S: " + allData.Count + " S.D: " + sd + " Mean: " + mean); uploadData.BeaconMinor = AP; uploadData.Label = "F"; uploadData.Samples = allData.Count; uploadData.Max = (int)Max; uploadData.Min = (int)Min; uploadData.Mean = mean; uploadData.SD = sd; UploadMembership(uploadData); dataClear(); RPs[2].Clear(); Console.WriteLine(); } Console.WriteLine("Finished, Press Any Key to stop the program"); Console.ReadKey(); }