private void BindProductConsume() { ProductConsumeService productConsumeService = new ProductConsumeService(); DataTable tbl = new DataTable(); tbl = productConsumeService.GetProductConsume(ReportId, true); rptProduct.DataSource = tbl; rptProduct.DataBind(); }
private void BindMaterialConsume() { ProductConsumeService productConsumeService = new ProductConsumeService(); DataTable tbl = new DataTable(); tbl = productConsumeService.GetProductConsume(ReportId, false); rptMaterial.DataSource = tbl; rptMaterial.DataBind(); }
protected void rptMaterial_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("delete")) { ProductConsumeService rptbso = new ProductConsumeService(); LinkButton btnDelete = (LinkButton)e.CommandSource; btnDelete.Visible = AllowEdit; long i = rptbso.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); if (i > 0) { BindMaterialConsume(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "alert('Xóa không thành không. Vui lòng thử lại');", true); } } else if (e.CommandName.Equals("edit")) { LinkButton btnEdit = (LinkButton)e.CommandSource; btnEdit.Visible = AllowEdit; ProductConsume productCapacity = new ProductConsume(); ProductConsumeService productCapacityService = new ProductConsumeService(); int ProductCapacityId = int.Parse(((LinkButton)e.CommandSource).CommandArgument); productCapacity = productCapacityService.FindByKey(ProductCapacityId); if (productCapacity != null) { try { txtMaterialQty.Text = productCapacity.Quantity.ToString(); ddlMaterial.SelectedValue = productCapacity.ProductId.ToString(); Product product = new Product(); ProductService productService = new ProductService(); product = productService.FindByKey(productCapacity.ProductId); ltMaterialMeasurement.Text = "(" + product.Measurement + ")"; } catch { } } hdnId.Value = ProductCapacityId.ToString(); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogMaterial(" + hdnId.Value + ");", true); } }
public void btnSaveProductUse_Click(object sender, EventArgs e) { ProductConsumeService productCapacityService = new ProductConsumeService(); ProductConsume productCapacity = new ProductConsume(); if (txtProductQty.Text.Trim() != "") { productCapacity.Quantity = Convert.ToDecimal(txtProductQty.Text.Trim()); } productCapacity.ProductId = Convert.ToInt32(ddlProduct.SelectedValue); productCapacity.AuditReportId = ReportId; int i = 0; if (hdnId.Value != "" && Convert.ToInt32(hdnId.Value) > 0) { productCapacity.Id = Convert.ToInt32(hdnId.Value); productCapacity = productCapacityService.Update(productCapacity); if (productCapacity != null) { i = 1; } } else { i = productCapacityService.Insert(productCapacity); } if (i <= 0) { ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogProduct(" + hdnId.Value + ");", true); ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công. Vui lòng thử lại!');", true); } else { BindProductConsume(); } }