Special_Reset.cs 25 KB

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