protected void btnDeleteSelf_Click(object sender, EventArgs e) { ElectrictConsumeService otherService = new ElectrictConsumeService(); if (otherService.DeleteByReport(ReportId, true) >= 0) { ltErrElectrictConsume.Text = "Xóa thành công"; BindElectricConsume(); ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogElectrictConsume();", true); } }
protected void btnSaveElectrictConsume_Click(object sender, EventArgs e) { ElectrictConsumeService otherService = new ElectrictConsumeService(); if (otherService.DeleteByReport(ReportId, false) >= 0) { for (int i = 1; i <= 12; i++) { ElectrictConsume other = new ElectrictConsume(); try { string strNormal = Request.Form["txtNormalNo" + i]; string strPeak = Request.Form["txtPeakNo" + i]; string strLow = Request.Form["txtLowNo" + i]; string strTotal = Request.Form["txtElectrictTotal" + i]; string strCost = Request.Form["txtCostTotal" + i]; if (strNormal != null && strNormal.Trim() != "") { other.NormalNo = Convert.ToInt64(strNormal.Trim()); } if (strPeak != null && strPeak.Trim() != "") { other.PeakNo = Convert.ToInt64(strPeak.Trim()); } if (strLow != null && strLow.Trim() != "") { other.LowNo = Convert.ToInt64(strLow.Trim()); } if (strTotal != null && strTotal.Trim() != "") { other.ElectrictTotal = Convert.ToInt64(strTotal.Trim()); } if (strCost != null && strCost.Trim() != "") { other.CostTotal = Convert.ToInt64(strCost.Trim()); } } catch (Exception ex) { } other.FuelId = 1;//Nhien lieu dien other.AuditReportId = ReportId; other.Month = i; other.IsSelf = false; other.Year = ReportYear; otherService.Insert(other); } BindElectricConsume(); ScriptManager.RegisterStartupScript(this, GetType(), "showgpkh", "ShowDialogElectrictConsume();", true); } }
void BindSelf() { DataTable dt = new ElectrictConsumeService().GetElectrictConsume(ReportId, true); if (dt != null && dt.Rows.Count == 0) { for (int i = 1; i <= 12; i++) { DataRow dr = dt.NewRow(); dt.Rows.Add(dr); } } rptDataSelf.DataSource = dt; rptDataSelf.DataBind(); }