Exemplo n.º 1
0
    void BindFuel()
    {
        ddlFuel.Items.Clear();
        IList <Fuel> list = new List <Fuel>();

        if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Fuel_All))
        {
            list = new FuelService().FindAll();
            AspNetCache.SetCache(Constants.Cache_ReportFuel_Fuel_All, list);
        }
        else
        {
            list = (IList <Fuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Fuel_All);
        }
        //int GroupId = 0;
        //if (ddlFuelType.SelectedIndex > 0)
        //    GroupId = Convert.ToInt32(ddlFuelType.SelectedValue);

        //ddlFuelType.DataSource = list;
        var listSearch = from o in list orderby o.FuelName ascending select o;

        ddlFuel.DataSource     = listSearch;
        ddlFuel.DataValueField = "Id";
        ddlFuel.DataTextField  = "FuelName";
        ddlFuel.DataBind();
        ddlFuel.Items.Insert(0, new ListItem("---Chọn nhiên liệu---", ""));
        if (ddlFuel.Items.Count == 2)
        {
            ddlFuel.SelectedIndex = 1;
        }
        BindMeasurement();
    }
Exemplo n.º 2
0
    void BindFuel()
    {
        ddlFuelType.Items.Clear();
        IList <Fuel> list = new List <Fuel>();

        if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Fuel_All))
        {
            list = new FuelService().FindAll();
            AspNetCache.SetCache(Constants.Cache_ReportFuel_Fuel_All, list);
        }
        else
        {
            list = (IList <Fuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Fuel_All);
        }
        int GroupId = 0;

        if (ddlFuelType.SelectedIndex > 0)
        {
            GroupId = Convert.ToInt32(ddlFuelType.SelectedValue);
        }

        var listSearch = from o in list where o.GroupFuelId == GroupId || GroupId == 0 select o;

        ddlFuelType.DataSource     = listSearch;
        ddlFuelType.DataValueField = "Id";
        ddlFuelType.DataTextField  = "FuelName";
        ddlFuelType.DataBind();
        ddlFuelType.Items.Insert(0, new ListItem("---Chọn loại nhiên liệu---", ""));

        ddlFuelType2.DataSource     = listSearch;
        ddlFuelType2.DataValueField = "Id";
        ddlFuelType2.DataTextField  = "FuelName";
        ddlFuelType2.DataBind();
        ddlFuelType2.Items.Insert(0, new ListItem("---Chọn loại nhiên liệu---", ""));
    }
Exemplo n.º 3
0
    protected void grvFuel_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string aId   = e.CommandArgument.ToString();
        string aName = e.CommandName.ToLower();
        int    fid   = 0;

        try
        {
            fid = Convert.ToInt32(aId);
        }
        catch { }

        if (fid > 0)
        {
            Fuel fuel = new FuelService().FindByKey(fid);
            if (fuel != null)
            {
                if (aName.Contains("_edit"))
                {
                    hdnEditId.Value = fid.ToString();
                    txtTitle.Text   = fuel.FuelName;
                    try
                    {
                        if (fuel.GroupFuelId > 0)
                        {
                            ddlGroupFuel.SelectedValue = fuel.GroupFuelId.ToString();
                        }
                    }
                    catch { }
                    try
                    {
                        if (fuel.MeasurementId > 0)
                        {
                            ddlMeasurement.SelectedValue = fuel.MeasurementId.ToString();
                        }
                    }
                    catch { }
                    ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updateFuel();", true);
                }
                else if (aName.Contains("_delete"))
                {
                    long iDelete = 0;
                    iDelete = new FuelService().Delete(fid);
                    if (iDelete > 0)
                    {
                        BindData();
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
    void BindData()
    {
        FuelService objFuelService = new FuelService();
        DataTable   list           = new DataTable();

        ePower.Core.PagingInfo paging = new ePower.Core.PagingInfo(PageSize, CurrentPage);
        int    groupId = 0;
        string strKey  = string.Empty;

        if (txtKeyword.Text != "" && txtKeyword.Text.Trim() != "")
        {
            strKey = txtKeyword.Text.Trim();
        }
        if (ddlParent.SelectedIndex > 0)
        {
            groupId = Convert.ToInt32(ddlParent.SelectedValue);
        }

        list = objFuelService.FindFuelList(strKey, 0, groupId, paging, true);
        if (list != null && list.Rows.Count > 0)
        {
            paging.RowsCount   = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging.PageSize    = PageSize;
            Paging.CurrentPage = CurrentPage;
            Paging.TotalRecord = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging.DataLoad();
            if (paging.PagesCount <= 1)
            {
                ltrTotal.Text  = "Tổng số " + paging.RowsCount + " nhiên liệu";
                Paging.Visible = false;
            }
            else
            {
                int  st  = (CurrentPage - 1) * PageSize + 1;
                long end = CurrentPage * PageSize;
                if (end > paging.RowsCount)
                {
                    end = paging.RowsCount;
                }
                ltrTotal.Text  = "Đang xem trang " + CurrentPage + ". Hiển thị từ " + st + " - " + end + " trên tổng số " + paging.RowsCount + " nhiên liệu";
                Paging.Visible = true;
            }
        }
        else
        {
            ltrTotal.Text  = "";
            Paging.Visible = false;
        }
        grvFuel.DataSource = list;
        grvFuel.DataBind();
    }
Exemplo n.º 5
0
    protected void rptAuditReport_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Literal ltSaveTOE  = (Literal)e.Item.FindControl("ltSaveTOE");
        Literal ltTotalTOE = (Literal)e.Item.FindControl("ltTotalTOE");

        StringBuilder sb = new StringBuilder();
        DataRowView   dr = (DataRowView)e.Item.DataItem;

        if (dr != null)
        {
            int     eID    = Convert.ToInt32(dr["Id"]);
            DataSet dsFuel = new AuditReportService().GetTOEByAuditReport(eID);

            IList <Fuel> listFuel = new List <Fuel>();
            if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Fuel_All))
            {
                listFuel = new FuelService().FindAll();
                AspNetCache.SetCache(Constants.Cache_ReportFuel_Fuel_All, listFuel);
            }
            else
            {
                listFuel = (IList <Fuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Fuel_All);
            }
            decimal dsum    = 0;
            decimal NoTOE   = 0;
            decimal dsumTK  = 0;
            decimal NoTOETK = 0;
            if (dsFuel != null && dsFuel.Tables.Count > 0)
            {
                for (int i = 0; i < dsFuel.Tables[0].Rows.Count; i++)
                {
                    dsum  = dsum + Convert.ToDecimal(dsFuel.Tables[0].Rows[i]["NoCO2"]);
                    NoTOE = NoTOE + Convert.ToDecimal(dsFuel.Tables[0].Rows[i]["NoTOE"]);
                }
                for (int i = 0; i < dsFuel.Tables[1].Rows.Count; i++)
                {
                    dsumTK  = dsumTK + Convert.ToDecimal(dsFuel.Tables[1].Rows[i]["NoCO2"]);
                    NoTOETK = NoTOETK + Convert.ToDecimal(dsFuel.Tables[1].Rows[i]["NoTOE"]);
                }
            }
            decimal rate = 0;
            if (NoTOE > 0)
            {
                rate = Math.Round((NoTOETK / NoTOE) * 100, 2);
            }
            ltSaveTOE.Text  = rate.ToString() + "%";
            ltTotalTOE.Text = Tool.ConvertDecimalToString(NoTOE, 2);
        }
    }
Exemplo n.º 6
0
    void BindData()
    {
        FuelService objFuelService = new FuelService();
        DataTable   list           = new DataTable();

        ePower.Core.PagingInfo paging = new ePower.Core.PagingInfo(1000, 1);
        int    groupId = 0;
        string strKey  = string.Empty;

        if (ddlParent.SelectedIndex > 0)
        {
            groupId = Convert.ToInt32(ddlParent.SelectedValue);
        }

        list = objFuelService.FindFuelList(strKey, 0, groupId, paging, true);

        grvFuel.DataSource = list;
        grvFuel.DataBind();
    }
Exemplo n.º 7
0
    private ReportFuelDetail ReceiveHtmlDetail()
    {
        ReportFuelDetail rep = new ReportFuelDetail();

        if (ddlFuel.SelectedIndex > 0)
        {
            rep.FuelId = Convert.ToInt32(ddlFuel.SelectedValue);
        }
        if (rep.FuelId > 0)
        {
            Fuel fuel = new FuelService().FindByKey(rep.FuelId);
            if (fuel != null)
            {
                rep.GroupFuelId = fuel.GroupFuelId;
            }
        }
        //if (ddlFuel.SelectedIndex > 0)
        //    rep.GroupFuelId = Convert.ToInt32(ddlFuelType.SelectedValue);
        if (ddlMeasure.SelectedIndex > 0)
        {
            rep.MeasurementId = Convert.ToInt32(ddlMeasure.SelectedValue);
        }
        if (txtNoFuel.Text.Trim() != "")
        {
            rep.NoFuel = Convert.ToDecimal(txtNoFuel.Text.Trim());
        }
        if (txtNoTOE.Text.Trim() != "")
        {
            rep.No_RateTOE = Convert.ToDecimal(txtNoTOE.Text.Trim());
        }
        rep.Reason = txtPropose.Text.Trim();

        if (txtPrice.Text.Trim() != "")
        {
            rep.Price = Convert.ToDecimal(txtPrice.Text.Trim());
        }
        rep.IsNextYear   = (hdnNextYear.Value == "1");
        rep.Year         = ReportYear;
        rep.ReportId     = ReportId;
        rep.EnterpriseId = memVal.OrgId;
        rep.NoFuel_TOE   = rep.NoFuel * rep.No_RateTOE;
        return(rep);
    }
    void BindFuel()
    {
        ddlFuelType.Items.Clear();
        IList <Fuel> list = new List <Fuel>();

        if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Fuel_All))
        {
            list = new FuelService().FindAll();
            AspNetCache.SetCache(Constants.Cache_ReportFuel_Fuel_All, list);
        }
        else
        {
            list = (IList <Fuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Fuel_All);
        }
        var listSearch = from o in list orderby o.FuelName ascending select o;

        ddlFuelType.DataSource     = listSearch;
        ddlFuelType.DataValueField = "Id";
        ddlFuelType.DataTextField  = "FuelName";
        ddlFuelType.DataBind();
        ddlFuelType.Items.Insert(0, new ListItem("---Chọn loại nhiên liệu---", ""));
    }
 public FuelServiceTestBase()
 {
     fuelService = new FuelService();
 }
Exemplo n.º 10
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        FuelService fuelService = new FuelService();
        Fuel        fuel        = new Fuel();
        int         FuelId      = 0;

        if (hdnEditId.Value != "")
        {
            try
            {
                FuelId = Convert.ToInt32(hdnEditId.Value.Trim());
            }
            catch
            { }
        }
        fuel.FuelName = txtTitle.Text.Trim();
        if (ddlGroupFuel.SelectedIndex > 0)
        {
            fuel.GroupFuelId = Convert.ToInt32(ddlGroupFuel.SelectedValue);
        }
        if (ddlMeasurement.SelectedIndex > 0)
        {
            fuel.MeasurementId = Convert.ToInt32(ddlMeasurement.SelectedValue);
        }
        if (FuelId > 0)
        {
            fuel.Id = FuelId;
            if (fuelService.Update(fuel) != null)
            {
                BindData();
                hdnEditId.Value = "0";
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updateFuel();", true);
            }
        }
        else
        {
            int id = fuelService.Insert(fuel);
            if (id > 0)
            {
                MeasurementFuelService measurementFuelService = new MeasurementFuelService();
                MeasurementFuel        objMeasurementFuel     = new MeasurementFuel();
                if (txtNoCO2_S.Text != "")
                {
                    objMeasurementFuel.NoCO2 = Convert.ToDecimal(txtNoCO2_S.Text.Trim());
                }
                if (txtFromTOE_S.Text != "" && txtToTOE_S.Text.Trim() != "" && ddlMeasurement.SelectedValue != "" && id > 0)
                {
                    if (ddlMeasurement.SelectedValue != "")
                    {
                        objMeasurementFuel.MeasurementId = Convert.ToInt32(ddlMeasurement.SelectedValue);
                    }
                    objMeasurementFuel.FuelId = fuel.Id;
                    decimal dfrom = 0;
                    decimal dto   = 0;
                    try
                    {
                        dfrom = Convert.ToDecimal(txtFromTOE_S.Text);
                    }
                    catch
                    {
                    }
                    if (txtToTOE_S.Text != "" && txtToTOE_S.Text.Trim() != "")
                    {
                        try
                        {
                            dto = Convert.ToDecimal(txtToTOE_S.Text.Trim());
                        }
                        catch
                        {
                        }
                    }
                    if (dfrom > 0)
                    {
                        objMeasurementFuel.From_TOE = dfrom;
                        objMeasurementFuel.TOE      = dfrom;
                    }
                    if (dto >= 0 && dto > dfrom)
                    {
                        objMeasurementFuel.To_TOE = dto;
                    }
                }
                measurementFuelService.UpdateTOE(objMeasurementFuel.FuelId, objMeasurementFuel.MeasurementId, objMeasurementFuel.From_TOE, objMeasurementFuel.To_TOE);
                BindData();
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showform", "addFuel();", true);
            }
        }
    }
Exemplo n.º 11
0
 public Task UpdateFuelServiceAsync(FuelService fuelService)
 {
     return(_db.UpdateAsync(fuelService));
 }
Exemplo n.º 12
0
    //void BindEnterprise()
    //{
    //    int EnterpriseId = 1;
    //    Enterprise enter = new Enterprise();
    //    enter = new EnterpriseService().FindByKey(EnterpriseId);
    //    if (enter != null)
    //    {
    //        txtEnterpriseName.Text = enter.Title;
    //        if (enter.SubAreaId > 0)
    //            ddlSubArea.SelectedValue = enter.SubAreaId.ToString();
    //        if (enter.AreaId > 0)
    //            ddlArea.SelectedValue = enter.AreaId.ToString();
    //        if (enter.ProvinceId > 0)
    //            ddlProvince.SelectedValue = enter.ProvinceId.ToString();
    //        if (enter.DistrictId > 0)
    //            ddlDistrict.SelectedValue = enter.DistrictId.ToString();
    //        txtAddress.Text = enter.Address;
    //        txtEmail.Text = enter.Email;
    //        txtFax.Text = enter.Fax;
    //        txtPhone.Text = enter.Phone;
    //        txtReportName.Text = enter.ManPerson;
    //        if (enter.ManProvinceId > 0)
    //            ddlProvinceReporter.SelectedValue = enter.ManProvinceId.ToString();
    //        if (enter.ManDistrictId > 0)
    //            ddlDistrictReporter.SelectedValue = enter.ManDistrictId.ToString();
    //        txtAddressReporter.Text = enter.ManAddress;
    //        txtEmail.Text = enter.ManEmail;
    //        txtFaxReporter.Text = enter.ManFax;
    //        txtPhoneReporter.Text = enter.ManPhone;
    //    }
    //}
    //void BindOrganization()
    //{
    //    IList<Organization> list = new List<Organization>();
    //    if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Organization_All))
    //    {
    //        list = new OrganizationService().FindAll();
    //        AspNetCache.SetCache(Constants.Cache_ReportFuel_Organization_All, list);
    //    }
    //    else
    //        list = (IList<Organization>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Organization_All);
    //    ddlOrg.DataSource = list;
    //    ddlOrg.DataTextField = "Title";
    //    ddlOrg.DataValueField = "Id";
    //    ddlOrg.DataBind();
    //    ddlOrg.Items.Insert(0, new ListItem("---Tất cả---", ""));
    //}
    private void BindData()
    {
        ltData.Text = "";
        IList <Fuel> listFuel = new List <Fuel>();

        if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Fuel_All))
        {
            listFuel = new FuelService().FindAll();
            AspNetCache.SetCache(Constants.Cache_ReportFuel_Fuel_All, listFuel);
        }
        else
        {
            listFuel = (IList <Fuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Fuel_All);
        }

        //IList<GroupFuel> listGroupFuel = new List<GroupFuel>();
        //if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_GroupFuel_All))
        //{
        //    listGroupFuel = new GroupFuelService().FindAll();
        //    AspNetCache.SetCache(Constants.Cache_ReportFuel_GroupFuel_All, listGroupFuel);
        //}
        //else
        //    listGroupFuel = (IList<GroupFuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_GroupFuel_All);
        ReportFuelService comBSO = new ReportFuelService();
        DataTable         list   = new DataTable();
        int AreaId     = 0;
        int DistrictId = 0;
        int Year       = 0;

        if (ddlArea.SelectedIndex > 0)
        {
            AreaId = Convert.ToInt32(ddlArea.SelectedValue);
        }
        if (ddlDistrict.SelectedIndex > 0)
        {
            DistrictId = Convert.ToInt32(ddlDistrict.SelectedValue);
        }
        if (ddlYear.SelectedIndex > 0)
        {
            Year = Convert.ToInt32(ddlYear.SelectedValue);
        }

        ePower.Core.PagingInfo paging = new ePower.Core.PagingInfo(PageSize, CurrentPage);
        list          = comBSO.FindList(false, AreaId, 0, m_UserValidation.OrgId, 0, DistrictId, 0, -1, true, Year, null, null, txtKeyword.Text.Trim(), paging);
        ltHeader.Text = "";
        //foreach (GroupFuel group in listGroupFuel)
        //{
        //    ltHeader.Text = ltHeader.Text + "<th>" + group.Title + " (" + group.MeasurementName + ")</th>";
        //}
        foreach (Fuel fuel in listFuel)
        {
            ltHeader.Text = ltHeader.Text + "<th>" + fuel.FuelName + "</th>";
        }
        if (list != null && list.Rows.Count > 0)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < list.Rows.Count; i++)
            {
                sb.Append("<tr><td class='text-center'>" + (i + 1) + "</td>");
                sb.Append("<td>" + list.Rows[i]["Title"] + "</td>");
                sb.Append("<td>" + list.Rows[i]["Address"] + "</td>");
                //sb.Append("<td>" + list.Rows[i]["ProvinceName"] + "</td>");
                //sb.Append("<td></td>");//Vung
                //sb.Append("<td>" + list.Rows[i]["RegionName"] + "</td>");//Vung
                sb.Append("<td>" + list.Rows[i]["ParentAreaName"] + "</td>");
                sb.Append("<td>" + list.Rows[i]["AreaName"] + "</td>");
                if (list.Rows[i]["Id"] != null && list.Rows[i]["Id"].ToString() != "")
                {
                    int ReportId = Convert.ToInt32(list.Rows[i]["Id"]);
                    if (ReportId > 0)
                    {
                        DataTable listDetail = new ReportFuelDetailService().GetFuelTOEByReport(ReportId, false);
                        int       SumTOE     = 0;
                        if (listDetail != null && listDetail.Rows.Count > 0)
                        {
                            foreach (Fuel fuel in listFuel)
                            {
                                DataRow[] dr = listDetail.Select("FuelId=" + fuel.Id);
                                if (dr != null && dr.Count() > 0)
                                {
                                    sb.Append("<td>");

                                    for (int j = 0; j < dr.Count(); j++)
                                    {
                                        if (dr[j]["NoFuel_TOE"] != DBNull.Value)
                                        {
                                            SumTOE = SumTOE + Convert.ToInt32(dr[j]["NoFuel_TOE"]);
                                            sb.Append(dr[j]["NoFuel"] + " (" + dr[j]["MeasurementName"] + ")");
                                        }
                                    }
                                    sb.Append("</td>");
                                }
                                else
                                {
                                    sb.Append("<td>0</td>");
                                }
                            }
                            sb.Append("<td>" + SumTOE + "</td>");
                        }
                        else
                        {
                            for (int j = 0; j < listFuel.Count; j++)
                            {
                                sb.Append("<td>0</td>");
                            }
                            sb.Append("<td>0</td>");
                        }
                    }
                    sb.Append("</tr>");
                }
            }
            ltData.Text        = sb.ToString();
            paging.RowsCount   = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging.PageSize    = PageSize;
            Paging.CurrentPage = CurrentPage;
            Paging.TotalRecord = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging.DataLoad();
            if (paging.PagesCount <= 1)
            {
                ltNotice.Text  = "Có tổng số " + paging.RowsCount + " báo cáo";
                Paging.Visible = false;
            }
            else
            {
                ltNotice.Text  = "Có" + list.Rows.Count + " trong tổng số " + paging.RowsCount + " báo cáo";
                Paging.Visible = true;
            }
        }
        else
        {
            ltNotice.Text  = "";
            Paging.Visible = false;
        }
    }
Exemplo n.º 13
0
    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")),
                                                            ""
                                                            ));
    }
Exemplo n.º 14
0
    void BindElectrictPlan()
    {
        UsingElectrict        usingElectrict        = new UsingElectrict();
        UsingElectrictService usingElectrictService = new UsingElectrictService();

        try
        {
            usingElectrict = usingElectrictService.GetUsingElectrictByReport(ReportId, true);
            if (usingElectrict != null)
            {
                if (usingElectrict.InstalledCapacity > 0)
                {
                    ltInstalledCapacityPlan.Text = usingElectrict.InstalledCapacity.ToString() + "(kV)";
                }
                else
                {
                    ltInstalledCapacityPlan.Text = "";
                }
                if (usingElectrict.Capacity > 0)
                {
                    ltCapacityPlan.Text = usingElectrict.Capacity.ToString() + "(kV)";
                }
                else
                {
                    ltCapacityPlan.Text = "";
                }
                if (usingElectrict.BuyCost > 0)
                {
                    ltPriceBuyPlan.Text = usingElectrict.BuyCost.ToString() + "(đồng/kWh)";
                }
                else
                {
                    ltPriceBuyPlan.Text = "";
                }
                if (usingElectrict.ProduceQty > 0)
                {
                    ltQuantityProducePlan.Text = usingElectrict.ProduceQty.ToString() + "(10<sup>6</sup> kWh/năm)";
                }
                else
                {
                    ltQuantityProducePlan.Text = "";
                }
                if (usingElectrict.Technology != null)
                {
                    ltTecnologyPlan.Text = usingElectrict.Technology.ToString();
                }

                if (usingElectrict.Quantity > 0)
                {
                    ltQuantityElectrictPlan.Text = usingElectrict.Quantity.ToString() + "(10<sup>6</sup> kWh/năm)";
                }
                else
                {
                    ltQuantityElectrictPlan.Text = "";
                }
                if (usingElectrict.PriceProduce > 0)
                {
                    ltPriceProducePlan.Text = usingElectrict.PriceProduce.ToString() + "(đồng/kWh)";
                }
                else
                {
                    ltPriceProducePlan.Text = "";
                }

                Fuel fuel = new Fuel();
                if (usingElectrict.FuelId > 0)
                {
                    fuel = new FuelService().FindByKey(usingElectrict.FuelId);
                    if (fuel != null)
                    {
                        ltFuelPlan.Text = fuel.FuelName;
                    }
                }
            }
        }
        catch { }
    }
Exemplo n.º 15
0
    void BindElectrictResult()
    {
        UsingElectrict        usingElectrict        = new UsingElectrict();
        UsingElectrictService usingElectrictService = new UsingElectrictService();

        try
        {
            usingElectrict = usingElectrictService.GetUsingElectrictByReport(ReportId, false);
            if (usingElectrict != null)
            {
                if (usingElectrict.InstalledCapacity > 0)
                {
                    ltInstalledResult.Text = usingElectrict.InstalledCapacity.ToString() + "(kV)";
                }
                else
                {
                    ltInstalledResult.Text = "";
                }
                if (usingElectrict.Capacity > 0)
                {
                    ltCapacityResult.Text = usingElectrict.Capacity.ToString() + "(kV)";
                }
                else
                {
                    ltCapacityResult.Text = "";
                }
                if (usingElectrict.BuyCost > 0)
                {
                    ltCostTotalResult.Text = usingElectrict.BuyCost.ToString() + "(10<sup>3</sup>đồng)";
                }
                else
                {
                    ltCostTotalResult.Text = "";
                }
                if (usingElectrict.ProduceQty > 0)
                {
                    ltQuantityProduceResult.Text = usingElectrict.ProduceQty.ToString() + "(10<sup>6</sup> kWh/năm)";
                }
                else
                {
                    ltQuantityProduceResult.Text = "";
                }
                if (usingElectrict.Technology != null)
                {
                    ltTechnologyResult.Text = usingElectrict.Technology.ToString();
                }

                if (usingElectrict.Quantity > 0)
                {
                    ltQuantityResult.Text = usingElectrict.Quantity.ToString() + "(10<sup>6</sup> kWh/năm)";
                }
                else
                {
                    ltQuantityResult.Text = "";
                }
                Fuel fuel = new Fuel();
                if (usingElectrict.FuelId > 0)
                {
                    fuel = new FuelService().FindByKey(usingElectrict.FuelId);
                    if (fuel != null)
                    {
                        ltFuelResult.Text = fuel.FuelName;
                    }
                }
            }
        }
        catch { }
    }
Exemplo n.º 16
0
        public async Task <int> AddFuelServiceAsync(FuelService fuelService)
        {
            await _db.InsertAsync(fuelService);

            return(fuelService.Id);
        }
Exemplo n.º 17
0
    protected void btnExport_Click(object sender, EventArgs e)
    {
        Response.ContentType = "application/force-download";
        Response.AddHeader("content-disposition", "attachment; filename=Bao-cao-sct-" + ddlYear.SelectedValue + ".xls");
        Response.Write("<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
        Response.Write("<head>");
        Response.Write("<META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
        Response.Write("<!--[if gte mso 9]><xml>");
        Response.Write("<x:ExcelWorkbook>");
        Response.Write("<x:ExcelWorksheets>");
        Response.Write("<x:ExcelWorksheet>");
        Response.Write("<x:Name>Report Data</x:Name>");
        Response.Write("<x:WorksheetOptions>");
        Response.Write("<x:Print>");
        Response.Write("<x:ValidPrinterInfo/>");
        Response.Write("</x:Print>");
        Response.Write("</x:WorksheetOptions>");
        Response.Write("</x:ExcelWorksheet>");
        Response.Write("</x:ExcelWorksheets>");
        Response.Write("</x:ExcelWorkbook>");
        Response.Write("</xml>");
        Response.Write("<![endif]--> ");
        Response.Write("</head><body>");
        //IList<GroupFuel> listGroupFuel = new List<GroupFuel>();
        //if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_GroupFuel_All))
        //{
        //    listGroupFuel = new GroupFuelService().FindAll();
        //    AspNetCache.SetCache(Constants.Cache_ReportFuel_GroupFuel_All, listGroupFuel);
        //}
        //else
        //    listGroupFuel = (IList<GroupFuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_GroupFuel_All);
        IList <Fuel> listFuel = new List <Fuel>();

        if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Fuel_All))
        {
            listFuel = new FuelService().FindAll();
            AspNetCache.SetCache(Constants.Cache_ReportFuel_Fuel_All, listFuel);
        }
        else
        {
            listFuel = (IList <Fuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Fuel_All);
        }
        ReportFuelService comBSO = new ReportFuelService();
        DataTable         list   = new DataTable();
        int AreaId    = 0;
        int SubAreaId = 0;
        int Year      = 0;

        if (ddlYear.SelectedIndex > 0)
        {
            Year = Convert.ToInt32(ddlYear.SelectedValue);
        }
        ePower.Core.PagingInfo paging = new ePower.Core.PagingInfo(2000, CurrentPage);
        list = comBSO.FindList(false, AreaId, SubAreaId, m_UserValidation.OrgId, 0, 0, 0, -1, true, Year, null, null, "", paging);
        string strHeader = "";

        foreach (Fuel group in listFuel)
        {
            strHeader = strHeader + "<th>" + group.FuelName + "</th>";
        }
        StringBuilder sb = new StringBuilder();

        sb.Append("<table class='table table-bordered table-hover mbn' width='100%'>");
        sb.Append("<tr class='primary fs12'>");
        sb.Append("<th style='width:5%'>STT</th>");
        sb.Append("<th style='width:35%'>Tên doanh nghiệp</th>");
        sb.Append("<th style='width:10%'>Địa chỉ</th>");
        sb.Append("<th style='width:10%'>Tỉnh/TP</th>");
        sb.Append("<th style='width:10%'>Vùng</th>");
        sb.Append("<th style='width:10%'>Lĩnh vực SX</th>");
        sb.Append("<th style='width:10%'>Ngành nghề SX,KD</th>");
        sb.Append(strHeader);
        sb.Append("<th style='width:10%'>Năng lượng tiêu thụ quy đổi (TOE)</th>");
        sb.Append("</tr>");

        if (list != null && list.Rows.Count > 0)
        {
            for (int i = 0; i < list.Rows.Count; i++)
            {
                sb.Append("<tr><td>" + (i + 1) + "</td>");
                sb.Append("<td>" + list.Rows[i]["Title"] + "</td>");
                sb.Append("<td>" + list.Rows[i]["Address"] + "</td>");
                //sb.Append("<td>" + list.Rows[i]["ProvinceName"] + "</td>");
                //sb.Append("<td></td>");//Vung
                //sb.Append("<td>" + list.Rows[i]["RegionName"] + "</td>");//Vung
                sb.Append("<td>" + list.Rows[i]["ParentAreaName"] + "</td>");
                sb.Append("<td>" + list.Rows[i]["AreaName"] + "</td>");
                if (list.Rows[i]["Id"] != null && list.Rows[i]["Id"].ToString() != "")
                {
                    int ReportId = Convert.ToInt32(list.Rows[i]["Id"]);
                    if (ReportId > 0)
                    {
                        DataTable listDetail = new ReportFuelDetailService().GetFuelTOEByReport(ReportId, false);
                        int       SumTOE     = 0;
                        if (listDetail != null && listDetail.Rows.Count > 0)
                        {
                            foreach (Fuel group in listFuel)
                            {
                                DataRow[] dr = listDetail.Select("FuelId=" + group.Id);
                                if (dr != null && dr.Count() > 0)
                                {
                                    sb.Append("<td>");
                                    for (int j = 0; j < dr.Count(); j++)
                                    {
                                        sb.Append(dr[j]["NoFuel"] + " (" + dr[j]["MeasurementName"] + ")");
                                    }
                                    sb.Append("</td>");
                                }
                                else
                                {
                                    sb.Append("<td>0</td>");
                                }
                            }
                            sb.Append("<td>" + SumTOE + "</td>");
                        }
                        else
                        {
                            for (int j = 0; j < listFuel.Count; j++)
                            {
                                sb.Append("<td>0</td>");
                            }
                            sb.Append("<td>0</td>");
                        }
                    }
                    sb.Append("</tr>");
                }
            }
        }
        sb.Append("</table>");

        Response.Write(sb.ToString());
        Response.Write("</body></html>");
        Response.End();
    }
Exemplo n.º 18
0
 public Task DeleteFuelServiceAsync(FuelService fuelService)
 {
     return(_db.DeleteAsync <FuelService>(fuelService.Id));
 }
Exemplo n.º 19
0
    private void BindData()
    {
        IList <Fuel> listFuel = new List <Fuel>();

        if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Fuel_All))
        {
            listFuel = new FuelService().FindAll();
            AspNetCache.SetCache(Constants.Cache_ReportFuel_Fuel_All, listFuel);
        }
        else
        {
            listFuel = (IList <Fuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Fuel_All);
        }
        foreach (Fuel fuel in listFuel)
        {
            ltHeaderFuel.Text = ltHeaderFuel.Text + "<th>" + fuel.FuelName + "</th>";
        }
        ePower.Core.PagingInfo paging = new ePower.Core.PagingInfo(PageSize, CurrentPage);
        //if (m_UserValidation.OrgId > 0)
        //{
        int AuditYear = 0;

        if (ddlYear.SelectedIndex > 0)
        {
            AuditYear = Convert.ToInt32(ddlYear.SelectedValue);
        }
        int AreaId = 0;

        if (ddlArea.SelectedIndex > 0)
        {
            AreaId = Convert.ToInt32(ddlArea.SelectedValue);
        }
        int DistrictId = 0;
        //if (ddlDistrict.SelectedIndex > 0)
        //    DistrictId = Convert.ToInt32(ddlDistrict.SelectedValue);
        DataTable list = new AuditReportService().FindList(AreaId, 0, 0, 0, 0, DistrictId, Convert.ToInt32(AuditReportStatus.CONFIRMED), AuditYear, txtKeyword.Text.Trim(), paging);

        rptAuditReport.DataSource = list;
        rptAuditReport.DataBind();
        if (list != null && list.Rows.Count > 0)
        {
            Paging.TotalRecord = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging.PageSize    = PageSize;
            Paging.DataLoad();
            Paging2.TotalRecord = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging2.PageSize    = PageSize;
            Paging2.DataLoad();
            if (Paging.TotalPages > 1)
            {
                ltTotal.Text    = "Có " + list.Rows.Count + " trong tổng số " + list.Rows[0]["Total"] + " báo cáo";
                Paging2.Visible = Paging.Visible = true;
            }
            else
            {
                ltTotal.Text    = "Có tổng số " + list.Rows[0]["Total"] + " báo cáo";
                Paging2.Visible = Paging.Visible = false;
            }
        }
        else
        {
            Paging2.Visible = Paging.Visible = false;
        }
        //}
    }
Exemplo n.º 20
0
    void BindData()
    {
        IList <Fuel> listFuel = new List <Fuel>();

        if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Fuel_All))
        {
            listFuel = new FuelService().FindAll();
            AspNetCache.SetCache(Constants.Cache_ReportFuel_Fuel_All, listFuel);
        }
        else
        {
            listFuel = (IList <Fuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Fuel_All);
        }
        var listSearchFuel = from o in listFuel orderby o.FuelName ascending select o;

        IList <Product> list = new List <Product>();

        list = new ProductService().GetListByEnterprise(memVal.OrgId);
        var listProduct = from o in list where o.IsProduct == true select o;
        EnergyQuotaService consumseService = new EnergyQuotaService();

        DataTable dt = consumseService.GetDataByFuel(ReportId);

        if (listProduct != null && listProduct.Count() > 0)
        {
            StringBuilder sb     = new StringBuilder();
            StringBuilder sbSub  = new StringBuilder();
            StringBuilder sbData = new StringBuilder();
            sb.Append("<table class='table table-bordered table-hover mbn' width='100%'>");
            sb.Append("<thead>");
            sb.Append("<tr>");
            sb.Append("<th>Sản phẩm</th>");
            for (int i = 0; i < listSearchFuel.Count(); i++)
            {
                sb.Append("<th>" + listSearchFuel.ToList()[i].FuelName + "</th>");
            }
            sb.Append("</tr>");
            sb.Append("</thead>");
            for (int j = 0; j < listProduct.Count(); j++)
            {
                sbData.Append("<tr>");
                sbData.Append("<td>" + listProduct.ToList()[j].ProductName + "</td>");
                for (int i = 0; i < listSearchFuel.Count(); i++)
                {
                    DataRow[] dr = dt.Select("FuelId=" + listSearchFuel.ToList()[i].Id.ToString() + " AND ProductId=" + listProduct.ToList()[j].Id);
                    if (dr != null && dr.Count() > 0)
                    {
                        sbData.Append("<td class='text-right'>" + dr[0]["Quantity"] + "</td>");
                    }
                    else
                    {
                        sbData.Append("<td class='text-right'>-</td>");
                    }
                }
                sbData.Append("</tr>");
            }
            sb.Append(sbData.ToString());
            sb.Append("</table>");
            ltQuota.Text = sb.ToString();
        }
    }
Exemplo n.º 21
0
    protected void rptAuditReport_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Literal ltNoTOE    = (Literal)e.Item.FindControl("ltNoTOE");
        Literal ltTotalTOE = (Literal)e.Item.FindControl("ltTotalTOE");

        StringBuilder sb = new StringBuilder();
        DataRowView   dr = (DataRowView)e.Item.DataItem;

        if (dr != null)
        {
            int       eID    = Convert.ToInt32(dr["Id"]);
            DataTable dtFuel = new AuditReportService().GetCO2ByReport(eID);

            IList <Fuel> listFuel = new List <Fuel>();
            if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Fuel_All))
            {
                listFuel = new FuelService().FindAll();
                AspNetCache.SetCache(Constants.Cache_ReportFuel_Fuel_All, listFuel);
            }
            else
            {
                listFuel = (IList <Fuel>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Fuel_All);
            }
            decimal dsum  = 0;
            decimal NoTOE = 0;
            if (dtFuel != null && dtFuel.Rows.Count > 0)
            {
                for (int i = 0; i < dtFuel.Rows.Count; i++)
                {
                    dsum  = dsum + Convert.ToDecimal(dtFuel.Rows[i]["NoCO2"]);
                    NoTOE = NoTOE + Convert.ToDecimal(dtFuel.Rows[i]["NoTOE"]);
                }
            }
            foreach (Fuel fuel in listFuel)
            {
                sb.Append("<td class='text-right'>");
                if (dtFuel != null && dtFuel.Rows.Count > 0)
                {
                    DataRow[] drows = dtFuel.Select("FuelId=" + fuel.Id);
                    if (drows != null && drows.Count() > 0)
                    {
                        decimal rate = 0;
                        if (NoTOE > 0)
                        {
                            rate = Math.Round((Convert.ToDecimal(drows[0]["NoTOE"]) / NoTOE) * 100, 2);
                        }
                        //sb.Append(Tool.ConvertDecimalToString(Math.Round(Convert.ToDecimal(drows[0]["NoTOE"]), 2)) + "(" + rate + "%)");
                        if (rate > 50)
                        {
                            sb.Append("<b>" + rate + "%</b>");
                        }
                        else
                        {
                            sb.Append(rate + "%");
                        }
                    }
                    else
                    {
                        sb.Append("-");
                    }
                }
                else
                {
                    sb.Append("-");
                }
                sb.Append("</td>");
            }
            ltNoTOE.Text    = sb.ToString();
            ltTotalTOE.Text = Tool.ConvertDecimalToString(NoTOE, 2);
        }
    }