华恒Mes鼎捷代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

592 lines
23 KiB

5 months ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraEditors;
  9. using ICSSoft.Frame.User.BLL;
  10. using ICSSoft.Base.Language.Tool;
  11. using ICSSoft.Base.UserControl.MessageControl;
  12. using System.Data.SqlClient;
  13. using ICSSoft.Base.Config.AppConfig;
  14. using ICSSoft.Base.Report.Filter;
  15. using ICSSoft.Base.Config.DBHelper;
  16. using ICSSoft.Base.UserControl.FormControl;
  17. using ICSSoft.Base.ReferForm.AppReferForm;
  18. using ICSSoft.Base.Lable.PrintTool;
  19. using ICSSoft.Frame.Data.DAL;
  20. using ICSSoft.Frame.Data.BLL;
  21. using ICSSoft.Frame.Data.Entity;
  22. using System.Text.RegularExpressions;
  23. namespace ICSSoft.Frame.APP
  24. {
  25. public partial class FormICSProjectReports1 : DevExpress.XtraEditors.XtraForm
  26. {
  27. private string sqltxt = "";
  28. private string sqlconn = "";
  29. DataTable dt;
  30. string opcodes = "";
  31. string vencode = "";
  32. string pocode = "";
  33. Color color ;
  34. private DataTable dataSource = null;
  35. DataTable Color_table = null;
  36. #region 构造函数
  37. public FormICSProjectReports1()
  38. {
  39. InitializeComponent();
  40. this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  41. this.WindowState = FormWindowState.Maximized;
  42. button7.BackColor = Color.FromArgb(254, 177, 95);
  43. checkDate.Checked = true;
  44. txtStartDate.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
  45. txtEndDate.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1);
  46. Search();
  47. }
  48. #endregion
  49. private void Search()
  50. {
  51. string sql = @"select * from dbo.ICSLOTONWIP order by MTIME desc";
  52. sql = string.Format(sql);
  53. dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  54. }
  55. #region 移动窗体
  56. private const int WM_NCHITTEST = 0x84;
  57. private const int HTCLIENT = 0x1;
  58. private const int HTCAPTION = 0x2;
  59. //首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
  60. //系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
  61. //假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
  62. //同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
  63. //重写窗体,使窗体可以不通过自带标题栏实现移动
  64. protected override void WndProc(ref Message m)
  65. {
  66. //当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
  67. //当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
  68. //这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
  69. //注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
  70. switch (m.Msg)
  71. {
  72. case WM_NCHITTEST:
  73. base.WndProc(ref m);
  74. if ((int)m.Result == HTCLIENT)
  75. m.Result = (IntPtr)HTCAPTION;
  76. return;
  77. }
  78. //拦截双击标题栏、移动窗体的系统消息
  79. if (m.Msg != 0xA3)
  80. {
  81. base.WndProc(ref m);
  82. }
  83. }
  84. #endregion
  85. #region 权限
  86. /// <summary>
  87. /// 操作权限
  88. /// </summary>
  89. /// <returns></returns>
  90. public DataTable RightOfExute()
  91. {
  92. DataTable rData = new DataTable();
  93. rData.Columns.Add("BtnName");
  94. rData.Columns.Add("ActionName");
  95. //查看权限(必须有)
  96. DataRow seeRow = rData.NewRow();
  97. seeRow["BtnName"] = "see";
  98. seeRow["ActionName"] = "查看";
  99. rData.Rows.Add(seeRow);
  100. //List<Control> ControlList = new List<Control>();
  101. //foreach (Control ctr in ControlList)
  102. //{
  103. // if (ctr.GetType() == typeof(SimpleButton))
  104. // {
  105. // DataRow dr = rData.NewRow();
  106. // dr["BtnName"] = ctr.Name;
  107. // dr["ActionName"] = ctr.Text;
  108. // rData.Rows.Add(dr);
  109. // }
  110. //}
  111. rData.AcceptChanges();
  112. return rData;
  113. }
  114. /// <summary>
  115. /// 数据权限
  116. /// </summary>
  117. /// <returns></returns>
  118. public DataTable RightOfData()
  119. {
  120. DataTable rData = new DataTable();
  121. rData.Columns.Add("BodyName");
  122. rData.Columns.Add("ControlName");
  123. rData.Columns.Add("ControlCaption");
  124. rData.AcceptChanges();
  125. return rData;
  126. }
  127. #endregion
  128. #region 退出
  129. private void btnClose_Click(object sender, EventArgs e)
  130. {
  131. AppConfig.CloseFormShow(this.Text);
  132. this.Close();
  133. }
  134. private void btnExit_Click(object sender, EventArgs e)
  135. {
  136. AppConfig.CloseFormShow(this.Text);
  137. this.Close();
  138. }
  139. #endregion
  140. #region 拼接查询条件
  141. private string getWhere()
  142. {
  143. string where = "1=1";
  144. if (!string.IsNullOrEmpty(txtMoCodeS.Text)) {
  145. where += " and c.transno like '"+txtMoCodeS.Text+"' ";
  146. }
  147. //if (!string.IsNullOrEmpty(txtStartDate.Text.Trim()))
  148. //{
  149. // where += " and c.transno like '" + txtMoCodeS.Text + "' ";
  150. //}
  151. if (!string.IsNullOrEmpty(txtLotNOS.Text)) {
  152. where += " and c.lotno like '"+txtLotNOS.Text+"'";
  153. }
  154. if (!string.IsNullOrEmpty(MDeptCode.Text))
  155. {
  156. where += " and MDeptCode like '" + MDeptCode.Text + "'";
  157. }
  158. if (!string.IsNullOrEmpty(txtOrderNo.Text.Trim()))
  159. {
  160. where += " and d.OrderNO like '%" + txtOrderNo.Text.Trim() + "%'";
  161. }
  162. #region 预计完工时间
  163. if (checkDate.Checked)
  164. {
  165. where += " and d.MOPLANENDDATE BETWEEN " + "'" + Convert.ToDateTime(txtStartDate.Text).ToString("yyyy-MM-dd") + "'" + " AND " + "'" + Convert.ToDateTime(txtEndDate.Text).ToString("yyyy-MM-dd") + "'";
  166. }
  167. #endregion
  168. return where;
  169. }
  170. #endregion
  171. #region 拼接查询条件
  172. private string getWhere2()
  173. {
  174. string where = "1=1";
  175. if (!string.IsNullOrEmpty(txtMoCodeS.Text))
  176. {
  177. where += " and a.mocode like ''" + txtMoCodeS.Text + "'' ";
  178. }
  179. if (!string.IsNullOrEmpty(txtLotNOS.Text))
  180. {
  181. where += " and b.lotno like ''" + txtLotNOS.Text + "''";
  182. }
  183. if (!string.IsNullOrEmpty(MDeptCode.Text))
  184. {
  185. where += " and MDeptCode like ''" + MDeptCode.Text + "''";
  186. }
  187. if (!string.IsNullOrEmpty(txtOrderNo.Text.Trim()))
  188. {
  189. where += " and A.OrderNO like ''%" + txtOrderNo.Text.Trim() + "%''";
  190. }
  191. #region 预计完工时间
  192. if (checkDate.Checked)
  193. {
  194. where += " and a.MOPLANENDDATE BETWEEN " + "''" + Convert.ToDateTime(txtStartDate.Text).ToString("yyyy-MM-dd") + "''" + " AND " + "''" + Convert.ToDateTime(txtEndDate.Text).ToString("yyyy-MM-dd") + "''";
  195. }
  196. #endregion
  197. return where;
  198. }
  199. #endregion
  200. #region 查询
  201. private void btnFilter_Click(object sender, EventArgs e)
  202. {
  203. grvDetail.Columns.Clear();
  204. grdDetail.DataSource = null;
  205. DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
  206. try
  207. {
  208. _wait.Show();
  209. string sql = @"SELECT DISTINCT
  210. lot.LOTNO,
  211. mo2user.id,
  212. a.OPCODE,
  213. b.Result,
  214. a.ACTIONRESULT,
  215. ncr.ID
  216. FROM
  217. icsitemlot lot WITH(nolock)
  218. inner join icsmo mo WITH(nolock) on mo.mocode=lot.transno and mo.moseq=lot.transline
  219. left join icsmo2user mo2user on mo2user.lotno=lot.lotno
  220. left join ICSLOTONWIP a WITH(nolock) on a.lotno=lot.lotno and a.opcode=mo2user.opcode
  221. LEFT JOIN ICSLOTONWIPCheck b WITH(nolock) ON a.ID=b.ONWIPID
  222. LEFT JOIN ICSLOTSIMULATION c WITH(nolock) ON a.MOCODE=c.MOCODE AND a.MOSEQ=c.MOSEQ AND a.LOTNO=c.LOTNO
  223. LEFT JOIN ICSNCRDoc ncr on ncr.LOTNO=A.LotNO and ncr.OPCode=A.OPCODE and ncr.ErrorType=''
  224. WHERE (a.EATTRIBUTE1 is null OR a.EATTRIBUTE1 <>'') ";
  225. Color_table = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
  226. dataSource = null;
  227. #region 查询sql
  228. sqltxt = @"if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#TEMP1') and type='U')
  229. DROP TABLE #TEMP1
  230. if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempopname') and type='U')
  231. DROP TABLE #tempopname
  232. if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..##tempmain') and type='U')
  233. DROP TABLE ##tempmain
  234. select a.lotno,opcode,''+CONVERT(NVARCHAR(20),opseq) AS ,opseq INTO #TEMP1 from (select a.lotno,a.OPCODE+':'+b.OPNAME as opcode,ROW_NUMBER() OVER( PARTITION BY a.LOTNO ORDER BY a.LOTNO,OPSEQ) AS opseq from ICSITEMROUTE2OPLot a
  235. left join ICSOP b on b.OPCODE=a.OPCODE
  236. inner join ICSITEMLot c on c.lotno=a.LotNo
  237. inner join icsmo d on d.mocode=c.transno and d.moseq=c.transline
  238. where d.mostatus<>'' and {0}
  239. )a
  240. if @@ROWCOUNT=0
  241. raiserror('!',16,1)
  242. select distinct ,opseq into #tempopname from #TEMP1
  243. order by opseq
  244. declare @sqlopname nvarchar(100)=''
  245. select @sqlopname= STUFF((select ','+ from #tempopname
  246. FOR XML PATH('')),1,1,'')
  247. declare @sql nvarchar(max)='select * into ##tempmain from (select a.MOCODE as ,a.MOSEQ as ,a.MOPLANQTY as ,a.MOPLANSTARTDATE as ,a.MOPLANENDDATE as ,b.LotNO as ,convert(decimal(18,2),b.LOTQTY) as ,a.ITEMCODE as ,c.invname as ,A.ORDERNO AS ,d.opcode,d.,E.,A.eattribute4 AS ,
  248. CASE WHEN h.ISCOM=1 THEN h.MTIME WHEN h.ISCOM=0 THEN null END AS ,
  249. CASE WHEN ISNULL(B.ISCOM,'''')=''1'' THEN ''是'' else ''否'' end as ,b.storageMUser as ,B.STORAGEDATE AS
  250. from ICSMO a
  251. inner join ICSITEMLot b on a.MOCODE=b.TransNO and a.MOSEQ=b.TransLine
  252. left join ICSINVENTORY c on c.INVCODE=a.ITEMCODE
  253. LEFT JOIN ICSLOTSIMULATION h with(nolock) ON h.LOTNO=b.LOTNO
  254. left join #TEMP1 d on d.lotno=b.LotNO
  255. left join (
  256. select lotno,count(*) as from ICSITEMROUTE2OPLot group by lotno
  257. )E ON E.LOTNO=B.LOTNO
  258. where {1}
  259. )a
  260. pivot(
  261. max(opcode)
  262. FOR a. IN ('+@sqlopname+')
  263. )b
  264. select * from ##tempmain
  265. '
  266. exec(@sql)";
  267. string where = getWhere();
  268. string where1 = getWhere2();
  269. //if (!string.IsNullOrWhiteSpace(where))
  270. //{
  271. // sqltxt += where;
  272. //}
  273. //sqltxt += " ORDER BY a.MOVER,a.MOCODE,g.LOTNO";
  274. #endregion
  275. sqltxt = string.Format(sqltxt, where, where1);
  276. DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqltxt).Tables[0];
  277. grdDetail.DataSource = dt;
  278. grvDetail.BestFitColumns();
  279. rptPage.PageSize = 100;
  280. rptPage.PageIndex = 1;
  281. rptPage.ReLoad();
  282. _wait.Close();
  283. }
  284. catch (Exception ex)
  285. {
  286. //MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  287. ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
  288. grdDetail.DataSource = null;
  289. _wait.Close();
  290. }
  291. }
  292. #endregion
  293. #region 分页
  294. private void rptPage_PageIndexChanged(object Sender, EventArgs e)
  295. {
  296. DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
  297. //DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
  298. grdDetail.DataSource = data;
  299. }
  300. #endregion
  301. #region 列表
  302. private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  303. {
  304. }
  305. #endregion
  306. #region 加载
  307. private void FormICSFACTORY_Load(object sender, EventArgs e)
  308. {
  309. }
  310. #endregion
  311. #region 导出
  312. private void btnOutPut_Click(object sender, EventArgs e)
  313. {
  314. FormOutExcel foe = new FormOutExcel();
  315. if (foe.ShowDialog() == DialogResult.OK)
  316. {
  317. try
  318. {
  319. string outtype = foe._OutType;
  320. string exceltype = foe._ExcelType;
  321. string filename = foe._FileName;
  322. string url = foe._Url;
  323. string sheetname = foe._SheetName;
  324. string name = "";
  325. if (outtype.ToLower() == "excel")
  326. {
  327. DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
  328. op.SheetName = sheetname;
  329. grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
  330. name = url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx");
  331. }
  332. else
  333. {
  334. grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
  335. name = url + "\\" + filename + ".pdf";
  336. }
  337. DialogResult result = MessageBox.Show("导出成功,是否打开此文件?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
  338. if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(name))
  339. {
  340. System.Diagnostics.Process.Start(name);
  341. }
  342. }
  343. catch (Exception ex)
  344. {
  345. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  346. }
  347. }
  348. }
  349. #endregion
  350. private void chkMO2UserDate_CheckedChanged(object sender, EventArgs e)
  351. {
  352. //if (chkMO2UserDate.Checked)
  353. //{
  354. // dtpMO2UserDateS.Enabled = true;
  355. // dtpMO2UserDateE.Enabled = true;
  356. //}
  357. //else
  358. //{
  359. // dtpMO2UserDateS.Enabled = false;
  360. // dtpMO2UserDateE.Enabled = false;
  361. //}
  362. }
  363. private void chkLotBeginDate_CheckedChanged(object sender, EventArgs e)
  364. {
  365. //if (chkLotBeginDate.Checked)
  366. //{
  367. // dtpLotBeginDateS.Enabled = true;
  368. // dtpLotBeginDateE.Enabled = true;
  369. //}
  370. //else
  371. //{
  372. // dtpLotBeginDateS.Enabled = false;
  373. // dtpLotBeginDateE.Enabled = false;
  374. //}
  375. }
  376. #region 单元格背景色设置
  377. private void grvDetail_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
  378. {
  379. #region 现逻辑
  380. //单元格
  381. if (e != null && e.RowHandle >= 0 && e.Column.FieldName.Contains("工序") && grvDetail.GetRowCellValue(e.RowHandle, e.Column.FieldName) != null && e.Column.FieldName != "工序数")
  382. {
  383. string oppcode = "";
  384. string oppcodes = "";
  385. string opcode = grvDetail.GetRowCellValue(e.RowHandle, e.Column.FieldName).ToString();
  386. string lotno = grvDetail.GetRowCellValue(e.RowHandle, "产品跟踪码").ToString();
  387. string[] opArray = opcode.Split(':');
  388. if (opArray.Length == 3)
  389. {
  390. oppcode = opArray[1];
  391. }
  392. else
  393. {
  394. oppcode = opArray[0];
  395. }
  396. DataTable dt = Color_table.AsEnumerable().Where(a => a["LOTNO"].ToString()== lotno && a["OPCODE"].ToString()== oppcode).AsDataView().ToTable();
  397. //未派工
  398. if ((dt.Rows.Count<=0|| string.IsNullOrEmpty(dt.Rows[0]["id"].ToString()))&&oppcode!="")
  399. {
  400. e.Appearance.BackColor = Color.Blue;
  401. }
  402. //派工,未开工
  403. else if (dt != null && dt.Rows.Count > 0 && string.IsNullOrEmpty(dt.Rows[0]["id"].ToString()) == false && string.IsNullOrEmpty(dt.Rows[0]["OPCODE"].ToString()))
  404. {
  405. e.Appearance.BackColor = Color.Aqua;
  406. }
  407. //完工、检验合格
  408. else if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["Result"].ToString() == "合格" && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END")
  409. {
  410. e.Appearance.BackColor = Color.Green;
  411. color = Color.Green;
  412. }
  413. //完工、检验不合格
  414. else if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["Result"].ToString() == "不合格" && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END")
  415. {
  416. e.Appearance.BackColor = Color.Red;
  417. color = Color.Red;
  418. }
  419. //完工、自检不合格
  420. else if (dt != null && dt.Rows.Count > 0 && (dt.Rows[0]["Result"].ToString() == "") && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END" && !String.IsNullOrEmpty(dt.Rows[0]["ID"].ToString()))
  421. {
  422. e.Appearance.BackColor = Color.FromArgb(254, 177, 95);
  423. color = Color.FromArgb(254, 177, 95);
  424. }
  425. //完工、未检验
  426. else if (dt != null && dt.Rows.Count > 0 && (dt.Rows[0]["Result"].ToString() == "" || dt.Rows[0]["Result"].ToString() == "待检") && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END")
  427. {
  428. e.Appearance.BackColor = Color.GreenYellow;
  429. color = Color.GreenYellow;
  430. }
  431. //开工、未完工
  432. else if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_BEGIN" && dt.Rows[0]["ACTIONRESULT"].ToString() != "COLLECT_END")
  433. {
  434. e.Appearance.BackColor = Color.Yellow;
  435. color = Color.Yellow;
  436. }
  437. }
  438. #endregion
  439. }
  440. #endregion
  441. #region 单元格背景色设置
  442. private void grdView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
  443. {
  444. }
  445. #endregion
  446. private void rptPage_Load(object sender, EventArgs e)
  447. {
  448. }
  449. private void panel1_Paint(object sender, PaintEventArgs e)
  450. {
  451. }
  452. private void MDeptCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
  453. {
  454. ButtonEdit btn = (ButtonEdit)sender;
  455. string sql = @"select distinct MDeptCode from icsmo";
  456. //object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
  457. //if (obj == null)
  458. //{
  459. // ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
  460. //}
  461. DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
  462. FormDataRefer reForm = new FormDataRefer();
  463. reForm.FormTitle = "生产部门";
  464. DataTable menuData = data;
  465. reForm.DataSource = menuData;
  466. reForm.MSelectFlag = false;
  467. reForm.RowIndexWidth = 35;
  468. reForm.FormWidth = 500;
  469. reForm.FormHeight = 500;
  470. //reForm.FilterKey = btn.Text;
  471. //grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
  472. if (reForm.ShowDialog() == DialogResult.OK)
  473. {
  474. DataTable retData = reForm.ReturnData;
  475. string type = "";
  476. foreach (DataRow dr in retData.Rows)
  477. {
  478. MDeptCode.Text = dr["MDeptCode"].ToString();
  479. }
  480. }
  481. }
  482. private void simpleButton1_Click(object sender, EventArgs e)
  483. {
  484. FormOutExcel foe = new FormOutExcel();
  485. if (foe.ShowDialog() == DialogResult.OK)
  486. {
  487. try
  488. {
  489. string outtype = foe._OutType;
  490. string exceltype = foe._ExcelType;
  491. string filename = foe._FileName;
  492. string url = foe._Url;
  493. string sheetname = foe._SheetName;
  494. if (outtype.ToLower() == "excel")
  495. {
  496. DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
  497. op.SheetName = sheetname;
  498. grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
  499. }
  500. else
  501. {
  502. grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
  503. }
  504. MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  505. }
  506. catch (Exception ex)
  507. {
  508. MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
  509. }
  510. }
  511. }
  512. }
  513. }