/// <summary> /// 开关按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { dt = Export_All_SY.DBQuery(tb); if (this.button1.Text == "开") { if (dt.Rows.Count > 0) { MessageBox.Show("数据库中已有数据,请进行下一个实验或点击重新实验"); return; } timer1.Start(); this.button1.Text = "关"; this.button1.BackColor = Color.SandyBrown; } else if (this.button1.Text == "关") { timer1.Enabled = false; this.button1.Text = "开"; this.button1.BackColor = Color.FloralWhite; this.pictureBox1.Image = Properties.Resources.Start; this.pictureBox2.Image = Properties.Resources.Start; this.pictureBox3.Image = Properties.Resources.Start; this.pictureBox4.Image = Properties.Resources.Start; this.pictureBox5.Image = Properties.Resources.Start; this.pictureBox6.Image = Properties.Resources.Start; this.pictureBox7.Image = Properties.Resources.Start; this.pictureBox8.Image = Properties.Resources.Start; } }
static iTextSharp.text.Font fonttitle3 = new iTextSharp.text.Font(bf1, 10); //表格內容字体,大小15 public static void Exp_SY1_SY2() { PdfReader pdfReader; PdfStamper pdfStamper; AcroFields pdfFormFields; BaseFont bf1 = BaseFont.CreateFont("C:\\Windows\\Fonts\\SIMSUN.TTC,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); //文件保存的真正路径 String tempname = getfilename(); if (tempname == "") { return; } string path = AppDomain.CurrentDomain.BaseDirectory; int flag = 1; path = System.IO.Directory.GetParent(path).Parent.Parent.FullName + "\\SY1_SY2_MB.pdf"; //MessageBox.Show(path); pdfReader = new PdfReader(path);//模板的路径 pdfStamper = new PdfStamper(pdfReader, new FileStream(tempname, FileMode.OpenOrCreate)); pdfFormFields = pdfStamper.AcroFields; pdfStamper.FormFlattening = true; pdfFormFields.AddSubstitutionFont(bf1); dtb = Export_All_SY.DBQuery("Sy1_Fdsk"); Export_All_SY.DBDel("Sy1_Fdsk"); Export_Table_Design.SY1_Table(pdfFormFields, ref flag, dtb); flag = 1; dtb = Export_All_SY.DBQuery("Sy2_Gzzd"); Export_All_SY.DBDel("Sy2_Gzzd"); Export_Table_Design.SY2_Table(pdfFormFields, ref flag, dtb); pdfStamper.Close(); pdfReader.Close(); }
public static void Exp_HPSY() { String tempname = getfilename(); if (tempname == "") { return; } Document document = new Document(); document.SetPageSize(PageSize.A4.Rotate()); // 设置文档为横向 PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(tempname, FileMode.Create)); document.Open(); document.NewPage(); table = new PdfPTable(13);// 设计试验8的表格总共有13列 table.WidthPercentage = 100; Paragraph Title1 = new Paragraph("7. 滑板控制装置(I型车)火炮联锁试验记录", fonttitle); Title1.SetAlignment("center"); document.Add(Title1); nullb = new Paragraph(" ", fonttitle2); nullb.Leading = 10; //此数值用于调整空白大小0 document.Add(nullb); dtb = Export_All_SY.DBQuery("SY8_Hplx"); table = Export_Table_Design.SY8_Table(table, dtb); Export_All_SY.DBDel("SY8_Hplx"); document.Add(table); //將table放到pdf文件中 Title1 = new Paragraph("注:试验中“√”表示动作正常,“×”表示动作异常", fonttitle3); document.Add(Title1); //将标题段加入PDF文档中 document.Close(); }
public static void Exp_SY6() { String tempname = getfilename(); if (tempname == "") { return; } Document document = new Document(); document.SetPageSize(PageSize.A4.Rotate()); // 设置文档为横向 PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(tempname, FileMode.Create)); document.Open(); document.NewPage(); table = new PdfPTable(21);// 设计试验6的表格总共有21列 table.WidthPercentage = 100; Paragraph Title = new Paragraph("6. 滑板控制装置系统调试精度试验记录", fonttitle); Title.SetAlignment("center"); document.Add(Title); nullb = new Paragraph(" ", fonttitle2); nullb.Leading = 10; //此数值用于调整空白大小0 document.Add(nullb); dtb = Export_All_SY.DBQuery("SY6_Xtts"); table = Export_Table_Design.SY6_Table(table, dtb); Export_All_SY.DBDel("SY6_Xtts"); document.Add(table);//將table放到pdf文件中 Title = new Paragraph("注:表中θ表示尾翼板角度,β表示首下板角度,φ表示首上板角度", fonttitle3); Title.SetAlignment("center"); document.Add(Title); //将标题段加入PDF文档中 document.Close(); }
public static void Exp_SY3_SY4() { String tempname = getfilename(); if (tempname == "") { return; } Document document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(tempname, FileMode.Create)); document.Open(); table = new PdfPTable(3);// 设计试验3的表格总共有3列 table.WidthPercentage = 82; table.SetTotalWidth(new float[] { 100f, 200f, 250f }); ///表頭設計 //添加段落,第二个参数指定使用fonttitle格式的字体,写入中文必须指定字体否则无法显示中文 Paragraph Title = new Paragraph("3. 滑板控制装置首板收板时间试验记录", fonttitle); Title.SetAlignment("center"); //设置居中 document.Add(Title); //将标题段加入PDF文档中 //空一行 nullb = new Paragraph(" ", fonttitle2); nullb.Leading = 10; //此数值用于调整空白大小0 document.Add(nullb); DataTable dtb = Export_All_SY.DBQuery("SY3_Timer"); //表格3设计单独做一个函数 table = Export_Table_Design.SY3_Table(table, dtb); Export_All_SY.DBDel("SY3_Timer"); document.Add(table); //空一行 nullb = new Paragraph(" ", fonttitle2); nullb.Leading = 60; //此数值用于调整空白大小0 document.Add(nullb); table = new PdfPTable(5); // 设计试验4的表格总共有5列 table.WidthPercentage = 82; table.SetTotalWidth(new float[] { 100f, 200f, 200f, 200f, 200f }); Title = new Paragraph("4. 滑板控制装置连续收板(手动20次)试验记录", fonttitle); Title.SetAlignment("center"); document.Add(Title); nullb = new Paragraph(" ", fonttitle2); nullb.Leading = 10; //此数值用于调整空白大小0 document.Add(nullb); dtb = Export_All_SY.DBQuery("SY4_Lxsb"); //表格4设计单独做一个函数 table = Export_Table_Design.SY4_Table(table, dtb); Export_All_SY.DBDel("SY4_Lxsb"); document.Add(table); //將table放到pdf文件中 Title = new Paragraph(" 注:试验中“√”表示动作正常,“×”表示动作异常", fonttitle3); document.Add(Title); //将标题段加入PDF文档中 document.Close(); }
public static void Exp_SY7() { Paragraph Title; String tempname = getfilename(); if (tempname == "") { return; } Document document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(tempname, FileMode.Create)); document.Open(); table = new PdfPTable(2);// 设计试验7的表格总共有6列 table.WidthPercentage = 100; if (MainFrom.comBoxData_Form == "HBK-II/1") { Title = new Paragraph("7. 滑板控制装置连续收板(程控20次)试验记录", fonttitle); } else { Title = new Paragraph("8. 滑板控制装置连续收板(程控20次)试验记录", fonttitle); } Title.SetAlignment("center"); document.Add(Title); nullb = new Paragraph(" ", fonttitle2); nullb.Leading = 10; //此数值用于调整空白大小0 document.Add(nullb); int flag = 1; PdfPTable table1 = new PdfPTable(6); PdfPTable table2 = new PdfPTable(6); dtb = Export_All_SY.DBQuery("SY7_Lxsb_Ck"); table1 = Export_Table_Design.SY7_Table1(table1, ref flag, dtb); //表格7设计单独做一个函数 table2 = Export_Table_Design.SY7_Table2(table2, ref flag, dtb); //表格7设计单独做一个函数 Export_All_SY.DBDel("SY7_Lxsb_Ck"); cell1 = new PdfPCell(table1); cell1.Padding = 0; table.AddCell(cell1); cell1 = new PdfPCell(table2); cell1.Padding = 0.5f; table.AddCell(cell1); document.Add(table); //將table放到pdf文件中 Title = new Paragraph(" 注:试验中“√”表示动作正常,“×”表示动作异常", fonttitle3); document.Add(Title); //将标题段加入PDF文档中 document.Close(); }
/// <summary> /// 控制模拟数据开始接受数据,(定时器的开始与暂停) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_open_Click(object sender, EventArgs e) { dt = Export_All_SY.DBQuery(tb); if (this.button_open.Text == "开") { if (dt.Rows.Count > 0) { MessageBox.Show("数据库中已有数据,请进行下一个实验或点击重新实验"); return; } this.button1.Enabled = true; this.hight_one.Enabled = true; this.higth_two.Enabled = true; this.hight_three.Enabled = true; timer_Show.Enabled = true; this.button_open.BackColor = Color.SandyBrown; this.button_open.Text = "关"; } else if (this.button_open.Text == "关") { if (this.button1.Text == "停止采集") { MessageBox.Show("请先关闭数据采集的线程开关!!!", "提示"); return; } timer_Show.Enabled = false; this.button_open.BackColor = Color.FloralWhite; this.label1.Text = " " + 0; this.label2.Text = " " + 0; this.label3.Text = " " + 0; this.label4.Text = " " + 0; this.label12.Text = " " + 0; this.label20.Text = " " + 0; this.button_open.Text = "开"; this.button1.Enabled = false; this.hight_one.Enabled = false; this.higth_two.Enabled = false; this.hight_three.Enabled = false; this.pictureBox1.Image = Properties.Resources.Start; this.pictureBox2.Image = Properties.Resources.Start; this.pictureBox3.Image = Properties.Resources.Start; this.pictureBox4.Image = Properties.Resources.Start; this.pictureBox5.Image = Properties.Resources.Start; } }
private void button1_Click(object sender, EventArgs e) { dt = Export_All_SY.DBQuery(tb); if (dt.Rows.Count > 0) { MessageBox.Show("数据库中已有数据,请进行下一个实验或点击重新实验"); return; } if (chB1.Checked == true) { checkData[0] = 1; } if (chB2.Checked == true) { checkData[1] = 1; } if (chB3.Checked == true) { checkData[2] = 1; } if (chB4.Checked == true) { checkData[3] = 1; } if (chB5.Checked == true) { checkData[4] = 1; } if (chB6.Checked == true) { checkData[5] = 1; } DateTime timer = DateTime.Now; String sqldata = "insert into [SY1_Fdsk](Ss_s,Ss_f,Sx_s,Sx_f,Wy_s,Wy_f,Insert_timer,Sy_user,P_no,C_no,Angle_no)" + " values(@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9,@a10,@a11)"; SqlHelper.ExecuteNonQuery(sqldata, new SqlParameter("@a1", checkData[0]), new SqlParameter("@a2", checkData[1]), new SqlParameter("@a3", checkData[2]), new SqlParameter("@a4", checkData[3]), new SqlParameter("@a5", checkData[4]), new SqlParameter("@a6", checkData[5]), new SqlParameter("@a7", timer), new SqlParameter("@a8", MainFrom.Uname), new SqlParameter("@a9", MainFrom.comBoxData_Form), new SqlParameter("@a10", MainFrom.textB_HbData_Form) , new SqlParameter("@a11", MainFrom.textB_CgqData_Form)); MessageBox.Show("数据提交成功,记得及时打印!!!"); }
/// <summary> /// 开启数据开关 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_open_Click(object sender, EventArgs e) { dt = Export_All_SY.DBQuery(tb); if (this.button_open.Text == "开") { if (dt.Rows.Count > 0) { MessageBox.Show("数据库中已有数据,请进行下一个实验或点击重新实验"); return; } t1 = new Thread(dj_AskMsg);//陀螺仪接收数据线程 timer_Six_Show.Start(); t1.Start(); this.button_open.BackColor = Color.SandyBrown; this.button_open.Text = "关"; } else if (this.button_open.Text == "关") { timer_Six_Show.Enabled = false; this.button_open.BackColor = Color.FloralWhite; if (t1.IsAlive) { t1.Abort(); } if (socket2 != null) { socket2.Close(); } this.label1.Text = "" + 0; this.label2.Text = "" + 0; this.label3.Text = "" + 0; this.label4.Text = "" + 0; this.label15.Text = "" + 0; this.label16.Text = "" + 0; this.label13.Text = "" + 0; this.label14.Text = "" + 0; this.button_open.Text = "开"; } }
private void button1_Click(object sender, EventArgs e) { dt = Export_All_SY.DBQuery(tb); if (dt.Rows.Count > 0) { MessageBox.Show("数据库中已有数据,请进行下一个实验或点击重新实验"); return; } string[] data_Beizhu = new string[8]; for (int i = 0; i < data_Beizhu.Length; i++) { data_Beizhu[i] = ""; } data_Beizhu[0] = textBox1.Text.Trim(); data_Beizhu[1] = textBox2.Text.Trim(); data_Beizhu[2] = textBox3.Text.Trim(); data_Beizhu[3] = textBox4.Text.Trim(); data_Beizhu[4] = textBox5.Text.Trim(); data_Beizhu[5] = textBox6.Text.Trim(); data_Beizhu[6] = textBox7.Text.Trim(); data_Beizhu[7] = textBox8.Text.Trim(); int[] data_one = new int[24]; for (int i = 0; i < data_one.Length; i++) { data_one[i] = 0; } if (checkBox1.Checked == true) { data_one[0] = 1; } if (checkBox2.Checked == true) { data_one[1] = 1; } if (checkBox3.Checked == true) { data_one[2] = 1; } if (checkBox4.Checked == true) { data_one[3] = 1; } if (checkBox5.Checked == true) { data_one[4] = 1; } if (checkBox6.Checked == true) { data_one[5] = 1; } if (checkBox7.Checked == true) { data_one[6] = 1; } if (checkBox8.Checked == true) { data_one[7] = 1; } if (checkBox9.Checked == true) { data_one[8] = 1; } if (checkBox10.Checked == true) { data_one[9] = 1; } if (checkBox11.Checked == true) { data_one[10] = 1; } if (checkBox12.Checked == true) { data_one[11] = 1; } if (checkBox13.Checked == true) { data_one[12] = 1; } if (checkBox14.Checked == true) { data_one[13] = 1; } if (checkBox15.Checked == true) { data_one[14] = 1; } if (checkBox16.Checked == true) { data_one[15] = 1; } if (checkBox17.Checked == true) { data_one[16] = 1; } if (checkBox18.Checked == true) { data_one[17] = 1; } if (checkBox19.Checked == true) { data_one[18] = 1; } if (checkBox20.Checked == true) { data_one[19] = 1; } if (checkBox21.Checked == true) { data_one[20] = 1; } if (checkBox22.Checked == true) { data_one[21] = 1; } if (checkBox23.Checked == true) { data_one[22] = 1; } if (checkBox24.Checked == true) { data_one[23] = 1; } C_no++; if (C_no == 2) { this.button1.Enabled = false; this.button2.Enabled = true; this.button3.Enabled = false; } string[] Gk = new string[8]; Gk[0] = "陆上"; Gk[1] = "低速"; Gk[2] = "中速"; Gk[3] = "高速"; Gk[4] = "应急"; Gk[5] = "中速"; Gk[6] = "低速"; Gk[7] = "陆上"; //插入数据库 String sqldata; for (int i = 0; i < 8; i++) { DateTime timer = DateTime.Now; sqldata = "insert into [SY7_Lxsb_Ck](Gk,Ss_b,Sx_b,Wy_b,Beizhu,Insert_timer,Sy_user,P_no,C_no,Angle_no)" + " values(@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9,@a10)"; SqlHelper.ExecuteNonQuery(sqldata, new SqlParameter("@a1", Gk[i]), new SqlParameter("@a2", data_one[3 * i]), new SqlParameter("@a3", data_one[3 * i + 1]), new SqlParameter("@a4", data_one[3 * i + 2]), new SqlParameter("@a5", data_Beizhu[i]), new SqlParameter("@a6", timer), new SqlParameter("@a7", MainFrom.Uname), new SqlParameter("@a8", MainFrom.comBoxData_Form), new SqlParameter("@a9", MainFrom.textB_HbData_Form), new SqlParameter("@a10", MainFrom.textB_CgqData_Form)); } }
private void Second_Btn_Result_Click(object sender, EventArgs e) { dt = Export_All_SY.DBQuery(tb); if (dt.Rows.Count > 0) { MessageBox.Show("数据库中已有数据,请进行下一个实验或点击重新实验"); return; } int[] a = new int[15]; for (int i = 0; i < 15; i++) { a[i] = 0; } if (chB01.Checked == true) { a[0] = 1; } if (chB02.Checked == true) { a[1] = 1; } if (chB03.Checked == true) { a[2] = 1; } if (chB04.Checked == true) { a[3] = 1; } if (chB05.Checked == true) { a[4] = 1; } if (chB06.Checked == true) { a[5] = 1; } if (chB07.Checked == true) { a[6] = 1; } if (chB08.Checked == true) { a[7] = 1; } if (chB09.Checked == true) { a[8] = 1; } if (chB10.Checked == true) { a[9] = 1; } if (chB11.Checked == true) { a[10] = 1; } if (chB12.Checked == true) { a[11] = 1; } if (chB13.Checked == true) { a[12] = 1; } if (chB14.Checked == true) { a[13] = 1; } if (chB15.Checked == true) { a[14] = 1; } DateTime timer = DateTime.Now; String sqldata = "insert into [SY2_Gzzd](XH_G,YC_G,DD_D,DD_Z,DD_G,DL_D,DL_Z,DL_G,JT_D,JT_Z,DY_D,DY_Z,DY_G,DL_CK,KL_CK,Insert_timer,Sy_user,P_no,C_no,Angle_no)" + " values(@a1,@a2,@a3,@a4,@a5,@a6,@a7,@a8,@a9,@a10,@a11,@a12,@a13,@a14,@a15,@a16,@a17,@a18,@a19,@a20)"; SqlHelper.ExecuteNonQuery(sqldata, new SqlParameter("@a1", a[0]), new SqlParameter("@a2", a[1]), new SqlParameter("@a3", a[2]), new SqlParameter("@a4", a[3]), new SqlParameter("@a5", a[4]), new SqlParameter("@a6", a[5]), new SqlParameter("@a7", a[6]), new SqlParameter("@a8", a[7]), new SqlParameter("@a9", a[8]), new SqlParameter("@a10", a[9]), new SqlParameter("@a11", a[10]), new SqlParameter("@a12", a[11]), new SqlParameter("@a13", a[12]), new SqlParameter("@a14", a[13]), new SqlParameter("@a15", a[14]), new SqlParameter("@a16", timer), new SqlParameter("@a17", MainFrom.Uname), new SqlParameter("@a18", MainFrom.comBoxData_Form), new SqlParameter("@a19", MainFrom.textB_HbData_Form), new SqlParameter("@a20", MainFrom.textB_CgqData_Form)); MessageBox.Show("数据提交成功,记得及时打印!!!"); }