Packing_CartonTransfer.cs 31 KB

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