public void OP_Command(object sender, CommandEventArgs e) { int intId = Convert.ToInt32(e.CommandArgument); string strUrlBack = "?cid=" + ViewState["ContractId"] + "&cpage=" + ViewState["ContractPage"]; if (e.CommandName == "edit") { if (HelperUtility.hasPurviewOP("SalesGoods_update")) { string strUrl = "edit.aspx" + strUrlBack; strUrl += "&page=" + ViewState["page"] + "&id=" + intId.ToString(); Response.Redirect(strUrl); } else { HelperUtility.showAlert("没有操作权限", "list.aspx" + strUrlBack + "&page=" + ViewState["page"]); } } else if (e.CommandName == "del") { if (HelperUtility.hasPurviewOP("SalesGoods_del")) { BllSalesGoods.deleteById(intId); } else { HelperUtility.showAlert("没有操作权限", "list.aspx" + strUrlBack + "&page=" + ViewState["page"]); } } LoadDataPage(); }
// 批量更改选中货品的入库单ID protected void btnTrans_Click(object sender, EventArgs e) { int intCount = 0, intId, intContractId; intContractId = Convert.ToInt32(ddlSalesContract.SelectedValue); foreach (GridViewRow objGVRow in gvShow.Rows) { CheckBox objCB = (CheckBox)objGVRow.FindControl("cbSelect"); //Label lblId = (Label)objGVRow.FindControl("lblId"); //intId = Convert.ToInt32(lblId.Text); if (objCB == null) { continue; } if (objCB.Checked) { intId = Convert.ToInt32(gvShow.DataKeys[objGVRow.RowIndex].Value); if (intId > 0) { BllSalesGoods.updateContractId(intId, intContractId); intCount += 1; } } } string strUrlBack = "?cid=" + ViewState["ContractId"] + "&cpage=" + ViewState["ContractPage"]; HelperUtility.showAlert("转移成功 " + intCount + " 条数据!", "list.aspx" + strUrlBack + "&page=" + ViewState["page"]); }
// 添加出库货品记录,并更新货品的库存量 public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; if (context.Request.Params["CheckoutContractId"] == null || !HelperUtility.isDecimal(context.Request.Params["CheckoutContractId"].ToString())) { context.Response.Write(HelperUtility.setReturnJson("500", "需要指明出库单ID!", "")); return; } if (context.Request.Params["GoodsId"] == null || !HelperUtility.isDecimal(context.Request.Params["GoodsId"].ToString())) { context.Response.Write(HelperUtility.setReturnJson("500", "需要指明出库单ID!", "")); return; } if (context.Request.Params["Amount"] == null || !HelperUtility.isDecimal(context.Request.Params["Amount"].ToString())) { context.Response.Write(HelperUtility.setReturnJson("500", "需要指明数量!", "")); return; } int intCheckoutContractId = Convert.ToInt32(context.Request.Params["CheckoutContractId"]); int intGoodsId = Convert.ToInt32(context.Request.Params["GoodsId"]); decimal dcmAmount = Convert.ToDecimal(context.Request.Params["Amount"]); if (!(intCheckoutContractId > 0 && intGoodsId > 0 && dcmAmount > 0)) { context.Response.Write(HelperUtility.setReturnJson("500", "数字不对!", "")); return; } ModelCheckoutRecord model = new ModelCheckoutRecord(); model.id_contract = intCheckoutContractId; model.id_goods = intGoodsId; model.amount = dcmAmount; int intId = BllCheckoutRecord.add(model); if (intId > 0) { // 出库货品表里添加完了一条记录后,更新此货品的库存量 BllSalesGoods.updateAmountStockByCheckOut(dcmAmount, intGoodsId); context.Response.Write(HelperUtility.setReturnJson("200", "", intId.ToString())); return; } else { context.Response.Write(HelperUtility.setReturnJson("500", "添加失败,请联系管理员!", "")); return; } }
public void LoadData(string strNameProduct, string strNameFactory) { DataTable objDT = BllSalesGoods.getDTByName(strNameProduct, strNameFactory); if (objDT == null || objDT.Rows.Count <= 0) { pnlInfo.Visible = true; gvShow.Visible = false; } else { pnlInfo.Visible = false; gvShow.Visible = true; } gvShow.DataSource = objDT; gvShow.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int intAdminId = HelperUtility.hasPurviewPage("SalesGoods_update"); ViewState["AdminId"] = intAdminId; ViewState["ContractId"] = HelperUtility.getQueryInt("cid"); ViewState["ContractPage"] = HelperUtility.getQueryInt("cpage"); ViewState["Page"] = HelperUtility.getQueryInt("page"); int intId = HelperUtility.getQueryInt("id"); ViewState["Id"] = intId; ModelSalesGoods model = BllSalesGoods.getById(intId); tbProductName.Value = model.name_product; tbType.Text = model.type; tbFactoryName.Value = model.name_factory; tbUnit.Text = model.unit; tbAmount.Text = model.amount.ToString(); tbPriceUnit.Text = model.price_unit.ToString(); tbBatchNumber.Value = model.batch_number; tbValidityPeriod.Value = model.validity_period.ToString(); tbComment.Text = model.comment; // 设置照片 string strPhotoUrls = model.photo_urls; if (!"".Equals(strPhotoUrls)) { string strImgUrl, strJS; List <string> listPhotoUrls = strPhotoUrls.Split(',').ToList(); intPhotoAmounts = listPhotoUrls.Count; for (int i = 0; i < intPhotoAmounts; i++) { strImgUrl = listPhotoUrls[i]; strJS = "<div id=\"img-" + i + "\" class=\"wrapper-photo-show\">"; strJS += "<img width=\"100\" height=\"100\" src=\"" + strImgUrl + "\" /><br />"; strJS += "<input type=\"button\" id=\"btnDelPhoto\" class=\"btn btn-sm btn-warning\"" + " onclick=\"delPhoto(" + i + ")\" value=\"删除\" /></div>"; ltrShowPhoto.Text += strJS; } } tbPhotoUrls.Value = strPhotoUrls; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int intAdminId = HelperUtility.hasPurviewPage("SalesGoods_show"); ViewState["AdminId"] = intAdminId; // 本页只能从list.aspx的编辑页转过来 // 因此要得到要显示哪个入库单的cid值和页面的cpage值用于返回 int intContractId = HelperUtility.getQueryInt("cid"); if (intContractId == 0) { HelperUtility.showAlert("", "/BackManager/login.aspx"); } ViewState["ContractId"] = intContractId; ViewState["ContractPage"] = HelperUtility.getQueryInt("cpage"); // 得到现在的页面值 int intCurrentPage = HelperUtility.getQueryInt("page"); if (intCurrentPage <= 0) { intCurrentPage = 1; } lblCurentPage.Text = intCurrentPage.ToString(); LoadDataPage(); // 设置其他控件值,以货币形式显示 2.5.ToString("C") // 得到入库单的信息 ModelSalesContract model = BllSalesContract.getById(intContractId); if (model.id_company > 0) { lblCompanyName.Text = "【" + BllSalesCompany.getById(model.id_company).name + "】"; } else { lblCompanyName.Text = "【预入库】"; } lblTimeCreate.Text = model.time_create.ToString("yyyy-MM-dd"); lblPriceTotal.Text = BllSalesGoods.getPriceTotal(intContractId).ToString("C"); hlBackContract.NavigateUrl = "../sales_contract/list.aspx?page=" + ViewState["ContractPage"]; hlAddNew.NavigateUrl = "add.aspx?cid=" + intContractId; // 绑定所有入库单的下拉列表 BllSalesContract.bindDDL(ddlSalesContract); } }
protected void gvShow_RowUpdating(object sender, GridViewUpdateEventArgs e) { int intId, intGoodsId; // string strId = gvShow.DataKeys[e.RowIndex].Values[0].ToString(); intId = Convert.ToInt32(gvShow.DataKeys[e.RowIndex].Values["id"].ToString()); Label lblGoodsId = (Label)gvShow.Rows[e.RowIndex].FindControl("lblGoodsId"); if (lblGoodsId != null) { intGoodsId = Convert.ToInt32(lblGoodsId.Text); } else { intGoodsId = 0; } // 更新盘点数 TextBox tbInventoryAmountFill = (TextBox)gvShow.Rows[e.RowIndex].FindControl("tbInventoryAmountFill"); if (null == tbInventoryAmountFill) { return; } if ("".Equals(tbInventoryAmountFill.Text)) { tbInventoryAmountFill.Text = "0"; } decimal dcmInventoryAmountFill = Convert.ToDecimal(tbInventoryAmountFill.Text); // 只有盘点数大于0的时候才去更新货品的盘点数 if (dcmInventoryAmountFill >= 0) { // 更新盘点表里的盘点数 BllInventoryRecord.updateFillById(dcmInventoryAmountFill, intId); // 同时更新货品的库存量为盘点量 BllSalesGoods.updateAmountStockByInventory(dcmInventoryAmountFill, intGoodsId); } gvShow.EditIndex = -1; LoadDataPage(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int intAdminId = HelperUtility.hasPurviewPage("SalesGoods_show"); int intId = HelperUtility.getQueryInt("id"); ModelSalesGoods model = BllSalesGoods.getById(intId); if (model == null) { HelperUtility.showAlert("没有找到此货品!", "list.aspx"); } lblProductName.Text = model.name_product; lblType.Text = model.type; lblFactoryName.Text = model.name_factory; lblUnit.Text = model.unit; lblAmount.Text = model.amount.ToString(); lblPriceUnit.Text = model.price_unit.ToString("C"); lblPriceTotal.Text = model.price_total.ToString("C"); lblBatchNumber.Text = model.batch_number; lblValidityPeriod.Text = model.validity_period.ToString(); lblComment.Text = model.comment; // 设置照片 string strPhotoUrls = model.photo_urls; if (!"".Equals(strPhotoUrls)) { string strImgUrl, strJS; List <string> listPhotoUrls = strPhotoUrls.Split(',').ToList(); for (int i = 0; i < listPhotoUrls.Count; i++) { strImgUrl = listPhotoUrls[i]; strJS = "<div id=\"img-" + i + "\" class=\"wrapper-photo-show\">"; strJS += "<a href=\"" + strImgUrl + "\">"; strJS += "<img width=\"100\" height=\"100\" src=\"" + strImgUrl + "\" />"; strJS += "</a></div>"; ltrShowPhoto.Text += strJS; } } } }
protected void btnEdit_Click(object sender, EventArgs e) { string strUrl; // 验证权限 if (!HelperUtility.hasPurviewOP("SalesGoods_update")) { HelperUtility.showAlert("没有操作权限", "/BackManager/home.aspx"); } // 验证表单 string strMsgError = ""; int intId = Convert.ToInt32(ViewState["Id"]); string strProductName = tbProductName.Value.Trim(); if ("".Equals(strProductName)) { strMsgError += "货品名称不能为空!"; } string strType = tbType.Text.Trim(); string strFactoryName = tbFactoryName.Value.Trim(); string strUnit = tbUnit.Text.Trim(); decimal dcmAmount = Convert.ToDecimal(tbAmount.Text.Trim()); decimal dcmPriceUnit = Convert.ToDecimal(tbPriceUnit.Text.Trim()); decimal dcmPriceTotal = dcmAmount * dcmPriceUnit; string strBatchNumber = tbBatchNumber.Value.Trim(); if ("".Equals(tbValidityPeriod.Value.Trim())) { strMsgError += "有效期时间不能为空!"; } if (!HelperUtility.isDateType(tbValidityPeriod.Value.Trim())) { strMsgError += "有效期时间格式不正确!"; } DateTime dateValidityPeriod = Convert.ToDateTime(tbValidityPeriod.Value.Trim()); string strApprovalNumber = ""; string strComment = tbComment.Text.Trim(); if (strComment.Length > 1000) { strMsgError += "备注信息不能超过500个字数!"; } string strPhotoUrls = tbPhotoUrls.Value; if (strPhotoUrls.EndsWith(",")) { strPhotoUrls = strPhotoUrls.Substring(0, strPhotoUrls.Length - 1); } if (!"".Equals(strMsgError)) { HelperUtility.showAlert(strMsgError, "edit.aspx?id=" + intId); return; } // 验证完毕,提交数据 ModelSalesGoods model = BllSalesGoods.getById(intId); model.name_product = strProductName; model.type = strType; model.name_factory = strFactoryName; model.unit = strUnit; model.amount = dcmAmount; model.price_unit = dcmPriceUnit; model.price_total = dcmPriceTotal; model.batch_number = strBatchNumber; model.validity_period = dateValidityPeriod; model.approval_number = strApprovalNumber; model.comment = strComment; model.photo_urls = strPhotoUrls; model.amount_stock = dcmAmount; BllSalesGoods.update(model); strUrl = "list.aspx" + "?cid=" + ViewState["ContractId"] + "&cpage=" + ViewState["ContractPage"] + "&page=" + ViewState["Page"]; HelperUtility.showAlert("修改成功!", strUrl); }
protected void btnAdd_Click(object sender, EventArgs e) { string strUrl; // 验证权限 if (!HelperUtility.hasPurviewOP("SalesGoods_add")) { HelperUtility.showAlert("没有操作权限", "/BackManager/home.aspx"); } // 验证表单 string strMsgError = ""; int intContractId = (int)ViewState["ContractId"]; string strProductName = tbProductName.Value.Trim(); if ("".Equals(strProductName)) { strMsgError += "货品名称不能为空!"; } string strType = tbType.Text.Trim(); string strFactoryName = tbFactoryName.Value.Trim(); string strUnit = tbUnit.Text.Trim(); decimal dcmAmount = Convert.ToDecimal(tbAmount.Text.Trim()); decimal dcmPriceUnit = Convert.ToDecimal(tbPriceUnit.Text.Trim()); decimal dcmPriceTotal = dcmAmount * dcmPriceUnit; string strBatchNumber = tbBatchNumber.Value.Trim(); if ("".Equals(tbValidityPeriod.Value.Trim())) { strMsgError += "有效期时间不能为空!"; } if (!HelperUtility.isDateType(tbValidityPeriod.Value.Trim())) { strMsgError += "有效期时间格式不正确!"; } DateTime dateValidityPeriod = Convert.ToDateTime(tbValidityPeriod.Value.Trim()); string strApprovalNumber = ""; string strComment = tbComment.Text.Trim(); if (strComment.Length > 1000) { strMsgError += "备注信息不能超过500个字数!"; } string strPhotoUrls = tbPhotoUrls.Value; if (strPhotoUrls.EndsWith(",")) { strPhotoUrls = strPhotoUrls.Substring(0, strPhotoUrls.Length - 1); } int intAdminId = (int)ViewState["AdminId"]; DateTime dateTimeAdd = DateTime.Now; if (!"".Equals(strMsgError)) { HelperUtility.showAlert(strMsgError, "add.aspx?cid=" + intContractId); return; } // 验证完毕,提交数据 ModelSalesGoods model = new ModelSalesGoods(); model.id_contract = intContractId; model.name_product = strProductName; model.type = strType; model.name_factory = strFactoryName; model.unit = strUnit; model.amount = dcmAmount; model.price_unit = dcmPriceUnit; model.price_total = dcmPriceTotal; model.batch_number = strBatchNumber; model.validity_period = dateValidityPeriod; model.approval_number = strApprovalNumber; model.comment = strComment; model.photo_urls = strPhotoUrls; model.id_admin = intAdminId; model.time_add = dateTimeAdd; model.amount_stock = dcmAmount; int intId = BllSalesGoods.add(model); if (intId > 0) { strUrl = "list.aspx?cid=" + intContractId; HelperUtility.showAlert("添加成功!", strUrl); } else { strUrl = "add.aspx?cid=" + intContractId; HelperUtility.showAlert("添加失败,请联系管理员!", strUrl); } }
private int intRecordCount = 0; //总记录数 public void LoadDataPage() { int intContractId = (int)ViewState["ContractId"]; DataTable objDT; if ("".Equals(lblCurentPage.Text.Trim())) { lblCurentPage.Text = "1"; } intCurrentPage = Convert.ToInt32(lblCurentPage.Text.Trim()); if (intCurrentPage <= 0) { intCurrentPage = 1; } // 得到总记录数 intRecordCount = BllSalesGoods.getRecordsAmount(intContractId); // 计算总页数 intPageCount = (intRecordCount + intPageSize - 1) / intPageSize; if (intCurrentPage > intPageCount) { intCurrentPage = intPageCount; } lblPageCount.Text = intPageCount.ToString(); // 根据当前页获取当前页的分页记录DataTable if (intRecordCount > 0) { objDT = BllSalesGoods.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; }