コード例 #1
0
 protected void btnUpdateAccount_Click(object sender, EventArgs e)
 {
     ePower.DE.Domain.Member member = new ePower.DE.Domain.Member();
     member.AccountName  = txtAdminName.Text.Trim();
     member.Password     = new SecurityBSO().EncPwd(txtAdminPass.Text.Trim());
     member.IsDelete     = false;
     member.EnterpriseId = ItemId;
     if (MemberId > 0)
     {
         member.Id = MemberId;
         if (new MemberService().Update(member) != null)
         {
             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
     {
         if (new MemberService().Insert(member) > 0)
         {
             error.Text = "<div class='alert alert-primary'>Thêm mới thành công !</div>";
         }
         else
         {
             error.Text = "<div class='alert alert-dangers'>Thêm mới không thành công !</div>";
         }
     }
 }
コード例 #2
0
 protected void btnAddMember_Click(object sender, EventArgs e)
 {
     if (OrgId > 0)
     {
         Organization org = new OrganizationService().FindByKey(OrgId);
         if (org != null)
         {
             int                     noAccount     = new EnterpriseService().GetNoAccount(OrgId);
             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;
             string spassdefault = "abc123";
             spassdefault       = ConfigurationManager.AppSettings["DefaultPassword"].ToString();
             member.AccountName = "dn." + Utils.UCS2Convert(org.Title).Replace(" ", "").Replace("-", "").ToLower() + "." + (noAccount).ToString("000");
             member.Password    = securityBSO.EncPwd(spassdefault);
             if (memberService.Insert(member) > 0)
             {
                 BindMember();
             }
             else
             {
                 error.Text = "<div style='color:#ff0000;font:bold 12px Arial;padding:5px 0;'>Tạo tài khoản không thành công !</div>";
             }
         }
         else
         {
             error.Text = "<div style='color:#ff0000;font:bold 12px Arial;padding:5px 0;'>Chưa cập nhật đơn vị quản lý !</div>";
         }
     }
 }
コード例 #3
0
    protected void btn_add_Click(object sender, EventArgs e)
    {
        ePower.DE.Domain.Member admin = ReceiveHtml();
        try
        {
            MemberService adminBSO = new MemberService();
            if (adminBSO.ExistAccount(admin.AccountName))
            {
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Tài khoản đã được đăng ký. Vui lòng đăng ký lại !</div>";
            }
            else
            if (adminBSO.ExistEmail(admin.Email))
            {
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Địa chỉ Email đã được đăng ký. Vui lòng đăng ký lại !</div>";
            }
            else
            {
                int id = adminBSO.Insert(admin);

                if (id > 0)
                {
                    error.Text = "<div class='alert alert-sm alert-success bg-gradient'>Thêm mới thành công !</div>";
                    Response.Redirect(ResolveUrl("~") + "Admin/ListMember.aspx");
                }
                else
                {
                    error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới không thành công !</div>";
                }
            }
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
コード例 #4
0
 protected void btnSavePass_Click(object sender, EventArgs e)
 {
     ltErrorMember.Text = "";
     if (hdnMemberId.Value != "" && Convert.ToInt32(hdnMemberId.Value) > 0)
     {
         ePower.DE.Domain.Member admin = new ePower.DE.Domain.Member();
         try
         {
             SecurityBSO   securityBSO = new SecurityBSO();
             MemberService adminBSO    = new MemberService();
             admin = adminBSO.FindByKey(Convert.ToInt32(hdnMemberId.Value));
             if (admin != null)
             {
                 if (txtAdminPass.Text != "")
                 {
                     admin.Password = securityBSO.EncPwd(txtAdminPass.Text.Trim());
                 }
                 if (adminBSO.Update(admin) != null)
                 {
                     ScriptManager.RegisterStartupScript(this, GetType(), "showform", "alert('Reset mật khẩu DN thành công');", true);
                 }
                 else
                 {
                     ltErrorMember.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Reset mật khẩu DN không thành công !</div>";
                     ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updatePass();", true);
                 }
             }
         }
         catch (Exception ex)
         {
             error.Text = ex.Message.ToString();
         }
     }
 }
コード例 #5
0
    protected void btnCreateMember_Click(object sender, EventArgs e)
    {
        EnterpriseService enterpriseService = new EnterpriseService();

        OrganizationService  comBSO  = new OrganizationService();
        IList <Organization> listOrg = new List <Organization>();

        listOrg = comBSO.FindAll();
        SecurityBSO   securityBSO   = new SecurityBSO();
        AdminRolesBSO adminRolesBSO = new AdminRolesBSO();
        AdminBSO      adminBSO      = new AdminBSO();
        Utils         objUtil       = new Utils();
        MemberService memberService = new MemberService();

        foreach (Organization org in listOrg)
        {
            int STT = 0;
            IList <Enterprise> list = enterpriseService.FindList(0, 0, 0, org.Id, 0, 0, null, "", new ePower.Core.PagingInfo(1000, 1));
            foreach (Enterprise enter in list)
            {
                STT++;
                ePower.DE.Domain.Member member = new ePower.DE.Domain.Member();
                member.EnterpriseId = enter.Id;
                member.IsDelete     = false;
                member.AccountName  = "DN." + Utils.UCS2Convert(org.Title).Replace(" ", "").Replace("-", "").ToUpper() + "." + (STT).ToString("000");
                member.Password     = securityBSO.EncPwd("123456");
                memberService.Insert(member);
            }
        }
    }
コード例 #6
0
    protected void grvAdmin_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string aId   = e.CommandArgument.ToString();
        string aName = e.CommandName.ToLower();

        switch (aName)
        {
        case "_edit":
            ePower.DE.Domain.Member adminEdit = new ePower.DE.Domain.Member();
            adminEdit = new MemberService().FindByKey(Convert.ToInt32(aId));
            if (adminEdit != null)
            {
                hdnMemberId.Value      = aId;
                txtAdminName1.Text     = adminEdit.AccountName;
                txtAdminName.Enabled   = false;
                frmConfirmPass.Visible = false;
                frmPass.Visible        = false;
                txtAdminFullName.Text  = adminEdit.FullName;
                txtAdminEmail.Text     = adminEdit.Email;
                cbxManActive.Checked   = adminEdit.IsActive;
                txtAdminAddress.Text   = adminEdit.Address;
                txtAdminPhone.Text     = adminEdit.Phone;

                ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updatemember();", true);
            }
            break;

        case "_reset":
            ePower.DE.Domain.Member adminReset = new ePower.DE.Domain.Member();
            adminReset = new MemberService().FindByKey(Convert.ToInt32(aId));
            if (adminReset != null)
            {
                hdnMemberId.Value     = aId;
                txtAdminName.Text     = adminReset.AccountName;
                txtAdminName.Enabled  = false;
                txtAdminFullName.Text = adminReset.FullName;
                txtAdminEmail.Text    = adminReset.Email;
                cbxManActive.Checked  = adminReset.IsActive;
                txtAdminAddress.Text  = adminReset.Address;
                txtAdminPhone.Text    = adminReset.Phone;
                string spassdefault = "abc123";
                spassdefault             = ConfigurationManager.AppSettings["DefaultPassword"].ToString();
                txtAdminPass.Text        = spassdefault;
                txtAdminConfirmPass.Text = spassdefault;
                ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updatePass();", true);
            }
            break;

        case "_delete":
            MemberService           adminBSO = new MemberService();
            ePower.DE.Domain.Member admin    = adminBSO.FindByKey(Convert.ToInt32(aId));
            admin.IsDelete = true;
            adminBSO.Update(admin);
            BindMember();
            break;
        }
    }
コード例 #7
0
    protected void BindData()
    {
        if (MemberId > 0)
        {
            btn_add.Visible  = false;
            btn_edit.Visible = true;

            btn_add1.Visible  = false;
            btn_edit1.Visible = true;

            try
            {
                MemberService           adminBSO = new MemberService();
                ePower.DE.Domain.Member admin    = adminBSO.FindByKey(MemberId);
                hddAdmin_Username.Value = admin.AccountName;
                txtAdminName.Text       = admin.AccountName;
                txtAdminName.Enabled    = false;
                hddPass.Value           = admin.Password;

                txtFullName.Text   = admin.FullName;
                txtAdminEmail.Text = admin.Email;

                rdbList.Checked   = admin.IsActive;
                hdd_Created.Value = admin.Created.ToString();

                txtAddress.Text = admin.Address;

                txtPhone.Text = admin.Phone;

                if (admin.EnterpriseId > 0)
                {
                    ddlEnterprise.SelectedValue = admin.EnterpriseId.ToString();
                }
            }
            catch (Exception ex)
            {
                error.Text = ex.Message.ToString();
            }
        }
        else
        {
            hddAdmin_Id.Value       = "0";
            hddAdmin_Username.Value = "";
            hdd_Created.Value       = DateTime.Now.ToString();
            hdd_log.Value           = DateTime.Now.ToString();
            btn_add.Visible         = true;
            btn_edit.Visible        = false;

            btn_add1.Visible  = true;
            btn_edit1.Visible = false;
        }
    }
コード例 #8
0
    protected void grvAdmin_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string aId   = e.CommandArgument.ToString();
        string aName = e.CommandName.ToLower();

        switch (aName)
        {
        case "_edit":
            Response.Redirect("~/Admins/editMember/" + aId + "/Default.aspx");
            break;

        case "_delete":
            MemberService           adminBSO = new MemberService();
            ePower.DE.Domain.Member admin    = adminBSO.FindByKey(Convert.ToInt32(aId));
            admin.IsDelete = true;
            adminBSO.Update(admin);
            BindData();
            break;
        }
    }
コード例 #9
0
 protected void btnUpdateInfo_Click(object sender, EventArgs e)
 {
     ePower.DE.Domain.Member member = new ePower.DE.Domain.Member();
     member         = new MemberService().FindByKey(memVal.UserId);
     ltInfoErr.Text = "";
     if (member != null)
     {
         member.Address  = txtAddressMember.Text.Trim();
         member.Phone    = txtPhoneMember.Text.Trim();
         member.FullName = txtFullName.Text.Trim();
         member.Email    = txtAdminEmail.Text.Trim();
         //member.EnterpriseId = Convert.ToInt32(memVal.OrgId);
         if (new MemberService().Update(member) != null)
         {
             ltInfoErr.Text = "<div class='alert alert-sm alert-success bg-gradient'>Cập nhật thành công !</div>";
         }
         else
         {
             ltInfoErr.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật không thành công !</div>";
         }
     }
 }
コード例 #10
0
    public ePower.DE.Domain.Member ReceiveHtml()
    {
        SecurityBSO securityBSO = new SecurityBSO();

        ePower.DE.Domain.Member admin = new ePower.DE.Domain.Member();

        admin.Password    = (txtAdminPass.Text != "") ? securityBSO.EncPwd(txtAdminPass.Text.Trim()) : hddPass.Value;
        admin.AccountName = txtAdminName.Text.Trim();
        admin.Email       = (txtAdminEmail.Text != "") ? txtAdminEmail.Text.Trim() : "";

        admin.IsActive = rdbList.Checked;
        admin.FullName = (txtFullName.Text != "") ? txtFullName.Text.Trim() : "";


        admin.Address = (txtAddress.Text != "") ? txtAddress.Text.Trim() : "";
        admin.Phone   = (txtPhone.Text != "") ? txtPhone.Text.Trim() : "";
        if (ddlEnterprise.SelectedIndex > 0)
        {
            admin.EnterpriseId = Convert.ToInt32(ddlEnterprise.SelectedValue);
        }

        return(admin);
    }
コード例 #11
0
    protected void btn_edit_Click(object sender, EventArgs e)
    {
        ePower.DE.Domain.Member admin = ReceiveHtml();
        try
        {
            SecurityBSO   securityBSO = new SecurityBSO();
            MemberService adminBSO    = new MemberService();
            admin          = adminBSO.FindByKey(MemberId);
            admin.Password = (txtAdminPass.Text != "") ? securityBSO.EncPwd(txtAdminPass.Text.Trim()) : hddPass.Value;
            admin.Email    = (txtAdminEmail.Text != "") ? txtAdminEmail.Text.Trim() : "";

            admin.IsActive = rdbList.Checked;
            admin.FullName = (txtFullName.Text != "") ? txtFullName.Text.Trim() : "";


            admin.Address = (txtAddress.Text != "") ? txtAddress.Text.Trim() : "";
            admin.Phone   = (txtPhone.Text != "") ? txtPhone.Text.Trim() : "";
            if (ddlEnterprise.SelectedIndex > 0)
            {
                admin.EnterpriseId = Convert.ToInt32(ddlEnterprise.SelectedValue);
            }

            if (adminBSO.Update(admin) != null)
            {
                Response.Redirect(ResolveUrl("~") + "Admin/ListMember.aspx");
                error.Text = "<div class='alert alert-sm alert-success bg-gradient'>Cập nhật thành công !</div>";
            }
            else
            {
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật không thành công !</div>";
            }
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
コード例 #12
0
    private void BindData()
    {
        if (memVal.UserId > 0 && memVal.OrgId > 0)
        {
            EnterpriseService objlogic = new EnterpriseService();
            Enterprise        obj      = new Enterprise();
            obj = objlogic.FindByKey(Convert.ToInt32(memVal.OrgId));
            if (obj != null)
            {
                txtTitle.Text = obj.Title;
                try
                {
                    if (obj.ProvinceId > 0)
                    {
                        ddlProvince.SelectedValue = obj.ProvinceId.ToString();
                        BindDistrict();
                        if (obj.DistrictId > 0)
                        {
                            ddlDistrict.SelectedValue = obj.DistrictId.ToString();
                        }
                    }
                }
                catch { }
                if (obj.AreaId > 0)
                {
                    ddlArea.SelectedValue = obj.AreaId.ToString();
                    BindSubArea();
                    if (obj.SubAreaId > 0)
                    {
                        ddlSubArea.SelectedValue = obj.SubAreaId.ToString();
                    }
                }

                //if (obj.ReportTemplate != null && obj.ReportTemplate > 0)
                //    ddlReportTemplate.SelectedValue = obj.ReportTemplate.ToString();

                txtMST.Text          = obj.TaxCode;
                txtCustomerCode.Text = obj.CustomerCode;
                txtPhone.Text        = obj.Phone;
                txtFax.Text          = obj.Fax;
                txtEmail.Text        = obj.Email;
                txtResponsible.Text  = obj.ManPerson;
                txtAddress.Text      = obj.Address;
                if (obj.OwnerId > 0)
                {
                    ddlOwner.SelectedValue = obj.OwnerId.ToString();
                }
                txtNote.Text = obj.Info;

                txtParentName.Text = obj.ParentName;
                if (obj.ManProvinceId > 0)
                {
                    ddlProvinceReporter.SelectedValue = obj.ManProvinceId.ToString();
                    BindDistrictReporter();
                    if (obj.ManDistrictId > 0)
                    {
                        ddlDistrictReporter.SelectedValue = obj.ManDistrictId.ToString();
                    }
                }
                if (obj.ActiveYear > 0)
                {
                    txtActiveYear.Text = obj.ActiveYear.ToString();
                }
                txtAddressReporter.Text = obj.ManAddress;
                txtPhoneReporter.Text   = obj.ManPhone;
                txtFaxReporter.Text     = obj.ManFax;
                txtManEmail.Text        = obj.ManEmail;

                int _MoHinhQLNL = obj.MoHinhQLNL;
                switch (_MoHinhQLNL)
                {
                case 0:
                    cbMoHinhQLNL_ChuaAD.Checked = true;
                    break;

                case 1:
                    cbMoHinhQLNL_DaAD.Checked = true;
                    break;

                case 2:
                    cbMoHinhQLNL_DaAD_ISO.Checked = true;
                    break;
                }

                ePower.DE.Domain.Member member = new ePower.DE.Domain.Member();
                member = new MemberService().FindByKey(memVal.UserId);
                if (member != null)
                {
                    ltrAdminName.Text     = member.AccountName;
                    txtAdminName.Text     = member.AccountName;
                    txtAdminEmail.Text    = member.Email;
                    txtAddressMember.Text = member.Address;
                    txtFullName.Text      = member.FullName;
                    txtPhoneMember.Text   = member.Phone;
                }
            }
        }
    }
コード例 #13
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);
            }
        }
    }
コード例 #14
0
    protected void btn_add_Click(object sender, EventArgs e)
    {
        try
        {
            EnterpriseService objlogic = new EnterpriseService();
            Enterprise        obj      = new Enterprise();
            obj.Title = txtTitle.Text;
            //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 { }


            obj.OrganizationId = m_UserValidation.OrgId;
            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;
                    //    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(m_UserValidation.OrgId);
                    if (org != null)
                    {
                        int                     noAccount     = new EnterpriseService().GetNoAccount(m_UserValidation.OrgId);
                        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("-", "").ToLower() + "." + (noAccount).ToString("000");
                        string spassdefault = "abc123";
                        spassdefault    = ConfigurationManager.AppSettings["DefaultPassword"].ToString();
                        member.Password = securityBSO.EncPwd(spassdefault);
                        int iMember = 0;
                        iMember = memberService.Insert(member);
                        //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;
                    //    new EnterpriseYearService().Insert(ey);
                    //}
                    Response.Redirect(ResolveUrl("~") + "Admin/EditEnterprise/" + 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();
        }
    }
コード例 #15
0
    protected void btnSaveAccount_Click(object sender, EventArgs e)
    {
        ltErrorMember.Text = "";
        if (hdnMemberId.Value != "" && Convert.ToInt32(hdnMemberId.Value) > 0)
        {
            ePower.DE.Domain.Member admin = new ePower.DE.Domain.Member();
            try
            {
                SecurityBSO   securityBSO = new SecurityBSO();
                MemberService adminBSO    = new MemberService();
                admin              = adminBSO.FindByKey(Convert.ToInt32(hdnMemberId.Value));
                admin.Email        = txtAdminEmail.Text.Trim();
                admin.IsActive     = cbxManActive.Checked;
                admin.FullName     = txtAdminFullName.Text.Trim();
                admin.Address      = txtAdminAddress.Text.Trim();
                admin.Phone        = txtAdminPhone.Text.Trim();
                admin.EnterpriseId = ItemId;

                if (adminBSO.Update(admin) != null)
                {
                    BindMember();
                    ltErrorMember.Text = "<div class='alert alert-sm alert-success bg-gradient'>Cập nhật thành công !</div>";
                }
                else
                {
                    ltErrorMember.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật không thành công !</div>";
                    ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updatemember();", true);
                }
            }
            catch (Exception ex)
            {
                error.Text = ex.Message.ToString();
            }
        }
        else
        {
            MemberService           adminBSO    = new MemberService();
            SecurityBSO             securityBSO = new SecurityBSO();
            ePower.DE.Domain.Member admin       = new ePower.DE.Domain.Member();

            admin.Password     = securityBSO.EncPwd(txtAdminPass1.Text);
            admin.AccountName  = txtAdminName1.Text.Trim();
            admin.Email        = txtAdminEmail.Text.Trim();
            admin.IsActive     = cbxManActive.Checked;
            admin.FullName     = txtAdminFullName.Text.Trim();
            admin.Address      = txtAdminAddress.Text.Trim();
            admin.Phone        = txtAdminPhone.Text.Trim();
            admin.EnterpriseId = ItemId;
            if (adminBSO.ExistAccount(admin.AccountName))
            {
                ltErrorMember.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Tài khoản đã được đăng ký. Vui lòng nhập tên tài khoản khác !</div>";
                ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updatemember();", true);
            }
            else
            if (adminBSO.ExistEmail(admin.Email))
            {
                ltErrorMember.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Địa chỉ Email đã được đăng ký. Vui lòng nhập Email tài khoản khác !</div>";
                ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updatemember();", true);
            }
            else
            {
                int id = adminBSO.Insert(admin);
                if (id > 0)
                {
                    ltErrorMember.Text = "";
                    BindMember();
                }
                else
                {
                    ltErrorMember.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Tạo mới tài khoản không thành công !</div>";
                    ScriptManager.RegisterStartupScript(this, GetType(), "showform", "updatemember();", true);
                }
            }
        }
    }
コード例 #16
0
    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";
        }
    }