protected void dgArea_DeleteCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "Delete") { string whcode = dsArea.Tables[0].Rows[e.Item.ItemIndex]["WH_CODE"].ToString(); string areaCode = dsArea.Tables[0].Rows[e.Item.ItemIndex]["AREACODE"].ToString(); int areaid = Convert.ToInt32(dsArea.Tables[0].Rows[e.Item.ItemIndex]["AREA_ID"].ToString()); int count = objShelf.QueryShelfByAreaCode(areaCode).Tables[0].Rows.Count; if (count > 0) { JScript.Instance.ShowMessage(this.UpdatePanel1, areaCode + "库区还有下属货架,不能删除!"); return; } else { objArea.Delete(areaid); TreeNode nodeArea = tvWarehouse.FindNode(whcode + "/" + areaCode); if (nodeArea != null) { nodeArea.Parent.ChildNodes.Remove(nodeArea); } //LoadHouseTree(); } } }
protected void GridDataBind() { BindWarehouse(); if (this.hdnShelfCode.Value != "") { dsArea = objArea.QueryAreaByWHCODE(this.hdnWarehouseCode.Value); this.dgArea.DataSource = dsArea.Tables[0]; this.dgArea.DataBind(); dsShelf = objShelf.QueryShelfByAreaCode(this.hdnAreaCode.Value); this.dgShelf.DataSource = dsShelf.Tables[0].DefaultView; this.dgShelf.DataBind(); dsCell = objCell.QueryWarehouseCell("SHELFCODE='" + this.hdnShelfCode.Value + "'"); dgCell.DataSource = dsCell.Tables[0].DefaultView; dgCell.DataBind(); } if (this.hdnAreaCode.Value != "" && this.hdnShelfCode.Value == "") { dsArea = objArea.QueryAreaByWHCODE(this.hdnWarehouseCode.Value); this.dgArea.DataSource = dsArea.Tables[0]; this.dgArea.DataBind(); dsShelf = objShelf.QueryShelfByAreaCode(this.hdnAreaCode.Value); this.dgShelf.DataSource = dsShelf.Tables[0].DefaultView; this.dgShelf.DataBind(); dsCell = objCell.QueryWarehouseCell("AREACODE='" + this.hdnAreaCode.Value + "'"); dgCell.DataSource = dsCell.Tables[0].DefaultView; dgCell.DataBind(); } if (this.hdnWarehouseCode.Value != "" && this.hdnAreaCode.Value == "") { dsArea = objArea.QueryAreaByWHCODE(this.hdnWarehouseCode.Value); this.dgArea.DataSource = dsArea.Tables[0]; this.dgArea.DataBind(); dsShelf = objShelf.QueryShelfByWHCODE(this.hdnWarehouseCode.Value); this.dgShelf.DataSource = dsShelf.Tables[0].DefaultView; this.dgShelf.DataBind(); dsCell = objCell.QueryWarehouseCell("WH_CODE='" + this.hdnWarehouseCode.Value + "'"); dgCell.DataSource = dsCell.Tables[0].DefaultView; dgCell.DataBind(); } }
protected void btnDelete_Click(object sender, EventArgs e) { string whcode = this.txtWhCode.Text; string areaCode = this.txtAreaCode.Text; int areaid = Convert.ToInt32(this.txtAreaID.Text); WarehouseShelf objShelf = new WarehouseShelf(); int count = objShelf.QueryShelfByAreaCode(areaCode).Tables[0].Rows.Count; if (count > 0) { JScript.Instance.ShowMessage(this, areaCode + "库区还有下属货架,不能删除!"); return; } else { objArea.Delete(areaid); this.txtAreaID.Text = ""; this.txtAreaCode.Text = objArea.GetNewAreaCode(this.txtWhCode.Text); this.txtAreaName.Text = ""; this.txtShortName.Text = ""; this.ddlActive.SelectedIndex = 0; this.txtAreaType.Text = ""; this.txtMemo.Text = ""; this.txtAreaCode.ReadOnly = false; this.btnDelete.Enabled = false; //JScript.Instance.ShowMessage(this, "库区删除成功!"); string path = whcode + "/" + areaCode; JScript.Instance.RegisterScript(this, "RefreshParent('" + path + "');"); } }