Special_Reset.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  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. DataTable dt2 = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_outboxcode = '" + sb[i].ToString() + "'", "select");
  99. for (int k = 0; k < dt2.Rows.Count; k++)
  100. {
  101. ReSN(dt2.Rows[k]["ms_sncode"].ToString(), cd_stepcode.Text);
  102. }
  103. dh.ExecuteSql("delete from labelprintlog where lpl_value='" + sb[i].ToString() + "'", "delete");
  104. 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)" +
  105. " 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");
  106. dh.ExecuteSql("insert into PACKAGEBACKUPDETAIL select * from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "insert");
  107. dh.ExecuteSql("delete from package where pa_outboxcode = '" + sb[i].ToString() + "'", "delete");
  108. //删除箱的明细
  109. dh.ExecuteSql("delete from packagedetail where pd_outboxcode='" + sb[i].ToString() + "'", "delete");
  110. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "站点重置", "站点重置至" + stname, sb[i].ToString(), "");
  111. OperatResult.AppendText("卡通箱:" + sb[i].ToString() + "回流至" + cd_stepcode.Text + "完成\n", Color.Green);
  112. }
  113. WeighRecord.Clear();
  114. sb.Clear();
  115. }
  116. sql.Clear();
  117. 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");
  118. 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");
  119. sql.Append(" ON (makecraftdetail.MCD_MACODE = A.MCD_MACODE and makecraftdetail.mcd_stepcode = A.mcd_stepcode) ");
  120. sql.Append(" WHEN MATCHED THEN UPDATE SET makecraftdetail.mcd_inqty = A.inqty,makecraftdetail.mcd_outqty = A.inqty,makecraftdetail.mcd_okqty = A.inqty ");
  121. dh.ExecuteSql(sql.GetString(), "update");
  122. }
  123. }
  124. private void bigboxBtn_Click(object sender, EventArgs e)
  125. {
  126. if (((RadioButton)sender).Checked == true)
  127. {
  128. if (WeighRecord.Items.Count > 0)
  129. {
  130. string logout_confirm = MessageBox.Show(this.ParentForm, "是否更换采集项(已录入信息会清空)?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  131. if (logout_confirm == "Yes")
  132. {
  133. WeighRecord.Items.Clear();
  134. sb.Clear();
  135. ms_makecode.Text = "";
  136. ms_prodcode.Text = "";
  137. cr_code.Text = "";
  138. cd_stepcode.Text = "";
  139. }
  140. else
  141. {
  142. serBtn.Checked = bigboxBtn.Checked;
  143. bigboxBtn.Checked = !serBtn.Checked;
  144. }
  145. }
  146. if (((RadioButton)sender).Name == "serBtn")
  147. {
  148. input.Focus();
  149. OperatResult.AppendText("请输入序列号进行采集\n", Color.Black, input);
  150. }
  151. else if (((RadioButton)sender).Name == "bigboxBtn")
  152. {
  153. input.Focus();
  154. OperatResult.AppendText("请输入箱号进行采集\n", Color.Black, input);
  155. }
  156. }
  157. }
  158. private void cr_code_TextChanged(object sender, EventArgs e)
  159. {
  160. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  161. }
  162. private void input_KeyDown(object sender, KeyEventArgs e)
  163. {
  164. if (e.KeyCode == Keys.Enter)
  165. {
  166. if (serBtn.Checked)
  167. {
  168. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei1='" + input.Text + "' order by ms_id desc", "select");
  169. if (dt.Rows.Count > 0)
  170. {
  171. input.Text = dt.Rows[0]["ms_sncode"].ToString();
  172. }
  173. else
  174. {
  175. dt = (DataTable)dh.ExecuteSql("select ms_sncode from makeserial where ms_imei2='" + 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 mil_sncode from makeimeilist where mil_imei1='" + input.Text + "' order by mil_id desc", "select");
  183. if (dt.Rows.Count > 0)
  184. {
  185. input.Text = dt.Rows[0]["mil_sncode"].ToString();
  186. }
  187. else
  188. {
  189. dt = (DataTable)dh.ExecuteSql("select mil_sncode from makeimeilist where mil_imei2='" + 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. }
  195. }
  196. }
  197. 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");
  198. if (dt.Rows.Count > 0)
  199. {
  200. input.Text = dt.Rows[0]["ms_sncode"].ToString();
  201. if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
  202. {
  203. OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
  204. return;
  205. }
  206. if (dt.Rows[0]["ms_status"].ToString() == "3")
  207. {
  208. OperatResult.AppendText("SN:" + input.Text + "为不良品,不允许采集\n", Color.Red, input);
  209. return;
  210. }
  211. if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
  212. {
  213. OperatResult.AppendText("SN:" + input.Text + "已装箱" + dt.Rows[0]["ms_outboxcode"].ToString() + ",不允许采集\n", Color.Red, input);
  214. return;
  215. }
  216. BaseUtil.SetFormValue(this.Controls, dt);
  217. if (sb.Contains(dt.Rows[0]["ms_sncode"].ToString()))
  218. {
  219. OperatResult.AppendText("SN:" + input.Text + "已采集\n", Color.Red, input);
  220. return;
  221. }
  222. WeighRecord.Items.Add(dt.Rows[0]["ms_sncode"].ToString());
  223. sb.Add(dt.Rows[0]["ms_sncode"].ToString());
  224. OperatResult.AppendText("SN:" + input.Text + "采集\n", Color.Green, input);
  225. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  226. }
  227. else
  228. {
  229. OperatResult.AppendText("SN:" + input.Text + "不存在\n", Color.Red, input);
  230. return;
  231. }
  232. }
  233. else if (bigboxBtn.Checked)
  234. {
  235. 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");
  236. if (dt.Rows.Count > 0)
  237. {
  238. if (ms_makecode.Text != "" && dt.Rows[0]["ms_makecode"].ToString() != ms_makecode.Text)
  239. {
  240. OperatResult.AppendText("SN:" + input.Text + "所属工单" + dt.Rows[0]["ms_makecode"].ToString() + "与当前工单" + ms_makecode.Text + "不一致\n", Color.Red, input);
  241. return;
  242. }
  243. if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
  244. {
  245. OperatResult.AppendText("卡通箱:" + input.Text + "处于状态入库状态,不允许采集\n", Color.Red, input);
  246. return;
  247. }
  248. if (dt.Rows[0]["pa_mothercode"].ToString() != "")
  249. {
  250. OperatResult.AppendText("卡通箱:" + input.Text + "已装栈板" + dt.Rows[0]["pa_mothercode"].ToString() + ",不允许采集\n", Color.Red, input);
  251. return;
  252. }
  253. BaseUtil.SetFormValue(this.Controls, dt);
  254. if (sb.Contains(dt.Rows[0]["pa_outboxcode"].ToString()))
  255. {
  256. OperatResult.AppendText("卡通箱:" + input.Text + "已采集\n", Color.Red, input);
  257. return;
  258. }
  259. WeighRecord.Items.Add(dt.Rows[0]["pa_outboxcode"].ToString());
  260. sb.Add(dt.Rows[0]["pa_outboxcode"].ToString());
  261. OperatResult.AppendText("卡通箱:" + input.Text + "采集\n", Color.Green, input);
  262. cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
  263. }
  264. else
  265. {
  266. OperatResult.AppendText("卡通箱:" + input.Text + "不存在\n", Color.Red, input);
  267. return;
  268. }
  269. }
  270. }
  271. }
  272. private void 数据清空_Click(object sender, EventArgs e)
  273. {
  274. BaseUtil.CleanControls(this.Controls);
  275. WeighRecord.Items.Clear();
  276. sb.Clear();
  277. }
  278. private void Special_Reset_SizeChanged(object sender, EventArgs e)
  279. {
  280. asc.controlAutoSize(this);
  281. }
  282. private void Export_Click(object sender, EventArgs e)
  283. {
  284. ExportFileDialog.Description = "选择导出的路径";
  285. DialogResult result = ExportFileDialog.ShowDialog();
  286. if (result == DialogResult.OK)
  287. {
  288. ExcelHandler eh = new ExcelHandler();
  289. sql.Clear();
  290. sql.Append("select ''箱号,'' SN from dual ");
  291. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  292. eh.ExportExcel(dt, ExportFileDialog.SelectedPath+"\\导出模板.xls");
  293. //string close = MessageBox.Show(this.ParentForm, "导出成功,是否打开文件", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question).ToString();
  294. }
  295. }
  296. private void ImportExcel_Click(object sender, EventArgs e)
  297. {
  298. ImportExcel1.Filter = "(*.xls)|*.xls";
  299. DialogResult result;
  300. result = ImportExcel1.ShowDialog();
  301. if (result == DialogResult.OK)
  302. {
  303. DataTable dt = ExcelToDataTable(ImportExcel1.FileName, true);
  304. for (int i = 0; i < dt.Rows.Count; i++)
  305. {
  306. if (bigboxBtn.Checked)
  307. {
  308. input.Text= dt.Rows[i]["箱号"].ToString();
  309. input_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  310. }
  311. if (serBtn.Checked)
  312. {
  313. input.Text = dt.Rows[i]["SN"].ToString();
  314. input_KeyDown(sender, new KeyEventArgs(Keys.Enter));
  315. }
  316. }
  317. }
  318. }
  319. public static DataTable ExcelToDataTable(string filePath, bool isColumnName)
  320. {
  321. DataTable dataTable = null;
  322. FileStream fs = null;
  323. DataColumn column = null;
  324. DataRow dataRow = null;
  325. IWorkbook workbook = null;
  326. ISheet sheet = null;
  327. IRow row = null;
  328. ICell cell = null;
  329. int startRow = 0;
  330. try
  331. {
  332. using (fs = File.OpenRead(filePath))
  333. {
  334. // 2007版本
  335. workbook = new HSSFWorkbook(fs);
  336. if (workbook != null)
  337. {
  338. sheet = workbook.GetSheetAt(0);//读取第一个sheet,当然也可以循环读取每个sheet
  339. dataTable = new DataTable();
  340. if (sheet != null)
  341. {
  342. int rowCount = sheet.LastRowNum;//总行数
  343. if (rowCount > 0)
  344. {
  345. IRow firstRow = sheet.GetRow(0);//第一行
  346. int cellCount = firstRow.LastCellNum;//列数
  347. //构建datatable的列
  348. if (isColumnName)
  349. {
  350. startRow = 1;//如果第一行是列名,则从第二行开始读取
  351. for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
  352. {
  353. cell = firstRow.GetCell(i);
  354. if (cell != null)
  355. {
  356. if (cell.StringCellValue != null)
  357. {
  358. column = new DataColumn(cell.StringCellValue);
  359. dataTable.Columns.Add(column);
  360. }
  361. }
  362. }
  363. }
  364. else
  365. {
  366. for (int i = firstRow.FirstCellNum; i < cellCount; ++i)
  367. {
  368. column = new DataColumn("column" + (i + 1));
  369. dataTable.Columns.Add(column);
  370. }
  371. }
  372. //填充行
  373. for (int i = startRow; i <= rowCount; ++i)
  374. {
  375. row = sheet.GetRow(i);
  376. if (row == null) continue;
  377. dataRow = dataTable.NewRow();
  378. for (int j = row.FirstCellNum; j < cellCount; ++j)
  379. {
  380. cell = row.GetCell(j);
  381. if (cell == null)
  382. {
  383. dataRow[j] = "";
  384. }
  385. else
  386. {
  387. //CellType(Unknown = -1,Numeric = 0,String = 1,Formula = 2,Blank = 3,Boolean = 4,Error = 5,)
  388. switch (cell.CellType)
  389. {
  390. case CellType.BLANK:
  391. dataRow[j] = "";
  392. break;
  393. case CellType.NUMERIC:
  394. short format = cell.CellStyle.DataFormat;
  395. //对时间格式(2015.12.5、2015/12/5、2015-12-5等)的处理
  396. if (format == 14 || format == 31 || format == 57 || format == 58)
  397. dataRow[j] = cell.DateCellValue;
  398. else
  399. dataRow[j] = cell.NumericCellValue;
  400. break;
  401. case CellType.STRING:
  402. dataRow[j] = cell.StringCellValue;
  403. break;
  404. case CellType.FORMULA:
  405. dataRow[j] = cell.StringCellValue;
  406. break;
  407. }
  408. }
  409. }
  410. dataTable.Rows.Add(dataRow);
  411. }
  412. }
  413. }
  414. }
  415. }
  416. return dataTable;
  417. }
  418. catch (Exception ex)
  419. {
  420. Console.WriteLine(ex.Message);
  421. if (fs != null)
  422. {
  423. fs.Close();
  424. }
  425. return null;
  426. }
  427. }
  428. }
  429. }