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);
            }
        }
    }
 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>";
         }
     }
 }
 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();
         }
     }
 }
示例#4
0
    protected Admin ReceiveHtml()
    {
        SecurityBSO securityBSO = new SecurityBSO();
        Admin       admin       = new Admin();

        admin.AdminName      = txtAdminUser.Text;
        admin.AdminEmail     = txtAdminEmail.Text;
        admin.AdminLoginType = Convert.ToBoolean(hddAdminLoginType.Value);
        if (admin.AdminLoginType)
        {
            admin.AdminPass = securityBSO.EncPwd(News_Pass.Text.Trim());
        }
        else
        {
            admin.AdminPass = "";
        }
        admin.AdminPass   = securityBSO.EncPwd(News_Pass.Text.Trim());
        admin.RolesID     = Convert.ToInt32(hddRoles_ID.Value);
        admin.AdminActive = Convert.ToBoolean(hddActied.Value);

        admin.AdminFullName = (txtFullName.Text != "") ? txtFullName.Text.Trim() : "";

        admin.AdminCreated    = Convert.ToDateTime(hdd_Created.Value);
        admin.AdminLog        = Convert.ToDateTime(hdd_log.Value);
        admin.AdminPermission = (hddPermission.Value != "") ? hddPermission.Value : "";

        admin.AdminAddress   = hddAddress.Value;
        admin.AdminPhone     = hddPhone.Value;
        admin.AdminNickYahoo = hddNickYahoo.Value;
        admin.AdminNickSkype = hddNickSkype.Value;
        admin.AdminAvatar    = hddImageThumb.Value;
        admin.AdminSex       = Convert.ToBoolean(hddSex.Value);
        admin.AdminBirth     = Convert.ToDateTime(hddBirth.Value);



        return(admin);
    }
示例#5
0
    public Admin ReceiveHtml()
    {
        SecurityBSO securityBSO = new SecurityBSO();
        Admin       admin       = new Admin();

        admin.AdminLoginType = rdbLoginType.Checked;


        admin.AdminID = (hddAdmin_Id.Value != "") ? Convert.ToInt32(hddAdmin_Id.Value) : 0;
        //if (rdbLoginType.SelectedItem.Value.Equals("True"))
        //{
        admin.AdminPass  = (txtAdminPass.Text != "") ? securityBSO.EncPwd(txtAdminPass.Text.Trim()) : hddPass.Value;
        admin.AdminName  = (txtAdminName.Text != "") ? txtAdminName.Text.Trim() : hddAdmin_Username.Value;
        admin.AdminEmail = (txtAdminEmail.Text != "") ? txtAdminEmail.Text.Trim() : "";

        //}


        // admin.RolesID = (ddlRoles.SelectedValue != "") ? Convert.ToInt32(ddlRoles.SelectedValue) : 0;
        admin.RolesID       = 1;
        admin.AdminActive   = rdbList.Checked;
        admin.AdminFullName = (txtFullName.Text != "") ? txtFullName.Text.Trim() : "";

        admin.AdminCreated = Convert.ToDateTime(hdd_Created.Value);
        admin.AdminLog     = Convert.ToDateTime(hdd_log.Value);
        //admin.AdminPermission = "";
        admin.AdminPermission = (CheckedList() != "") ? CheckedList() : "";

        admin.AdminAddress   = (txtAddress.Text != "") ? txtAddress.Text.Trim() : "";
        admin.AdminPhone     = (txtPhone.Text != "") ? txtPhone.Text.Trim() : "";
        admin.AdminNickYahoo = (txtNickYahoo.Text != "") ? txtNickYahoo.Text.Trim() : "";
        admin.AdminNickSkype = (txtNickSkype.Text != "") ? txtNickSkype.Text.Trim() : "";
        admin.AdminAvatar    = (txtimage4_3.Text != "") ? txtimage4_3.Text : hddImageThumb.Value;
        admin.AdminSex       = rdbSex.Checked;
        IFormatProvider culture = new System.Globalization.CultureInfo("en-US", true);

        admin.AdminBirth = DateTime.ParseExact(txtBirth.Text, "dd/MM/yyyy HH:mm", culture);
        if (ddlOrg.SelectedIndex > 0)
        {
            admin.AdminOrganizationId = Convert.ToInt32(ddlOrg.SelectedValue);
        }

        return(admin);
    }
示例#6
0
    public int CheckLogin(string UserName, string PassWord)
    {
        SecurityBSO securityBSO = new SecurityBSO();
        int         nRet        = 1;
        AdminBSO    adminBSO    = new AdminBSO();
        Admin       objUser     = adminBSO.GetAdminByAccountPass(UserName, PassWord);

        if (objUser == null)
        {
            nRet = -1;
        }
        else if (objUser.AdminPass != securityBSO.EncPwd(PassWord))
        {
            nRet = -1;
        }
        if (nRet == -1)
        {
            return(nRet);
        }

        return(nRet);
    }
示例#7
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);
    }
示例#8
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();
        }
    }
示例#9
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);
            }
        }
    }
示例#10
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();
        }
    }
示例#11
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);
                }
            }
        }
    }
示例#12
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";
        }
    }
    protected void btnCreateUser_Click(object sender, EventArgs e)
    {
        OrganizationService  comBSO = new OrganizationService();
        IList <Organization> list   = new List <Organization>();

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

        foreach (Organization org in list)
        {
            Admin admin = new Admin();

            admin.AdminLoginType = false;
            admin.AdminPass      = securityBSO.EncPwd("123456");
            admin.AdminName      = "SCT." + Utils.UCS2Convert(org.Title).Replace(" ", "").Replace("-", "").ToUpper();;
            admin.AdminEmail     = org.Email;

            //}


            // admin.RolesID = (ddlRoles.SelectedValue != "") ? Convert.ToInt32(ddlRoles.SelectedValue) : 0;
            admin.RolesID       = 1;
            admin.AdminActive   = true;
            admin.AdminFullName = "Sở công thương" + org.Title;

            admin.AdminCreated = DateTime.Now;
            admin.AdminLog     = DateTime.Now;
            //admin.AdminPermission = "";
            admin.AdminPermission = "Read,";

            admin.AdminAddress   = "";
            admin.AdminPhone     = org.Phone;
            admin.AdminNickYahoo = "";
            admin.AdminNickSkype = "";
            admin.AdminAvatar    = "";
            admin.AdminSex       = true;
            IFormatProvider culture = new System.Globalization.CultureInfo("en-US", true);
            admin.AdminBirth = DateTime.Now;
            if (org.Email != null && org.Email != "")
            {
                admin.AdminEmail = org.Email;
            }
            else
            {
                admin.AdminEmail = "sct" + "@" + admin.AdminName.ToLower() + ".gov.vn";
            }

            admin.AdminOrganizationId = org.Id;
            int id = adminBSO.CreateAdmin(admin);

            AdminRoles adminRoles = new AdminRoles();
            adminRoles.RolesID       = 14;
            adminRoles.AdminUserName = admin.AdminName;
            adminRoles.UserName      = Session["Admin_UserName"].ToString();
            //adminRoles.Permission = subrow["Permission"].ToString();
            adminRoles.Permission = "";
            adminRoles.Created    = DateTime.Now;

            adminRolesBSO.CreateAdminRoles(adminRoles);
        }
    }