/// <summary> /// 导出 /// </summary> private void MasterToolBar_DoExport_Click(object sender, EventArgs e) { _currentDt = bCompositionProductsSpecification.GetList(GetConduction()).Tables[0]; if (isSearch && _currentDt.Rows.Count > 0) { int result = CExport.DataTableToExcel(_currentDt, CConstant.MACHINE_HEADER, CConstant.MACHINE_COLUMNS, "MACHINE", "MACHINE"); if (result == CConstant.EXPORT_SUCCESS) { MessageBox.Show("数据已经成功导出!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == CConstant.EXPORT_FAILURE) { MessageBox.Show("数据导出失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("没有可以导出的数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 数据绑定 /// </summary> /// <param name="dgv"></param> /// <param name="code"></param> private void BindData(DataGridView dgv, string code) { DataTable dtData = bCompositionProductsProductionProcess.GetList("COMPOSITION_PRODUCTS_CODE = '" + code + "'").Tables[0]; if (dtData != null && dtData.Rows.Count > 0) { foreach (DataRow row in dtData.Rows) { try { object[] obj = { false, row["SPECIFICATION_CODE"], row["SPECIFICATION_NAME"], 1 }; dgv.Rows.Add(obj); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
/// <summary> /// 页面初始化 /// </summary> private void FrmProductionDownLoad_Load(object sender, EventArgs e) { _currentDt.Columns.Add("NAME", Type.GetType("System.String")); _currentDt.Columns.Add("SIZE", Type.GetType("System.String")); _currentDt.Columns.Add("TYPE", Type.GetType("System.String")); #region try { //if (Directory.Exists(_fullPath)) // { // DirectoryInfo di = new DirectoryInfo(_fullPath); Czzd.Common.Library.FTPOperate myftp = new Czzd.Common.Library.FTPOperate("112.82.245.2", "YS_ERP\\production\\" + _slipNumber, "FTP_user", "czzd", 21); string[] files = myftp.Dir("\\YS_ERP\\production\\" + _slipNumber); Hashtable dwHt = new Hashtable(); Hashtable technologyHt = new Hashtable(); if (_CTag.Equals("productionProcess")) { _currentDt.Rows.Clear(); DataTable productionProcessDt = bProductionProcess.GetList(" CODE = '" + _productionProcessCode + "'").Tables[0]; foreach (DataRow dr in productionProcessDt.Rows) { for (int l = 1; l <= 6; l++) { string dwCode = CConvert.ToString(dr["DRAWING_TYPE_CODE" + l]); if (string.IsNullOrEmpty(dwCode)) { continue; } if (dwHt.ContainsKey(dwCode)) { } else { dwHt.Add(dwCode, ""); } } } foreach (DictionaryEntry de in dwHt) { DataTable drawingDt = new DataTable(); string drawingcode = de.Key.ToString(); drawingDt = bproductionDrawing.GetProductionDrawingUpload(" SLIP_NUMBER = '" + _slipNumber + "'" + " AND DRAWING_CODE = '" + drawingcode + "'").Tables[0]; if (drawingDt.Rows.Count > 0) { //FileInfo[] files = di.GetFiles(); foreach (DataRow dr in drawingDt.Rows) { foreach (string file in files) { if (CConvert.ToString(dr["LOCATION_FILE_NAME"].ToString()).Equals(CConvert.ToString(file.ToString()))) { int _count = 0; if (_currentDt.Rows.Count > 0) { //foreach (DataRow filecurrentDt in _currentDt.Rows) for (int t = 0; t < _currentDt.Rows.Count; t++) { if (CConvert.ToString(_currentDt.Rows[t]["NAME"].ToString()).Equals(CConvert.ToString(file.ToString()))) { } else { _count++; } } if (_currentDt.Rows.Count == _count) { AddAttached(file); } } else { AddAttached(file); } } //if (CConvert.ToString(drawingDt.Rows[0]["SERVER_FILE_NAME"].ToString()).Equals(CConvert.ToString(file.ToString()))) //{ // AddAttached(file); //} } } } } } else { _currentDt.Rows.Clear(); DataTable productionTechnologyDt = bCompositionProductsProductionProcess.GetList(" COMPOSITION_PRODUCTS_CODE = '" + _partsCode + "'" + " AND PRODUCTION_PROCESS_CODE = '" + _productionProcessCode + "'").Tables[0]; foreach (DataRow dr in productionTechnologyDt.Rows) { for (int j = 1; j <= 3; j++) { string technologyCode = CConvert.ToString(dr["TECHNOLOGY_CODE" + j]); if (technologyCode != "") { DataTable technologyDt = bTechnology.GetList(" CODE = '" + technologyCode + "'").Tables[0]; foreach (DataRow drTechnology in technologyDt.Rows) { for (int k = 1; k <= 3; k++) { string drawCode = CConvert.ToString(drTechnology["TECHNOLOGY_DRAWING" + k]); if (string.IsNullOrEmpty(drawCode)) { continue; } if (technologyHt.ContainsKey(drawCode)) { } else { technologyHt.Add(drawCode, ""); } } } } } } foreach (DictionaryEntry de in technologyHt) { DataTable drawingDt = new DataTable(); string drawingcode = de.Key.ToString(); drawingDt = bproductionDrawing.GetProductionDrawingUpload(" SLIP_NUMBER = '" + _slipNumber + "'" + " AND DRAWING_CODE = '" + drawingcode + "'").Tables[0]; if (drawingDt.Rows.Count > 0) { try { //FileInfo[] files = di.GetFiles(); foreach (DataRow dr in drawingDt.Rows) { foreach (string file in files) { if (CConvert.ToString(dr["LOCATION_FILE_NAME"].ToString()).Equals(CConvert.ToString(file.ToString()))) { int _count = 0; if (_currentDt.Rows.Count > 0) { //foreach (DataRow filecurrentDt in _currentDt.Rows) for (int t = 0; t < _currentDt.Rows.Count; t++) { if (CConvert.ToString(_currentDt.Rows[t]["NAME"].ToString()).Equals(CConvert.ToString(file.ToString()))) { } else { _count++; } } if (_currentDt.Rows.Count == _count) { AddAttached(file); } } else { AddAttached(file); } } } } } catch (Exception ex) { } } } } // } } catch (IOException ex) { } #endregion dgvData.DataSource = _currentDt; }