/// <summary> /// 绑定Grid /// </summary> protected void BindGrid() { CSaleBillBB saleBillBB = new CSaleBillBB(); DataSet ds = new DataSet(); try { string strwhere = this.StrWhere; //销售订单编号 if (!string.IsNullOrEmpty(this.txtSaleBillNo.Text)) { strwhere += " and saleBillNo like '%" + this.txtSaleBillNo.Text.Trim().Replace("'", "''").Trim() + "%'"; } //客户 if (!string.IsNullOrEmpty(this.txtCustNo.Text)) { strwhere += " and (custNo like '%" + this.txtCustNo.Text.Replace("'", "''").Trim() + "%' or custNm like '" + this.txtCustNo.Text.Trim().Replace("'", "''") + "')"; } //订单状态 if (!string.IsNullOrEmpty(this.ddlState.SelectedValue)) { strwhere += " and instantState = '" + this.ddlState.SelectedValue.Replace("'", "''").Trim() + "'"; } ds = saleBillBB.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 { saleBillBB.Dispose(); } }
/// <summary> /// 显示销售订单信息 /// </summary> private void ShowInfo() { CSaleBillBB saleBillBB = new CSaleBillBB(); CSaleDetailBB saleDetailBB = new CSaleDetailBB(); try { string id = Request.Params["id"]; vCSaleBillData saleBillModel = saleBillBB.GetVModel(Convert.ToInt32(id)); DataSet ds = new DataSet(); this.saleBillNo.Text = saleBillModel.saleBillNo; this.saleBillDt.Text = Convert.ToDateTime(saleBillModel.saleBillDt).ToString("yyyy-MM-dd"); this.custNo.Text = saleBillModel.custNo; this.custNm.Text = saleBillModel.custNm; this.saleEmpNo.Text = saleBillModel.saleEmpNo; this.saleBillType.Text = saleBillModel.saleBillType; this.mark.Text = saleBillModel.mark; //根据提货单号、销售订单号、采购合同号,查找销售订单明细 ds = saleDetailBB.GetVList(" absEntry='" + saleBillModel.AbsEntry + "' and saleBillNo = '" + saleBillModel.saleBillNo + "' and lineNum='" + saleBillModel.lineNum.ToString() + "'"); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { this.grid.DataSource = ds; this.grid.DataBind(); } } finally { saleBillBB.Dispose(); saleDetailBB.Dispose(); } }
/// <summary> /// 删除提货单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { bool retChecked = false; CStockUpBillBC stockUpBillBC = new CStockUpBillBC(); CSaleBillBB saleBillBB = new CSaleBillBB(); try { //获取选中的数据Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { retChecked = true; int absEntry = 0; CSaleBillData saleBillModel = new CSaleBillData(); saleBillModel = saleBillBB.GetModel(Convert.ToInt32(chkId.ValidationGroup)); if (saleBillModel != null && saleBillModel.instantState != "01") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"销售订单已生成备货单,不允许删除!\");", true); return; } //删除提货单信息 absEntry = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["absEntry"]); stockUpBillBC.DeleteSaleBill(absEntry); } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { stockUpBillBC.Dispose(); saleBillBB.Dispose(); } if (retChecked) { this.BindGrid(); } else { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"请选择一条记录!\");", true); } }