/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { BBackBillBB backBillBB = new BBackBillBB(); DataSet ds = new DataSet(); try { string strWhere = this.StrWhere; if (this.txtTHBillNo.Text.Trim() != "") { strWhere += " and BackBillNo like '%" + this.txtTHBillNo.Text.Trim().Replace("'", "''") + "%'"; } //采购订单 if (this.tbFinanceBillNo.Text.Trim() != "") { strWhere += " and financeBillNo like '%" + this.tbFinanceBillNo.Text.Trim().Replace("'", "''") + "%'"; } //供应商 if (this.tbCust.Text.Trim() != "") { strWhere += " and (custNo like '%" + this.tbCust.Text.Trim().Replace("'", "''") + "%' or custNm like '%" + this.tbCust.Text.Trim().Replace("'", "''") + "%')"; } //物料 if (this.tbMaterial.Text.Trim() != "") { strWhere += " and (materialNo like '%" + this.tbMaterial.Text.Trim().Replace("'", "''") + "%' or materialDesc like '%" + this.tbMaterial.Text.Trim().Replace("'", "''") + "%')"; } //状态 if (this.ddlState.SelectedValue != "") { strWhere += " and instantState='" + this.ddlState.SelectedValue + "'"; } ds = backBillBB.GetVList(strWhere); this.grid.DataSource = ds.Tables[0]; this.grid.DataBind(); //赋值记录条数、页面总数 this.Label3.Text = ds.Tables[0].Rows.Count.ToString(); this.Label2.Text = this.grid.PageCount.ToString(); this.currPage.Text = (this.grid.PageIndex + 1).ToString(); } finally { backBillBB.Dispose(); } }
/// <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 != "03") { 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(); } }
/// <summary> /// 删除 /// 2015-07-28 新增删除退货单明细的功能 删除备货单的时候 重新处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { bool retChecked = false; BBackBillBB backBillBB = new BBackBillBB(); BBackBillBC backBillBC = new BBackBillBC(); BBackDetailBB backDetailBB = new BBackDetailBB(); try { foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { int id = int.Parse(chkId.ValidationGroup); string strBackBillNo = this.grid.DataKeys[gvrow.RowIndex]["backBillNo"].ToString(); BBackBillData backBillModel = backBillBB.GetModel(Convert.ToInt32(id)); if (backBillModel.instantState != "01") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条未提交退货单记录!\");", true); return; } else { retChecked = true; backBillBC.DeleteRecord(id, ""); backDetailBB.DeleteRecord(strBackBillNo); } } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { backBillBB.Dispose(); backBillBC.Dispose(); } if (retChecked) { this.BindGrid(); } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEdit_Click(object sender, EventArgs e) { BBackBillBB backBillBB = new BBackBillBB(); try { //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { BBackBillData backBillModel = backBillBB.GetModel(Convert.ToInt32(chkId.ValidationGroup)); if (backBillModel.instantState == "01") { Response.Redirect("BBackBill.aspx?state=2&id=" + chkId.ValidationGroup + "&itemNo=" + this.itemNo + "&pTypeNo=edit", false); return; } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条未提交退货单记录!\");", true); return; } } } this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条记录!\");", true); return; } finally { backBillBB.Dispose(); } }
/// <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> /// 展示数据 /// </summary> /// <param name="id">记录Id</param> private void ShowInfo(int id) { BBackBillBB backBillBB = new BBackBillBB(); vBBackBillData model = new vBBackBillData(); try { model = backBillBB.GetVModel(id); this.lbBackBillNo.Text = model.backBillNo; this.lbFinanceBillNo.Text = model.financeBillNo; this.lbCustNo.Text = model.custNo; this.lbCustNm.Text = model.custNm; //2015-07-30 修改 物料显示的时候 放到箱子的后边 //this.lbMaterialNo.Text = model.materialNo; //this.lbMaterialDesc.Text = model.materialDesc; this.lblcheckRemark.Text = model.checkRemark; } finally { backBillBB.Dispose(); } }
/// <summary> /// 数据保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { BBackBillData model = new BBackBillData(); BBackBillBB backBillBB = new BBackBillBB(); BBackBillBC backBillBC = new BBackBillBC(); try { if (this.State == "2") { model = backBillBB.GetModel(this.IdValue); model.updtDt = DateTime.Now.ToString(); model.updtEmpId = this.currentUser.empId; model.instantState = "03";//采购确认后状态改为03 if (backBillBC.ModityRecord(model, this.dtDetail, mark.Text)) { //保存的时候 将保存的信息 //保存信息 if (backBillBB.InsertToNotice(this.lbBackBillNo.Text.ToString(), this.currentUser.empId, txtCustAddress.Text.Trim(), txtCustPerson.Text.Trim(), this.txtPhone.Text.Trim(), this.txtMobile.Text.Trim())) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"采购确认退货单成功\");", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"采购确认退货单失败\");", true); return; } } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"采购确认退货单失败\");", true); return; } mark.Text = ""; } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { backBillBB.Dispose(); backBillBC.Dispose(); } Response.Redirect("BBackBillListBuyer.aspx?itemno=" + this.itemNo + "&pTypeNo=main", false); }
/// <summary> /// 展示数据 /// </summary> /// <param name="id">记录Id</param> private void ShowInfo(int id) { BBackBillBB backBillBB = new BBackBillBB(); vBBackBillData model = new vBBackBillData(); try { model = backBillBB.GetVModel(id); this.lbBackBillNo.Text = model.backBillNo; this.lbFinanceBillNo.Text = model.financeBillNo; this.lbCustNo.Text = model.custNo; this.lbCustNm.Text = model.custNm; //this.lbMaterialNo.Text = model.materialNo; //this.lbMaterialDesc.Text = model.materialDesc; this.lblcheckRemark.Text = model.checkRemark; this.mark.Text = model.buyerRemark; //2015-07-31增加退货地址以及联系人信息 DataTable dt = backBillBB.GetSupplierInfo("cardCode = '"+this.lbCustNo.Text.Trim()+"'"); if (dt != null) { txtCustAddress.Text = dt.Rows[0]["CustAddress"].ToString(); txtCustPerson.Text = dt.Rows[0]["CustLinkPerson"].ToString(); txtPhone.Text = dt.Rows[0]["CustTel"].ToString(); txtMobile.Text = dt.Rows[0]["CustMobile"].ToString(); } } finally { backBillBB.Dispose(); } }
/// <summary> /// 展示数据 /// </summary> /// <param name="id">记录Id</param> private void ShowInfo(int id) { BBackBillBB backBillBB = new BBackBillBB(); vBBackBillData model = new vBBackBillData(); try { model = backBillBB.GetVModel(id); this.lblBackBillNo.Text = model.backBillNo; this.lbFinanceBillNo.Text = model.financeBillNo; this.lblcheckRemark.Text = model.checkRemark; this.lblSupplier.Text = model.custNm; this.lblBuyerRemark.Text = model.buyerRemark; //获取相应的退货信息 DataTable dt = backBillBB.GetSupplierInfo("cardCode = '" + model.custNo + "'"); if (dt != null) { lblAddress.Text = dt.Rows[0]["CustAddress"].ToString(); lblPerson.Text = dt.Rows[0]["CustLinkPerson"].ToString(); lblPhone.Text = dt.Rows[0]["CustTel"].ToString(); lblMobilePhone.Text = dt.Rows[0]["CustMobile"].ToString(); } //获取相应的退货时间的信息 DataTable dtBack = backBillBB.GetBackInfo("backBillNo = '"+model.backBillNo+"'"); if (dtBack != null) { if (dtBack.Rows.Count > 0) { txtDMCheckPerson.Text = dtBack.Rows[0]["madeby"].ToString(); txtDMWareHousePerson.Text = dtBack.Rows[0]["storeKeeper"].ToString(); tbStartDt.Text = dtBack.Rows[0]["backDt"].ToString(); txtTranportPerson.Text = dtBack.Rows[0]["driver"].ToString(); txtTransPortPhone.Text = dtBack.Rows[0]["driverphone"].ToString(); txtTransPortID.Text = dtBack.Rows[0]["vehicleNo"].ToString(); } } } finally { backBillBB.Dispose(); } }
/// <summary> /// 数据保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { BBackBillData model = new BBackBillData(); BBackBillBB backBillBB = new BBackBillBB(); BBackBillBC backBillBC = new BBackBillBC(); try { if (this.State == "2") { model = backBillBB.GetModel(this.IdValue); model.updtDt = DateTime.Now.ToString(); model.updtEmpId = this.currentUser.empId; backBillBC.ModityRecord(model, this.dtDetail); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { backBillBB.Dispose(); backBillBC.Dispose(); } Response.Redirect("BBackBillList.aspx?itemno=" + this.itemNo + "&pTypeNo=main", false); }
/// <summary> /// 展示数据 /// </summary> /// <param name="id">记录Id</param> private void ShowInfo(int id) { BBackBillBB backBillBB = new BBackBillBB(); vBBackBillData model = new vBBackBillData(); try { model = backBillBB.GetVModel(id); this.lbBackBillNo.Text = model.backBillNo; this.lbFinanceBillNo.Text = model.financeBillNo; this.lbCustNo.Text = model.custNo; this.lbCustNm.Text = model.custNm; //this.lbMaterialNo.Text = model.materialNo; //this.lbMaterialDesc.Text = model.materialDesc; } finally { backBillBB.Dispose(); } }