Special_Reset.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. using DevExpress.XtraPrinting.Export.Pdf;
  2. using HslCommunication.Profinet.Knx;
  3. using NPOI.HSSF.UserModel;
  4. using NPOI.SS.UserModel;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Diagnostics;
  10. using System.Drawing;
  11. using System.IO;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using UAS_MES_NEW.DataOperate;
  16. using UAS_MES_NEW.Entity;
  17. using UAS_MES_NEW.PublicMethod;
  18. using NPOI.HSSF.UserModel;
  19. using NPOI.SS.UserModel;
  20. using NPOI.SS.Formula.Functions;
  21. namespace UAS_MES_NEW.Special
  22. {
  23. public partial class Special_Reset : Form
  24. {
  25. DataHelper dh;
  26. LogStringBuilder sql = new LogStringBuilder();
  27. AutoSizeFormClass asc = new AutoSizeFormClass();
  28. DataTable Dbfind;
  29. DataTable dt;
  30. List<String> sb = new List<string>();
  31. public Special_Reset()
  32. {
  33. InitializeComponent();
  34. }
  35. private void Special_BoxSplit_Load(object sender, EventArgs e)
  36. {
  37. dh = SystemInf.dh;
  38. asc.controllInitializeSize(this);
  39. cd_stepcode.FormName = Name;
  40. cd_stepcode.TableName = "craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id";
  41. cd_stepcode.SetValueField = new string[] { "cd_stepcode", "cd_stepno" };
  42. cd_stepcode.SelectField = "cd_stepname # 工序名称 ,cd_stepcode # 工序编号,cd_stepno # 执行顺序";
  43. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  44. cd_stepcode.DBTitle = "回流工序";
  45. cd_stepcode.DbChange += Cd_stepcode_DbChange;
  46. }
  47. private void Cd_stepcode_DbChange(object sender, EventArgs e)
  48. {
  49. Dbfind = cd_stepcode.ReturnData;
  50. BaseUtil.SetFormValue(this.Controls, Dbfind);
  51. }
  52. private bool ReSN(string sncode, string stepcode)
  53. {
  54. DataTable dt = (DataTable)dh.ExecuteSql("select ms_paststep,ms_makecode from makeserial where ms_sncode ='" + sncode + "' order by ms_id desc", "select");
  55. if (!dt.Rows[0]["ms_paststep"].ToString().Contains(cd_stepcode.Text))
  56. {
  57. OperatResult.AppendText(">>序列号" + sncode + "不允许回流到未执行工序\n", Color.Red);
  58. return false;
  59. }
  60. string makecode = dt.Rows[0]["ms_makecode"].ToString();
  61. string stname = dh.getFieldDataByCondition("step", "st_name", "st_code = '" + stepcode + "'").ToString();
  62. dh.ExecuteSql("update makeserial set ms_status=1,ms_outboxcode='',ms_printcount = 0, ms_nextstepcode= '" + stepcode + "' where ms_sncode='" + sncode + "' and ms_makecode='" + makecode + "'", "update");
  63. dh.ExecuteSql("delete makebad where mb_sncode = '" + sncode + "' and mb_makecode='" + makecode + "' and mb_status = 0", "delete");
  64. dh.ExecuteSql("delete labelprintlog where lpl_value = '" + sncode + "' ", "delete");
  65. sql.Clear();
  66. sql.Append("update craftmaterial set cm_status=-1,cm_lastdeco=-1,cm_dropman='" + User.UserCode + "',");
  67. sql.Append("cm_dropdate =sysdate,CM_REMARK = '重置站点拆解',cm_dropstep='" + User.CurrentStepCode + "',");
  68. sql.Append("cm_dropsccode='" + User.UserSourceCode + "' where cm_sncode = '" + sncode + "' and cm_makecode='" + makecode + "' and cm_stepcode in (select cd_stepcode from craftdetail left join step on st_code=cd_stepcode left join craft on cd_crid=cr_id where ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_detno >=" + cd_stepno.Text + " )");
  69. dh.ExecuteSql(sql.GetString(), "update");
  70. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "站点重置", "站点重置至" + stname, sncode, "");
  71. return true;
  72. }
  73. private void Split_Click(object sender, EventArgs e)
  74. {
  75. if (sb.Count == 0 || cd_stepcode.Text == "")
  76. {
  77. OperatResult.AppendText(">>采集数与回流工位不能为空\n", Color.Red);
  78. return;
  79. }
  80. string Delete = MessageBox.Show(this.ParentForm, "是否确认重置站点?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  81. if (Delete == "Yes")
  82. {
  83. if (serBtn.Checked)
  84. {
  85. for (int i = 0; i < sb.Count; i++)
  86. {
  87. if (ReSN(sb[i].ToString(), cd_stepcode.Text))
  88. OperatResult.AppendText("SN:" + sb[i].ToString() + "回流至" + cd_stepcode.Text + "完成\n", Color.Green);
  89. }
  90. WeighRecord.Clear();
  91. sb.Clear();
  92. }
  93. else if (bigboxBtn.Checked)
  94. {
  95. string stname = dh.getFieldDataByCondition("step", "st_name", "st_code = '" + cd_stepcode.Text + "'").ToString();
  96. for (int i = 0; i < sb.Count; i++)
  97. {
  98. if (dh.CheckExist("package", "pa_outboxcode='" + sb[i].ToString() + "' and pa_status=1"))
  99. {
  100. DataTable dt2 = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial left Join package on pa_outboxcode=ms_outboxcode where ms_outboxcode = '" + sb[i].ToString() + "' and pa_status=1", "select");
  101. for (int k = 0; k < dt2.Rows.Count; k++)
  102. {
  103. ReSN(dt2.Rows[k]["ms_sncode"].ToString(), cd_stepcode.Text);
  104. }
  105. dh.ExecuteSql("delete from labelprintlog where lpl_value='" + sb[i].ToString() + "'", "delete");
  106. dh.ExecuteSql("insert into PACKAGEBACKUP(PA_ID, PA_PRODCODE, PA_OUTBOXCODE, PA_PACKDATE, PA_LEVEL, PA_PACKAGEQTY, PA_TOTALQTY, PA_MAKECODE, PA_STATUS, PA_INDATE, PA_SALECODE, PA_PRINTCOUNT, PA_CUSTCODE, PA_TYPE, PA_WEIGHT, PA_CURRENTQTY, PA_PACKTYPE, PA_CHECKNO, PA_DOWNSTATUS, PA_STANDARDQTY, PA_SCCODE, PA_YMD, PA_MOTHERCODE, PA_CURRENTSTEP, PA_NEXTSTEP, PA_OUTNO, PA_IOSTATUS, PA_REMARK, PA_WHCODE, PA_B2BID, PA_INNO)" +
  107. " select PA_ID, PA_PRODCODE, PA_OUTBOXCODE, PA_PACKDATE, PA_LEVEL, PA_PACKAGEQTY, PA_TOTALQTY, PA_MAKECODE, PA_STATUS, PA_INDATE, PA_SALECODE, PA_PRINTCOUNT, PA_CUSTCODE, PA_TYPE, PA_WEIGHT, PA_CURRENTQTY, PA_PACKTYPE, PA_CHECKNO, PA_DOWNSTATUS, PA_STANDARDQTY, PA_SCCODE, PA_YMD, PA_MOTHERCODE, PA_CURRENTSTEP, PA_NEXTSTEP, PA_OUTNO, PA_IOSTATUS, PA_REMARK, PA_WHCODE, PA_B2BID, PA_INNO from package where pa_outboxcode='" + sb[i].ToString() + "'", "insert");
  108. dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "insert");
  109. dh.ExecuteSql("delete from package where pa_outboxcode = '" + sb[i].ToString() + "'", "delete");
  110. //删除箱的明细
  111. dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "delete");
  112. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "站点重置", "站点重置至" + stname, sb[i].ToString(), "");
  113. OperatResult.AppendText("卡通箱:" + sb[i].ToString() + "回流至" + cd_stepcode.Text + "完成\n", Color.Green);
  114. }
  115. else
  116. {
  117. OperatResult.AppendText("卡通箱:" + sb[i].ToString() + "未封箱,不允许回流\n", Color.Green);
  118. }
  119. }
  120. WeighRecord.Clear();
  121. sb.Clear();
  122. }
  123. sql.Clear();
  124. sql.Append("MERGE INTO makecraftdetail USING (select mcd_macode,mcd_detno,mcd_stepcode,mcd_stepname,nvl(count(distinct A.ms_sncode),0) n,nvl(count(distinct B.ms_sncode),0) bn,(select nvl(count(distinct sp_sncode),0) from STEPPASSED where SP_MAKECODE = mcd_macode AND SP_STEPCODE = mcd_stepcode) inqty from MAKECRAFTdetail");
  125. sql.Append(" left join makeserial A on mcd_macode = A.ms_makecode and mcd_stepcode = A.ms_nextstepcode AND A.MS_STATUS = 1 LEFT JOIN MAKESERIAL B ON mcd_macode = B.ms_makecode AND MCD_STEPCODE = B.MS_STEPCODE AND B.MS_STATUS = 3 where mcd_macode = '" + ms_makecode.Text + "' group by mcd_macode,mcd_detno, mcd_stepcode, mcd_stepname order by mcd_detno asc) A");
  126. sql.Append(" ON (makecraftdetail.MCD_MACODE = A.MCD_MACODE and makecraftdetail.mcd_stepcode = A.mcd_stepcode) ");
  127. sql.Append(" WHEN MATCHED THEN UPDATE SET makecraftdetail.mcd_inqty = A.inqty,makecraftdetail.mcd_outqty = A.inqty,makecraftdetail.mcd_okqty = A.inqty ");
  128. dh.ExecuteSql(sql.GetString(), "update");
  129. }
  130. }
  131. private void bigboxBtn_Click(object sender, EventArgs e)
  132. {
  133. if (((RadioButton)sender).Checked == true)
  134. {
  135. if (WeighRecord.Items.Count > 0)
  136. {
  137. string logout_confirm = MessageBox.Show(this.ParentForm, "是否更换采集项(已录入信息会清空)?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  138. if (logout_confirm == "Yes")
  139. {
  140. WeighRecord.Items.Clear();
  141. sb.Clear();
  142. ms_makecode.Text = "";
  143. ms_prodcode.Text = "";
  144. cr_code.Text = "";
  145. cd_stepcode.Text = "";
  146. }
  147. else
  148. {
  149. serBtn.Checked = bigboxBtn.Checked;
  150. bigboxBtn.Checked = !serBtn.Checked;
  151. }
  152. }
  153. if (((RadioButton)sender).Name == "serBtn")
  154. {
  155. input.Focus();
  156. OperatResult.AppendText("请输入序列号进行采集\n", Color.Black, input);
  157. }
  158. else if (((RadioButton)sender).Name == "bigboxBtn")
  159. {
  160. input.Focus();
  161. OperatResult.AppendText("请输入箱号进行采集\n", Color.Black, input);
  162. }
  163. }
  164. }
  165. private void cr_code_TextChanged(object sender, EventArgs e)
  166. {
  167. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  168. }
  169. private void input_KeyDown(object sender, KeyEventArgs e)
  170. {
  171. if (e.KeyCode == Keys.Enter)
  172. {
  173. if (serBtn.Checked)
  174. {
  175. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei1='" + input.Text + "' order by ms_id desc", "select");
  176. if (dt.Rows.Count > 0)
  177. {
  178. input.Text = dt.Rows[0]["ms_sncode"].ToString();
  179. }
  180. else
  181. {
  182. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + input.Text + "' order by ms_id desc", "select");
  183. if (dt.Rows.Count > 0)
  184. {
  185. input.Text = dt.Rows[0]["ms_sncode"].ToString();
  186. }
  187. else
  188. {
  189. dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei1='" + input.Text + "' order by mil_id desc", "select");
  190. if (dt.Rows.Count > 0)
  191. {
  192. input.Text = dt.Rows[0]["mil_sncode"].ToString();
  193. }
  194. else
  195. {
  196. dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei2='" + input.Text + "' order by mil_id desc", "select");
  197. if (dt.Rows.Count > 0)
  198. {
  199. input.Text = dt.Rows[0]["mil_sncode"].ToString();
  200. }
  201. }
  202. }
  203. }
  204. dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_prodcode,ms_sncode,ms_craftcode cr_code,ms_status,ms_outboxcode from makeserial where ms_sncode = '" + input.Text + "' or ms_imei1='" + input.Text + "' or ms_imei2='" + input.Text + "' order by ms_id desc", "select");
  205. if (dt.Rows.Count > 0)
  206. {
  207. input.Text = dt.Rows[0]["ms_sncode"].ToString();
  208. if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
  209. {
  210. OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
  211. return;
  212. }
  213. if (dt.Rows[0]["ms_status"].ToString() == "3")
  214. {
  215. OperatResult.AppendText("SN:" + input.Text + "为不良品,不允许采集\n", Color.Red, input);
  216. return;
  217. }
  218. if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
  219. {
  220. OperatResult.AppendText("SN:" + input.Text + "已装箱" + dt.Rows[0]["ms_outboxcode"].ToString() + ",不允许采集\n", Color.Red, input);
  221. return;
  222. }
  223. BaseUtil.SetFormValue(this.Controls, dt);
  224. if (sb.Contains(dt.Rows[0]["ms_sncode"].ToString()))
  225. {
  226. OperatResult.AppendText("SN:" + input.Text + "已采集\n", Color.Red, input);
  227. return;
  228. }
  229. WeighRecord.Items.Add(dt.Rows[0]["ms_sncode"].ToString());
  230. sb.Add(dt.Rows[0]["ms_sncode"].ToString());
  231. OperatResult.AppendText("SN:" + input.Text + "采集\n", Color.Green, input);
  232. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  233. }
  234. else
  235. {
  236. OperatResult.AppendText("SN:" + input.Text + "不存在\n", Color.Red, input);
  237. return;
  238. }
  239. }
  240. else if (bigboxBtn.Checked)
  241. {
  242. dt = (DataTable)dh.ExecuteSql("select pa_makecode ms_makecode,pa_prodcode ms_prodcode,pa_outboxcode,pa_mothercode,ma_craftcode,nvl(pa_iostatus,0)pa_iostatus,ma_craftcode cr_code from package left join make on pa_makecode = ma_code where pa_outboxcode = '" + input.Text + "' and pa_type = '1'", "select");
  243. if (dt.Rows.Count > 0)
  244. {
  245. if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
  246. {
  247. OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
  248. return;
  249. }
  250. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  251. {
  252. OperatResult.AppendText("卡通箱:" + input.Text + "处于状态入库状态,不允许采集\n", Color.Red, input);
  253. return;
  254. }
  255. if (dt.Rows[0]["pa_mothercode"].ToString() != "")
  256. {
  257. OperatResult.AppendText("卡通箱:" + input.Text + "已装栈板" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许采集\n", Color.Red, input);
  258. return;
  259. }
  260. BaseUtil.SetFormValue(this.Controls, dt);
  261. if (sb.Contains(dt.Rows[0]["pa_outboxcode"].ToString()))
  262. {
  263. OperatResult.AppendText("卡通箱:" + input.Text + "已采集\n", Color.Red, input);
  264. return;
  265. }
  266. WeighRecord.Items.Add(dt.Rows[0]["pa_outboxcode"].ToString());
  267. sb.Add(dt.Rows[0]["pa_outboxcode"].ToString());
  268. OperatResult.AppendText("卡通箱:" + input.Text + "采集\n", Color.Green, input);
  269. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  270. }
  271. else
  272. {
  273. OperatResult.AppendText("卡通箱:" + input.Text + "不存在\n", Color.Red, input);
  274. return;
  275. }
  276. }
  277. }
  278. }
  279. private void 数据清空_Click(object sender, EventArgs e)
  280. {
  281. BaseUtil.CleanControls(this.Controls);
  282. WeighRecord.Items.Clear();
  283. sb.Clear();
  284. }
  285. private void Special_Reset_SizeChanged(object sender, EventArgs e)
  286. {
  287. asc.controlAutoSize(this);
  288. }
  289. private void Export_Click(object sender, EventArgs e)
  290. {
  291. ExportFileDialog.Description = "选择导出的路径";
  292. DialogResult result = ExportFileDialog.ShowDialog();
  293. if (result == DialogResult.OK)
  294. {
  295. ExcelHandler eh = new ExcelHandler();
  296. sql.Clear();
  297. sql.Append("select ''箱号,'' SN from dual ");
  298. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  299. eh.ExportExcel(dt, ExportFileDialog.SelectedPath + "\\导出模板.xls");
  300. //string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  301. }
  302. }
  303. private void ImportExcel_Click(object sender, EventArgs e)
  304. {
  305. ImportExcel1.Filter = "(*.xls)|*.xls";
  306. DialogResult result;
  307. result = ImportExcel1.ShowDialog();
  308. if (result == DialogResult.OK)
  309. {
  310. DataTable dt = ExcelToDataTable(ImportExcel1.FileName, true);
  311. for (int i = 0; i < dt.Rows.Count; i++)
  312. {
  313. if (bigboxBtn.Checked)
  314. {
  315. input.Text = dt.Rows[i]["箱号"].ToString();
  316. input_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  317. }
  318. if (serBtn.Checked)
  319. {
  320. input.Text = dt.Rows[i]["SN"].ToString();
  321. input_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  322. }
  323. }
  324. }
  325. }
  326. public static DataTable ExcelToDataTable(string filePath, bool isColumnName)
  327. {
  328. DataTable dataTable = null;
  329. FileStream fs = null;
  330. DataColumn column = null;
  331. DataRow dataRow = null;
  332. IWorkbook workbook = null;
  333. ISheet sheet = null;
  334. IRow row = null;
  335. ICell cell = null;
  336. int startRow = 0;
  337. try
  338. {
  339. using (fs = File.OpenRead(filePath))
  340. {
  341. // 2007版本
  342. workbook = new HSSFWorkbook(fs);
  343. if (workbook != null)
  344. {
  345. sheet = workbook.GetSheetAt(0);//读取第一个sheet,当然也可以循环读取每个sheet
  346. dataTable = new DataTable();
  347. if (sheet != null)
  348. {
  349. int rowCount = sheet.LastRowNum;//总行数
  350. if (rowCount > 0)
  351. {
  352. IRow firstRow = sheet.GetRow(0);//第一行
  353. int cellCount = firstRow.LastCellNum;//列数
  354. //构建datatable的列
  355. if (isColumnName)
  356. {
  357. startRow = 1;//如果第一行是列名,则从第二行开始读取
  358. for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
  359. {
  360. cell = firstRow.GetCell(i);
  361. if (cell != null)
  362. {
  363. if (cell.StringCellValue != null)
  364. {
  365. column = new DataColumn(cell.StringCellValue);
  366. dataTable.Columns.Add(column);
  367. }
  368. }
  369. }
  370. }
  371. else
  372. {
  373. for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
  374. {
  375. column = new DataColumn("column" + (i + 1));
  376. dataTable.Columns.Add(column);
  377. }
  378. }
  379. //填充行
  380. for (int i = startRow; i <= rowCount; ++i)
  381. {
  382. row = sheet.GetRow(i);
  383. if (row == null) continue;
  384. dataRow = dataTable.NewRow();
  385. for (int j = row.FirstCellNum; j < cellCount; ++j)
  386. {
  387. cell = row.GetCell(j);
  388. if (cell == null)
  389. {
  390. dataRow[j] = "";
  391. }
  392. else
  393. {
  394. //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,)
  395. switch (cell.CellType)
  396. {
  397. case CellType.BLANK:
  398. dataRow[j] = "";
  399. break;
  400. case CellType.NUMERIC:
  401. short format = cell.CellStyle.DataFormat;
  402. //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理
  403. if (format == 14 || format == 31 || format == 57 || format == 58)
  404. dataRow[j] = cell.DateCellValue;
  405. else
  406. dataRow[j] = cell.NumericCellValue;
  407. break;
  408. case CellType.STRING:
  409. dataRow[j] = cell.StringCellValue;
  410. break;
  411. case CellType.FORMULA:
  412. dataRow[j] = cell.StringCellValue;
  413. break;
  414. }
  415. }
  416. }
  417. dataTable.Rows.Add(dataRow);
  418. }
  419. }
  420. }
  421. }
  422. }
  423. return dataTable;
  424. }
  425. catch (Exception ex)
  426. {
  427. Console.WriteLine(ex.Message);
  428. if (fs != null)
  429. {
  430. fs.Close();
  431. }
  432. return null;
  433. }
  434. }
  435. }
  436. }