Packing_CartonTransfer.cs 31 KB

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