private void SetQualFiles(string pSn, string pPlineCode) { Microsoft.Office.Interop.Excel.Application apps = new Microsoft.Office.Interop.Excel.Application(); //string filename = System.Windows.Forms.Application.StartupPath+"\\..\\.." + file_template; string filename = System.Windows.Forms.Application.StartupPath + file_template; object oMissing = System.Reflection.Missing.Value; Workbook _wkbook = apps.Workbooks.Open(filename, 0, true, 5, oMissing, oMissing, true, 1, oMissing, false, false, oMissing, false, oMissing, oMissing); Worksheet _wksheet = _wkbook.Sheets["sheet1"]; //OPCStationEntity aa=OPCStationFactory.GetByPlineCode( //List<OPCTagsEntity> qual_list=OPCTagsFactory.GetQualityItems( //_wksheet.Cells[1,7]="123"; //_wksheet.Range["G1"].Value = "123"; List <SNDetectdDataEntity> lst_detect = SNDetectFactory.GetByPlineCodeSn(theCompanyCode, pPlineCode, pSn); foreach (OPCTagsEntity s in OPC_TAGS) { SNDetectdDataEntity detect_data = (from p in lst_detect where p.DETECT_DATA_CODE == s.OPC_TAG_NAME select p).First(); //string ssi = _wksheet.Range[s.OPC_TAG_NAME].Value; string detect_value = detect_data.DETECT_DATA_VALUE.ToUpper(); if (detect_value == "TRUE") { detect_value = "合格"; } else if (detect_value == "FALSE") { detect_value = "不合格"; } _wksheet.Range[s.OPC_TAG_NAME].Value = detect_value; } List <PlanEntity> plan_data = PlanFactory.GetByPlanSO(pSn); //if (plan_data.Count != 0) //{ // _wksheet.Cells[3, 4] = plan_data.First().PRODUCT_SERIES.ToString(); // _wksheet.Cells[4, 6] = plan_data.First().PROJECT_CODE.ToString(); //} _wksheet.Cells[4, 4] = pSn; //_wkbook.Save(); apps.Visible = true; _wksheet.PrintPreview(null); //apps.Visible = false; _wkbook.Close(0, oMissing, oMissing); apps.Quit(); GC.Collect(); }
private void InitSn2Print() { string StationCode = LoginInfo.StationInfo.RMES_ID; string Pline = LoginInfo.StationInfo.PLINE_CODE; string pline_code = comboBox1.SelectedValue.ToString(); string date1 = this.dateTimePicker1.Value.ToString("yyyyMMdd"); string date2 = this.dateTimePicker2.Value.AddDays(1).ToString("yyyyMMdd"); if (textBox1.Text.ToString() != "") { if (listBox1.SelectedItems.Count == 0) { MessageBox.Show("成品号不能为空"); return; } string sn = listBox1.SelectedValue.ToString().Trim(); List <SNDetectdDataEntity> lst_detect_1 = SNDetectFactory.GetBySn(sn); var h = (from k in lst_detect_1 select new { SN = k.SN, PLINE_CODE = k.PLINE_CODE, WORK_TIME = k.WORK_TIME.ToShortDateString() }).ToList(); GridSn2Print.DataSource = h; } //List<DetectDataEntity> lst_rpt = new List<DetectDataEntity>(); else { List <SNDetectdDataEntity> lst_detect = SNDetectFactory.GetDetectDataAuto(theCompanyCode, pline_code, date1, date2); if (lst_detect.Count == 0) { MessageBox.Show("时间选择错误,请重新选择时间或选择成品号"); return; } var s = (from p in lst_detect select new { SN = p.SN, PLINE_CODE = p.PLINE_CODE, WORK_TIME = p.WORK_TIME.ToShortDateString() }).ToList(); //int a = s.Count(); GridSn2Print.DataSource = s; } }
private void setCondition() { //绑定表数据 //GridViewDataComboBoxColumn dgvComboBoxR = ASPxGridView1.Columns["CurrentResult"] as GridViewDataComboBoxColumn; //DataTable dt = new DataTable(); //dt.Columns.Add("DisplayField", typeof(string)); //dt.Columns.Add("ValueField", typeof(int)); //dt.Rows.Add("合格", 1); //dt.Rows.Add("不合格", 0); //dt.Rows.Add("未知状态", -1); //dgvComboBoxR.PropertiesComboBox.DataSource = dt; //dgvComboBoxR.PropertiesComboBox.TextField = "DisplayField"; //dgvComboBoxR.PropertiesComboBox.ValueField = "ValueField"; //GridViewDataComboBoxColumn dgvComboBoxT = ASPxGridView1.Columns["UnitType"] as GridViewDataComboBoxColumn; //DataTable dt1 = new DataTable(); //dt1.Columns.Add("DisplayField", typeof(string)); //dt1.Columns.Add("ValueField", typeof(string)); //dt1.Rows.Add( "数字","N"); //dt1.Rows.Add("字符","T" ); //dt1.Rows.Add("判断是否","B" ); //dt1.Rows.Add("文件路径","F"); //dgvComboBoxT.PropertiesComboBox.DataSource = dt1; //dgvComboBoxT.PropertiesComboBox.TextField = "DisplayField"; //dgvComboBoxT.PropertiesComboBox.ValueField = "ValueField"; GridViewDataComboBoxColumn dgvComboBoxU = (ASPxGridView1.Columns["USER_ID"] as GridViewDataComboBoxColumn); { dgvComboBoxU.PropertiesComboBox.DataSource = UserFactory.GetAll(); dgvComboBoxU.PropertiesComboBox.ValueField = "USER_ID"; dgvComboBoxU.PropertiesComboBox.TextField = "USER_NAME"; } //string sql = "SELECT A.RMES_ID,A.BatchNo,A.ProcessCode,A.ItemCode,A.ItemName, A.ItemDescription,A.MinValue,A.MaxValue,A.URL,A.CurrentValue,A.UnitName,A.Ordering,A.TIMESTAMP1,A.WORK_TIME,A.USER_ID,B.PLAN_CODE, " // + "decode(A.CurrentResult,'1','合格','0','不合格','-1','未知状态') CURRENTRESULT, " // + "decode(A.UNITTYPE,'N','数值','T','文字','B','判断','F','文件') UNITTYPE " // + "FROM DATA_SN_QUALITY A" // + " LEFT JOIN DATA_PLAN_SN B ON A.BatchNo = B.SN "; //DataTable dt3 = dc.GetTable(sql); //GridViewDataComboBoxColumn dgvComboBoxU = ASPxGridView1.Columns["USER_ID"] as GridViewDataComboBoxColumn; //DataTable dt2 = new DataTable(); //dt2.Columns.Add("DisplayField", typeof(string)); //dt2.Columns.Add("ValueField", typeof(string)); //List<QualitySnItem> quality = QualityFactory.GetAll(); //for (int i = 0; i < quality.Count; i++) //{ // UserEntity user = UserFactory.GetByID(quality[i].USER_ID); // dt2.Rows.Add(user.USER_NAME, quality[i].USER_ID); //} //dgvComboBoxU.PropertiesComboBox.DataSource = dt2; //dgvComboBoxU.PropertiesComboBox.TextField = "DisplayField"; //dgvComboBoxU.PropertiesComboBox.ValueField = "ValueField"; List <SNDetectEntity> entities = SNDetectFactory.GetAll(); ASPxGridView1.DataSource = entities; ASPxGridView1.DataBind(); //int columnCount = ASPxGridView1.Columns.Count;//获取列的数量 //for (int i = 0; i < columnCount; i++) //{ // GridViewDataHyperLinkColumn colLink = new GridViewDataHyperLinkColumn(); // if (((string)ASPxGridView1.GetRowValues(i, "UNITTYPE")) == "F") // { // } // else // { // colLink.PropertiesEdit.EnableDefaultAppearance = false; // //e.Row.Cells[8].Enabled = false; // //if (e.GetValue("UNITTYPE").ToString().Trim() == "") // ASPxGridView1.Selection.SetSelection(i, false); // } //} }