Packing_CartonTransfer.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. using System;
  2. using System.Data;
  3. using System.Drawing;
  4. using System.Windows.Forms;
  5. using UAS_MES_NEW.DataOperate;
  6. using UAS_MES_NEW.Entity;
  7. using UAS_MES_NEW.PublicMethod;
  8. namespace UAS_MES_NEW.Packing
  9. {
  10. public partial class Packing_CartonTransfer : Form
  11. {
  12. AutoSizeFormClass asc = new AutoSizeFormClass();
  13. DataTable dt;
  14. DataTable dt1;
  15. DataTable dtbar;
  16. DataTable dtst;
  17. LogStringBuilder sql = new LogStringBuilder();
  18. DataHelper dh;
  19. //目标箱号相关变量
  20. string new_pa_downstatus;
  21. string new_pa_currentqty;
  22. string new_pa_standardqty;
  23. string new_pa_packtype;
  24. string new_pa_prodcode;
  25. string new_pa_salecode;
  26. string new_pa_checkno;
  27. string new_ob_status;
  28. string new_pa_mothercode;
  29. string new_pa_iostatus;
  30. public Packing_CartonTransfer()
  31. {
  32. InitializeComponent();
  33. }
  34. private void Packing_CartonTransfer_Load(object sender, EventArgs e)
  35. {
  36. asc.controllInitializeSize(this);
  37. dh = SystemInf.dh;
  38. movepack.Focus();
  39. OperateResult.AppendText(">>请输入目标箱号\n", Color.Black);
  40. }
  41. private void Packing_CartonTransfer_SizeChanged(object sender, EventArgs e)
  42. {
  43. asc.controlAutoSize(this);
  44. }
  45. private void movepack_Click(object sender, EventArgs e)
  46. {
  47. if (((RadioButton)sender).Checked == true)
  48. {
  49. if (((RadioButton)sender).Name == "movepack")
  50. {
  51. pa_outboxcode.Text = "";
  52. pa_currentqty.Text = "";
  53. pa_standardqty.Text = "";
  54. pa_standardqty.Enabled = false;
  55. ALLMOVE.Enabled = false;
  56. pa_outboxcode.Focus();
  57. }
  58. else if (((RadioButton)sender).Name == "newpack")
  59. {
  60. pa_outboxcode.Text = "";
  61. pa_currentqty.Text = "";
  62. pa_standardqty.Text = "";
  63. pa_standardqty.Enabled = true;
  64. ALLMOVE.Enabled = true;
  65. pa_outboxcode.Focus();
  66. }
  67. }
  68. }
  69. private void pa_outboxcode_KeyDown(object sender, KeyEventArgs e)
  70. {
  71. if (e.KeyCode == Keys.Enter)
  72. {
  73. if (newpack.Checked)
  74. {
  75. if (dh.CheckExist("package", "pa_outboxcode = '" + pa_outboxcode.Text + "'"))
  76. {
  77. OperateResult.AppendText(">>该箱号" + pa_outboxcode.Text + "已经存在,如需转移至已经存在的箱号,请选择移箱\n", Color.Red, pa_outboxcode);
  78. pa_outboxcode.Focus();
  79. return;
  80. }
  81. }
  82. else if (movepack.Checked)
  83. {
  84. CheckBoxCode();
  85. }
  86. }
  87. }
  88. private void sn_code_KeyDown(object sender, KeyEventArgs e)
  89. {
  90. if (e.KeyCode == Keys.Enter)
  91. {
  92. string ms_id = dh.getFieldDataByCondition("makeserial", "max(ms_id) ms_id", "ms_sncode = '" + sn_code.Text + "'").ToString();
  93. if (ms_id != "")
  94. {
  95. OperateResult.AppendText(">>序列号:" + sn_code.Text + "\n", Color.Black);
  96. sql.Clear();
  97. sql.Append("select ms_id,ms_prodcode,ms_outboxcode,ms_makecode ms_msmakecode, ms_sccode,");
  98. sql.Append("nvl(ms_currentstepcode,ms_stepcode ) laststepcode, ms_sccode lastsccode,");
  99. sql.Append("ms_checkno from makeserial where ms_id='" + ms_id + "'");
  100. dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  101. string ms_outboxcode = dt1.Rows[0]["ms_outboxcode"].ToString();
  102. string msprodcode = dt1.Rows[0]["ms_prodcode"].ToString();
  103. string ms_makecode = dt1.Rows[0]["ms_msmakecode"].ToString();
  104. if (ms_outboxcode != "")
  105. {
  106. sql.Clear();
  107. sql.Append("select pa_id,pa_checkno,PA_MAKECODE,PA_CURRENTQTY pa_qty,PA_PACKTYPE,nvl(PA_DOWNSTATUS,0) PA_DOWNSTATUS,pa_prodcode pa_macode,pa_salecode,pa_level,pa_custcode,pa_type,pa_packtype,pa_mothercode,pa_weight,pa_nextstep,pa_status,pa_sccode,pa_iostatus from package where pa_outboxcode='" + ms_outboxcode + "'");
  108. dtbar = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  109. if (dtbar.Rows.Count > 0)
  110. {
  111. string pa_mothercode = dtbar.Rows[0]["pa_mothercode"].ToString();
  112. string PA_PACKTYPE = dtbar.Rows[0]["PA_PACKTYPE"].ToString();
  113. string pa_checkno = dtbar.Rows[0]["pa_checkno"].ToString();
  114. string PA_DOWNSTATUS = dtbar.Rows[0]["PA_DOWNSTATUS"].ToString();
  115. string old_pa_id = dtbar.Rows[0]["pa_id"].ToString();
  116. string pa_iostatus = dtbar.Rows[0]["pa_iostatus"].ToString();
  117. string ob_status = dh.getFieldDataByCondition("oqcbatch", "ob_status", "ob_checkno = '" + pa_checkno + "'").ToString();
  118. if (pa_iostatus == "1")
  119. {
  120. OperateResult.AppendText(">>原箱" + ms_outboxcode + "已采集入库,不允许转移\n", Color.Red, sn_code);
  121. return;
  122. }
  123. if (pa_mothercode != "")
  124. {
  125. OperateResult.AppendText(">>原箱" + ms_outboxcode + "已装入大箱或栈板" + pa_mothercode + ",不允许转移\n", Color.Red, sn_code);
  126. return;
  127. }
  128. if (PA_DOWNSTATUS == "0")
  129. {
  130. BaseUtil.SetFormValue(this.Controls, dtbar);
  131. BaseUtil.SetFormValue(this.Controls, dt1);
  132. if (PA_PACKTYPE == "MIX")
  133. {
  134. ms_prodcode.Text = "混包";
  135. }
  136. else if (PA_PACKTYPE == "SALE")
  137. {
  138. ms_msmakecode.Text = pa_salecode.Text;
  139. }
  140. if (newpack.Checked)
  141. {
  142. if (ob_status != "UNCHECK" || ob_status != "CHECKING")
  143. {
  144. if (pa_standardqty.Text != "")
  145. {
  146. if (pa_outboxcode.Text != "")
  147. {
  148. if (dh.CheckExist("package", "pa_outboxcode = '" + pa_outboxcode.Text + "'"))
  149. {
  150. OperateResult.AppendText(">>该箱号" + pa_outboxcode.Text + "已经存在,如需转移至已经存在的箱号,请选择移箱\n", Color.Red, pa_outboxcode);
  151. pa_outboxcode.Focus();
  152. return;
  153. }
  154. else
  155. {
  156. string pa_id = dh.GetSEQ("package_seq");
  157. //新增箱
  158. sql.Clear();
  159. sql.Append("insert into package (PA_ID, PA_OUTBOXCODE,PA_PRODCODE, PA_PACKDATE,");
  160. sql.Append("PA_LEVEL,PA_PACKAGEQTY,PA_TOTALQTY,PA_MAKECODE,PA_STATUS,PA_INDATE,");
  161. sql.Append("PA_SALECODE,PA_CUSTCODE,PA_TYPE,PA_CURRENTQTY,PA_PACKTYPE,PA_STANDARDQTY,pa_nextstep,pa_sccode,pa_checkno)");
  162. sql.Append("values ('" + pa_id + "','" + pa_outboxcode.Text + "','" + msprodcode + "',sysdate,'" + pa_level.Text + "','0','0'");
  163. sql.Append(",'" + ms_makecode + "','0',sysdate,'" + pa_salecode.Text + "','" + pa_custcode.Text + "','" + pa_type.Text + "','0','" + pa_packtype.Text + "','" + pa_standardqty.Text + "','" + pa_nextstep.Text + "','" + pa_sccode.Text + "','" + pa_checkno + "')");
  164. dh.ExecuteSql(sql.GetString(), "insert");
  165. //删除原明细
  166. dh.ExecuteSql("delete from packagedetail where pd_paid='" + old_pa_id + "' and pd_barcode = '" + sn_code.Text + "'", "delete");
  167. sql.Clear();
  168. sql.Append("insert into packagedetail (PD_ID,PD_PAID,PD_OUTBOXCODE,PD_BARCODE,PD_INNERQTY,PD_PRODCODE,PD_MAKECODE,PD_BUILDDATE,PD_YMD)");
  169. sql.Append("values (packagedetail_seq.nextval,'" + pa_id + "','" + pa_outboxcode.Text + "','" + sn_code.Text + "','1','" + msprodcode + "','" + ms_makecode + "',sysdate,to_char(sysdate,'yyyymmdd'))");
  170. dh.ExecuteSql(sql.GetString(), "insert");
  171. //更新原箱数量
  172. dh.UpdateByCondition("package", "pa_currentqty=pa_currentqty-1", "pa_outboxcode = '" + ms_outboxcode + "'");
  173. //更新目标箱数量
  174. dh.UpdateByCondition("package", "pa_currentqty=1, pa_totalqty=1,pa_packageqty=1", "pa_outboxcode = '" + pa_outboxcode.Text + "'");
  175. dh.UpdateByCondition("makeserial", "ms_outboxcode = '" + pa_outboxcode.Text + "'", "ms_id = '" + ms_id + "'");
  176. dh.UpdateByCondition("oqcbatchdetail", "obd_outboxcode = '" + pa_outboxcode.Text + "'", "obd_sncode = '" + sn_code.Text + "'");
  177. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "卡通箱转移", "卡通箱转移,生成目标箱号" + pa_outboxcode.Text + "", sn_code.Text, "");
  178. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "卡通箱转移", "序列号:" + sn_code.Text + ",从原箱号:" + ms_outboxcode + "转移至目标箱号:" + pa_outboxcode.Text + "", sn_code.Text, "");
  179. OperateResult.AppendText(">>序列号:" + sn_code.Text + ",从原箱号:" + ms_outboxcode + "转移至目标箱号:" + pa_outboxcode.Text + "\n", Color.Green);
  180. pa_outboxcode_KeyDown(sender, e);
  181. }
  182. }
  183. else
  184. {
  185. OperateResult.AppendText(">>必须填写新增目标箱号\n", Color.Red);
  186. return;
  187. }
  188. }
  189. else
  190. {
  191. OperateResult.AppendText(">>新增目标箱号必须填写标准容量\n", Color.Red);
  192. return;
  193. }
  194. }
  195. else
  196. {
  197. OperateResult.AppendText(">>原箱" + ms_outboxcode + "处于送检状态,不允许转移\n", Color.Red, sn_code);
  198. return;
  199. }
  200. }
  201. else if (movepack.Checked)
  202. {
  203. if (CheckBoxCode())
  204. {
  205. if (pa_outboxcode.Text == ms_outboxcode)
  206. {
  207. OperateResult.AppendText(">>原箱" + ms_outboxcode + "和目标箱号" + pa_outboxcode.Text + "相同,不允许转移\n", Color.Red, sn_code);
  208. return;
  209. }
  210. if (PA_PACKTYPE != new_pa_packtype)
  211. {
  212. OperateResult.AppendText(">>原箱" + ms_outboxcode + "和目标箱号" + pa_outboxcode.Text + "的包装方式不一致,不允许转移\n", Color.Red, sn_code);
  213. return;
  214. }
  215. if (PA_PACKTYPE != "MIX")
  216. {
  217. if (ms_prodcode.Text != new_pa_prodcode)
  218. {
  219. OperateResult.AppendText(">>原箱号和目标箱号(目标箱产品编号" + new_pa_prodcode + ")的产品编号不一致,不允许转移\n", Color.Red, sn_code);
  220. return;
  221. }
  222. if (PA_PACKTYPE == "SALE")
  223. {
  224. if (pa_salecode.Text != new_pa_salecode)
  225. {
  226. OperateResult.AppendText(">>原箱号和目标箱号的合同号不一致,不允许转移\n", Color.Red, sn_code);
  227. return;
  228. }
  229. }
  230. }
  231. if (pa_checkno != new_pa_checkno)
  232. {
  233. if ((pa_checkno == "" && new_pa_checkno != "") || (pa_checkno != "" && new_pa_checkno == ""))
  234. {
  235. if (pa_checkno != "" && (ob_status == "UNCHECK" || ob_status == "CHECKING"))
  236. {
  237. OperateResult.AppendText(">>原箱号处于送检状态,不允许转移\n", Color.Red, sn_code);
  238. return;
  239. }
  240. if (new_pa_checkno != "" && (new_ob_status == "UNCHECK" || new_ob_status == "CHECKING"))
  241. {
  242. OperateResult.AppendText(">>目标箱号处于送检状态,不允许转移\n", Color.Red, sn_code);
  243. return;
  244. }
  245. }
  246. if (pa_checkno != "" && new_pa_checkno != "")
  247. {
  248. string a_ob_result = dh.getFieldDataByCondition("oqcbatch", "ob_status", "ob_checkno = '" + pa_checkno + "'").ToString();
  249. string b_ob_result = dh.getFieldDataByCondition("oqcbatch", "ob_status", "ob_checkno = '" + new_pa_checkno + "'").ToString();
  250. if (!((a_ob_result == b_ob_result) && (b_ob_result == "OK" || b_ob_result == "NG")))
  251. {
  252. OperateResult.AppendText(">>原箱号和目标箱号必须抽检完成,并且结果一致才可以转移\n", Color.Red, sn_code);
  253. return;
  254. }
  255. }
  256. }
  257. string new_laststepcode = dh.getFieldDataByCondition("packagedetail inner join makeserial on ms_outboxcode=pd_outboxcode and ms_sncode=pd_barcode and ms_prodcode = pd_prodcode", "max(nvl(ms_currentstepcode,ms_stepcode))", "pd_outboxcode='" + pa_outboxcode.Text + "'").ToString();
  258. if (new_laststepcode != "" && (new_laststepcode != laststepcode.Text))
  259. {
  260. OperateResult.AppendText(">>目标箱号中的序列号最后所在工序与所录入序列号最后所在工序不一致\n", Color.Red, sn_code);
  261. return;
  262. }
  263. //删除原明细
  264. dh.ExecuteSql("delete from packagedetail where pd_paid='" + old_pa_id + "' and pd_barcode = '" + sn_code.Text + "'", "delete");
  265. //更新操作
  266. sql.Clear();
  267. sql.Append("insert into packagedetail (PD_ID,PD_PAID,PD_OUTBOXCODE,PD_BARCODE,PD_INNERQTY,PD_PRODCODE,PD_MAKECODE,PD_BUILDDATE,PD_YMD)");
  268. sql.Append("values (packagedetail_seq.nextval,'" + dh.getFieldDataByCondition("package", "pa_id", "PA_OUTBOXCODE = '" + pa_outboxcode.Text + "'").ToString() + "','" + pa_outboxcode.Text + "','" + sn_code.Text + "','1','" + msprodcode + "','" + ms_makecode + "',sysdate,to_char(sysdate,'yyyymmdd'))");
  269. dh.ExecuteSql(sql.GetString(), "insert");
  270. //更新原箱数量
  271. dh.UpdateByCondition("package", "pa_currentqty=pa_currentqty-1", "pa_outboxcode = '" + ms_outboxcode + "'");
  272. //更新目标箱数量
  273. dh.UpdateByCondition("package", "pa_currentqty=nvl(pa_currentqty,0)+ 1,pa_totalqty=nvl(pa_totalqty,0)+1,pa_packageqty=nvl(pa_packageqty ,0)+1", "pa_outboxcode = '" + pa_outboxcode.Text + "'");
  274. dh.UpdateByCondition("makeserial", "ms_outboxcode = '" + pa_outboxcode.Text + "'", "ms_id = '" + ms_id + "'");
  275. dh.UpdateByCondition("oqcbatchdetail", "obd_outboxcode = '" + pa_outboxcode.Text + "'", "obd_sncode = '" + sn_code.Text + "'");
  276. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "卡通箱转移", "序列号:" + sn_code.Text + ",从原箱号:" + ms_outboxcode + "转移至目标箱号:" + pa_outboxcode.Text + "", sn_code.Text, "");
  277. OperateResult.AppendText(">>序列号:" + sn_code.Text + ",从原箱号:" + ms_outboxcode + "转移至目标箱号:" + pa_outboxcode.Text + "\n", Color.Green);
  278. // pa_outboxcode_KeyDown(sender, e);
  279. sql.Clear();
  280. sql.Append("select pa_id,pa_checkno,PA_CURRENTQTY pa_qty,PA_PACKTYPE,nvl(PA_DOWNSTATUS,0) PA_DOWNSTATUS,pa_prodcode pa_macode,pa_salecode,pa_level,pa_custcode,pa_type,pa_packtype,pa_mothercode from package where pa_outboxcode='" + ms_outboxcode + "'");
  281. dtbar = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  282. BaseUtil.SetFormValue(this.Controls, dtbar);
  283. }
  284. }
  285. }
  286. else OperateResult.AppendText(">>原箱" + ms_outboxcode + "已经下地\n", Color.Red, sn_code);
  287. }
  288. else OperateResult.AppendText(">>序列号" + sn_code.Text + "未装箱\n", Color.Red, sn_code);
  289. }
  290. else OperateResult.AppendText(">>序列号" + sn_code.Text + "未装箱\n", Color.Red, sn_code);
  291. }
  292. else OperateResult.AppendText(">>序列号" + sn_code.Text + "不存在\n", Color.Red, sn_code);
  293. }
  294. }
  295. private Boolean CheckBoxCode()
  296. {
  297. sql.Clear();
  298. sql.Append("select pa_id,pa_outboxcode,pa_checkno,pa_standardqty,nvl(pa_currentqty,0) pa_currentqty,pa_packtype,pa_prodcode,nvl(pa_downstatus,0) pa_downstatus,pa_salecode,pa_mothercode,pa_iostatus from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
  299. dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  300. if (dt.Rows.Count > 0)
  301. {
  302. new_pa_downstatus = dt.Rows[0]["pa_downstatus"].ToString();
  303. new_pa_currentqty = dt.Rows[0]["pa_currentqty"].ToString();
  304. new_pa_standardqty = dt.Rows[0]["pa_standardqty"].ToString();
  305. new_pa_packtype = dt.Rows[0]["pa_packtype"].ToString();
  306. new_pa_prodcode = dt.Rows[0]["pa_prodcode"].ToString();
  307. new_pa_salecode = dt.Rows[0]["pa_salecode"].ToString();
  308. new_pa_checkno = dt.Rows[0]["pa_checkno"].ToString();
  309. new_pa_mothercode = dt.Rows[0]["pa_mothercode"].ToString();
  310. new_pa_iostatus = dt.Rows[0]["pa_iostatus"].ToString();
  311. new_ob_status = dh.getFieldDataByCondition("oqcbatch", "ob_status", "ob_checkno = '" + new_pa_checkno + "'").ToString();
  312. if (new_pa_iostatus == "1")
  313. {
  314. OperateResult.AppendText(">>该目标箱号" + pa_outboxcode.Text + "已入库,不允许操作\n", Color.Red, pa_outboxcode);
  315. BaseUtil.CleanControls(groupBoxWithBorder2.Controls);
  316. OperateResult.AppendText(">>请输入目标箱号\n", Color.Black);
  317. pa_outboxcode.Focus();
  318. return false;
  319. }
  320. if (new_pa_downstatus != "0")
  321. {
  322. OperateResult.AppendText(">>该目标箱号" + pa_outboxcode.Text + "处于下地状态,不允许操作\n", Color.Red, pa_outboxcode);
  323. BaseUtil.CleanControls(groupBoxWithBorder2.Controls);
  324. OperateResult.AppendText(">>请输入目标箱号\n", Color.Black);
  325. pa_outboxcode.Focus();
  326. return false;
  327. }
  328. else if (new_pa_currentqty == new_pa_standardqty)
  329. {
  330. OperateResult.AppendText(">>目标箱号" + pa_outboxcode.Text + "已装满\n", Color.Red, pa_outboxcode);
  331. BaseUtil.CleanControls(groupBoxWithBorder2.Controls);
  332. OperateResult.AppendText(">>请输入目标箱号\n", Color.Black);
  333. pa_outboxcode.Focus();
  334. return false;
  335. }
  336. else if (new_pa_mothercode != "")
  337. {
  338. OperateResult.AppendText(">>目标箱号" + pa_outboxcode.Text + "装入大箱\n", Color.Red, pa_outboxcode);
  339. BaseUtil.CleanControls(groupBoxWithBorder2.Controls);
  340. OperateResult.AppendText(">>请输入目标箱号\n", Color.Black);
  341. pa_outboxcode.Focus();
  342. return false;
  343. }
  344. BaseUtil.SetFormValue(this.Controls, dt);
  345. return true;
  346. }
  347. else
  348. {
  349. OperateResult.AppendText(">>该目标箱号" + pa_outboxcode.Text + "不存在\n", Color.Red, pa_outboxcode);
  350. OperateResult.AppendText(">>请输入目标箱号\n", Color.Black);
  351. pa_outboxcode.Focus();
  352. return false;
  353. }
  354. }
  355. private void button1_Click(object sender, EventArgs e)
  356. {
  357. BaseUtil.CleanControls(this.Controls);
  358. }
  359. private void ms_outboxcode_KeyDown(object sender, KeyEventArgs e)
  360. {
  361. if (e.KeyCode == Keys.Enter)
  362. {
  363. sql.Clear();
  364. sql.Append("select pa_id,pa_checkno,PA_MAKECODE,PA_CURRENTQTY pa_qty,PA_PACKTYPE,nvl(PA_DOWNSTATUS,0) PA_DOWNSTATUS,pa_prodcode pa_macode,pa_salecode,pa_level,pa_custcode,pa_type,pa_packtype,pa_mothercode,pa_weight,pa_nextstep,pa_status,pa_sccode,pa_iostatus from package where pa_outboxcode='" + ms_outboxcode.Text + "'");
  365. DataTable dtbar = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  366. if (dtbar.Rows.Count > 0)
  367. {
  368. BaseUtil.SetFormValue(this.Controls, dtbar);
  369. }
  370. else OperateResult.AppendText(">>箱号" + ms_outboxcode.Text + "不存在\n", Color.Red, ms_outboxcode);
  371. }
  372. }
  373. private void ALLMOVE_Click(object sender, EventArgs e)
  374. {
  375. sql.Clear();
  376. sql.Append("select pa_id,pa_checkno,PA_MAKECODE,PA_CURRENTQTY pa_qty,PA_PACKTYPE,nvl(PA_DOWNSTATUS,0) PA_DOWNSTATUS,pa_prodcode pa_macode,pa_salecode,pa_level,pa_custcode,pa_type,pa_packtype,pa_mothercode,pa_weight,pa_nextstep,pa_status,pa_sccode from package where pa_outboxcode='" + ms_outboxcode.Text + "'");
  377. dtbar = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
  378. if (dtbar.Rows.Count > 0)
  379. {
  380. BaseUtil.SetFormValue(this.Controls, dtbar);
  381. }
  382. else
  383. {
  384. OperateResult.AppendText(">>箱号" + ms_outboxcode.Text + "不存在\n", Color.Red, ms_outboxcode);
  385. return;
  386. }
  387. string pa_mothercode = dtbar.Rows[0]["pa_mothercode"].ToString();
  388. string PA_PACKTYPE = dtbar.Rows[0]["PA_PACKTYPE"].ToString();
  389. string pa_checkno = dtbar.Rows[0]["pa_checkno"].ToString();
  390. string PA_DOWNSTATUS = dtbar.Rows[0]["PA_DOWNSTATUS"].ToString();
  391. string old_pa_id = dtbar.Rows[0]["pa_id"].ToString();
  392. string pa_makecode = dtbar.Rows[0]["pa_makecode"].ToString();
  393. string pa_macode = dtbar.Rows[0]["pa_macode"].ToString();
  394. string ob_status = dh.getFieldDataByCondition("oqcbatch", "ob_status", "ob_checkno = '" + pa_checkno + "'").ToString();
  395. if (pa_mothercode != "")
  396. {
  397. OperateResult.AppendText(">>原箱" + ms_outboxcode.Text + "已装入大箱,不允许转移\n", Color.Red, sn_code);
  398. return;
  399. }
  400. if (ob_status != "UNCHECK" || ob_status != "CHECKING")
  401. {
  402. if (pa_standardqty.Text != "")
  403. {
  404. if (int.Parse(pa_standardqty.Text) < int.Parse(pa_qty.Text))
  405. {
  406. OperateResult.AppendText(">>填写的标准容量" + pa_standardqty.Text + "小于待转移箱的容量\n", Color.Red);
  407. return;
  408. }
  409. if (pa_outboxcode.Text != "")
  410. {
  411. if (dh.CheckExist("package", "pa_outboxcode = '" + pa_outboxcode.Text + "'"))
  412. {
  413. OperateResult.AppendText(">>该箱号" + pa_outboxcode.Text + "已经存在,如需转移至已经存在的箱号,请选择移箱\n", Color.Red, pa_outboxcode);
  414. pa_outboxcode.Focus();
  415. return;
  416. }
  417. else
  418. {
  419. string pa_id = dh.GetSEQ("package_seq");
  420. //新增箱
  421. sql.Clear();
  422. sql.Append("insert into package (PA_ID, PA_OUTBOXCODE,PA_PRODCODE, PA_PACKDATE,");
  423. sql.Append("PA_LEVEL,PA_PACKAGEQTY,PA_TOTALQTY,PA_MAKECODE,PA_STATUS,PA_INDATE,");
  424. sql.Append("PA_SALECODE,PA_CUSTCODE,PA_TYPE,PA_CURRENTQTY,PA_PACKTYPE,PA_STANDARDQTY,pa_weight,pa_nextstep,pa_sccode,pa_checkno)");
  425. sql.Append("values ('" + pa_id + "','" + pa_outboxcode.Text + "','" + pa_macode + "',sysdate,'" + pa_level.Text + "','0','0'");
  426. sql.Append(",'" + pa_makecode + "','" + pa_status.Text + "',sysdate,'" + pa_salecode.Text + "','" + pa_custcode.Text + "','" + pa_type.Text + "','0','" + pa_packtype.Text + "','" + pa_standardqty.Text + "','" + pa_weight.Text + "','" + pa_nextstep.Text + "','" + pa_sccode.Text + "','" + pa_checkno + "')");
  427. dh.ExecuteSql(sql.GetString(), "insert");
  428. ////删除原明细
  429. //dh.ExecuteSql("delete from packagedetail where pd_paid='" + old_pa_id + "'", "delete");
  430. //sql.Clear();
  431. //sql.Append("insert into packagedetail (PD_ID,PD_PAID,PD_OUTBOXCODE,PD_BARCODE,PD_INNERQTY,PD_PRODCODE,PD_MAKECODE,PD_BUILDDATE,PD_YMD)");
  432. //sql.Append("values (packagedetail_seq.nextval,'" + pa_id + "','" + pa_outboxcode.Text + "','" + sn_code.Text + "','1','" + pa_macode + "','" + pa_makecode + "',sysdate,to_char(sysdate,'yyyymmdd'))");
  433. //dh.ExecuteSql(sql.GetString(), "insert");
  434. dh.UpdateByCondition("packagedetail", "PD_OUTBOXCODE = '" + pa_outboxcode.Text + "',PD_PAID = '" + pa_id + "'", "pd_paid='" + old_pa_id + "'");
  435. //更新原箱数量
  436. dh.UpdateByCondition("package", "pa_currentqty=0,pa_status=0,pa_weight = '',pa_checkno = ''", "pa_outboxcode = '" + ms_outboxcode.Text + "'");
  437. //更新目标箱数量
  438. dh.UpdateByCondition("package", "pa_currentqty=" + int.Parse(pa_qty.Text) + ", pa_totalqty=" + int.Parse(pa_qty.Text) + ",pa_packageqty=" + int.Parse(pa_qty.Text) + "", "pa_outboxcode = '" + pa_outboxcode.Text + "'");
  439. dh.UpdateByCondition("makeserial", "ms_outboxcode = '" + pa_outboxcode.Text + "'", "ms_outboxcode = '" + ms_outboxcode.Text + "'");
  440. dh.UpdateByCondition("oqcbatchdetail", "obd_outboxcode = '" + pa_outboxcode.Text + "'", "obd_outboxcode = '" + ms_outboxcode.Text + "'");
  441. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, "卡通箱转移", "卡通箱转移,生成目标箱号" + pa_outboxcode.Text + "", "", "");
  442. LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode, User.UserLineCode, User.UserSourceCode, "卡通箱转移", "原箱号:" + ms_outboxcode.Text + "全部转移至目标箱号:" + pa_outboxcode.Text + "", "", "");
  443. OperateResult.AppendText("原箱号:" + ms_outboxcode.Text + "全部转移至目标箱号:" + pa_outboxcode.Text + "\n", Color.Green);
  444. }
  445. }
  446. else
  447. {
  448. OperateResult.AppendText(">>必须填写新增目标箱号\n", Color.Red);
  449. return;
  450. }
  451. }
  452. else
  453. {
  454. OperateResult.AppendText(">>新增目标箱号必须填写标准容量\n", Color.Red);
  455. return;
  456. }
  457. }
  458. else
  459. {
  460. OperateResult.AppendText(">>原箱" + ms_outboxcode.Text + "处于送检状态,不允许转移\n", Color.Red, sn_code);
  461. return;
  462. }
  463. }
  464. }
  465. }