public void OP_Command(object sender, CommandEventArgs e) { int intIdGoods = Convert.ToInt32(e.CommandArgument); int intIdContract = Convert.ToInt32(ViewState["ContractId"]); string strUrl; if (e.CommandName == "AddGoods") { if (!HelperUtility.hasPurviewOP("InventoryContract_update")) { HelperUtility.showAlert("没有操作权限", "list.aspx?page=" + ViewState["page"]); } int rowIndex = ((GridViewRow)((Button)sender).NamingContainer).RowIndex; GridViewRow row = gvShow.Rows[rowIndex]; TextBox tbAmountFill = (TextBox)row.FindControl("tbAmountFill"); if (tbAmountFill is null) { return; } Label lblAmountReal = (Label)row.FindControl("lblAmountReal"); Label lblAmountStock = (Label)row.FindControl("lblAmountStock"); ModelInventoryRecord model = new ModelInventoryRecord(); model.id_contract = intIdContract; model.id_goods = intIdGoods; model.amount_real = Convert.ToDecimal(lblAmountReal.Text); model.amount_stock = Convert.ToDecimal(lblAmountStock.Text); model.amount_fill = Convert.ToDecimal(tbAmountFill.Text); BllInventoryRecord.add(model); } LoadData(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; if (context.Request.Params["InventoryContractId"] == null || !HelperUtility.isDecimal(context.Request.Params["InventoryContractId"].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; } ModelInventoryRecord model = new ModelInventoryRecord(); model.id_contract = intCheckoutContractId; model.id_goods = intGoodsId; model.amount_real = dcmAmount; model.amount_stock = dcmAmount; model.amount_fill = dcmAmount; int intId = BllInventoryRecord.add(model); if (intId > 0) { context.Response.Write(HelperUtility.setReturnJson("200", "", intId.ToString())); return; } else { context.Response.Write(HelperUtility.setReturnJson("500", "添加失败,请联系管理员!", "")); return; } }