/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { BCheckBillBB checkBillBB = new BCheckBillBB(); DataSet ds = new DataSet(); try { string strWhere = this.StrWhere; #region 组合查询条件 if (this.ddlType.SelectedValue == "") { strWhere += " and (instantState='04' or instantState='05' or instantState='06')"; } else { strWhere += " and instantState='"+this.ddlType.SelectedValue+"' "; } //1、判断是否有下达日期限制 if (this.ucStartDt.Text != "") { strWhere += " and isrtDt>='" + this.ucStartDt.Text.Replace("'", "''") + "'"; } if (this.ucEndDt.Text != "") { strWhere += " and isrtDt-1<'" + this.ucEndDt.Text.Replace("'", "''") + "'"; } //2、检测单 if (this.checkBillNo.Text.Trim() != "") { strWhere += " and checkBillNo like '%" + this.checkBillNo.Text.Trim().Replace("'", "''") + "%'"; } //3、到货单 if (this.arriveBillNo.Text.Trim() != "") { strWhere += " and arriveBillNo like '%" + this.arriveBillNo.Text.Trim().Replace("'", "''") + "%'"; } //4、采购单 if (this.financeBillNo.Text.Trim() != "") { strWhere += " and financeBillNo like '%" + this.financeBillNo.Text.Trim().Replace("'", "''") + "%'"; } //5、物料号 if (this.materialNo.Text.Trim() != "") { strWhere += " and (materialNo like '%" + this.materialNo.Text.Trim().Replace("'", "''") + "%' or materialDesc like '%" + this.materialNo.Text.Trim().Replace("'", "''") + "%')"; } #endregion ds = checkBillBB.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 { checkBillBB.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.StrWhere = "1=1"; string id = Request.QueryString["id"]; BCheckBillBB billBB = new BCheckBillBB(); try { vBCheckBillData data = billBB.GetVModel(Convert.ToInt32(id)); lblano.Text = data.arriveBillNo; lblcno.Text = data.checkBillNo; lblfno.Text = data.financeBillNo; lblmnm.Text = data.materialDesc; lblmno.Text = data.materialNo; this.StrWhere += " and checkBillId=" + id; } finally { billBB.Dispose(); } this.BindGrid(); } }
/// <summary> /// 检测判定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCheckDetail_Click(object sender, EventArgs e) { foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { BCheckBillBB bCheckBillBB = new BCheckBillBB(); try { vBCheckBillData data = bCheckBillBB.GetVModel(Convert.ToInt32(chkId.ValidationGroup)); if (data.instantState != "04") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"只有检测完成才能进行检测结果判定!\");", true); return; } else { Response.Redirect("BCheckDetailList.aspx?itemNo=" + this.itemNo + "&pTypeNo=main&id=" + data.id + "&mno=" + data.materialNo + "&cno=" + data.checkBillNo + "&ano=" + data.arriveBillNo + "&fno=" + data.financeBillNo + "&mnm=" + Server.UrlEncode(data.materialDesc)); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } } } this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条记录!\");", true); return; }
/// <summary> /// 取消检测判定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUnSubmit_Click(object sender, EventArgs e) { SCommBB commBB = new SCommBB(); BCheckBillBB checkBillBB = new BCheckBillBB(); try { bool isChecked = false; foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { string strArriveBillNo = "", strFinanceBillNo = "", strMaterialNo = ""; strArriveBillNo = this.grid.DataKeys[gvrow.RowIndex]["arriveBillNo"].ToString(); strFinanceBillNo = this.grid.DataKeys[gvrow.RowIndex]["financeBillNo"].ToString(); strMaterialNo = this.grid.DataKeys[gvrow.RowIndex]["materialNo"].ToString(); //更改检测单 BCheckBillData checkBillModel = checkBillBB.GetModel(Convert.ToInt32(chkId.ValidationGroup)); if (checkBillModel.instantState != "05" && checkBillModel.instantState != "06") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前检测单未检测判定!\");", true); return; } isChecked = true; commBB.ExecuteSql("update dbo.BCheckBill set checkResult=null,checkEmpId=0,checkDt=null,instantState='04' where id=" + chkId.ValidationGroup); //更改箱检测结果 commBB.ExecuteSql("update dbo.BArrangeBillBox set checkResult=0,checkResultDt=null,checkResultEmpId=0 where arriveBillNo='" + strArriveBillNo + "' and financeBillNo='" + strFinanceBillNo + "' and materialNo='" + strMaterialNo + "'"); } } if (isChecked) { this.BindGrid(); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条记录!\");", true); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { commBB.Dispose(); checkBillBB.Dispose(); } }
/// <summary> /// 展示数据 /// </summary> /// <param name="id">记录Id</param> private void ShowInfo(int id) { BCheckBillBB checkBillBB = new BCheckBillBB(); SCommBB commBB = new SCommBB(); try { vBCheckBillData model = new vBCheckBillData(); DataSet ds = new DataSet(); string strSQL = ""; model = checkBillBB.GetVModel(id); this.lbCheckBillNo.Text = model.checkBillNo; this.tbArriveBillNo.Text = model.arriveBillNo; this.tbFinanceBillNo.Text = model.financeBillNo; this.hidMaterialNo.Value = model.materialNo; this.tbMaterialDesc.Text = model.materialDesc; this.tbCheckMark.Text = model.checkMark; //查找到货单明细ID strSQL = "select id,num from BArriveDetail where arriveBillNo='" + model.arriveBillNo + "' and financeBillNo='" + model.financeBillNo + "' and materialNo='" + model.materialNo + "'"; ds = commBB.Query(strSQL); if (ds != null && ds.Tables[0].Rows.Count > 0) { this.hidArriveDetailID.Value = ds.Tables[0].Rows[0]["id"].ToString(); this.tbNum.Text = ds.Tables[0].Rows[0]["num"].ToString(); } this.BindMateriel2();//绑定物料对应检测标准明细表 } finally { checkBillBB.Dispose(); } }
/// <summary> /// 操作实时验证 /// </summary> /// <returns></returns> private bool ValidataBillState() { //实时获取订单状态 using (BCheckBillBB checkBillBB = new BCheckBillBB()) { string strState = "", strWhere = ""; DataSet ds = new DataSet(); //确认检测的到货单明细物料,没有被其他检测单检测 strWhere = " id<>'" + this.IdValue + "' and arriveBillNo='" + this.tbArriveBillNo.Text + "' and financeBillNo='" + this.tbFinanceBillNo.Text + "' and materialNo='" + this.hidMaterialNo.Value + "'"; ds = checkBillBB.GetList(strWhere); if (ds != null && ds.Tables[0].Rows.Count > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"此到货单物料,已经生成检测单,无法重复。检测单号【" + ds.Tables[0].Rows[0]["checkBillNo"].ToString() + "】!\");", true); return false; } //实时校验检验单自身状态,防止被他人提交 ds = checkBillBB.GetList("id='" + this.IdValue + "'"); if (ds.Tables[0].Rows.Count > 0) { strState = ds.Tables[0].Rows[0]["instantState"].ToString(); } if (strState == "01" || strState == "") { return true; } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"此检测单已提交!\");", true); return false; } } }
/// <summary> /// 保存判断结果 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveRet_click(object sender, EventArgs e) { BCheckBillBB checkBillBB = new BCheckBillBB(); SCommBB commBB = new SCommBB(); try { HS.Model.BCheckBillData data = checkBillBB.GetModel(Convert.ToInt32(this.IdValue)); if (data.instantState == "04") { data.instantState = this.rdopass.Checked ? "05" : "06";//05 合格 06不合格 data.checkMark = this.txtMark.Text; data.checkDt = DateTime.Now.ToString(); data.checkEmpId = this.currentUser.empId; data.checkResult = this.rdopass.Checked ? "合格" : "不合格"; if (checkBillBB.ModifyRecord(data)) { bool checkResult = rdopass.Checked ? true : false; //更改所有箱的判定结果 commBB.ExecuteSql("update dbo.BArrangeBillBox set checkResult='" + checkResult + "',checkResultDt='" + System.DateTime.Now.ToString() + "',checkResultEmpId='" + this.currentUser.empId + "' where arriveBillNo='" + Request.QueryString["ano"] + "' and financeBillNo='" + Request.QueryString["fno"] + "' and materialNo='" + Request.QueryString["mno"] + "'"); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"检测单判定录入成功!\");location.replace('BCheckBillListResult.aspx?itemNo=0402&pTypeNo=main');", true); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"检测单判定录入失败!\");", true); } } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前检测单已经判定完成!\");", true); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { checkBillBB.Dispose(); commBB.Dispose(); } }
/// <summary> /// 数据保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (this.ValidataBillState()) { string strInfo = ""; bool isValidate = this.ValidatePageControlValue(out strInfo); if (isValidate) { BCheckBillBB checkBillBB = new BCheckBillBB(); BCheckBillBC checkBillBC = new BCheckBillBC(); try { BCheckBillData model = new BCheckBillData(); List<BCheckDetailData> listDetail = this.SetDetailApplyBillModel(); if (this.State == "1") { this.SetModel(ref model); model.checkBillNo = ""; model.isrtDt = DateTime.Now.ToString(); model.isrtEmpId = this.currentUser.empId; } else if (this.State == "2") { model = checkBillBB.GetModel(this.IdValue); this.SetModel(ref model); model.updtDt = DateTime.Now.ToString(); model.updtEmpId = this.currentUser.empId; } //保存检测单数据 checkBillBC.SavelData(model, listDetail, isReNew); Response.Write("<script laguage=\"javascript\">alert('保存成功,请及时提交检测单!');</script>");// "alert", "alert('订单保存成功,请及时提交订单!!');", true); Response.Redirect("BCheckBillList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false); Response.Flush(); //this.IdValue = model.id; //this.State = "2"; //this.ShowInfo(this.IdValue); //this.DtResult = null; //this.BindDetailTable("old"); return; } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { checkBillBB.Dispose(); checkBillBC.Dispose(); //Response.Redirect("BCheckBillList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false); } } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strInfo + "');", true); } } }
/// <summary> /// 提交 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSubmit_Click(object sender, EventArgs e) { bool retChecked = false; BCheckBillBB checkBillBB = new BCheckBillBB(); BCheckBillBC checkBillBC = new BCheckBillBC(); try { //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { retChecked = true; int id = int.Parse(chkId.ValidationGroup); BCheckBillData model = checkBillBB.GetModel(id); if (model.instantState == "01")//判断检测单是否已经提交,已经提交不允许提交 { //状态置为提交 model.commitDt = DateTime.Now.ToString(); model.commitEmpId = this.currentUser.empId; model.instantState = "02"; checkBillBC.CommitData(model); this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"提交成功!\");", true); } 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 { checkBillBB.Dispose(); checkBillBC.Dispose(); } if (retChecked) { this.BindGrid(); } }
/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { BCheckBillBB checkBillBB = new BCheckBillBB(); DataSet ds = new DataSet(); try { string strWhere = this.StrWhere; #region 组合查询条件 //状态 if (this.ddlType.SelectedValue != "") { strWhere += " and instantState='" + this.ddlType.SelectedValue + "' "; } //1、判断是否有下达日期限制 if (this.ucStartDt.Text != "") { strWhere += " and isrtDt>='" + this.ucStartDt.Text.Replace("'", "''") + "'"; } if (this.ucEndDt.Text != "") { strWhere += " and isrtDt-1<'" + this.ucEndDt.Text.Replace("'", "''") + "'"; } //2、检测单 if (this.checkBillNo.Text.Trim() != "") { strWhere += " and checkBillNo like '%" + this.checkBillNo.Text.Trim().Replace("'", "''") + "%'"; } //3、到货单 if (this.arriveBillNo.Text.Trim() != "") { strWhere += " and arriveBillNo like '%" + this.arriveBillNo.Text.Trim().Replace("'", "''") + "%'"; } //4、采购单 if (this.financeBillNo.Text.Trim() != "") { strWhere += " and financeBillNo like '%" + this.financeBillNo.Text.Trim().Replace("'", "''") + "%'"; } //5、物料 if (this.materialNo.Text.Trim() != "") { strWhere += " and (materialNo like '%" + this.materialNo.Text.Trim().Replace("'", "''") + "%' or materialDesc like '%" + this.materialNo.Text.Trim().Replace("'", "''") + "%')"; } #endregion 组合查询条件 ds = checkBillBB.GetVList(strWhere); //2015-11-04 董利特修改 //因为有重复的数据,不修改接口,增加Distinct功能,进行重复数据的去除 DataTable distinctTable = ds.Tables[0].DefaultView.ToTable(true, "id", "checkBillNo", "arriveBillNo", "financeBillNo", "materialNo", "materialDesc", "checkResult", "isrtDt", "commitDt", "instantStateNm"); this.grid.DataSource = distinctTable; 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 { checkBillBB.Dispose(); } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEdit_Click(object sender, EventArgs e) { BCheckBillBB checkBillBB = new BCheckBillBB(); try { foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { int id = int.Parse(chkId.ValidationGroup); BCheckBillData model = checkBillBB.GetModel(id); if (model.instantState == "01")//判断检测单是否已经提交,已经提交不允许再次修改 { Response.Redirect("BCheckBill.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; } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { checkBillBB.Dispose(); } }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { bool retChecked = false; BCheckBillBB checkBillBB = new BCheckBillBB(); SCommBB comBB = new SCommBB(); try { //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { retChecked = true; int id = int.Parse(chkId.ValidationGroup); BCheckBillData model = checkBillBB.GetModel(id); if (model.instantState == "01")//判断检测单是否已经提交,已经提交不允许删除 { //删除主数据 checkBillBB.DeleteRecord(id); //删除明细 string strsql = "delete from BCheckDetail where checkBillId='" + id.ToString() + "'"; comBB.Query(strsql); } 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 { checkBillBB.Dispose(); comBB.Dispose(); } if (retChecked) { this.BindGrid(); } }
public bool UpdateCheckBil(int checkBillId, int empId, string instantState, string checkResult, string checkmark, string checkDt, string arriveBillNo, string materialNo, string finaceBillNO) { //第一步 更新BcheckBill BCheckBillBB checkBillBB = new BCheckBillBB(); SCommBB commBB = new SCommBB(); HS.Model.BCheckBillData data = checkBillBB.GetModel(Convert.ToInt32(checkBillId)); try { if (data.instantState == "04") { data.instantState = instantState;//05是合格 06是不合格 data.checkMark = checkmark; data.checkDt = DateTime.Now.ToString(); data.checkEmpId = empId; data.checkResult = checkResult;//直接是合格或是不合格 if (checkBillBB.ModifyRecord(data)) { bool checkResultNew; if (checkResult == "合格") checkResultNew = true; else checkResultNew = false; //第二步 更新BarrangeBillBox //更改所有箱的判定结果 commBB.ExecuteSql("update dbo.BArrangeBillBox set checkResult='" + checkResultNew + "',checkResultDt='" + System.DateTime.Now.ToString() + "',checkResultEmpId='" + empId + "' where arriveBillNo='" + arriveBillNo + "' and financeBillNo='" + finaceBillNO + "' and materialNo='" + materialNo + "'"); } } return true; } catch { return false; } finally { checkBillBB.Dispose(); commBB.Dispose(); } }
public bool FinishCheckBill(int checkBillId) { BCheckBillBB checkBillBB = new BCheckBillBB(); try { BCheckBillData checkBillModel = new BCheckBillData(); checkBillModel = checkBillBB.GetModel(checkBillId); checkBillModel.instantState = "04"; return checkBillBB.ModifyRecord(checkBillModel); } finally { checkBillBB.Dispose(); } }
public DataTable GetCheckBillList() { BCheckBillBB checkBillBB = new BCheckBillBB(); try { DataTable dt = new DataTable(); dt = checkBillBB.GetVList("instantState in ('02','03')").Tables[0]; return dt; } finally { checkBillBB.Dispose(); } }