private void BindFurnaces() { FurnacesService productConsumeService = new FurnacesService(); DataTable tbl = new DataTable(); tbl = productConsumeService.GetFurnacesByReport(ReportId); rptFurnaces.DataSource = tbl; rptFurnaces.DataBind(); }
public void btnSaveF_Click(object sender, EventArgs e) { FurnacesService productCapacityService = new FurnacesService(); Furnaces productCapacity = new Furnaces(); productCapacity.DeviceName = txtDeviceNameF.Text.Trim(); if (txtQuantityF.Text.Trim() != "") { productCapacity.Quantity = Convert.ToInt32(txtQuantityF.Text.Trim()); } if (txtHoursF.Text.Trim() != "") { productCapacity.OperationHours = Convert.ToInt32(txtHoursF.Text.Trim()); } if (txtCapacityF.Text.Trim() != "") { productCapacity.CapacityInstalled = Convert.ToDecimal(txtCapacityF.Text.Trim()); } if (ddlFuelF.SelectedIndex > 0) { productCapacity.FuelId = Convert.ToInt32(ddlFuelF.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", "ShowDialogFurnaces(" + 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 { BindFurnaces(); } }
protected void rptFurnaces_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("delete")) { FurnacesService productCapacityService = new FurnacesService(); long i = productCapacityService.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); if (i > 0) { BindFurnaces(); } 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")) { Furnaces productCapacity = new Furnaces(); FurnacesService productCapacityService = new FurnacesService(); int ProductCapacityId = int.Parse(((LinkButton)e.CommandSource).CommandArgument); productCapacity = productCapacityService.FindByKey(ProductCapacityId); if (productCapacity != null) { txtDeviceNameF.Text = productCapacity.DeviceName; if (productCapacity.Quantity > 0) { txtQuantityF.Text = productCapacity.Quantity.ToString(); } if (productCapacity.CapacityInstalled > 0) { txtCapacityF.Text = productCapacity.CapacityInstalled.ToString(); } if (productCapacity.FuelId > 0) { ddlFuelF.SelectedValue = productCapacity.FuelId.ToString(); } if (productCapacity.OperationHours > 0) { txtHoursF.Text = productCapacity.OperationHours.ToString(); } } hdnId.Value = ProductCapacityId.ToString(); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogFurnaces(" + hdnId.Value + ");", true); } }