void BindResultTB() { PlanTBService plangpservice = new PlanTBService(); DataTable tbl = new DataTable(); tbl = plangpservice.GetPlanTBEnterprise(memVal.OrgId, ReportId, true, false); rptKetQuaTB.DataSource = tbl; rptKetQuaTB.DataBind(); }
void BindResultTB() { PlanTBService plangpservice = new PlanTBService(); DataTable tbl = new DataTable(); tbl = plangpservice.GetPlanTBEnterprise(m_UserValidation.OrgId, ReportId, false, false); rptResultTB.DataSource = tbl; rptResultTB.DataBind(); }
void BindThietBi() { PlanTBService plangpservice = new PlanTBService(); DataTable tbl = new DataTable(); tbl = plangpservice.GetPlanTBEnterprise(m_UserValidation.OrgId, ReportId, false, true); rptKHBoSungTB.DataSource = tbl; rptKHBoSungTB.DataBind(); }
public void btnSaveDevice_Click(object sender, EventArgs e) { try { PlanTB plantb = new PlanTB(); PlanTBService plantbservice = new PlanTBService(); if (ddlCacThucLD.SelectedIndex > 0) { plantb.CachLapDat = ddlCacThucLD.SelectedValue; } plantb.EnterpriseId = Convert.ToInt32(memVal.OrgId); plantb.NameTB = txtTenTB.Text; plantb.TinhNang = txtTinhNangTB.Text; plantb.LyDo = txtlydoTB.Text; plantb.Nam = (ReportYear + 1);//Convert.ToInt32(txtnamTB.Text); if (ddlCamKetTB.SelectedIndex > 0) { plantb.CamKet = ddlCamKetTB.SelectedValue; } plantb.KhaNang = txtKhaNangTB.Text.Trim(); plantb.IdPlan = ReportId; plantb.IsFiveYear = false; plantb.IsPlan = true; plantb.IsNew = false; if (hddkhTB.Value != "" && Convert.ToInt32(hddkhTB.Value) > 0) { plantb.Id = Convert.ToInt32(hddkhTB.Value); if (plantbservice.Update(plantb) != null) { BindThietBi(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công!');", true); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogDevicePlanOne(" + hddkhTB.Value + ");", true); } } else { int i = plantbservice.Insert(plantb); if (i > 0) { BindThietBi(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showx", "alert('Cập nhật không thành công!');", true); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogDevicePlanOne(0);", true); } } } catch (Exception) { throw; } }
protected void rptResultTB_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("delete")) { PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); LinkButton btnDelete = (LinkButton)e.CommandSource; btnDelete.Visible = AllowEdit; rptbso.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); BindResultTB(); } else if (e.CommandName.Equals("edit")) { LinkButton btnDelete = (LinkButton)e.CommandSource; btnDelete.Visible = AllowEdit; PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); rpt = rptbso.FindByKey(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); if (rpt.CachLapDat != "") { try { ddlCacThucLDBS.SelectedValue = rpt.CachLapDat; } catch { } } txtMoTaTinhNangBS.Text = rpt.TinhNang; txtTenTietBiBS.Text = rpt.NameTB; txtLyDoKhongThucHien.Text = rpt.LyDo; if (rpt.IsExecuted) { rblThucHien.SelectedIndex = 0; } else { rblThucHien.SelectedIndex = 1; } if (rpt.IsNew) { rblIsNew.SelectedIndex = 1; } else { rblIsNew.SelectedIndex = 0; } txtLyDoKhongThucHien.Text = rpt.LyDoLapDat; txtLyDoKhongThucHien.Text = rpt.LyDoLapDat; hddkhTB.Value = rpt.Id.ToString(); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogDeviceResultOne(" + hddkhTB.Value + ");", true); } }
protected void rptResultTB_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("delete")) { PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); rptbso.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); BindResultTB(); } else if (e.CommandName.Equals("edit")) { PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); rpt = rptbso.FindByKey(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); if (rpt.CachLapDat != "") { try { ddlCacThucLDBS.SelectedValue = rpt.CachLapDat; } catch { } } txtMoTaTinhNangBS.Text = rpt.TinhNang; txtTenTietBiBS.Text = rpt.NameTB; txtLyDoKhongThucHien.Text = rpt.LyDo; cbxThucHien.Checked = rpt.IsExecuted; if (rpt.IsNew) { if (cbxThucHien.Checked) { txtLyDoKhongThucHien.Text = rpt.LyDoLapDat; } else { txtLyDoKhongThucHien.Text = rpt.LyDo; } } else { txtLyDoKhongThucHien.Text = rpt.LyDoLapDat; } hddkhTB.Value = rpt.Id.ToString(); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "updategiaiphapTB();", true); } }
protected void rptKetQuaTB_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("delete")) { PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); rptbso.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); BindResultTB(); } else if (e.CommandName.Equals("edit")) { PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); rpt = rptbso.FindByKey(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); hddkhTB.Value = rpt.Id.ToString(); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "updateiaiphapTB5(" + hdnFiveYear.Value + "," + hdnPlan.Value + ");", true); } }
protected void rptKHBoSungTB_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("delete")) { PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); LinkButton btnDelete = (LinkButton)e.CommandSource; btnDelete.Visible = AllowEdit; rptbso.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); BindThietBi(); } else if (e.CommandName.Equals("edit")) { PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); LinkButton btnDelete = (LinkButton)e.CommandSource; btnDelete.Visible = AllowEdit; rpt = rptbso.FindByKey(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); if (rpt.CachLapDat != "") { try { ddlCacThucLD.SelectedValue = rpt.CachLapDat; } catch { } } txtlydoTB.Text = rpt.LyDo; txtTenTB.Text = rpt.NameTB; try { ddlCamKetTB.SelectedValue = rpt.CamKet; } catch { } txtKhaNangTB.Text = rpt.KhaNang; txtTinhNangTB.Text = rpt.TinhNang; hddkhTB.Value = rpt.Id.ToString(); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "ShowDialogDevicePlanOne(" + hddkhTB.Value + ");", true); } }
protected void cpRepeaterTB_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("delete")) { PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); rptbso.Delete(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); BindThietBi(); ScriptManager.RegisterStartupScript(this, GetType(), "showkh", "showkehoach();", true); } else if (e.CommandName.Equals("edit")) { PlanTB rpt = new PlanTB(); PlanTBService rptbso = new PlanTBService(); rpt = rptbso.FindByKey(int.Parse(((LinkButton)e.CommandSource).CommandArgument)); //txtMucCamKetTB.Text = rpt.CamKet; if (rpt.CachLapDat != "") { try { ddlCacThucLD.SelectedValue = rpt.CachLapDat; } catch { } } txtlydoTB.Text = rpt.LyDo; txtnamTB.Text = rpt.Nam.ToString(); txtTenTB.Text = rpt.NameTB; txtCamKetTB.Text = rpt.CamKet; ddlKhaNangTB.SelectedValue = rpt.KhaNang; txtTinhNangTB.Text = rpt.TinhNang; hddkhTB.Value = rpt.Id.ToString(); //BindThietBi(); ScriptManager.RegisterStartupScript(this, GetType(), "showkhd", "showkehoach();", true); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "showgiaiphapTB('1');", true); } }
public void btnSaveAddDevice_Click(object sender, EventArgs e) { try { PlanTB plantb = new PlanTB(); PlanTBService plantbservice = new PlanTBService(); if (hddkhTB.Value != "") { plantb = plantbservice.FindByKey(Convert.ToInt32(hddkhTB.Value)); if (ddlCacThucLDBS.SelectedIndex > 0) { plantb.CachLapDat = ddlCacThucLDBS.SelectedValue; } plantb.EnterpriseId = m_UserValidation.OrgId; plantb.NameTB = txtTenTietBiBS.Text; plantb.TinhNang = txtMoTaTinhNangBS.Text; if (cbxThucHien.Checked) { plantb.LyDoLapDat = txtLyDoKhongThucHien.Text; } else { plantb.LyDo = txtLyDoKhongThucHien.Text; } plantb.Nam = ReportYear; plantb.IsExecuted = cbxThucHien.Checked; plantb.IdPlan = ReportId; plantb.IsFiveYear = false; plantb.IsPlan = false; plantb.IsNew = false; int i = plantbservice.Update(plantb).Id; if (i > 0) { BindResultTB(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showkhd", "updateiaiphapTB();", true); ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công!');", true); } } else { plantb.EnterpriseId = m_UserValidation.OrgId; if (ddlCacThucLDBS.SelectedIndex > 0) { plantb.CachLapDat = ddlCacThucLDBS.SelectedValue; } plantb.NameTB = txtTenTietBiBS.Text; plantb.TinhNang = txtMoTaTinhNangBS.Text; plantb.Nam = ReportYear; plantb.IsExecuted = cbxThucHien.Checked; if (cbxThucHien.Checked) { plantb.LyDoLapDat = txtLyDoKhongThucHien.Text; } else { plantb.LyDo = txtLyDoKhongThucHien.Text; } plantb.IsNew = true; plantb.IsFiveYear = false; plantb.IsPlan = false; plantb.IdPlan = ReportId; int i = plantbservice.Insert(plantb); if (i > 0) { BindResultTB(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showkhd", "updateiaiphapTB();", true); ScriptManager.RegisterStartupScript(this, GetType(), "showx", "alert('Cập nhật không thành công!');", true); } } } catch (Exception) { throw; } }
public void btnSaveDevice_Click(object sender, EventArgs e) { try { PlanTB plantb = new PlanTB(); PlanTBService plantbservice = new PlanTBService(); if (hddkhTB.Value != "") { plantb = plantbservice.FindByKey(Convert.ToInt32(hddkhTB.Value)); if (ddlCacThucLD.SelectedIndex > 0) { plantb.CachLapDat = ddlCacThucLD.SelectedValue; } plantb.EnterpriseId = m_UserValidation.OrgId; plantb.NameTB = txtTenTB.Text; plantb.TinhNang = txtTinhNangTB.Text; plantb.LyDo = txtlydoTB.Text; plantb.Nam = Convert.ToInt32(txtnamTB.Text); if (ddlKhaNangTB.SelectedIndex > 0) { plantb.KhaNang = ddlKhaNangTB.SelectedValue; } plantb.CamKet = txtCamKetTB.Text.Trim(); plantb.IdPlan = ReportId; plantb.IsFiveYear = false; plantb.IsPlan = true; plantb.IsNew = false; int i = plantbservice.Update(plantb).Id; if (i > 0) { BindThietBi(); ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "showgiaiphapTB('1');", true); } else { ScriptManager.RegisterStartupScript(this, GetType(), "message", "alert('Cập nhật không thành công!');", true); } } else { //plantb.CamKet = txtMucCamKetTB.Text; if (ddlCacThucLD.SelectedIndex > 0) { plantb.CachLapDat = ddlCacThucLD.SelectedValue; } plantb.EnterpriseId = m_UserValidation.OrgId; plantb.NameTB = txtTenTB.Text; plantb.TinhNang = txtTinhNangTB.Text; plantb.LyDo = txtlydoTB.Text; plantb.Nam = Convert.ToInt32(txtnamTB.Text); if (ddlKhaNangTB.SelectedIndex > 0) { plantb.KhaNang = ddlKhaNangTB.SelectedValue; } plantb.CamKet = txtCamKetTB.Text.Trim(); plantb.IsFiveYear = false; plantb.IsPlan = true; plantb.IsNew = false; plantb.IdPlan = ReportId; int i = plantbservice.Insert(plantb); if (i > 0) { BindThietBi(); } else { ScriptManager.RegisterStartupScript(this, GetType(), "showtb", "showgiaiphapTB('1');", true); ScriptManager.RegisterStartupScript(this, GetType(), "showx", "alert('Cập nhật không thành công!');", true); } } } catch (Exception) { throw; } }
protected void btnExport_Click(object sender, EventArgs e) { #region get data WordExtend ex = new WordExtend(); string temp = "TempReport/TemMauBaoCao" + drpmaubaocao.SelectedValue + ".doc"; ex.OpenFile(Server.MapPath(ResolveUrl("~") + temp)); Enterprise or = new Enterprise(); EnterpriseService orser = new EnterpriseService(); or = orser.FindByKey(Convert.ToInt32(memVal.OrgId)); DataTable dtinfo = new DataTable(); ex.WriteToMergeField("BC_MaDN", ""); if (memVal.OrgId > 0) { dtinfo = new ReportFuelService().GetInfoReportFuel(ReportId); } if (or != null) { ex.WriteToMergeField("BC_Title", or.Title); ex.WriteToMergeField("BC_TenCoSo", or.Title); ex.WriteToMergeField("BC_TenCoSo1", or.Title); ex.WriteToMergeField("BC_TenCoSo2", or.Title); } else { ex.WriteToMergeField("BC_TenCoSo", ""); } if (dtinfo.Rows[0]["Year"] != DBNull.Value) { string NextYear = (Convert.ToInt32(dtinfo.Rows[0]["Year"]) + 1).ToString(); ex.WriteToMergeField("BC_NextYear", NextYear); ex.WriteToMergeField("BC_NextYear1", NextYear); ex.WriteToMergeField("BC_NextYear2", NextYear); ex.WriteToMergeField("BC_Year", dtinfo.Rows[0]["Year"].ToString()); ex.WriteToMergeField("BC_Year1", dtinfo.Rows[0]["Year"].ToString()); } if (dtinfo.Rows[0]["Responsible"] != DBNull.Value) { ex.WriteToMergeField("BC_ChiuTrachNhiem", dtinfo.Rows[0]["Responsible"].ToString()); } else { ex.WriteToMergeField("BC_ChiuTrachNhiem", ""); } if (dtinfo.Rows[0]["ReportDate"] != DBNull.Value) { ex.WriteToMergeField("BC_NgayLap", Convert.ToDateTime(dtinfo.Rows[0]["ReportDate"]).ToString("dd/MM/yyyy")); ex.WriteToMergeField("BC_NgayBC", Convert.ToDateTime(dtinfo.Rows[0]["ReportDate"]).ToString("dd/MM/yyyy")); } if (dtinfo.Rows[0]["ReceivedDate"] != DBNull.Value) { ex.WriteToMergeField("BC_NgayNhan", Convert.ToDateTime(dtinfo.Rows[0]["ReceivedDate"]).ToString("dd/MM/yyyy")); } else { ex.WriteToMergeField("BC_NgayNhan", ""); } if (dtinfo.Rows[0]["ConfirmedDate"] != DBNull.Value) { ex.WriteToMergeField("BC_NgayXacNhan", Convert.ToDateTime(dtinfo.Rows[0]["ConfirmedDate"]).ToString("dd/MM/yyyy")); } else { ex.WriteToMergeField("BC_NgayXacNhan", ""); } if (dtinfo.Rows[0]["SubAreaName"] != DBNull.Value) { ex.WriteToMergeField("BC_PhanNganh", dtinfo.Rows[0]["SubAreaName"].ToString()); } else { ex.WriteToMergeField("BC_PhanNganh", ""); } if (dtinfo.Rows[0]["TaxCode"] != DBNull.Value) { ex.WriteToMergeField("BC_TaxCode", dtinfo.Rows[0]["TaxCode"].ToString()); } else { ex.WriteToMergeField("BC_TaxCode", ""); } ex.WriteToMergeField("BC_Owner", ltOwner.Text); if (or.Address != null) { ex.WriteToMergeField("BC_DiaChi", or.Address); } if (dtinfo.Rows[0]["DistrictName"] != DBNull.Value) { ex.WriteToMergeField("BC_Huyen", dtinfo.Rows[0]["DistrictName"].ToString()); } else { ex.WriteToMergeField("BC_Huyen", ""); } if (dtinfo.Rows[0]["ProvinceName"] != DBNull.Value) { ex.WriteToMergeField("BC_Tinh", dtinfo.Rows[0]["ProvinceName"].ToString()); } else { ex.WriteToMergeField("BC_Tinh", ""); } if (dtinfo.Rows[0]["ReporterName"] != DBNull.Value) { ex.WriteToMergeField("BC_NguoiBC", dtinfo.Rows[0]["ReporterName"].ToString()); } else { ex.WriteToMergeField("BC_NguoiBC", ""); } if (dtinfo.Rows[0]["Fax"] != DBNull.Value) { ex.WriteToMergeField("BC_Fax", dtinfo.Rows[0]["Fax"].ToString()); } else { ex.WriteToMergeField("BC_Fax", ""); } if (dtinfo.Rows[0]["Email"] != DBNull.Value) { ex.WriteToMergeField("BC_Email", dtinfo.Rows[0]["Email"].ToString()); } else { ex.WriteToMergeField("BC_Email", ""); } if (dtinfo.Rows[0]["Phone"] != DBNull.Value) { ex.WriteToMergeField("BC_DienThoai", dtinfo.Rows[0]["Phone"].ToString()); } else { ex.WriteToMergeField("BC_DienThoai", ""); } if (dtinfo.Rows[0]["ParentName"] != DBNull.Value) { ex.WriteToMergeField("BC_TenCtyMe", dtinfo.Rows[0]["ParentName"].ToString()); } else { ex.WriteToMergeField("BC_TenCtyMe", ""); } if (dtinfo.Rows[0]["AddressParent"] != null) { ex.WriteToMergeField("BC_DiaChiP", dtinfo.Rows[0]["AddressParent"].ToString()); } else { ex.WriteToMergeField("BC_DiaChiP", ""); } if (dtinfo.Rows[0]["DistrictNameP"] != null) { ex.WriteToMergeField("BC_HuyenP", dtinfo.Rows[0]["DistrictNameP"].ToString()); } else { ex.WriteToMergeField("BC_HuyenP", ""); } if (dtinfo.Rows[0]["ProvinceNameP"] != DBNull.Value) { ex.WriteToMergeField("BC_TinhP", dtinfo.Rows[0]["ProvinceNameP"].ToString()); } else { ex.WriteToMergeField("BC_TinhP", ""); } if (dtinfo.Rows[0]["PhoneParent"] != DBNull.Value) { ex.WriteToMergeField("BC_DienThoaiP", dtinfo.Rows[0]["PhoneParent"].ToString()); } else { ex.WriteToMergeField("BC_DienThoaiP", ""); } if (dtinfo.Rows[0]["FaxParent"] != DBNull.Value) { ex.WriteToMergeField("BC_FaxP", dtinfo.Rows[0]["FaxParent"].ToString()); } else { ex.WriteToMergeField("BC_FaxP", ""); } if (dtinfo.Rows[0]["EmailParent"] != DBNull.Value) { ex.WriteToMergeField("BC_EmailP", dtinfo.Rows[0]["EmailParent"].ToString()); } else { ex.WriteToMergeField("BC_EmailP", ""); } if (or.ActiveYear > 0) { ex.WriteToMergeField("ActiveYear", or.ActiveYear.ToString()); } else { ex.WriteToMergeField("ActiveYear", ""); } Infrastructure infra = new Infrastructure(); InfrastructureService infraService = new InfrastructureService(); infra = infraService.GetInfrastructureByReport(ReportId); if (infra != null) { if (infra.ProduceAreaNo > 0) { ex.WriteToMergeField("ProduceAreaNo", infra.ProduceAreaNo.ToString()); } else { ex.WriteToMergeField("ProduceAreaNo", ""); } if (infra.OfficeAreaNo > 0) { ex.WriteToMergeField("OfficeAreaNo", infra.OfficeAreaNo.ToString()); } else { ex.WriteToMergeField("OfficeAreaNo", ""); } if (infra.ProduceEmployeeNo > 0) { ex.WriteToMergeField("ProduceEmployeeNo", infra.ProduceEmployeeNo.ToString()); } else { ex.WriteToMergeField("ProduceEmployeeNo", ""); } if (infra.OfficeEmployeeNo > 0) { ex.WriteToMergeField("OfficeEmployeeNo", infra.OfficeEmployeeNo.ToString()); } else { ex.WriteToMergeField("OfficeEmployeeNo", ""); } } else { ex.WriteToMergeField("ProduceAreaNo", ""); ex.WriteToMergeField("OfficeAreaNo", ""); ex.WriteToMergeField("ProduceEmployeeNo", ""); ex.WriteToMergeField("OfficeEmployeeNo", ""); } UsingElectrict usingElectrict = new UsingElectrict(); UsingElectrictService usingElectrictService = new UsingElectrictService(); usingElectrict = usingElectrictService.GetUsingElectrictByReport(ReportId, false); if (usingElectrict != null) { //Su dung dien 2 if (usingElectrict.Quantity > 0) { ex.WriteToMergeField("QuantityResult2", usingElectrict.Quantity.ToString()); } else { ex.WriteToMergeField("QuantityResult2", ""); } if (usingElectrict.InstalledCapacity > 0) { ex.WriteToMergeField("InstalledCapacityResult2", usingElectrict.InstalledCapacity.ToString()); } else { ex.WriteToMergeField("InstalledCapacityResult2", ""); } if (usingElectrict.Capacity > 0) { ex.WriteToMergeField("CapacityResult2", usingElectrict.Capacity.ToString()); } else { ex.WriteToMergeField("CapacityResult2", ""); } if (usingElectrict.BuyCost > 0) { ex.WriteToMergeField("BuyCostResult2", usingElectrict.BuyCost.ToString()); } else { ex.WriteToMergeField("BuyCostResult2", ""); } if (usingElectrict.BuyCost > 0 && usingElectrict.Capacity > 0) { ex.WriteToMergeField("BuyPriceResult2", Math.Round((usingElectrict.BuyCost / (usingElectrict.Capacity * 1000)), 0).ToString()); } else { ex.WriteToMergeField("BuyPriceResult2", ""); } if (usingElectrict.ProduceQty > 0) { ex.WriteToMergeField("ProduceQtyResult2", usingElectrict.ProduceQty.ToString()); } else { ex.WriteToMergeField("ProduceQtyResult2", ""); } if (usingElectrict.Technology != null) { ex.WriteToMergeField("TechnologyResult2", usingElectrict.Technology.ToString()); } else { ex.WriteToMergeField("TechnologyResult2", ""); } if (usingElectrict.FuelId > 0) { Fuel fuel = new Fuel(); fuel = new FuelService().FindByKey(usingElectrict.FuelId); if (fuel != null) { ex.WriteToMergeField("FuelNameResult2", fuel.FuelName); ex.WriteToMergeField("FuelNameResult", fuel.FuelName); } else { ex.WriteToMergeField("FuelNameResult2", ""); ex.WriteToMergeField("FuelNameResult", ""); } } else { ex.WriteToMergeField("FuelNameResult2", ""); ex.WriteToMergeField("FuelNameResult", ""); } if (usingElectrict.PriceProduce > 0) { ex.WriteToMergeField("PriceProduceResult2", usingElectrict.PriceProduce.ToString()); } else { ex.WriteToMergeField("PriceProduceResult2", ""); } //Su dung dien 1 if (usingElectrict.Quantity > 0) { ex.WriteToMergeField("QuantityResult", usingElectrict.Quantity.ToString()); } else { ex.WriteToMergeField("QuantityResult", ""); } if (usingElectrict.InstalledCapacity > 0) { ex.WriteToMergeField("InstalledCapacityResult", usingElectrict.InstalledCapacity.ToString()); } else { ex.WriteToMergeField("InstalledCapacityResult", ""); } if (usingElectrict.Capacity > 0) { ex.WriteToMergeField("CapacityResult", usingElectrict.Capacity.ToString()); } else { ex.WriteToMergeField("CapacityResult", ""); } if (usingElectrict.BuyCost > 0) { ex.WriteToMergeField("BuyCostResult", usingElectrict.BuyCost.ToString()); } else { ex.WriteToMergeField("BuyCostResult", ""); } if (usingElectrict.BuyCost > 0 && usingElectrict.Capacity > 0) { ex.WriteToMergeField("BuyPriceResult", Math.Round((usingElectrict.BuyCost / (usingElectrict.Capacity * 1000)), 0).ToString()); } else { ex.WriteToMergeField("BuyPriceResult", ""); } if (usingElectrict.ProduceQty > 0) { ex.WriteToMergeField("ProduceQtyResult", usingElectrict.ProduceQty.ToString()); } else { ex.WriteToMergeField("ProduceQtyResult", ""); } if (usingElectrict.Technology != null) { ex.WriteToMergeField("TechnologyResult", usingElectrict.Technology.ToString()); } else { ex.WriteToMergeField("TechnologyResult", ""); } if (usingElectrict.FuelId > 0) { ex.WriteToMergeField("FuelNameResult", usingElectrict.FuelId.ToString()); } else { ex.WriteToMergeField("FuelNameResult", ""); } } else { ex.WriteToMergeField("QuantityResult2", ""); ex.WriteToMergeField("InstalledCapacityResult2", ""); ex.WriteToMergeField("CapacityResult2", ""); ex.WriteToMergeField("BuyCostResult2", ""); ex.WriteToMergeField("ProduceQtyResult2", ""); ex.WriteToMergeField("TechnologyResult2", ""); ex.WriteToMergeField("FuelNameResult2", ""); ex.WriteToMergeField("PriceProduceResult2", ""); ex.WriteToMergeField("QuantityResult", ""); ex.WriteToMergeField("InstalledCapacityResult", ""); ex.WriteToMergeField("CapacityResult", ""); ex.WriteToMergeField("BuyCostResult", ""); ex.WriteToMergeField("ProduceQtyResult", ""); ex.WriteToMergeField("TechnologyResult", ""); ex.WriteToMergeField("FuelNameResult", ""); } usingElectrict = new UsingElectrict(); usingElectrict = usingElectrictService.GetUsingElectrictByReport(ReportId, true); if (usingElectrict != null) { //Su dung dien 2 if (usingElectrict.Quantity > 0) { ex.WriteToMergeField("QuantityPlan", usingElectrict.Quantity.ToString()); } else { ex.WriteToMergeField("QuantityPlan", ""); } if (usingElectrict.InstalledCapacity > 0) { ex.WriteToMergeField("InstalledCapacityPlan", usingElectrict.InstalledCapacity.ToString()); } else { ex.WriteToMergeField("InstalledCapacityPlan", ""); } if (usingElectrict.Capacity > 0) { ex.WriteToMergeField("CapacityPlan", usingElectrict.Capacity.ToString()); } else { ex.WriteToMergeField("CapacityPlan", ""); } if (usingElectrict.BuyCost > 0) { ex.WriteToMergeField("BuyCostPlan", usingElectrict.BuyCost.ToString()); } else { ex.WriteToMergeField("BuyCostPlan", ""); } if (usingElectrict.BuyCost > 0) { ex.WriteToMergeField("BuyPricePlan", usingElectrict.BuyCost.ToString()); } else { ex.WriteToMergeField("BuyPricePlan", ""); } if (usingElectrict.ProduceQty > 0) { ex.WriteToMergeField("ProduceQtyPlan", usingElectrict.ProduceQty.ToString()); } else { ex.WriteToMergeField("ProduceQtyPlan", ""); } if (usingElectrict.Technology != null) { ex.WriteToMergeField("TechnologyPlan", usingElectrict.Technology.ToString()); } else { ex.WriteToMergeField("TechnologyPlan", ""); } if (usingElectrict.FuelId > 0) { Fuel fuel = new Fuel(); fuel = new FuelService().FindByKey(usingElectrict.FuelId); if (fuel != null) { ex.WriteToMergeField("FuelNamePlan", fuel.FuelName); } else { ex.WriteToMergeField("FuelNamePlan", ""); } } else { ex.WriteToMergeField("FuelNamePlan", ""); } if (usingElectrict.PriceProduce > 0) { ex.WriteToMergeField("PriceProducePlan", usingElectrict.PriceProduce.ToString()); } else { ex.WriteToMergeField("PriceProducePlan", ""); } } else { ex.WriteToMergeField("QuantityPlan", ""); ex.WriteToMergeField("InstalledCapacityPlan", ""); ex.WriteToMergeField("CapacityPlan", ""); ex.WriteToMergeField("BuyCostPlan", ""); ex.WriteToMergeField("ProduceQtyPlan", ""); ex.WriteToMergeField("TechnologyPlan", ""); ex.WriteToMergeField("FuelNamePlan", ""); ex.WriteToMergeField("PriceProducePlan", ""); } DataTable dthientai = new DataTable(); DataTable dtdukien = new DataTable(); DataSet dshientai = new DataSet("tbl1"); DataTable dt = new DataTable(); dt = new ReportFuelDetailService().GetNoFuelDetailByReport(ReportId, false); dt.Columns.Add("dvnhietnang", typeof(string)); dt.Columns.Add("dvnhieulieu", typeof(string)); dthientai = dt.Clone(); foreach (DataRow item in dt.Rows) { DataRow workRow = null; workRow = dthientai.NewRow(); workRow = item; if (workRow["MeasurementName"].ToString().Contains("Mét khối")) { workRow["dvnhietnang"] = "kJ/m3"; } else { workRow["dvnhietnang"] = "kJ/kg"; } if (workRow["MeasurementName"].ToString().Contains("tấn") || workRow["MeasurementName"].ToString().Contains("Klg")) { workRow["dvnhieulieu"] = "kJ/tấn"; } else { workRow["dvnhieulieu"] = "đ/m3"; } workRow.AcceptChanges(); dthientai.AcceptChanges(); dthientai.ImportRow(workRow); } dt = new ReportFuelDetailService().GetNoFuelDetailByReport(ReportId, true); dt.Columns.Add("dvnhietnang", typeof(string)); dt.Columns.Add("dvnhieulieu", typeof(string)); dtdukien = dt.Clone(); foreach (DataRow item in dt.Rows) { DataRow workRow = null; workRow = dtdukien.NewRow(); workRow = item; if (workRow["MeasurementName"].ToString().Contains("Mét khối")) { workRow["dvnhietnang"] = "kJ/m3"; } else { workRow["dvnhietnang"] = "kJ/kg"; } if (workRow["MeasurementName"].ToString().Contains("tấn") || workRow["MeasurementName"].ToString().Contains("Klg")) { workRow["dvnhieulieu"] = "kJ/tấn"; } else { workRow["dvnhieulieu"] = "đ/m3"; } workRow.AcceptChanges(); dtdukien.ImportRow(workRow); dtdukien.AcceptChanges(); } ProductCapacityService productCapacityService = new ProductCapacityService(); DataTable tblProductResult = new DataTable(); tblProductResult = productCapacityService.GetDataCapacity(ReportId, false); dshientai.Merge(tblProductResult); dshientai.Tables[0].TableName = "tbl1"; dshientai.Merge(dthientai); dshientai.Tables[1].TableName = "tbl2"; //ex.WriteDataSetToMergeField(dshientai); DataTable tblProductPlan = new DataTable(); tblProductPlan = productCapacityService.GetDataCapacity(ReportId, true); dshientai.Merge(tblProductPlan); dshientai.Tables[2].TableName = "tbl3"; dshientai.Merge(dtdukien); dshientai.Tables[3].TableName = "tbl4"; //ex.WriteDataSetToMergeField(dshientai); DataSet dsData = new DataSet(); PlanTBService plangpservice = new PlanTBService(); PlanTKNLService plangTKNLservice = new PlanTKNLService(); DataTable tblGPTKNLPlan = new DataTable(); tblGPTKNLPlan = plangTKNLservice.GetPlanTKNLEnerprise(Convert.ToInt32(memVal.OrgId), ReportId, false, true); dshientai.Merge(tblGPTKNLPlan); dshientai.Tables[4].TableName = "tbl5"; DataTable tblTBPlan = new DataTable(); tblTBPlan = plangpservice.GetPlanTBEnterprise(memVal.OrgId, ReportId, false, true); dshientai.Merge(tblTBPlan); dshientai.Tables[5].TableName = "tbl6"; dshientai.Merge(tblProductPlan.Copy()); dshientai.Tables[6].TableName = "tbl7"; dshientai.Merge(dthientai.Copy()); dshientai.Tables[7].TableName = "tbl8"; DataTable tblGPTKNLResult = new DataTable(); tblGPTKNLResult = plangTKNLservice.GetPlanTKNLEnerprise(Convert.ToInt32(memVal.OrgId), ReportId, false, false); dshientai.Merge(tblGPTKNLResult); dshientai.Tables[8].TableName = "tbl9"; DataTable tblTBResult = new DataTable(); tblTBResult = plangpservice.GetPlanTBEnterprise(memVal.OrgId, ReportId, false, false); dshientai.Merge(tblTBResult); dshientai.Tables[9].TableName = "tbl10"; dshientai.Tables.Add(tblTBResult.Copy()); dshientai.Tables[10].TableName = "tbl11"; ex.WriteDataSetToMergeField(dshientai); // dsg.Tables.Add(dst); //var dt2 = ExcelExportHelper.CreateGroupInDT(dt, "DepName", "STT"); #endregion ex.Save(Server.MapPath(ResolveUrl("~") + "TempReport/" + memVal.UserName + ".Bao-cao-hang-nam-" + dtinfo.Rows[0]["Year"] + ".doc")); HttpContext.Current.Response.Redirect(string.Format("~/Download.aspx?fp={0}&fn={1}", System.IO.Path.GetFileName(Server.MapPath(ResolveUrl("~") + "TempReport/" + memVal.UserName + ".Bao-cao-hang-nam-" + dtinfo.Rows[0]["Year"] + ".doc")), "" )); }