private int CopyFromHead(string billno) { int insertId = 0; string sql = "select top 1 SHIP_ID,VOYAGE_NO,BILL_NO,I_E_FLAG,PACK_NO,I_E_DATE,DEC_TYPE from EHS_SCAN_HEAD where BILL_NO=@BILL_NO"; Hashtable ht = new Hashtable(); ht["BILL_NO"] = billno; DataRow dr = comm.GetOneRow(sql, ht); if (dr != null) { Hashtable htparm = DataRowToHashtable(dr); htparm["Multi_Pack_No"] = 1; htparm["SCAN_NO"] = maxScanNo + 1; htparm["SEND_TYPE"] = dr["DEC_TYPE"]; insertId = comm.InsertByHashtable("EHS_SCAN_TMP1", htparm, true); SendComData(insertId, htparm); UpdateList2(dr["VOYAGE_NO"].ToString(), true); UpdateHead(billno); } else { DataRow drLast = GetLastScanDataInTmp(); if (drLast != null) { ht["SHIP_ID"] = drLast["SHIP_ID"].ToString(); ht["VOYAGE_NO"] = drLast["VOYAGE_NO"].ToString(); ht["I_E_FLAG"] = drLast["I_E_FLAG"].ToString(); ht["I_E_DATE"] = drLast["I_E_DATE"]; ht["PACK_NO"] = 1; ht["DEC_TYPE"] = 1; ht["SCAN_NO"] = maxScanNo + 1; ht["Multi_Pack_No"] = 1; ht["SEND_TYPE"] = 2; insertId = comm.InsertByHashtable("EHS_SCAN_TMP1", ht, true); SendComData(insertId, ht); UpdateList2(drLast["VOYAGE_NO"].ToString(), true); } else { ht["SHIP_ID"] = "111111"; ht["VOYAGE_NO"] = "111111"; ht["I_E_FLAG"] = "I"; ht["I_E_DATE"] = DateTime.Now; ht["PACK_NO"] = 1; ht["DEC_TYPE"] = 1; ht["SCAN_NO"] = maxScanNo + 1; ht["Multi_Pack_No"] = 1; ht["SEND_TYPE"] = 2; insertId = comm.InsertByHashtable("EHS_SCAN_TMP1", ht, true); SendComData(insertId, ht); UpdateList2("111111", true); } } return(insertId); }