/// <summary> /// 提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCommit_Click(object sender, EventArgs e) { //bool retChecked = false; //BBackBillBB backBillBB = new BBackBillBB(); //try //{ // foreach (GridViewRow gvrow in this.grid.Rows) // { // CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); // if (chkId.Checked == true) // { // int id = int.Parse(chkId.ValidationGroup); // BBackBillData backBillModel = backBillBB.GetModel(Convert.ToInt32(id)); // if (backBillModel.instantState != "01") // { // this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条未提交退货单记录!\");", true); // return; // } // else // { // retChecked = true; // backBillModel.commitDt = System.DateTime.Now.ToString(); // backBillModel.commitEmpId = this.currentUser.empId; // backBillModel.instantState = "02"; // backBillBB.ModifyRecord(backBillModel); // } // DataTable dtDetail = new DataTable(); // BBackDetailBB backDetailBB = new BBackDetailBB(); // //获取退货明细数据源 // dtDetail = backDetailBB.GetList("backBillNo='" + backBillModel.backBillNo + "'").Tables[0]; // string commadPallet = ""; // for (int i = 0; i < dtDetail.Rows.Count; i++) // { // if (i == dtDetail.Rows.Count - 1) // { // commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "'"; // } // else // { // commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "' or "; // } // } // string command = "select distinct palletNo from BArrangeBillBox where " + commadPallet;//获取订单下的托盘号码 // SCommBB bb = new SCommBB(); // DataTable dt = bb.Query(command).Tables[0]; // bb.Dispose(); // //BForkliftTaskBC bforkTaskBC = new BForkliftTaskBC(); // //for (int j = 0; j < dt.Rows.Count; j++) // //{ // // bforkTaskBC.SaveForkliftTaskWithTHD(dt.Rows[j][0].ToString(), "YCQ", "N01.01", "30", this.currentUser.empId,backBillModel.backBillNo); // //} // } // } //} //catch (Exception ex) //{ // this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); // return; //} //finally //{ // backBillBB.Dispose(); //} //if (retChecked) //{ // this.BindGrid(); //} bool retChecked = false; BBackBillBB backBillBB = new BBackBillBB(); try { foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { int id = int.Parse(chkId.ValidationGroup); BBackBillData backBillModel = backBillBB.GetModel(Convert.ToInt32(id)); if (backBillModel.instantState != "01") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条未提交退货单记录!\");", true); return; } else { DataTable dtDetail = new DataTable(); BBackDetailBB backDetailBB = new BBackDetailBB(); //获取退货明细数据源 dtDetail = backDetailBB.GetList("backBillNo='" + backBillModel.backBillNo + "'").Tables[0]; string commadPallet = ""; for (int i = 0; i < dtDetail.Rows.Count; i++) { if (i == dtDetail.Rows.Count - 1) { commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "'"; } else { commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "' or "; } } string command = "select distinct palletNo from BArrangeBillBox where " + commadPallet;//获取订单下的托盘号码 SCommBB bb = new SCommBB(); DataTable dt = bb.Query(command).Tables[0]; //发现即便是没有数据 if (dt.Rows.Count > 0) { if (string.IsNullOrEmpty(dt.Rows[0][0].ToString())) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"箱没有在托盘上请确定!\");", true); return; } } if (dt.Rows.Count > 1) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"托盘不唯一!\");", true); return; } command = @"select checkResult from BArrangeBillBox where palletNo in ( select distinct palletNo from BArrangeBillBox where " + commadPallet + ") and checkResult = 1 "; DataTable noPass = bb.Query(command).Tables[0]; bb.Dispose(); if (noPass.Rows.Count > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"托盘上有合格的产品需要不能进行退货!\");", true); return; } //2015-08-07 修改到异常区的叉车任务的功能 BForkliftTaskBC bforkTaskBC = new BForkliftTaskBC(); if ( bforkTaskBC.SaveForkliftTaskWithTHD(dt.Rows[0][0].ToString(), "", "", "30", this.currentUser.empId, backBillModel.backBillNo)) { retChecked = true; backBillModel.commitDt = System.DateTime.Now.ToString(); backBillModel.commitEmpId = this.currentUser.empId; backBillModel.instantState = "02"; backBillBB.ModifyRecord(backBillModel); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"生成叉车任务失败!\");", true); return; } } } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { backBillBB.Dispose(); } if (retChecked) { this.BindGrid(); } }
/// <summary> /// 确定退货 /// 董利特 2015-02-05 /// 生成叉车任务 确定退货 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnConfirmReturn_Click(object sender, EventArgs e) { //生成从N01.01出库 //增加YCCK01库位 //01是未提交 02是已提交 03是已经扫描出库 bool retChecked = false; BBackBillBB backBillBB = new BBackBillBB(); try { foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { int id = int.Parse(chkId.ValidationGroup); BBackBillData backBillModel = backBillBB.GetModel(Convert.ToInt32(id)); if (backBillModel.instantState != "01") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条未提交退货单记录!\");", true); return; } else { DataTable dtDetail = new DataTable(); BBackDetailBB backDetailBB = new BBackDetailBB(); //获取退货明细数据源 dtDetail = backDetailBB.GetList("backBillNo='" + backBillModel.backBillNo + "'").Tables[0]; string commadPallet = ""; for (int i = 0; i < dtDetail.Rows.Count; i++) { if (i == dtDetail.Rows.Count - 1) { commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "'"; } else { commadPallet += "BoxNO = '" + dtDetail.Rows[i]["BoxNo"].ToString().ToUpper().Trim() + "' or "; } } string command = "select distinct palletNo from BArrangeBillBox where " + commadPallet;//获取订单下的托盘号码 SCommBB bb = new SCommBB(); DataTable dt = bb.Query(command).Tables[0]; if (dt.Rows.Count > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"所要退货的托盘多于一个 请先拆到一个托盘上!\");", true); return; } command = @"select checkResult from BArrangeBillBox where palletNo in ( select distinct palletNo from BArrangeBillBox where " + commadPallet + ") and checkResult = 0 "; DataTable noPass = bb.Query(command).Tables[0]; bb.Dispose(); if (noPass.Rows.Count > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"托盘上有合格的产品需要不能进行退货!\");", true); return; } BForkliftTaskBC bforkTaskBC = new BForkliftTaskBC(); if ( bforkTaskBC.SaveForkliftTaskWithTHD(dt.Rows[0][0].ToString(), "YCQ", "N01.01", "30", this.currentUser.empId, backBillModel.backBillNo)) { retChecked = true; backBillModel.commitDt = System.DateTime.Now.ToString(); backBillModel.commitEmpId = this.currentUser.empId; backBillModel.instantState = "02"; backBillBB.ModifyRecord(backBillModel); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"生成叉车任务失败!\");", true); return; } } } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { backBillBB.Dispose(); } if (retChecked) { this.BindGrid(); } }