private void button1_Click(object sender, EventArgs e) { string clid = mainPanel.stationid + mainPanel.lineid + "_" + dateTimePicker1.Value.ToString("yyyyMMdd"); if (vmasdal.Have_SelfCheckData(clid)) { SYS.Model.selfcheckdata checkdata = vmasdal.Get_SelfCheckData(clid); writeExcel.writeSelfCheckData(checkdata); } else { MessageBox.Show("没有检测到该日期的自检记录", "提示!"); } //string selfcheckid = mainPanel.stationid + mainPanel.lineid + "_" + DateTime.Now.ToString("yyyyMMdd"); }
public void display_Vmas(string clid) { SYS.Model.selfcheckdata vmas_data = vmasdal.Get_SelfCheckData(clid); }
public static bool writeSelfCheckData(SYS.Model.selfcheckdata cgjdata) { Microsoft.Office.Interop.Excel.Application appexcel = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbooks appworkbook = (Microsoft.Office.Interop.Excel.Workbooks)appexcel.Workbooks; if (File.Exists(Application.StartupPath + "\\bk\\自检日志.xls")) { string filename = Application.StartupPath + "\\bk\\检测信息" + DateTime.Now.ToString("yyMMdd") + ".xls"; if (!File.Exists(filename)) { File.Copy(Application.StartupPath + "\\bk\\自检日志.xls", filename, true); } appworkbook.Open(filename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); Microsoft.Office.Interop.Excel.Workbook objbook = appworkbook.get_Item(1); Microsoft.Office.Interop.Excel.Sheets msheets = (Microsoft.Office.Interop.Excel.Sheets)objbook.Worksheets; Microsoft.Office.Interop.Excel._Worksheet objsheet = (Microsoft.Office.Interop.Excel._Worksheet)msheets.get_Item(1); Microsoft.Office.Interop.Excel.Range m_objRange = (Microsoft.Office.Interop.Excel.Range)objsheet.get_Range("A1", "F30"); objsheet.Cells[2, 2] = cgjdata.WORKTIME.ToString("yyyy-MM-dd"); objsheet.Cells[2, 4] = cgjdata.WORKTIME.ToString("HH:mm:ss"); objsheet.Cells[2, 6] = cgjdata.WORKER; if (cgjdata.ISCGJCHECK == "Y") { objsheet.Cells[18, 3] = (cgjdata.CGJTX == "Y") ? "√正常" : "□正常"; objsheet.Cells[18, 4] = (cgjdata.CGJTX == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[19, 3] = (cgjdata.CGJYR == "Y") ? "√正常" : "□正常"; objsheet.Cells[19, 4] = (cgjdata.CGJYR == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[20, 3] = (cgjdata.CGJQL == "Y") ? "√正常" : "□正常"; objsheet.Cells[20, 4] = (cgjdata.CGJQL == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[21, 3] = (cgjdata.CGJJSGL == "Y") ? "√正常" : "□正常"; objsheet.Cells[21, 4] = (cgjdata.CGJJSGL == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[24, 3] = (cgjdata.CGJJZHX == "Y") ? "√正常" : "□正常"; objsheet.Cells[24, 4] = (cgjdata.CGJJZHX == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[21, 6] = cgjdata.CGJEDGL; objsheet.Cells[22, 6] = cgjdata.CGJSJGL; objsheet.Cells[23, 6] = cgjdata.CGJGLWC; objsheet.Cells[24, 6] = cgjdata.CGJVITRUALTIME; objsheet.Cells[25, 6] = cgjdata.CGJREALTIME; objsheet.Cells[26, 6] = cgjdata.CGJTIMEWC; } if (cgjdata.ISQXZCHECK == "Y") { objsheet.Cells[5, 3] = (cgjdata.TEMPOK == "Y") ? "√正常" : "□正常"; objsheet.Cells[5, 4] = (cgjdata.TEMPOK == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[6, 3] = (cgjdata.HUMIOK == "Y") ? "√正常" : "□正常"; objsheet.Cells[6, 4] = (cgjdata.HUMIOK == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[7, 3] = (cgjdata.AIRPOK == "Y") ? "√正常" : "□正常"; objsheet.Cells[7, 4] = (cgjdata.AIRPOK == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[5, 6] = cgjdata.TEMP; objsheet.Cells[6, 6] = cgjdata.HUMI; objsheet.Cells[7, 6] = cgjdata.AIRP; } if (cgjdata.ISFQYCHECK == "Y") { objsheet.Cells[8, 3] = (cgjdata.FQYTX == "Y") ? "√正常" : "□正常"; objsheet.Cells[8, 4] = (cgjdata.FQYTX == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[9, 3] = (cgjdata.FQYYR == "Y") ? "√正常" : "□正常"; objsheet.Cells[9, 4] = (cgjdata.FQYYR == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[10, 3] = (cgjdata.FQYTL == "Y") ? "√正常" : "□正常"; objsheet.Cells[10, 4] = (cgjdata.FQYTL == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[11, 3] = (cgjdata.FQYJL == "Y") ? "√正常" : "□正常"; objsheet.Cells[11, 4] = (cgjdata.FQYJL == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[12, 3] = (cgjdata.FQYLC == "Y") ? "√正常" : "□正常"; objsheet.Cells[12, 4] = (cgjdata.FQYLC == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[12, 6] = cgjdata.FQYO2; } if (cgjdata.ISBTGCHECK == "Y") { objsheet.Cells[13, 3] = (cgjdata.BTGTX == "Y") ? "√正常" : "□正常"; objsheet.Cells[13, 4] = (cgjdata.BTGTX == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[14, 3] = (cgjdata.BTGYR == "Y") ? "√正常" : "□正常"; objsheet.Cells[14, 4] = (cgjdata.BTGYR == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[15, 3] = (cgjdata.BTGTL == "Y") ? "√正常" : "□正常"; objsheet.Cells[15, 4] = (cgjdata.BTGTL == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[16, 3] = (cgjdata.BTGLC == "Y") ? "√正常" : "□正常"; objsheet.Cells[16, 4] = (cgjdata.BTGLC == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[17, 3] = (cgjdata.BTGJZ == "Y") ? "√正常" : "□正常"; objsheet.Cells[17, 4] = (cgjdata.BTGJZ == "Y") ? "□不正常" : "√不正常"; } if (cgjdata.ISZSJCHECK == "Y") { objsheet.Cells[29, 3] = (cgjdata.ZSJTX == "Y") ? "√正常" : "□正常"; objsheet.Cells[29, 4] = (cgjdata.ZSJTX == "Y") ? "□不正常" : "√不正常"; objsheet.Cells[30, 3] = (cgjdata.ZSJLC == "Y") ? "√正常" : "□正常"; objsheet.Cells[30, 4] = (cgjdata.ZSJLC == "Y") ? "□不正常" : "√不正常"; } System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objRange); m_objRange = null; //objbook.Save(); //appworkbook.Close(); //调用方法关闭excel进程 appexcel.Visible = true; return(true); } else { return(false); } }