public void LoadDataQuery(int intContractId, string strProductName) { DataTable objDT = BllInventoryRecord.getByQuery(intContractId, strProductName); gvShow.DataSource = objDT; gvShow.DataBind(); lbtnFirst.Enabled = false; lbtnPrev.Enabled = false; lbtnNext.Enabled = false; lbtnLast.Enabled = false; ViewState["page"] = "1"; lblCurentPage.Text = "1"; // 设置显示盘点总金额的Label控件值,以货币形式显示 2.5.ToString("C") decimal[] aryPriceTotal = BllInventoryRecord.getPriceTotalInventory(intContractId); lblPriceTotalReal.Text = aryPriceTotal[0].ToString("C"); lblPriceTotalStock.Text = aryPriceTotal[1].ToString("C"); lblPriceTotalFill.Text = aryPriceTotal[2].ToString("C"); }
/* 货品出库时 * 一、出库表里新加一条记录 * 二、更新某个货品的库存数量字段(amount_stock)(更新方法是amount_stock = amount_stock - amountOut) * 添加出库货品时显示的是某个货品的库存量(amount_stock), * 货品表里每个货品有一个进货数量(amount)和库存数量(amount_stock) * 盘点时 * 一、新建盘点单,然后搜索所有库存量大于0的货品添加到此盘点单对应的盘点货品单里。 * 二、盘点时,修改盘点货品单里每个货品的盘点数量和修改(显示用)数量。 * 三、在修改盘点货品表时,同时将某次盘点货品单里所有货品的库存量(amount_stock)都修改为盘点量(还是修改量???)。 * 显示某盘点单下所有盘点货品时,显示的是该货品的库存数量(amount_stock)字段,盘点货品单下的盘点数量和修改数量。 */ protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int intAdminId = HelperUtility.hasPurviewPage("InventoryRecord_show"); ViewState["AdminId"] = intAdminId; // 因此要得到要显示哪个盘点单的cid值和页面的cpage值用于返回 int intContractId = HelperUtility.getQueryInt("cid"); if (intContractId == 0) { HelperUtility.showAlert("", "/BackManager/login.aspx"); } ViewState["ContractId"] = intContractId; ViewState["ContractPage"] = HelperUtility.getQueryInt("cpage"); LoadDataPage(); hlBackContract.NavigateUrl = "../inventory_contract/list.aspx?page=" + ViewState["ContractPage"]; // hlAddNew.NavigateUrl = "add.aspx?cid=" + intContractId; // 设置显示库存总金额的Label控件值,以货币形式显示 2.5.ToString("C") decimal[] aryPriceTotal = BllInventoryRecord.getPriceTotalInventory(intContractId); lblPriceTotalReal.Text = aryPriceTotal[0].ToString("C"); lblPriceTotalStock.Text = aryPriceTotal[1].ToString("C"); lblPriceTotalFill.Text = aryPriceTotal[2].ToString("C"); } }
// 读取所有的数据并分页 public void LoadDataPage() { int intContractId = Convert.ToInt32(ViewState["ContractId"]); string strProductName = Convert.ToString(ViewState["NameProduct"]); if (!"".Equals(strProductName)) { // 如果关键字词不为空,说明是根据关键字词查询得到的数据 LoadDataQuery(intContractId, strProductName); } else { DataTable objDT; if ("".Equals(lblCurentPage.Text.Trim())) { lblCurentPage.Text = "1"; } intCurrentPage = Convert.ToInt32(lblCurentPage.Text.Trim()); if (intCurrentPage <= 0) { intCurrentPage = 1; } // 得到总记录数 intRecordCount = BllInventoryRecord.getRecordsAmount(intContractId); // 计算总页数 intPageCount = (intRecordCount + intPageSize - 1) / intPageSize; if (intCurrentPage > intPageCount) { intCurrentPage = intPageCount; } lblPageCount.Text = intPageCount.ToString(); // 根据当前页获取当前页的分页记录DataTable if (intRecordCount > 0) { objDT = BllInventoryRecord.getPage(intContractId, intCurrentPage, intPageSize); } else { lblCurentPage.Text = "1"; objDT = null; } if (objDT != null && objDT.Rows.Count > 0) { lbtnFirst.Enabled = true; lbtnPrev.Enabled = true; lbtnNext.Enabled = true; lbtnLast.Enabled = true; if (intCurrentPage == 1) { lbtnFirst.Enabled = false; lbtnPrev.Enabled = false; } if (intCurrentPage == intPageCount) { lbtnNext.Enabled = false; lbtnLast.Enabled = false; } } else { lbtnFirst.Enabled = false; lbtnPrev.Enabled = false; lbtnNext.Enabled = false; lbtnLast.Enabled = false; } gvShow.DataSource = objDT; gvShow.DataBind(); lblRecordCount.Text = intRecordCount.ToString(); lblCurentPage.Text = intCurrentPage.ToString(); tbPageNum.Text = intCurrentPage.ToString(); ViewState["page"] = intCurrentPage; // 设置显示盘点总金额的Label控件值,以货币形式显示 2.5.ToString("C") decimal[] aryPriceTotal = BllInventoryRecord.getPriceTotalInventory(intContractId); lblPriceTotalReal.Text = aryPriceTotal[0].ToString("C"); lblPriceTotalStock.Text = aryPriceTotal[1].ToString("C"); lblPriceTotalFill.Text = aryPriceTotal[2].ToString("C"); } }