protected void btn_delete_importantyear_Click(object sender, EventArgs e)
 {
     if (ItemId > 0)
     {
         LinkButton btn_delete_importantyear = (LinkButton)sender;
         int        iDelteteId = 0;
         iDelteteId = Convert.ToInt32(btn_delete_importantyear.CommandArgument);
         if (iDelteteId > 0)
         {
             EnterpriseYear ey = new EnterpriseYear();
             ey = new EnterpriseYearService().FindByKey(iDelteteId);
             if (ey != null)
             {
                 ey.IsDelete = true;
                 if (new EnterpriseYearService().Update(ey) != null)
                 {
                     BindImportantYear();
                     BindData();
                     ltErrorImportantYear.Text = "<div class='alert alert-primary'>Xóa thành công !</div>";
                 }
                 else
                 {
                     ltErrorImportantYear.Text = "<div class='alert alert-dangers'>Xóa không thành công !</div>";
                 }
             }
         }
     }
 }
Beispiel #2
0
        public EnterpriseYear Update(EnterpriseYear obj)
        {
            EnterpriseYearBO enterpriseyearBO = new EnterpriseYearBO(obj);

            enterpriseyearDao.Update(enterpriseyearBO);
            return(obj);
        }
Beispiel #3
0
 protected void btnAddImportantYear_Click(object sender, EventArgs e)
 {
     if (ItemId > 0)
     {
         if (hdnImportantYearEdit.Value != "0")
         {
             EnterpriseYear ey = new EnterpriseYear();
             ey = new EnterpriseYearService().FindByKey(Convert.ToInt32(hdnImportantYearEdit.Value));
             if (ey != null)
             {
                 if (ImportantYears != "" && !ImportantYears.Contains(ddlImportantYear.SelectedValue))
                 {
                     if (txtNoTOE.Text.Trim() != "")
                     {
                         ey.No_TOE = Convert.ToDecimal(txtNoTOE.Text.Trim());
                     }
                     ey.IsKey = (rblKeu.SelectedIndex == 0);
                     ey.Year  = Convert.ToInt32(ddlImportantYear.SelectedValue);
                     if (new EnterpriseYearService().Update(ey) != null)
                     {
                         BindImportantYear();
                         BindData();
                         ltErrorImportantYear.Text = "<div class='alert alert-primary'>Cập nhật thành công !</div>";
                     }
                     else
                     {
                         ltErrorImportantYear.Text = "<div class='alert alert-dangers'>Cập nhật không thành công !</div>";
                     }
                 }
             }
         }
         else
         {
             EnterpriseYear ey = new EnterpriseYear();
             if (ImportantYears != "" && !ImportantYears.Contains(ddlImportantYear.SelectedValue))
             {
                 ey.EnterpriseId = ItemId;
                 ey.Year         = Convert.ToInt32(ddlImportantYear.SelectedValue);
                 ey.IsKey        = true;
                 ey.IsDelete     = false;
                 if (new EnterpriseYearService().Insert(ey) > 0)
                 {
                     BindImportantYear();
                     BindData();
                     ltErrorImportantYear.Text = "<div class='alert alert-primary'>Thêm mới thành công !</div>";
                 }
                 else
                 {
                     ltErrorImportantYear.Text = "<div class='alert alert-dangers'>Thêm mới không thành công !</div>";
                 }
             }
         }
         hdnImportantYearEdit.Value = "0";
     }
 }
 protected void btn_edit_importantyear_Click(object sender, EventArgs e)
 {
     if (ItemId > 0)
     {
         LinkButton btn_edit_importantyear = (LinkButton)sender;
         int        iEditId = 0;
         iEditId = Convert.ToInt32(btn_edit_importantyear.CommandArgument);
         if (iEditId > 0)
         {
             EnterpriseYear ey = new EnterpriseYear();
             ey = new EnterpriseYearService().FindByKey(iEditId);
             if (ey != null)
             {
                 hdnImportantYearEdit.Value     = iEditId.ToString();
                 ddlImportantYear.SelectedValue = ey.Year.ToString();
                 ScriptManager.RegisterStartupScript(this, GetType(), "showform", "UpdateImportantYear();", true);
             }
         }
     }
 }
Beispiel #5
0
    protected void btnAddReport_Click(object sender, EventArgs e)
    {
        ltErr.Text = "";
        if (memVal.OrgId > 0)
        {
            ReportFuelService reportService = new ReportFuelService();
            int ReportYear = Convert.ToInt32(ddlYear.SelectedValue);
            //int iReportNo = reportService.CheckReport(ReportYear, memVal.OrgId);
            int iReportNo = reportService.CheckReportWithType(ReportYear, memVal.OrgId, ReportKey.ANNUAL);
            if (iReportNo > 0)
            {
                ltErr.Text = "<span style='color:red'>Đã có báo cáo hàng năm của năm " + ddlYear.SelectedValue + ". Vui lòng chọn năm báo cáo khác.</span>";
                ScriptManager.RegisterStartupScript(this, GetType(), "addReport", "ShowDialogInitReport();", true);
            }
            else
            {
                ReportFuel report = new ReportFuel();
                report.EnterpriseId = Convert.ToInt32(memVal.OrgId);
                Enterprise enter = new EnterpriseService().FindByKey(report.EnterpriseId);
                if (enter != null)
                {
                    if (enter.ProvinceId > 0)
                    {
                        report.ProviceId = enter.ProvinceId;
                    }
                    if (enter.DistrictId > 0)
                    {
                        report.DistrictId = enter.DistrictId;
                    }
                    if (enter.AreaId > 0)
                    {
                        report.AreaId = enter.AreaId;
                    }
                    if (enter.SubAreaId > 0)
                    {
                        report.SubAreaId = enter.SubAreaId;
                    }
                    report.ReporterName = enter.ManPerson;
                    IFormatProvider culture = new System.Globalization.CultureInfo("en-US", true);

                    report.ReportDate       = DateTime.Now;
                    report.Address          = enter.Address;
                    report.Email            = enter.Email;
                    report.Phone            = enter.Phone;
                    report.Fax              = enter.Fax;
                    report.ParentName       = enter.ParentName;
                    report.TaxCode          = enter.TaxCode;
                    report.FaxParent        = enter.ManFax;
                    report.PhoneParent      = enter.ManPhone;
                    report.EmailParent      = enter.ManEmail;
                    report.AddressParent    = enter.ManAddress;
                    report.ProvinceParentId = enter.ManProvinceId;
                    report.DistrictParentId = enter.ManDistrictId;
                    report.CompanyName      = enter.Title;
                    report.Responsible      = enter.ManPerson;
                    report.ReportType       = ReportKey.ANNUAL;

                    if (enter != null)
                    {
                        report.OrganizationId = enter.OrganizationId;
                    }
                }
                if (ddlYear.SelectedIndex > 0)
                {
                    report.Year = Convert.ToInt32(ddlYear.SelectedValue);
                }
                report.IsFiveYear = false;
                int ret = reportService.Insert(report);

                if (ret > 0)
                {
                    EnterpriseYearService yearService = new EnterpriseYearService();
                    if (yearService.UpdateTOE(memVal.OrgId, report.Year, ret, 0, 0) <= 0)
                    {
                        EnterpriseYear year = new EnterpriseYear();
                        year.EnterpriseId = memVal.OrgId;
                        year.Year         = report.Year;
                        year.No_TOE       = 0;
                        year.NoTOE_Plan   = 0;
                        year.IsKey        = true;
                        yearService.Insert(year);
                    }
                    //Response.Redirect(ResolveUrl("~") + "bao-cao-so-lieu-hang-nam-r" + ret + ".aspx");
                    Response.Redirect(ResolveUrl("~") + "dn-lap-bao-cao" + ret + ".aspx");
                }
                else
                {
                    ltErr.Text = "Chưa tạo được báo cáo. Vui lòng thử lại.";
                    ScriptManager.RegisterStartupScript(this, GetType(), "addReport", "ShowDialogInitReport();", true);
                }
            }
        }
    }
Beispiel #6
0
    protected void btnImportTemp_Click(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();

        string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", Server.MapPath("~/UserFile/Data_2016.xls"));
        //string query = String.Format("select * from [{0}$]", "Area");
        string           query       = String.Format("select * from [{0}$]", "Nam_2016");
        SecurityBSO      securityBSO = new SecurityBSO();
        OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);
        DataSet          dataSet     = new DataSet();

        dataAdapter.Fill(dataSet);

        DataTable         myTable = dataSet.Tables[0];
        EnterpriseService comBSO  = new EnterpriseService();

        foreach (DataRow drow in myTable.Rows)
        {
            ReportTemp2014 temp = new ReportTemp2014();
            Enterprise     area = new Enterprise();
            area.Title = drow["Title"].ToString();
            temp.Title = area.Title;
            if (drow["Address"] != null)
            {
                area.Address = drow["Address"].ToString();
                temp.Address = area.Address;
            }

            area.OrganizationId = Convert.ToInt32(drow["OrgId"]);
            temp.OrgId          = area.OrganizationId;
            Organization org = new OrganizationService().FindByKey(area.OrganizationId);

            if (drow["AreaName"] != null && drow["AreaName"].ToString() != "")
            {
                temp.AreaName = drow["AreaName"].ToString();
                if (drow["AreaName"].ToString() == "Công nghiệp")
                {
                    area.AreaId = 5;
                }
                else
                if (drow["AreaName"].ToString() == "Nông nghiệp")
                {
                    area.AreaId = 3;
                }
                else
                if (drow["AreaName"].ToString() == "Công trình xây dựng")
                {
                    area.AreaId = 6;
                }
                else
                {
                    area.AreaId = 1;
                }
                temp.AreaId = area.AreaId;
            }
            if (drow["SubAreaName"] != null && drow["SubAreaName"].ToString() != "")
            {
                DataTable dtSub = new AreaService().getAreaByName(drow["SubAreaName"].ToString());
                if (dtSub != null && dtSub.Rows.Count > 0)
                {
                    area.SubAreaId = Convert.ToInt32(dtSub.Rows[0]["Id"]);
                    temp.SubAreaId = area.SubAreaId;
                }
                else
                {
                    Area sub = new Area();
                    sub.AreaName  = drow["SubAreaName"].ToString();
                    sub.ParentId  = area.AreaId;
                    sub.IsStatus  = 1;
                    sub.SortOrder = 0;
                    int subId = new AreaService().Insert(sub);
                    temp.SubAreaId = subId;
                    area.SubAreaId = subId;
                }
                area.Info        = drow["SubAreaName"].ToString();
                temp.SubAreaName = drow["SubAreaName"].ToString();
            }

            area.ProvinceId    = Convert.ToInt32(drow["ProvinceId"]);
            area.ManProvinceId = Convert.ToInt32(drow["ManProvinceId"]);
            int eId = comBSO.Insert(area);//Them doanh  nghiep

            if (eId > 0)
            {
                temp.EnterpriseId = eId;
                if (drow["Dien_kWh"] != null && drow["Dien_kWh"].ToString().Trim() != "")
                {
                    temp.Dien_kWh = drow["Dien_kWh"].ToString();
                }

                if (drow["Than_Tan"] != null && drow["Than_Tan"].ToString().Trim() != "")
                {
                    temp.Than_Tan = drow["Than_Tan"].ToString();
                }

                if (drow["DO_Tan"] != null && drow["DO_Tan"].ToString().Trim() != "")
                {
                    temp.DO_Tan = drow["DO_Tan"].ToString();
                }
                if (drow["DO_lit"] != null && drow["DO_lit"].ToString().Trim() != "")
                {
                    temp.DO_lit = drow["DO_lit"].ToString();
                }

                if (drow["FO_Tan"] != null && drow["FO_Tan"].ToString().Trim() != "")
                {
                    temp.FO_Tan = drow["FO_Tan"].ToString();
                }
                if (drow["FO_lit"] != null && drow["FO_lit"].ToString().Trim() != "")
                {
                    temp.FO_lit = drow["FO_Tan"].ToString();
                }

                if (drow["Xang_Tan"] != null && drow["Xang_Tan"].ToString().Trim() != "")
                {
                    temp.Xang_Tan = drow["Xang_Tan"].ToString();
                }
                if (drow["Xang_lit"] != null && drow["Xang_lit"].ToString().Trim() != "")
                {
                    temp.Xang_lit = drow["Xang_lit"].ToString();
                }

                if (drow["Gas_Tan"] != null && drow["Gas_Tan"].ToString().Trim() != "")
                {
                    temp.Gas_Tan = drow["Gas_Tan"].ToString();
                }

                if (drow["Khi_m3"] != null && drow["Khi_m3"].ToString().Trim() != "")
                {
                    temp.Khi_M3 = drow["Khi_m3"].ToString();
                }

                if (drow["LPG_Tan"] != null && drow["LPG_Tan"].ToString().Trim() != "")
                {
                    temp.LPG_Tan = drow["LPG_Tan"].ToString();
                }
                if (drow["NLPL_Tan"] != null && drow["NLPL_Tan"].ToString().Trim() != "")
                {
                    temp.NLPL_Tan = drow["NLPL_Tan"].ToString();
                }

                if (drow["Khac_tan"] != null && drow["Khac_tan"].ToString().Trim() != "")
                {
                    temp.KhacSoDo = drow["Khac_tan"].ToString();
                }

                if (drow["Note"] != null && drow["Note"].ToString().Trim() != "")
                {
                    temp.Note = drow["Note"].ToString();
                }


                EnterpriseYearService eYService = new EnterpriseYearService();
                EnterpriseYear        ey        = new EnterpriseYear();
                ey.EnterpriseId = eId;

                if (drow["No_TOE"] != null && drow["No_TOE"].ToString().Trim() != "" && Convert.ToDecimal(drow["No_TOE"]) > 0)
                {
                    ey.No_TOE   = Convert.ToDecimal(drow["No_TOE"]);
                    temp.No_TOE = ey.No_TOE;
                    temp.Year   = 2016;
                    int retTemp = new ReportTemp2014Service().Insert(temp);//Them bao cao tam
                    ey.IsDelete = false;
                    ey.Year     = temp.Year;
                    eYService.Insert(ey);//Them nam bao cao
                }
                //Tao tai khoan doanh nghiep

                Utils         objUtil       = new Utils();
                MemberService memberService = new MemberService();
                int           STT           = 0;

                STT = new EnterpriseService().GetNoAccount(area.OrganizationId);

                STT++;
                ePower.DE.Domain.Member member = new ePower.DE.Domain.Member();
                member.EnterpriseId = eId;
                member.IsDelete     = false;
                member.AccountName  = "dn." + Utils.UCS2Convert(org.Title).Replace(" ", "").Replace("-", "").ToLower() + "." + STT.ToString("000");
                member.Password     = securityBSO.EncPwd("123456");
                memberService.Insert(member);
            }
        }
    }
    protected void btnImport_Click(object sender, EventArgs e)
    {
        lterror.Text = "";

        if (flReport.HasFile)
        {
            string strext = Path.GetExtension(flReport.PostedFile.FileName).Substring(1);
            if (strext == "xls" || strext == "xlsx")
            {
                string fullfilename = "~/UserFile/" + flReport.FileName;
                if (File.Exists(Server.MapPath(fullfilename)))
                {
                    lterror.Text = "File đã tồn tại, vui lòng đổi tên khác";
                    return;
                }
                flReport.PostedFile.SaveAs(Server.MapPath(fullfilename));
                if (File.Exists(Server.MapPath(fullfilename)))
                {
                    log.Info("File: " + flReport.FileName);
                    DataTable        dt = new DataTable();
                    string           connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", Server.MapPath(fullfilename));
                    string           query            = String.Format("select * from [{0}$]", "Sheet1");
                    SecurityBSO      securityBSO      = new SecurityBSO();
                    OleDbDataAdapter dataAdapter      = new OleDbDataAdapter(query, connectionString);
                    DataSet          dataSet          = new DataSet();
                    dataAdapter.Fill(dataSet);

                    DataTable         myTable = dataSet.Tables[0];
                    EnterpriseService comBSO  = new EnterpriseService();
                    int rowi = 0;
                    foreach (DataRow drow in myTable.Rows)
                    {
                        rowi++;
                        log.Info("Dong thu: " + rowi);


                        try
                        {
                            ReportTemp2014 temp  = new ReportTemp2014();
                            Enterprise     enter = new Enterprise();
                            int            eId   = 0;
                            enter.Title = drow["Ten_DN"].ToString();
                            temp.Title  = enter.Title;
                            log.Info("Doanh nghiep: " + enter.Title);
                            enter.OrganizationId = Convert.ToInt32(drow["SCT_ID"]);
                            temp.OrgId           = enter.OrganizationId;
                            if (drow["DiaChi"] != DBNull.Value)
                            {
                                enter.Address = drow["DiaChi"].ToString();
                                temp.Address  = enter.Address;
                            }
                            if (drow["LinhVuc_Id"] != DBNull.Value && drow["LinhVuc_Id"].ToString() != "")
                            {
                                temp.AreaId  = Convert.ToInt32(drow["LinhVuc_Id"]);
                                enter.AreaId = temp.AreaId;
                            }
                            enter.ProvinceId     = Convert.ToInt32(drow["TinhTP_ID"]);
                            enter.ManProvinceId  = enter.ProvinceId;
                            enter.OrganizationId = Convert.ToInt32(drow["SCT_ID"]);
                            if (drow["Ma_DN"] != DBNull.Value && drow["Ma_DN"].ToString().Trim() != "")
                            {
                                eId = Convert.ToInt32(drow["Ma_DN"]);
                                //enter = comBSO.FindByKey(eId);
                            }
                            else
                            {
                                enter.ActiveYear   = 2015;
                                enter.CustomerCode = "";
                                enter.TaxCode      = "";
                                if (drow["PhanNganh"] != DBNull.Value && drow["PhanNganh"].ToString() != "")
                                {
                                    DataTable dtSub = new AreaService().getAreaByName(drow["PhanNganh"].ToString());
                                    if (dtSub != null && dtSub.Rows.Count > 0)
                                    {
                                        enter.SubAreaId = Convert.ToInt32(dtSub.Rows[0]["Id"]);
                                        temp.SubAreaId  = enter.SubAreaId;
                                    }
                                    else
                                    {
                                        Area sub = new Area();
                                        sub.AreaName  = drow["PhanNganh"].ToString();
                                        sub.ParentId  = enter.AreaId;
                                        sub.IsStatus  = 1;
                                        sub.SortOrder = 0;
                                        int subId = new AreaService().Insert(sub);
                                        temp.SubAreaId  = subId;
                                        enter.SubAreaId = subId;
                                    }
                                    enter.Info       = drow["PhanNganh"].ToString();
                                    temp.SubAreaName = drow["PhanNganh"].ToString();
                                }


                                eId = comBSO.Insert(enter);//Them doanh  nghiep
                                if (eId > 0)
                                {
                                    Organization org = new OrganizationService().FindByKey(enter.OrganizationId);
                                    //Tao tai khoan doanh nghiep
                                    Utils         objUtil       = new Utils();
                                    MemberService memberService = new MemberService();
                                    int           STT           = 0;
                                    STT = new EnterpriseService().GetNoAccount(enter.OrganizationId);
                                    STT++;
                                    ePower.DE.Domain.Member member = new ePower.DE.Domain.Member();
                                    member.EnterpriseId = eId;
                                    member.IsDelete     = false;
                                    member.AccountName  = "dn." + Utils.UCS2Convert(org.Title).Replace(" ", "").Replace("-", "").ToLower() + "." + STT.ToString("000");
                                    member.Password     = securityBSO.EncPwd("abc123");
                                    int mId = memberService.Insert(member);
                                    if (mId < 0)
                                    {
                                        log.Info("Khong tao duoc tai khoan");
                                    }
                                }
                                else
                                {
                                    log.Info("Khong tao duoc DN");
                                }
                            }
                            if (eId > 0)
                            {
                                ReportFuel        report        = new ReportFuel();
                                ReportFuelService reportService = new ReportFuelService();
                                report.EnterpriseId   = eId;
                                report.OrganizationId = enter.OrganizationId;
                                report.ReportDate     = DateTime.Now;
                                report.CompanyName    = enter.Title;
                                report.Address        = enter.Address;
                                report.ApprovedSatus  = true;
                                report.AprovedDate    = DateTime.Now;
                                report.AreaId         = enter.AreaId;
                                report.ConfirmedDate  = DateTime.Now;
                                report.Created        = DateTime.Now;
                                report.DistrictId     = enter.DistrictId;
                                report.Email          = enter.Email;
                                report.Fax            = enter.Fax;
                                report.IsFiveYear     = false;
                                report.IsDelete       = false;
                                report.Phone          = enter.Phone;
                                report.ReportDate     = DateTime.Now;
                                report.SendSatus      = 1;
                                report.Year           = 2018;

                                report.SubAreaId  = enter.SubAreaId;
                                report.Year       = Convert.ToInt32(txtPlanYear.Text.Trim());
                                temp.EnterpriseId = eId;
                                int reportId = reportService.Insert(report);
                                if (reportId > 0)
                                {
                                    ReportFuelDetailService serviceDetail = new ReportFuelDetailService();
                                    ReportFuelDetail        detail        = new ReportFuelDetail();
                                    int detailid = 0;
                                    if (drow["Dien_kWh"] != DBNull.Value && drow["Dien_kWh"].ToString().Trim() != "")
                                    {
                                        temp.Dien_kWh        = drow["Dien_kWh"].ToString();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 1;
                                        detail.MeasurementId = 1;
                                        detail.No_RateTOE    = 0.0001543m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["Dien_kWh"] != DBNull.Value && drow["Dien_kWh"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["Dien_kWh"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them dien loi");
                                        }
                                    }

                                    if (drow["ThanDa_Tan"] != DBNull.Value && drow["ThanDa_Tan"].ToString().Trim() != "")
                                    {
                                        detail               = new ReportFuelDetail();
                                        temp.Than_Tan        = drow["ThanDa_Tan"].ToString();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 2;
                                        detail.MeasurementId = 2;
                                        detail.No_RateTOE    = 0.7m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["ThanDa_Tan"] != DBNull.Value && drow["ThanDa_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["ThanDa_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;

                                        detailid = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them than da_tan loi");
                                        }
                                    }
                                    if (drow["Than12_Tan"] != DBNull.Value && drow["Than12_Tan"].ToString().Trim() != "")
                                    {
                                        detail               = new ReportFuelDetail();
                                        temp.Than_Tan        = drow["Than12_Tan"].ToString();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 3;
                                        detail.MeasurementId = 2;
                                        detail.No_RateTOE    = 0.7m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["Than12_Tan"] != DBNull.Value && drow["Than12_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["Than12_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them than 12 loi");
                                        }
                                    }
                                    if (drow["Than34_Tan"] != DBNull.Value && drow["Than34_Tan"].ToString().Trim() != "")
                                    {
                                        detail               = new ReportFuelDetail();
                                        temp.Than_Tan        = drow["Than34_Tan"].ToString();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 4;
                                        detail.MeasurementId = 2;
                                        detail.No_RateTOE    = 0.6m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["Than34_Tan"] != DBNull.Value && drow["Than34_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["Than34_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them than34 loi");
                                        }
                                    }
                                    if (drow["Than56_Tan"] != DBNull.Value && drow["Than56_Tan"].ToString().Trim() != "")
                                    {
                                        detail               = new ReportFuelDetail();
                                        temp.Than_Tan        = drow["Than56_Tan"].ToString();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 5;
                                        detail.MeasurementId = 2;
                                        detail.No_RateTOE    = 0.5m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["Than56_Tan"] != DBNull.Value && drow["Than56_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["Than56_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them than56 loi");
                                        }
                                    }
                                    if (drow["DO_Tan"] != DBNull.Value && drow["DO_Tan"].ToString().Trim() != "")
                                    {
                                        detail               = new ReportFuelDetail();
                                        temp.DO_Tan          = drow["DO_Tan"].ToString();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 6;
                                        detail.MeasurementId = 2;
                                        detail.No_RateTOE    = 1.02m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["DO_Tan"] != DBNull.Value && drow["DO_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["DO_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them dau do_tan loi");
                                        }
                                    }
                                    if (drow["DO_lit"] != DBNull.Value && drow["DO_lit"].ToString().Trim() != "")
                                    {
                                        temp.DO_lit          = drow["DO_lit"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 6;
                                        detail.MeasurementId = 3;
                                        detail.No_RateTOE    = 0.00088m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["DO_lit"] != DBNull.Value && drow["DO_lit"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["DO_lit"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them dauDO_lit loi");
                                        }
                                    }

                                    if (drow["FO_Tan"] != DBNull.Value && drow["FO_Tan"].ToString().Trim() != "")
                                    {
                                        temp.FO_Tan          = drow["FO_Tan"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 7;
                                        detail.MeasurementId = 2;
                                        detail.No_RateTOE    = 0.99m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["FO_Tan"] != DBNull.Value && drow["FO_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["FO_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them dau FO_tan loi");
                                        }
                                    }
                                    if (drow["FO_lit"] != DBNull.Value && drow["FO_lit"].ToString().Trim() != "")
                                    {
                                        temp.FO_lit          = drow["FO_lit"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 7;
                                        detail.MeasurementId = 3;
                                        detail.No_RateTOE    = 0.00094m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["FO_lit"] != DBNull.Value && drow["FO_lit"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["FO_lit"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them dau FO_Lit loi");
                                        }
                                    }

                                    if (drow["Xang_Tan"] != DBNull.Value && drow["Xang_Tan"].ToString().Trim() != "")
                                    {
                                        temp.Xang_Tan        = drow["Xang_Tan"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 11;
                                        detail.MeasurementId = 2;
                                        detail.No_RateTOE    = 1.05m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["Xang_Tan"] != DBNull.Value && drow["Xang_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["Xang_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them xang_tan loi");
                                        }
                                    }
                                    if (drow["Xang_lit"] != DBNull.Value && drow["Xang_lit"].ToString().Trim() != "")
                                    {
                                        temp.Xang_lit        = drow["Xang_lit"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 11;
                                        detail.MeasurementId = 3;
                                        detail.No_RateTOE    = 0.00083m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["Xang_lit"] != DBNull.Value && drow["Xang_lit"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["Xang_lit"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them xang_lit loi");
                                        }
                                    }

                                    if (drow["Gas_Tan"] != DBNull.Value && drow["Gas_Tan"].ToString().Trim() != "")
                                    {
                                        temp.Gas_Tan         = drow["Gas_Tan"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 10;
                                        detail.MeasurementId = 4;
                                        detail.No_RateTOE    = 0.0009m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["Gas_Tan"] != DBNull.Value && drow["Gas_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["Gas_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them Gas_Tan loi");
                                        }
                                    }

                                    if (drow["Khi_m3"] != DBNull.Value && drow["Khi_m3"].ToString().Trim() != "")
                                    {
                                        temp.Khi_M3          = drow["Khi_m3"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 10;
                                        detail.MeasurementId = 1;
                                        detail.No_RateTOE    = 0.0009m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["Khi_m3"] != DBNull.Value && drow["Khi_m3"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["Khi_m3"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them Khi_m3 loi");
                                        }
                                    }

                                    if (drow["LPG_Tan"] != DBNull.Value && drow["LPG_Tan"].ToString().Trim() != "")
                                    {
                                        temp.LPG_Tan         = drow["LPG_Tan"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 8;
                                        detail.MeasurementId = 2;
                                        detail.No_RateTOE    = 1.09m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["LPG_Tan"] != DBNull.Value && drow["LPG_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["LPG_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them LPG loi");
                                        }
                                    }
                                    if (drow["NLPL_Tan"] != DBNull.Value && drow["NLPL_Tan"].ToString().Trim() != "")
                                    {
                                        temp.NLPL_Tan        = drow["NLPL_Tan"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 12;
                                        detail.MeasurementId = 2;
                                        detail.No_RateTOE    = 1.05m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["NLPL_Tan"] != DBNull.Value && drow["NLPL_Tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["NLPL_Tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them NLPL loi");
                                        }
                                    }

                                    if (drow["Khac_tan"] != DBNull.Value && drow["Khac_tan"].ToString().Trim() != "")
                                    {
                                        temp.KhacSoDo        = drow["Khac_tan"].ToString();
                                        detail               = new ReportFuelDetail();
                                        detail.EnterpriseId  = report.EnterpriseId;
                                        detail.FuelId        = 1;
                                        detail.MeasurementId = 1;
                                        detail.No_RateTOE    = 0.0002770000m;
                                        detail.Price         = 0;
                                        detail.Year          = 2017;
                                        if (drow["Khac_tan"] != DBNull.Value && drow["Khac_tan"].ToString() != "")
                                        {
                                            detail.NoFuel = Convert.ToDecimal(drow["Khac_tan"]);
                                        }
                                        detail.NoFuel_TOE = detail.No_RateTOE * detail.NoFuel;
                                        detail.ReportId   = reportId;
                                        detailid          = serviceDetail.Insert(detail);
                                        if (detailid <= 0)
                                        {
                                            log.Info("Them khac loi");
                                        }
                                    }

                                    if (drow["GhiChu"] != DBNull.Value && drow["GhiChu"].ToString().Trim() != "")
                                    {
                                        temp.Note = drow["GhiChu"].ToString();
                                    }

                                    EnterpriseYearService eYService = new EnterpriseYearService();
                                    EnterpriseYear        ey        = new EnterpriseYear();
                                    ey.EnterpriseId = eId;
                                    ey.ReportId     = reportId;
                                    ey.Year         = 2017;
                                    ey.IsKey        = true;
                                    if (drow["No_TOE"] != DBNull.Value && drow["No_TOE"].ToString().Trim() != "")
                                    {
                                        ey.No_TOE = Convert.ToDecimal(drow["No_TOE"]);
                                    }
                                    temp.No_TOE = ey.No_TOE;
                                    temp.Year   = 2017;
                                    int retTemp = new ReportTemp2014Service().Insert(temp);//Them bao cao tam
                                    ey.IsDelete = false;
                                    ey.Year     = temp.Year;
                                    int retempId = eYService.Insert(ey);//Them nam bao cao
                                    if (retempId <= 0)
                                    {
                                        log.Info("Them bao cao loi loi");
                                    }
                                }
                                else
                                {
                                    log.Info("Khong tao duoc bao cao");
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            log.Error("Loi import du lieu dong thu i: " + rowi, ex);
                        }
                    }
                }
                else
                {
                    lterror.Text = "Không upload được file";
                }
            }
            else
            {
                lterror.Text = "Chỉ chọn file Excel đuôi .xls và .xlsx";
            }
        }
        else
        {
            lterror.Text = "File không tồn tại";
        }
    }
Beispiel #8
0
        public int Insert(EnterpriseYear obj)
        {
            EnterpriseYearBO enterpriseyearBO = new EnterpriseYearBO(obj);

            return(enterpriseyearDao.Insert(enterpriseyearBO));
        }
Beispiel #9
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();

        string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", Server.MapPath("~/UserFile/Data_2016.xls"));
        //string query = String.Format("select * from [{0}$]", "Area");
        string query = String.Format("select * from [{0}$]", "2014_2015");

        OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);
        DataSet          dataSet     = new DataSet();

        dataAdapter.Fill(dataSet);

        DataTable         myTable = dataSet.Tables[0];
        EnterpriseService comBSO  = new EnterpriseService();

        foreach (DataRow drow in myTable.Rows)
        {
            ReportTemp2014 temp = new ReportTemp2014();
            temp.Title = drow["Title"].ToString();
            if (temp.Title != null && temp.Title != "")
            {
                temp.OrgId = Convert.ToInt32(drow["OrgId"]);
                DataTable dtE = comBSO.GetDNByName(temp.Title, temp.OrgId);
                if (drow["Address"] != null)
                {
                    temp.Address = drow["Address"].ToString();
                }

                if (drow["AreaName"] != null && drow["AreaName"].ToString() != "")
                {
                    temp.AreaName = drow["AreaName"].ToString();
                    if (drow["AreaName"].ToString() == "Công nghiệp")
                    {
                        temp.AreaId = 5;
                    }
                    else
                    if (drow["AreaName"].ToString() == "Nông nghiệp")
                    {
                        temp.AreaId = 3;
                    }
                    else
                    if (drow["AreaName"].ToString() == "Công trình xây dựng")
                    {
                        temp.AreaId = 6;
                    }
                    else
                    {
                        temp.AreaId = 1;
                    }
                }
                //Kiem phan nganh da co trong CSDL chua
                if (drow["SubAreaName"] != null && drow["SubAreaName"].ToString() != "")
                {
                    DataTable dtSub = new AreaService().getAreaByName(drow["SubAreaName"].ToString());
                    if (dtSub != null && dtSub.Rows.Count > 0)
                    {
                        temp.SubAreaId = Convert.ToInt32(dtSub.Rows[0]["Id"]);
                    }
                    else
                    {//Neu khong ton tai thi bo sung them phan nganh
                        Area sub = new Area();
                        sub.AreaName  = drow["SubAreaName"].ToString();
                        sub.ParentId  = temp.AreaId;
                        sub.IsStatus  = 1;
                        sub.SortOrder = 0;
                        int subId = new AreaService().Insert(sub);
                        temp.SubAreaId = subId;
                    }
                    temp.SubAreaName = drow["SubAreaName"].ToString();
                }
                //Kiem tra xem doanh nghiep da ton tai
                if (dtE != null && dtE.Rows.Count > 0)
                {
                    if (dtE.Rows.Count == 1)
                    {
                        Enterprise area = new Enterprise();
                        int        eId  = Convert.ToInt32(dtE.Rows[0]["Id"]);
                        ////area = new EnterpriseService().FindByKey(eId);
                        ////area.SubAreaId = temp.SubAreaId;
                        ////area.AreaId = temp.AreaId;

                        EnterpriseYearService eYService = new EnterpriseYearService();
                        EnterpriseYear        ey        = new EnterpriseYear();
                        ey.EnterpriseId = eId;
                        if (drow["No_TOE"] != null && drow["No_TOE"].ToString().Trim() != "")
                        {
                            ey.No_TOE = Convert.ToDecimal(drow["No_TOE"]);
                        }
                        ey.IsDelete = false;
                        ey.Year     = 2016;
                        eYService.Insert(ey);//Insert vao doanh nghiep trong diem nam
                        temp.EnterpriseId = eId;
                        if (drow["Dien_kWh"] != null && drow["Dien_kWh"].ToString().Trim() != "")
                        {
                            temp.Dien_kWh = drow["Dien_kWh"].ToString();
                        }

                        if (drow["Than_Tan"] != null && drow["Than_Tan"].ToString().Trim() != "")
                        {
                            temp.Than_Tan = drow["Than_Tan"].ToString();
                        }

                        if (drow["DO_Tan"] != null && drow["DO_Tan"].ToString().Trim() != "")
                        {
                            temp.DO_Tan = drow["DO_Tan"].ToString();
                        }
                        if (drow["DO_lit"] != null && drow["DO_lit"].ToString().Trim() != "")
                        {
                            temp.DO_lit = drow["DO_lit"].ToString();
                        }

                        if (drow["FO_Tan"] != null && drow["FO_Tan"].ToString().Trim() != "")
                        {
                            temp.FO_Tan = drow["FO_Tan"].ToString();
                        }
                        if (drow["FO_lit"] != null && drow["FO_lit"].ToString().Trim() != "")
                        {
                            temp.FO_lit = drow["FO_Tan"].ToString();
                        }

                        if (drow["Xang_Tan"] != null && drow["Xang_Tan"].ToString().Trim() != "")
                        {
                            temp.Xang_Tan = drow["Xang_Tan"].ToString();
                        }
                        if (drow["Xang_lit"] != null && drow["Xang_lit"].ToString().Trim() != "")
                        {
                            temp.Xang_lit = drow["Xang_lit"].ToString();
                        }

                        if (drow["Gas_Tan"] != null && drow["Gas_Tan"].ToString().Trim() != "")
                        {
                            temp.Gas_Tan = drow["Gas_Tan"].ToString();
                        }

                        if (drow["Khi_m3"] != null && drow["Khi_m3"].ToString().Trim() != "")
                        {
                            temp.Khi_M3 = drow["Khi_m3"].ToString();
                        }

                        if (drow["LPG_Tan"] != null && drow["LPG_Tan"].ToString().Trim() != "")
                        {
                            temp.LPG_Tan = drow["LPG_Tan"].ToString();
                        }
                        if (drow["NLPL_Tan"] != null && drow["NLPL_Tan"].ToString().Trim() != "")
                        {
                            temp.NLPL_Tan = drow["NLPL_Tan"].ToString();
                        }

                        if (drow["Khac_tan"] != null && drow["Khac_tan"].ToString().Trim() != "")
                        {
                            temp.KhacSoDo = drow["Khac_tan"].ToString();
                        }
                        if (drow["No_TOE"] != null && drow["No_TOE"].ToString().Trim() != "" && Convert.ToDecimal(drow["No_TOE"]) > 0)
                        {
                            temp.No_TOE = Convert.ToDecimal(drow["No_TOE"]);
                        }
                        temp.Year = 2016;
                        int retTemp = new ReportTemp2014Service().Insert(temp);//Them bao cao tam
                    }
                    else
                    {
                        if (drow["Dien_kWh"] != null && drow["Dien_kWh"].ToString().Trim() != "")
                        {
                            temp.Dien_kWh = drow["Dien_kWh"].ToString();
                        }

                        if (drow["Than_Tan"] != null && drow["Than_Tan"].ToString().Trim() != "")
                        {
                            temp.Than_Tan = drow["Than_Tan"].ToString();
                        }

                        if (drow["DO_Tan"] != null && drow["DO_Tan"].ToString().Trim() != "")
                        {
                            temp.DO_Tan = drow["DO_Tan"].ToString();
                        }
                        if (drow["DO_lit"] != null && drow["DO_lit"].ToString().Trim() != "")
                        {
                            temp.DO_lit = drow["DO_lit"].ToString();
                        }

                        if (drow["FO_Tan"] != null && drow["FO_Tan"].ToString().Trim() != "")
                        {
                            temp.FO_Tan = drow["FO_Tan"].ToString();
                        }
                        if (drow["FO_lit"] != null && drow["FO_lit"].ToString().Trim() != "")
                        {
                            temp.FO_lit = drow["FO_Tan"].ToString();
                        }

                        if (drow["Xang_Tan"] != null && drow["Xang_Tan"].ToString().Trim() != "")
                        {
                            temp.Xang_Tan = drow["Xang_Tan"].ToString();
                        }
                        if (drow["Xang_lit"] != null && drow["Xang_lit"].ToString().Trim() != "")
                        {
                            temp.Xang_lit = drow["Xang_lit"].ToString();
                        }

                        if (drow["Gas_Tan"] != null && drow["Gas_Tan"].ToString().Trim() != "")
                        {
                            temp.Gas_Tan = drow["Gas_Tan"].ToString();
                        }

                        if (drow["Khi_m3"] != null && drow["Khi_m3"].ToString().Trim() != "")
                        {
                            temp.Khi_M3 = drow["Khi_m3"].ToString();
                        }

                        if (drow["LPG_Tan"] != null && drow["LPG_Tan"].ToString().Trim() != "")
                        {
                            temp.LPG_Tan = drow["LPG_Tan"].ToString();
                        }
                        if (drow["NLPL_Tan"] != null && drow["NLPL_Tan"].ToString().Trim() != "")
                        {
                            temp.NLPL_Tan = drow["NLPL_Tan"].ToString();
                        }

                        if (drow["Khac_tan"] != null && drow["Khac_tan"].ToString().Trim() != "")
                        {
                            temp.KhacSoDo = drow["Khac_tan"].ToString();
                        }
                        if (drow["No_TOE"] != null && drow["No_TOE"].ToString().Trim() != "" && Convert.ToDecimal(drow["No_TOE"]) > 0)
                        {
                            temp.No_TOE = Convert.ToDecimal(drow["No_TOE"]);
                        }
                        temp.Year = 2016;
                        if (dtE.Rows.Count > 1)
                        {
                            temp.Note = "Tim thay " + dtE.Rows.Count + " DN";
                        }

                        else
                        {
                            temp.Note = "Khong tim thay " + dtE.Rows.Count + " DN";
                        }
                        int retTemp = new ReportTemp2014Service().Insert(temp);//Them bao cao tam
                    }
                }
                else
                {
                    if (drow["Dien_kWh"] != null && drow["Dien_kWh"].ToString().Trim() != "")
                    {
                        temp.Dien_kWh = drow["Dien_kWh"].ToString();
                    }

                    if (drow["Than_Tan"] != null && drow["Than_Tan"].ToString().Trim() != "")
                    {
                        temp.Than_Tan = drow["Than_Tan"].ToString();
                    }

                    if (drow["DO_Tan"] != null && drow["DO_Tan"].ToString().Trim() != "")
                    {
                        temp.DO_Tan = drow["DO_Tan"].ToString();
                    }
                    if (drow["DO_lit"] != null && drow["DO_lit"].ToString().Trim() != "")
                    {
                        temp.DO_lit = drow["DO_lit"].ToString();
                    }

                    if (drow["FO_Tan"] != null && drow["FO_Tan"].ToString().Trim() != "")
                    {
                        temp.FO_Tan = drow["FO_Tan"].ToString();
                    }
                    if (drow["FO_lit"] != null && drow["FO_lit"].ToString().Trim() != "")
                    {
                        temp.FO_lit = drow["FO_Tan"].ToString();
                    }

                    if (drow["Xang_Tan"] != null && drow["Xang_Tan"].ToString().Trim() != "")
                    {
                        temp.Xang_Tan = drow["Xang_Tan"].ToString();
                    }
                    if (drow["Xang_lit"] != null && drow["Xang_lit"].ToString().Trim() != "")
                    {
                        temp.Xang_lit = drow["Xang_lit"].ToString();
                    }

                    if (drow["Gas_Tan"] != null && drow["Gas_Tan"].ToString().Trim() != "")
                    {
                        temp.Gas_Tan = drow["Gas_Tan"].ToString();
                    }

                    if (drow["Khi_m3"] != null && drow["Khi_m3"].ToString().Trim() != "")
                    {
                        temp.Khi_M3 = drow["Khi_m3"].ToString();
                    }

                    if (drow["LPG_Tan"] != null && drow["LPG_Tan"].ToString().Trim() != "")
                    {
                        temp.LPG_Tan = drow["LPG_Tan"].ToString();
                    }
                    if (drow["NLPL_Tan"] != null && drow["NLPL_Tan"].ToString().Trim() != "")
                    {
                        temp.NLPL_Tan = drow["NLPL_Tan"].ToString();
                    }

                    if (drow["Khac_tan"] != null && drow["Khac_tan"].ToString().Trim() != "")
                    {
                        temp.KhacSoDo = drow["Khac_tan"].ToString();
                    }
                    if (drow["No_TOE"] != null && drow["No_TOE"].ToString().Trim() != "" && Convert.ToDecimal(drow["No_TOE"]) > 0)
                    {
                        temp.No_TOE = Convert.ToDecimal(drow["No_TOE"]);
                    }
                    temp.Year = 2016;
                    temp.Note = "Khong tim thay " + dtE.Rows.Count + " DN";
                    int retTemp = new ReportTemp2014Service().Insert(temp);//Them bao cao tam
                }
            }
        }
    }
Beispiel #10
0
    protected void btnApproved_Click(object sender, EventArgs e)
    {
        try
        {
            ReportFuelService faqsBSO = new ReportFuelService();
            if (rblApproved.SelectedIndex == 1)
            {
                ReportLog log = new ReportLog();
                log.ActionName = "Phê duyệt báo cáo";
                log.Comment    = txtmota.Text;
                log.ReportId   = ReportId;
                log.Created    = DateTime.Now;
                log.MemberId   = memVal.UserId;
                log.UserName   = memVal.UserName;
                log.Status     = "Yêu cầu bổ sung, hiệu chỉnh";
                log.LogType    = Convert.ToInt32(LogType.ANNUALREPORT);
                new ReportLogService().Insert(log);
                if (faqsBSO.UpdateStatusEnterprise(ReportId, 3) > 0)
                {
                    if (fAttachApp.HasFile)
                    {
                        string strPath = Server.MapPath("~/UserFile/Report/");
                        try
                        {
                            string strFilename = "";
                            strFilename = memVal.UserName + "_" + ReportYear + "_" + new Random(10).Next(100) + System.IO.Path.GetExtension(fAttachApp.FileName).ToLower();
                            if (System.IO.File.Exists(strPath + strFilename))
                            {
                                strFilename = memVal.UserName + "_" + ReportYear + "_" + new Random(10).Next(100) + System.IO.Path.GetExtension(fAttachApp.FileName).ToLower();
                            }
                            fAttachApp.PostedFile.SaveAs(strPath + strFilename);

                            ReportAttachFile reportAtt = new ReportAttachFile();
                            reportAtt.ReportId   = ReportId;
                            reportAtt.PathFile   = strFilename;
                            reportAtt.Created    = DateTime.Now;
                            reportAtt.ActionName = "SCT đã tải file báo cáo";
                            reportAtt.Comment    = txtmota.Text;
                            reportAtt.UserName   = memVal.UserName;
                            reportAtt.UserId     = memVal.UserId;
                            reportAtt.ReportType = Convert.ToInt32(LogType.ANNUALREPORT);
                            if (new ReportAttachFileService().Insert(reportAtt) > 0)
                            {
                                BindReportFile();
                            }
                        }
                        catch (Exception ex) { ScriptManager.RegisterStartupScript(this, GetType(), "sendreport", "sendreport();", true); return; }
                    }
                    Response.Redirect(ResolveUrl("~") + "Admin/ListReportProcessing/Default.aspx");
                }
            }
            else
            {
                IFormatProvider culture = new System.Globalization.CultureInfo("en-US", true);
                if (faqsBSO.ApproveReport(ReportId, DateTime.ParseExact(txtApprovedDate.Text, "dd/MM/yyyy", culture), (rblApproved.SelectedIndex == 0)) > 0)
                {
                    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         listDetail = new ReportFuelDetailService().GetTOEByReport(ReportId);
                    decimal           SumTOE     = 0;
                    decimal           SumTOEP    = 0;
                    if (listDetail != null && listDetail.Rows.Count > 0)
                    {
                        if (listDetail.Rows.Count > 2)
                        {
                            SumTOE  = Convert.ToDecimal(listDetail.Rows[0]["NoFuel_TOE"]);
                            SumTOEP = Convert.ToDecimal(listDetail.Rows[1]["NoFuel_TOE"]);
                        }
                        else
                        {
                            if (Convert.ToBoolean(listDetail.Rows[0]["IsNextYear"]))
                            {
                                SumTOEP = Convert.ToDecimal(listDetail.Rows[0]["NoFuel_TOE"]);
                            }
                            else
                            {
                                SumTOE = Convert.ToDecimal(listDetail.Rows[0]["NoFuel_TOE"]);
                            }
                        }
                    }
                    EnterpriseYearService enterService = new EnterpriseYearService();
                    int i = enterService.UpdateTOE(EnterpriseId, ReportYear, ReportId, SumTOE, SumTOEP);
                    if (i == 0)
                    {
                        EnterpriseYear enterYear = new EnterpriseYear();
                        enterYear.IsKey        = false;
                        enterYear.No_TOE       = SumTOE;
                        enterYear.NoTOE_Plan   = SumTOEP;
                        enterYear.Year         = ReportYear;
                        enterYear.EnterpriseId = EnterpriseId;
                        enterYear.ReportId     = ReportId;
                        enterService.Insert(enterYear);
                    }

                    ReportLog log = new ReportLog();
                    log.ActionName = "Phê duyệt báo cáo";
                    log.Comment    = txtmota.Text;
                    log.ReportId   = ReportId;
                    log.Created    = DateTime.Now;
                    log.MemberId   = memVal.UserId;
                    log.UserName   = memVal.UserName;
                    log.Status     = "Đã duyệt báo cáo";
                    log.LogType    = Convert.ToInt32(LogType.ANNUALREPORT);
                    new ReportLogService().Insert(log);
                    Response.Redirect(ResolveUrl("~") + "Admin/ListReportProcessing/Default.aspx");
                }
                else
                {
                    //clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Xảy ra lỗi chưa phê duyệt được báo cáo. Vui lòng thử lại!</div>";
                    ScriptManager.RegisterStartupScript(this, GetType(), "showformDetail", "approvedReport();", true);
                }
            }
        }
        catch (Exception ex)
        {
            //clientview.Text = ex.Message.ToString();
        }
    }
Beispiel #11
0
    protected void btn_add_Click(object sender, EventArgs e)
    {
        try
        {
            EnterpriseService objlogic = new EnterpriseService();
            Enterprise        obj      = new Enterprise();
            obj.Title = txtTitle.Text;
            if (ddlOrg.SelectedIndex > 0)
            {
                obj.OrganizationId = Convert.ToInt32(ddlOrg.SelectedValue);
            }
            if (ddlProvince.SelectedIndex > 0)
            {
                obj.ProvinceId = Convert.ToInt32(ddlProvince.SelectedValue);
            }
            if (ddlDistrict.SelectedIndex > 0)
            {
                obj.DistrictId = Convert.ToInt32(ddlDistrict.SelectedValue);
            }

            if (ddlArea.SelectedIndex > 0)
            {
                obj.AreaId = Convert.ToInt32(ddlArea.SelectedValue);
            }
            if (ddlSubArea.SelectedIndex > 0)
            {
                obj.SubAreaId = Convert.ToInt32(ddlSubArea.SelectedValue);
            }

            IFormatProvider culture = new System.Globalization.CultureInfo("en-US", true);
            if (txtMST.Text != "")
            {
                obj.TaxCode = txtMST.Text.Trim();
            }
            if (txtCustomerCode.Text != "")
            {
                obj.CustomerCode = txtCustomerCode.Text.Trim();
            }
            obj.Phone     = txtPhone.Text;
            obj.Email     = txtEmail.Text;
            obj.Fax       = txtFax.Text;
            obj.ManPerson = txtResponsible.Text;
            obj.Address   = txtAddress.Text;
            obj.OwnerId   = Convert.ToInt32(ddlOwner.SelectedValue);

            obj.ParentName = txtParentName.Text;
            if (ddlProvinceReporter.SelectedIndex > 0)
            {
                obj.ManProvinceId = Convert.ToInt32(ddlProvinceReporter.SelectedValue);
            }
            if (ddlDistrictReporter.SelectedIndex > 0)
            {
                obj.ManDistrictId = Convert.ToInt32(ddlDistrictReporter.SelectedValue);
            }
            obj.ManAddress = txtAddressReporter.Text;
            obj.ManPhone   = txtPhoneReporter.Text;
            obj.ManFax     = txtFaxReporter.Text;
            obj.ManEmail   = txtManEmail.Text;
            if (cbxActive.Checked)
            {
                obj.IsActive = true;
            }
            else
            {
                obj.IsActive = false;
            }
            try
            {
                if (txtAtiveYear.Text.Trim() != "")
                {
                    obj.ActiveYear = Convert.ToInt32(txtAtiveYear.Text);
                }
            }
            catch { }

            if (ItemId > 0)
            {
                obj.Id = ItemId;
                if (objlogic.Update(obj) != null)
                {
                    /*Cap nhat du lieu trong diem nam hien tai*/
                    if (ImportantYears != "" && !ImportantYears.Contains(DateTime.Today.ToString("yyyy")) && cbxIsImportant.Checked)
                    {
                        EnterpriseYear ey = new EnterpriseYear();
                        ey.EnterpriseId = ItemId;
                        ey.Year         = DateTime.Today.Year;
                        ey.IsKey        = true;
                        new EnterpriseYearService().Insert(ey);
                    }
                    BindImportantYear();
                    BindData();
                    error.Text = "<div class='alert alert-primary'>Cập nhật thành công !</div>";
                }
                else
                {
                    error.Text = "<div class='alert alert-dangers'>Cập nhật không thành công !</div>";
                }
            }
            else
            {
                ItemId = objlogic.Insert(obj);
                if (ItemId > 0)
                {
                    /*Tao tai khoan mac dinh*/
                    Organization org = new OrganizationService().FindByKey(obj.OrganizationId);
                    if (org != null)
                    {
                        int                     noAccount     = new EnterpriseService().GetNoAccount(obj.OrganizationId);
                        SecurityBSO             securityBSO   = new SecurityBSO();
                        AdminRolesBSO           adminRolesBSO = new AdminRolesBSO();
                        Utils                   objUtil       = new Utils();
                        MemberService           memberService = new MemberService();
                        ePower.DE.Domain.Member member        = new ePower.DE.Domain.Member();
                        member.EnterpriseId = ItemId;
                        member.IsDelete     = false;
                        member.IsActive     = true;
                        member.AccountName  = "DN." + Utils.UCS2Convert(org.Title).Replace(" ", "").Replace("-", "").ToUpper() + "." + (noAccount).ToString("000");
                        string spassdefault = "abc123";
                        spassdefault    = ConfigurationManager.AppSettings["DefaultPassword"].ToString();
                        member.Password = securityBSO.EncPwd(spassdefault);
                        if (memberService.Insert(member) > 0)
                        {
                            BindMember();
                        }
                        else
                        {
                            error.Text = "<div class='alert alert-dangers'>Tạo tài khoản không thành công !</div>";
                        }
                    }
                    /*Cap nhat du lieu trong diem nam hien tai*/
                    if (ImportantYears != "" && !ImportantYears.Contains(DateTime.Today.ToString("yyyy")) && cbxIsImportant.Checked)
                    {
                        EnterpriseYear ey = new EnterpriseYear();
                        ey.EnterpriseId = ItemId;
                        ey.Year         = DateTime.Today.Year;
                        ey.IsKey        = true;
                        new EnterpriseYearService().Insert(ey);
                    }
                    Response.Redirect(ResolveUrl("~") + "Admin/EditEnterpriseForOrg/" + ItemId.ToString() + "/Default.aspx");
                }
                else
                {
                    error.Text = "<div class='alert alert-dangers'>Thêm mới không thành công !</div>";
                }
            }
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
Beispiel #12
0
    protected void btnImportEN_Click(object sender, EventArgs e)
    {
        DataTable dt = new DataTable();

        string connectionString = String.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""", Server.MapPath("~/UserFile/Data_2014.xlsx"));
        //string query = String.Format("select * from [{0}$]", "Area");
        string query = String.Format("select * from [{0}$]", "DN");

        OleDbDataAdapter dataAdapter = new OleDbDataAdapter(query, connectionString);
        DataSet          dataSet     = new DataSet();

        dataAdapter.Fill(dataSet);

        DataTable         myTable = dataSet.Tables[0];
        EnterpriseService comBSO  = new EnterpriseService();

        foreach (DataRow drow in myTable.Rows)
        {
            ReportTemp2014 temp = new ReportTemp2014();
            Enterprise     area = new Enterprise();
            area.Title = drow["Title"].ToString();
            temp.Title = area.Title;
            if (drow["Address"] != null)
            {
                area.Address = drow["Address"].ToString();
                temp.Address = area.Address;
            }
            //if (drow["Phone"] != null)
            //{
            //    area.Phone = drow["Phone"].ToString();
            //    temp.Phone = area.Phone;
            //}
            area.OrganizationId = Convert.ToInt32(drow["OrgId"]);
            temp.OrgId          = area.OrganizationId;

            //if (drow["SubArea"] != null && drow["SubArea"].ToString() != "")
            //{

            //}
            if (drow["AreaName"] != null && drow["AreaName"].ToString() != "")
            {
                temp.AreaName = drow["AreaName"].ToString();
                if (drow["AreaName"].ToString() == "Công nghiệp")
                {
                    area.AreaId = 5;
                }
                else
                if (drow["AreaName"].ToString() == "Nông nghiệp")
                {
                    area.AreaId = 3;
                }
                else
                if (drow["AreaName"].ToString() == "Công trình xây dựng")
                {
                    area.AreaId = 6;
                }
                else
                {
                    area.AreaId = 1;
                }
                temp.AreaId = area.AreaId;
            }
            if (drow["SubAreaName"] != null && drow["SubAreaName"].ToString() != "")
            {
                DataTable dtSub = new AreaService().getAreaByName(drow["SubAreaName"].ToString().Trim());
                if (dtSub != null && dtSub.Rows.Count > 0)
                {
                    area.SubAreaId = Convert.ToInt32(dtSub.Rows[0]["Id"]);
                    temp.SubAreaId = area.SubAreaId;
                }
                else
                {
                    Area sub = new Area();
                    sub.AreaName  = drow["SubAreaName"].ToString().Trim();
                    sub.ParentId  = area.AreaId;
                    sub.IsStatus  = 1;
                    sub.SortOrder = 0;
                    int subId = new AreaService().Insert(sub);
                    temp.SubAreaId = subId;
                    area.SubAreaId = subId;
                }
                area.Info        = drow["SubAreaName"].ToString().Trim();
                temp.SubAreaName = drow["SubAreaName"].ToString().Trim();
            }

            area.ProvinceId    = Convert.ToInt32(drow["ProvinceId"]);
            area.ManProvinceId = Convert.ToInt32(drow["ManProvinceId"]);
            int eId = comBSO.Insert(area);//Them doanh  nghiep
            if (eId > 0)
            {
                temp.EnterpriseId = eId;
                if (drow["Dien_kWh"] != null && drow["Dien_kWh"].ToString().Trim() != "")
                {
                    temp.Dien_kWh = drow["Dien_kWh"].ToString();
                }

                if (drow["Than_Tan"] != null && drow["Than_Tan"].ToString().Trim() != "")
                {
                    temp.Than_Tan = drow["Than_Tan"].ToString();
                }

                if (drow["DO_Tan"] != null && drow["DO_Tan"].ToString().Trim() != "")
                {
                    temp.DO_Tan = drow["DO_Tan"].ToString();
                }

                if (drow["FO_Tan"] != null && drow["FO_Tan"].ToString().Trim() != "")
                {
                    temp.FO_Tan = drow["FO_Tan"].ToString();
                }

                if (drow["Xang_Tan"] != null && drow["Xang_Tan"].ToString().Trim() != "")
                {
                    temp.Xang_Tan = drow["Xang_Tan"].ToString();
                }

                if (drow["Gas_Tan"] != null && drow["Gas_Tan"].ToString().Trim() != "")
                {
                    temp.Gas_Tan = drow["Gas_Tan"].ToString();
                }

                if (drow["Khi_m3"] != null && drow["Khi_m3"].ToString().Trim() != "")
                {
                    temp.Khi_M3 = drow["Khi_m3"].ToString();
                }

                if (drow["LPG_Tan"] != null && drow["LPG_Tan"].ToString().Trim() != "")
                {
                    temp.LPG_Tan = drow["LPG_Tan"].ToString();
                }

                if (drow["Khac_SoDo"] != null && drow["Khac_SoDo"].ToString().Trim() != "")
                {
                    temp.KhacSoDo = drow["Khac_SoDo"].ToString();
                }

                //if (drow["Note"] != null && drow["Note"].ToString().Trim() != "")
                //    temp.Note = drow["Note"].ToString();

                EnterpriseYearService eYService = new EnterpriseYearService();
                EnterpriseYear        ey        = new EnterpriseYear();
                ey.EnterpriseId = eId;

                if (drow["No_TOE"] != null && drow["No_TOE"].ToString().Trim() != "" && Convert.ToDecimal(drow["No_TOE"]) > 0)
                {
                    ey.No_TOE   = Convert.ToDecimal(drow["No_TOE"]);
                    temp.No_TOE = ey.No_TOE;
                    temp.Year   = 2014;
                    int retTemp = new ReportTemp2014Service().Insert(temp);//Them bao cao tam
                    ey.IsDelete = false;
                    ey.Year     = temp.Year;
                    eYService.Insert(ey);//Them nam bao cao
                }
            }
        }
    }