public Form2() { var compressorList = new List <String>(); InitializeComponent(); set_chart(20, -20, 75, 10); ysrongtiao_TB.Text = Convert.ToString(n); pqwendu_TB.Text = Convert.ToString(pqwdqiwang); zfwendu_textBox1.Text = Convert.ToString(5); lnwendu_textBox1.Text = Convert.ToString(40); xqguore_TB.Text = Convert.ToString(5); ytguoleng_TB.Text = Convert.ToString(5); string str = System.IO.Directory.GetCurrentDirectory(); String dir = str + "/Lisen.mdb"; mdbHelp = new readMDB(dir); try { mdbHelp.Open(); // 打開數據庫 System.Diagnostics.Debug.WriteLine(str); var ds = mdbHelp.GetDataSet("select * from 压缩机基础数据"); System.Diagnostics.Debug.WriteLine(ds.Tables[0].Rows[0]["压缩机型号"]); int row = ds.Tables[0].Rows.Count; for (int i = 0; i < row; i++) { compressorList.Add((String)ds.Tables[0].Rows[i][1]); } // mdbHelp.Close(); // 關閉數據庫 } finally { // mdbHelp = null; } cool_comboBox.DataSource = coolItems; compressor_comboBox.DataSource = compressorList; power_comboBox.DataSource = ysdianyuanItems; nrjibi_comboBox.DataSource = nrjibiItems; lqfangshi_combox.DataSource = lqfangshiItems; this.chart1.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; this.chart1.Series[0].Name = "Series1"; this.chart1.Series[1].Points.AddXY(0, 0); this.chart1.Series[0].BorderWidth = 3; chartArea2.AxisX.Interval = 5D; chartArea2.AxisX.Maximum = 20D; chartArea2.AxisX.Minimum = -20D; chartArea2.AxisY.Interval = 10D; chartArea2.AxisY.Maximum = 75D; chartArea2.AxisY.Minimum = 10D; //cal(); }
private void cal_button_Click(object sender, EventArgs e) { Double Te = 0; Double Tc = 0; Double SC = 0; Double SH = 0; Double Q1 = long.MaxValue, Q2 = long.MaxValue, Q, P1 = 0, P2 = 0; String xinghao1 = "", xinghao2 = ""; Double Qin = 0; Double I1 = 0, I2 = 0; if (zfwd_textBox.Text == "" || lnwd_textBox.Text == "" || ytgld_textBox.Text == "" || xqgrd_textBox.Text == "" || zll_textBox.Text == "") { showNullDialog(); } else { Te = Convert.ToDouble(zfwd_textBox.Text); Tc = Convert.ToDouble(lnwd_textBox.Text); SC = Convert.ToDouble(ytgld_textBox.Text); SH = Convert.ToDouble(xqgrd_textBox.Text); Qin = Convert.ToDouble(zll_textBox.Text); cool = zlj_comboBox.Text; nrjibi = nrjb_comboBox.Text; List <String> ysjxh_list = new List <String>(); dataset = mdbHelp.GetDataSet("select * from 压缩机基础数据"); dataset2 = mdbHelp.GetDataSet("select * from 制冷剂参数 where 滑阀型号='" + nrjibi + "'" + " and " + "制冷剂='" + cool + "'"); for (int i = 0; i < dataset.Tables[0].Rows.Count; i++) { ysjxh_list.Add(dataset.Tables[0].Rows[i]["压缩机型号"].ToString()); } foreach (String xinghao in ysjxh_list) { dataset = mdbHelp.GetDataSet("select * from 压缩机基础数据 where 压缩机型号=" + "'" + xinghao + "'"); Double[] res = calQ(Te, Tc, SC, SH); Q = res[0]; if (Math.Abs(Q - Qin) < Math.Abs(Q1 - Qin)) { Q1 = Q; P1 = res[1]; xinghao1 = xinghao; } else if (Math.Abs(Q - Qin) < Math.Abs(Q2 - Qin)) { Q2 = Q; P2 = res[1]; xinghao2 = xinghao; } I1 = P1 * 1000 / (3 * 220 * (B1 * n * n + B2 * n + B3)); I2 = P2 * 1000 / (3 * 220 * (B1 * n * n + B2 * n + B3)); Double Pe = PropsSI("P", "T", Te + 273.15, "Q", 1, cool); Double Pc = PropsSI("P", "T", Tc + 273.15, "Q", 1, cool); Double hs = PropsSI("H", "P", Pe, "T", Te + 273.15 + SH, cool); Double T1 = Tc - SC; Double hc = PropsSI("H", "P", Pc, "T", T1 + 273.15, cool); Double ms1 = Q1 / (hs - hc) * 3600 * 1000; Double ms2 = Q2 / (hs - hc) * 3600 * 1000; ysjxh1_textBox.Text = xinghao1; ysjxh2_textBox.Text = xinghao2; zll1_textBox.Text = Q1.ToString("0.0"); zll2_textBox.Text = Q2.ToString("0.0"); srgl1_textBox.Text = P1.ToString("0.0"); srgl2_textBox.Text = P2.ToString("0.0"); yxdl1_textBox.Text = I1.ToString("0.0"); yxdl2_textBox.Text = I2.ToString("0.0"); nxb1_textBox.Text = (Q1 / P1).ToString("0.0"); nxb2_textBox.Text = (Q2 / P2).ToString("0.0"); xqzlll1_textBox.Text = ms1.ToString("0.0"); xqzlll2_textBox.Text = ms2.ToString("0.0"); sheet1.GetRow(8).Cells[4].SetCellValue(Qin.ToString("0.0")); sheet1.GetRow(9).Cells[4].SetCellValue(cool); sheet1.GetRow(10).Cells[4].SetCellValue(gjdy_comboBox.Text); sheet1.GetRow(11).Cells[4].SetCellValue(zfwd_textBox.Text); sheet1.GetRow(12).Cells[4].SetCellValue(lnwd_textBox.Text); sheet1.GetRow(13).Cells[4].SetCellValue(nrjb_comboBox.Text); sheet1.GetRow(14).Cells[4].SetCellValue(ytgld_textBox.Text); sheet1.GetRow(15).Cells[4].SetCellValue(xqgrd_textBox.Text); sheet1.GetRow(22).Cells[3].SetCellValue(xinghao1); sheet1.GetRow(22).Cells[5].SetCellValue(xinghao2); sheet1.GetRow(23).Cells[3].SetCellValue(Q1.ToString("0.0")); sheet1.GetRow(23).Cells[5].SetCellValue(Q2.ToString("0.0")); sheet1.GetRow(24).Cells[3].SetCellValue(P1.ToString("0.0")); sheet1.GetRow(24).Cells[5].SetCellValue(P2.ToString("0.0")); sheet1.GetRow(25).Cells[3].SetCellValue(I1.ToString("0.0")); sheet1.GetRow(25).Cells[5].SetCellValue(I1.ToString("0.0")); sheet1.GetRow(26).Cells[3].SetCellValue((Q1 / P1).ToString("0.0")); sheet1.GetRow(26).Cells[5].SetCellValue((Q2 / P2).ToString("0.0")); sheet1.GetRow(27).Cells[3].SetCellValue(ms1.ToString("0.0")); sheet1.GetRow(27).Cells[5].SetCellValue(ms2.ToString("0.0")); } } }
private void jisuan_button_Click(object sender, EventArgs e) { xinghao = compressor_comboBox.Text; nrjibi = nrjibi_comboBox.Text; cool = cool_comboBox.Text; dataset = mdbHelp.GetDataSet("select * from 压缩机基础数据 where 压缩机型号='" + xinghao + "'"); dataset2 = mdbHelp.GetDataSet("select * from 制冷剂参数 where 滑阀型号='" + nrjibi + "'" + " and " + "制冷剂='" + cool + "'"); Double minn = readParam("最小容调"); if (zfwendu_textBox1.Text != "" && lnwendu_textBox1.Text != "" && xqguore_TB.Text != "" && ytguoleng_TB.Text != "" && pqwendu_TB.Text != "" && cool != "R407") { Te = Convert.ToDouble(zfwendu_textBox1.Text); Tc = Convert.ToDouble(lnwendu_textBox1.Text); SH = Convert.ToDouble(xqguore_TB.Text); SC = Convert.ToDouble(ytguoleng_TB.Text); n = Convert.ToDouble(ysrongtiao_TB.Text); pqwdqiwang = Convert.ToDouble(pqwendu_TB.Text); economyMode = (int)economy_mode.CheckState; this.chart1.Series[0].Points.Clear(); this.chart1.Series[1].Points.Clear(); this.chart1.Series[1].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastPoint; this.chart1.Series[1].Points.AddXY(Te, Tc); this.chart1.Series[1].BorderWidth = 5; this.chart1.Series[1].Color = Color.Red; int minX = 0; int maxX = 0; int minY = 0; int maxY = 0; if (cool == "R134a" && nrjibi == "Vr2.2") { vertx = Vr2_2R134arunRangeX; verty = Vr2_2R134arunRangeY; minX = -20; maxX = 20; minY = 15; maxY = 75; } else if (cool == "R134a" && nrjibi == "Vr3.0") { vertx = Vr3_0R134arunRangeX; verty = Vr3_0R134arunRangeY; minX = -25; maxX = 20; minY = 15; maxY = 75; } else if (cool == "R22" || cool == "R407" && nrjibi == "Vr2.2") { vertx = Vr2_2R22runrangeX; verty = Vr2_2R22runRangeY; minX = -25; maxX = 20; minY = 5; maxY = 75; } else if (cool == "R22" || cool == "R407" && nrjibi == "Vr3.0") { vertx = Vr3_0R22runRangeX; verty = Vr3_0R22runRangeY; minX = -35; maxX = 20; minY = 5; maxY = 75; } set_chart(minX, maxX, minY, maxY); drawChart(); for (int h = 0; h < 7; h++) { points[h] = new PointF(vertx[h], verty[h]); } PointF test = new PointF((float)(Te), (float)Tc); if (!PositionPnpoly(Vr2_2R134arunRangeX.Length, vertx, verty, Te, Tc) && !OnRegion(points, test)) { showDialog(); } else if (n > 100 || n < minn) { showDialog("压缩机容调状态" + Convert.ToString(minn) + "至" + "100"); } else if (pqwdqiwang < 75) { showDialog("排气期望温度需要大于75"); } else if (SH < 0.1) { showDialog("过热度最小值为0.1"); } else if (SC < 0.1) { showDialog("过冷度最小值为0.1"); } else { drawChart(); cal(); set_table(); } } else { showNullDialog(); } }