using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CoreFS.CA06;
namespace Core.LZMes.Client.UIM
{
public partial class UIM010060 : FrmBase
{
int queryType = 0;
string queryDate = "";
public UIM010060()
{
InitializeComponent();
}
private void UIM010060_Load(object sender, EventArgs e)
{
//默认查询入库记录
this.ultraComboEditor1.Value = 0;
this.ultraComboEditor8.SelectedIndex = 0;
this.QueryCustomers();//查询并显示收货单位
}
public override void ToolBar_Click(object sender, string ToolbarKey)
{
switch (ToolbarKey)
{
case "Query":
this.DoQuery();
break;
case "Export":
this.DoExport();
break;
case "Exit":
this.Close();
break;
}
}
///
/// 查询原料库钢卷出入库记录
///
private void DoQuery()
{
try
{
this.dataSet1.Tables[0].Clear();
string startTime = this.ultraDateTimeEditor1.DateTime.ToString("yyyyMMdd");//开始时间
queryDate = this.ultraDateTimeEditor1.DateTime.ToString("yyyy/MM/dd");
string endTime = this.ultraDateTimeEditor2.DateTime.ToString("yyyyMMdd");//结束时间
queryType = int.Parse(this.ultraComboEditor1.Value.ToString());//查询类型 0 入库记录 1 出库记录
string specStlGrd = this.textBox3.Text.Trim();//牌号
string coilWthMin = this.textBox4.Text.Trim();//宽度最小值
string coilWthMax = this.textBox5.Text.Trim();//宽度最大值
string coilThkMin = this.textBox6.Text.Trim();//厚度最小值
string coilThkMax = this.textBox7.Text.Trim();//厚度最大值
string curLoadLoc = this.textBox8.Text.Trim();//垛位
string coilNo = this.textBox9.Text.Trim();//轧批号
string coilNo1 = this.textBox13.Text.Trim();//轧批号
string coilNo2 = this.textBox14.Text.Trim();//钢卷号
string shift = -1 == this.ultraComboEditor2.SelectedIndex ? "" : this.ultraComboEditor2.Value.ToString();//班次
string group = -1 == this.ultraComboEditor3.SelectedIndex ? "" : this.ultraComboEditor3.Value.ToString();//班组
string regId = this.textBox10.Text.Trim();//作业人
string custCd = -1 == this.ultraComboEditor4.SelectedIndex ? "" : this.ultraComboEditor4.Value.ToString();//客户编号
string ordNo = this.textBox11.Text.Trim();//订单号
string ordSeq = this.textBox12.Text.Trim();//合同号
string ordFl = -1 == this.ultraComboEditor5.SelectedIndex ? "" : this.ultraComboEditor5.Value.ToString();//订单区分
string prodnmCd = -1 == this.ultraComboEditor6.SelectedIndex ? "" : this.ultraComboEditor6.Value.ToString();//产品类型
string outType = -1 == this.ultraComboEditor7.SelectedIndex ? "" : this.ultraComboEditor7.Value.ToString();//出库类型
string deldatefr = this.ultraDateTimeEditor4.Value != null ? ultraDateTimeEditor4.DateTime.ToString("yyyyMMdd") : "";//入库开始时间
string deldateto = this.ultraDateTimeEditor3.Value != null ? ultraDateTimeEditor3.DateTime.ToString("yyyyMMdd") : "";//入库结束时间
string yardtype = -1 == this.ultraComboEditor8.SelectedIndex ? "" : this.ultraComboEditor8.Value.ToString();//库存类型
string[] queryParams = new string[] { startTime, endTime, specStlGrd, coilWthMin, coilWthMax,
coilThkMin, coilThkMax, curLoadLoc, coilNo,coilNo1, shift, group, regId, custCd, ordNo, ordSeq,
ordFl, prodnmCd,outType,coilNo2,deldatefr,deldateto,yardtype };
List list = new List();
list.Add(queryParams);
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010060";
ccp.MethodName = "queryYardList";
ccp.ServerParams = new object[] { queryType, list };
ccp.SourceDataTable = this.dataSet1.Tables[0];
this.ExecuteQueryToDataTable(ccp, CoreInvokeType.Internal);
DataRowCollection drs = this.dataSet1.Tables[0].Rows;
int coilCount = 0;
double wgtCount = 0;
int drsSize = drs.Count;
coilCount = drsSize;
for (int i = 0; i < drsSize; i++)
{
//wgtCount += double.Parse(drs[i]["ACT_WGT"].ToString());
// double actWgt = 0;
try
{
// actWgt = double.Parse(drs[i]["ACT_WGT"].ToString());
wgtCount += double.Parse(drs[i]["ACT_WGT"].ToString());
}
catch (Exception e)
{
}
// wgtCount += actWgt;
}
this.textBox1.Text = coilCount.ToString();
this.textBox2.Text = (wgtCount/1000).ToString();
}
catch (Exception EX)
{
MessageBox.Show(EX.ToString());
}
}
///
/// 查询并显示收货单位
///
private void QueryCustomers()
{
CoreClientParam ccp = new CoreClientParam();
ccp.ServerName = "UIM.UIM010060";
ccp.MethodName = "queryCustomers";
ccp = this.ExecuteQuery(ccp, CoreInvokeType.Internal);
ArrayList custList = (ArrayList)ccp.ReturnObject;
int listSize = custList.Count;
Infragistics.Win.ValueListItem[] valueListItems = new Infragistics.Win.ValueListItem[listSize];
for (int i = 0; i < listSize; i++)
{
Infragistics.Win.ValueListItem item = new Infragistics.Win.ValueListItem();
Hashtable ht = (Hashtable)custList[i];
item.DataValue = ht["VALUE"].ToString();
object obj = ht["LABEL"];
if (obj != null)
{
item.DisplayText = ht["LABEL"].ToString();
}
else
{
item.DisplayText = "";
}
valueListItems[i] = item;
}
this.ultraComboEditor4.Items.AddRange(valueListItems);
}
///
/// 导出出入库记录
///
private void DoExport()
{
try
{
if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
{
//改字体
this.ultraGrid1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
// 重量改为t
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
{
double tempWGT;
double.TryParse(row.Cells["ACT_WGT"].Value.ToString(), out tempWGT);
tempWGT = tempWGT * 0.001;
row.Cells["ACT_WGT"].Value = tempWGT.ToString();
}
ultraGrid1.UpdateData();
string fileName = this.saveFileDialog1.FileName;
string exportName = "原料";
string operation = queryDate;
operation += " ";
operation += tools.UserInfoExt.Get_UserOrder(UserInfo) + "/" + tools.UserInfoExt.Get_UserGroup(UserInfo);
operation += " 制表人:";
operation += UserInfo.GetUserName();
this.ultraGrid1.DisplayLayout.Bands[0].Columns["YARD_ENTRY_DTIME"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODNM_CD"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["CZSJ"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["SHIFT"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["WKGROUP"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["CZR"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_DEC_GRD"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["MATLQLTY_DEC_GRD"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_DEC_RST"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["EXTSHAPE_DEC_GRD"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["WGT_DEC_RST"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_NO"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_SEQ"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["DLIV_TP"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORDCUST_CD"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["CHARGE_NO"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["TRNF_DTIME"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_LEN"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_INDIA"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_OUTDIA"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_WGT"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["COIL_LEN"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["COIL_INDIA"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["COIL_OUTDIA"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["TRNF_TYPE"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["FANXIU"].Hidden = true;
//DEL_TO_DATE FANXIU
this.ultraGrid1.DisplayLayout.Bands[0].Columns["DEL_TO_DATE"].Hidden = true;
if (queryType == 0)
{
this.ultraGrid1.DisplayLayout.Bands[0].Columns["ZPH"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["OLD_SAMPL_NO"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["SPEC_STL_GRD"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACT_WGT"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["CUR_LOAD_LOC"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["TOT_DEC_GRD"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["IN_YARD_KIND"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["OUT_YARD_KIND"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["HOUKUAN"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["NHOUKUAN"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["ROWNUM"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["BEF_STL_GRD"].Hidden = true;
exportName += "入库单";
}
else
{
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["ZPH"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["OLD_SAMPL_NO"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["SPEC_STL_GRD"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACT_WGT"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["CUR_LOAD_LOC"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["TOT_DEC_GRD"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["IN_YARD_KIND"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["OUT_YARD_KIND"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["HOUKUAN"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["NHOUKUAN"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["ROWNUM"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["SPEC_STL_GRD"].Hidden = true;
exportName += "出库单";
}
this.ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.None;
ultraGridExcelExporter1.Export(ultraGrid1, fileName);
if (isExcelInstalled())
{
Microsoft.Office.Interop.Excel.Application excel;
Microsoft.Office.Interop.Excel._Workbook objBook;
Microsoft.Office.Interop.Excel.Workbooks objBooks;//接口 workbooks
Microsoft.Office.Interop.Excel.Sheets objSheets;// 接口 sheets
Microsoft.Office.Interop.Excel.Worksheet objSheet;//接口 worksheet
Microsoft.Office.Interop.Excel.Range range = null;
try
{
excel = new Microsoft.Office.Interop.Excel.Application();
objBooks = excel.Workbooks;
//Object miss = System.Reflection.Missing.Value;
objBook = objBooks.Add(fileName);
objSheets = objBook.Sheets;
objSheet = (Microsoft.Office.Interop.Excel.Worksheet)objSheets[1];
excel.Visible = false; //让后台执行设置为不可见,为true的话会看到打开一个Excel,然后数据在往里写
Microsoft.Office.Interop.Excel.Range tmpRange = (Microsoft.Office.Interop.Excel.Range)objSheet.Rows[1, System.Reflection.Missing.Value];
tmpRange.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown, System.Reflection.Missing.Value);
tmpRange.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown, System.Reflection.Missing.Value);
objSheet.get_Range("A1", "I1").Merge(objSheet.get_Range("A1", "I1").MergeCells);
objSheet.get_Range("A2", "I2").Merge(objSheet.get_Range("A2", "I2").MergeCells);
objSheet.get_Range("A1", "I1").VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
objSheet.get_Range("A2", "I2").VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
objSheet.get_Range("A1", "I1").HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
objSheet.get_Range("A2", "I2").HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft;
((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[1, 1]).Font.Size = 24;
((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[1, 1]).RowHeight = 45;
((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[1, 1]).Font.Bold = true;
((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[1, 1]).Interior.Color = ((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[4, 1]).Interior.Color;
((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[2, 1]).Interior.Color = ((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[4, 1]).Interior.Color;
excel.Cells[1, 1] = exportName;
excel.Cells[2, 1] = operation;
int iRowCnt = objSheet.UsedRange.Cells.Rows.Count;
int iBgnRow = (objSheet.UsedRange.Cells.Row > 3 ? objSheet.UsedRange.Cells.Row : objSheet.UsedRange.Cells.Row + 1) + 1;
int insertIdx = iRowCnt - 1,insertIdx1 = iRowCnt-1;
string befStlStr = ((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[insertIdx - 1, queryType == 0 ? 4 : 5]).Text.ToString();
string befThkStr = GetThickBySize(((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[insertIdx - 1, queryType == 0 ? 5 : 6]).Text.ToString());
string curStlStr = string.Empty, curThkStr = string.Empty;
int coilCount = 0,coilCount1 = 0;
double weightSum = 0,weightSum1 = 0;
for (int i = iRowCnt - 2; i >= iBgnRow; i--)
{
curStlStr = ((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[i, queryType == 0 ? 4 : 5]).Text.ToString();
curThkStr = GetThickBySize(((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[i, queryType == 0 ? 5 : 6]).Text.ToString());
if (!befStlStr.Equals(curStlStr) || !befThkStr.Equals(curThkStr))
{
if (!befStlStr.Equals(curStlStr))
{
tmpRange = (Microsoft.Office.Interop.Excel.Range)objSheet.Rows[insertIdx1, System.Reflection.Missing.Value];
tmpRange.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown, System.Reflection.Missing.Value);
excel.Cells[insertIdx1, queryType == 0 ? 3 : 4] = coilCount1.ToString();
excel.Cells[insertIdx1, queryType == 0 ? 8 : 9] = weightSum1.ToString();
coilCount1 = 0;
weightSum1 = 0;
insertIdx1 = i;
}
tmpRange = (Microsoft.Office.Interop.Excel.Range)objSheet.Rows[insertIdx, System.Reflection.Missing.Value];
tmpRange.Insert(Microsoft.Office.Interop.Excel.XlInsertShiftDirection.xlShiftDown, System.Reflection.Missing.Value);
excel.Cells[insertIdx, queryType == 0 ? 3 : 4] = coilCount.ToString();
excel.Cells[insertIdx, queryType == 0 ? 8 : 9] = weightSum.ToString();
coilCount = 0;
weightSum = 0;
insertIdx = i + 1;
insertIdx1++;
}
if (i > iBgnRow)
{
coilCount++;
weightSum += Convert.ToDouble(((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[i, queryType == 0 ? 8 : 9]).Text);
coilCount1++;
weightSum1 += Convert.ToDouble(((Microsoft.Office.Interop.Excel.Range)objSheet.UsedRange.Cells[i, queryType == 0 ? 8 : 9]).Text);
}
befStlStr = curStlStr;
befThkStr = curThkStr;
}
objBook.SaveCopyAs(fileName);
//设置禁止弹出保存和覆盖的询问提示框
excel.DisplayAlerts = false;
excel.AlertBeforeOverwriting = false;
//确保Excel进程关闭
objBooks.Close();
excel.Workbooks.Close();
excel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(objBook);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objBooks);
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
GC.Collect();
System.GC.WaitForPendingFinalizers();
//MessageBox.Show("数据导出完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (System.IO.File.Exists(fileName))
System.Diagnostics.Process.Start(fileName); //保存成功后打开此文件
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "错误提示");
}
}
else
{
ET.Application excel;
ET._Workbook objBook;
ET.Workbooks objBooks;//接口 workbooks
ET.Sheets objSheets;// 接口 sheets
ET.Worksheet objSheet;//接口 worksheet
ET.Range range = null;
try
{
excel = new ET.Application();
objBooks = excel.Workbooks;
//Object miss = System.Reflection.Missing.Value;
objBook = objBooks.Add(fileName);
objSheets = objBook.Sheets;
objSheet = (ET.Worksheet)objSheets[1];
excel.Visible = false; //让后台执行设置为不可见,为true的话会看到打开一个Excel,然后数据在往里写
ET.Range tmpRange = (ET.Range)objSheet.Rows[1, System.Reflection.Missing.Value];
tmpRange.Insert(ET.XlInsertShiftDirection.xlShiftDown, System.Reflection.Missing.Value);
tmpRange.Insert(ET.XlInsertShiftDirection.xlShiftDown, System.Reflection.Missing.Value);
objSheet.get_Range("A1", "I1").Merge(true);
objSheet.get_Range("A2", "I2").Merge(true);
objSheet.get_Range("A1", "I1").VerticalAlignment = ET.ETVAlign.etVAlignCenter;
objSheet.get_Range("A2", "I2").VerticalAlignment = ET.ETVAlign.etVAlignCenter;
objSheet.get_Range("A1", "I1").HorizontalAlignment = ET.ETHAlign.etHAlignCenter;
objSheet.get_Range("A2", "I2").HorizontalAlignment = ET.ETHAlign.etHAlignLeft;
((ET.Range)objSheet.UsedRange.Cells[1, 1]).Font.Size = 24;
((ET.Range)objSheet.UsedRange.Cells[1, 1]).RowHeight = 45;
((ET.Range)objSheet.UsedRange.Cells[1, 1]).Font.Bold = true;
((ET.Range)objSheet.UsedRange.Cells[1, 1]).Interior.Color = ((ET.Range)objSheet.UsedRange.Cells[4, 1]).Interior.Color;
((ET.Range)objSheet.UsedRange.Cells[2, 1]).Interior.Color = ((ET.Range)objSheet.UsedRange.Cells[4, 1]).Interior.Color;
excel.Cells[1, 1] = exportName;
excel.Cells[2, 1] = operation;
int iRowCnt = objSheet.UsedRange.Cells.Rows.Count;
int iBgnRow = (objSheet.UsedRange.Cells.Row > 3 ? objSheet.UsedRange.Cells.Row : objSheet.UsedRange.Cells.Row + 1) + 1;
int insertIdx = iRowCnt - 1;
string befStlStr = ((ET.Range)objSheet.UsedRange.Cells[insertIdx - 1, queryType == 0 ? 4 : 5]).Text.ToString();
string befThkStr = GetThickBySize(((ET.Range)objSheet.UsedRange.Cells[insertIdx - 1, queryType == 0 ? 5 : 6]).Text.ToString());
string curStlStr = string.Empty, curThkStr = string.Empty;
int coilCount = 0;
double weightSum = 0;
for (int i = iRowCnt - 2; i >= iBgnRow; i--)
{
curStlStr = ((ET.Range)objSheet.UsedRange.Cells[i, queryType == 0 ? 4 : 5]).Text.ToString();
curThkStr = GetThickBySize(((ET.Range)objSheet.UsedRange.Cells[i, queryType == 0 ? 5 : 6]).Text.ToString());
if (befStlStr.Equals(curStlStr) && befThkStr.Equals(curThkStr))
{
//coilCount++;
//weightSum += Convert.ToDouble(((ET.Range)objSheet.UsedRange.Cells[i, 7]).Text);
}
else
{
tmpRange = (ET.Range)objSheet.Rows[insertIdx, System.Reflection.Missing.Value];
tmpRange.Insert(ET.XlInsertShiftDirection.xlShiftDown, System.Reflection.Missing.Value);
excel.Cells[insertIdx, queryType == 0 ? 3 : 4] = coilCount.ToString();
excel.Cells[insertIdx, queryType == 0 ? 8 : 9] = weightSum.ToString();
coilCount = 0;
weightSum = 0;
insertIdx = i + 1;
}
if (i > iBgnRow)
{
coilCount++;
weightSum += Convert.ToDouble(((ET.Range)objSheet.UsedRange.Cells[i, queryType == 0 ? 8 :9]).Text);
}
befStlStr = curStlStr;
befThkStr = curThkStr;
}
System.Reflection.Missing miss = System.Reflection.Missing.Value;
objBook.SaveAs(fileName, miss, miss, miss, miss, miss, ET.ETSaveAsAccessMode.etNoChange, miss, miss, miss, miss);
//objBook.SaveCopyAs(fileName);
//设置禁止弹出保存和覆盖的询问提示框
excel.DisplayAlerts = false;
//excel.AlertBeforeOverwriting = false;
//确保Excel进程关闭
objBooks.Close(false);
excel.Workbooks.Close(false);
excel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(objBook);
System.Runtime.InteropServices.Marshal.ReleaseComObject(objBooks);
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
GC.Collect();
System.GC.WaitForPendingFinalizers();
//MessageBox.Show("数据导出完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (System.IO.File.Exists(fileName))
System.Diagnostics.Process.Start(fileName); //保存成功后打开此文件
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "错误提示");
}
}
this.ultraGrid1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in ultraGrid1.Rows)
{
double tempWGT;
double.TryParse(row.Cells["ACT_WGT"].Value.ToString(), out tempWGT);
tempWGT = tempWGT * 1000;
row.Cells["ACT_WGT"].Value = tempWGT.ToString();
}
ultraGrid1.UpdateData();
this.ShowColumns();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private bool isExcelInstalled()
{
Type type = Type.GetTypeFromProgID("Excel.Application");
return type != null;
}
private string GetThickBySize(string coilSize)
{
string thick = string.Empty;
if (!string.IsNullOrEmpty(coilSize) && coilSize.Contains("*"))
{
thick = coilSize.Substring(0, coilSize.IndexOf("*"));
}
return thick;
}
private void ShowColumns()
{
this.ultraGrid1.BeginUpdate();
this.ultraGrid1.DisplayLayout.Bands[0].Columns["YARD_ENTRY_DTIME"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODNM_CD"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["CZSJ"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["SHIFT"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["WKGROUP"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["CZR"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["ZPH"].Hidden = false;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["OLD_SAMPL_NO"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["SPEC_STL_GRD"].Hidden = true;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["ACT_WGT"].Hidden = true;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["CUR_LOAD_LOC"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["TOT_DEC_GRD"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INGR_DEC_GRD"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["MATLQLTY_DEC_GRD"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["SIZE_DEC_RST"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["EXTSHAPE_DEC_GRD"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["WGT_DEC_RST"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_NO"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORD_SEQ"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["DLIV_TP"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["ORDCUST_CD"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["CHARGE_NO"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["TRNF_DTIME"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_LEN"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_INDIA"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_OUTDIA"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["INSTR_COIL_WGT"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["COIL_LEN"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["COIL_INDIA"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["COIL_OUTDIA"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["IN_YARD_KIND"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["OUT_YARD_KIND"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["HOUKUAN"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["NHOUKUAN"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["BEF_STL_GRD"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["SPEC_STL_GRD"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["TRNF_TYPE"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["DEL_TO_DATE"].Hidden = false;
this.ultraGrid1.DisplayLayout.Bands[0].Columns["FANXIU"].Hidden = false;
//this.ultraGrid1.DisplayLayout.Bands[0].Columns["ROWNUM"].Hidden = false;
this.ultraGrid1.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ExtendLastColumn;
this.ultraGrid1.EndUpdate();
}
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
try
{
if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
{
string fileName = this.saveFileDialog1.FileName;
this.ultraGridExcelExporter1.Export(ultraGrid1, fileName);
System.Diagnostics.Process.Start(fileName);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}