protected void grvNewsComment_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton image_del = (LinkButton)e.Row.FindControl("btn_delete");
            //   image_del.Attributes.Add("onclick", "return confirm('Bạn có chắc chắn muốn xóa?');");
            LinkButton image_edit = (LinkButton)e.Row.FindControl("btn_edit");

            LinkButton image_view = (LinkButton)e.Row.FindControl("btn_view");
            image_view.Attributes.Add("onclick", "javascript:window.open('" + ResolveUrl("~/") + "Client/Admin/NewsFlow/ViewNewsComment.aspx?Id=" + DataBinder.Eval(e.Row.DataItem, "NewsGroupID") + "','_blank','width=800,height=600');return false;");


            AdminBSO adminBSO = new AdminBSO();
            //Admin admin = new Admin();
            //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                image_del.Attributes.Add("onclick", "javascript:return confirm('Bạn có muốn chắc chắn xóa ???');");
            }
            else
            {
                image_edit.Attributes.Add("onclick", "javascript:return confirm('Bạn không có đủ quyền ???');");
                image_del.Attributes.Add("onclick", "javascript:return confirm('Bạn không có đủ quyền ???');");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["dll"]))
        {
            NavigationTitle(Request["dll"]);
        }

        AdminBSO adminBSO = new AdminBSO();

        //Admin admin = new Admin();
        //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

        if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
        {
            btn_editpage.Visible = true;
            btn_delall.Visible   = true;
        }
        else
        {
            btn_editpage.Visible = false;
            btn_delall.Visible   = false;
        }

        int group = -1;

        hddGroup.Value = Convert.ToString(group);

        if (!IsPostBack)
        {
            BindControl(group);
            ViewNewsGroup(group);
        }
    }
    protected void grvNewsLog_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int        Id         = Convert.ToInt32(e.CommandArgument.ToString());
        NewsLogBSO newsLogBSO = new NewsLogBSO();
        NewsLog    newslog    = newsLogBSO.GetNewsLogById(Id);

        string   nName    = e.CommandName.ToLower();
        AdminBSO adminBSO = new AdminBSO();
        Admin    admin    = new Admin();

        switch (nName)
        {
        case "_view":
            break;

        case "_edit":
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                // Response.Redirect("~/Admin/editnewslog/" + Id + "/Default.aspx");
                Response.Redirect("~/Admin/s/EditNewsbyUser/" + hddNewsGroupID.Value + "/" + Id + "/Default.aspx");
            }
            break;

        case "_delete":
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                newsLogBSO.DeleteNewsLog(Id, -1);
                ViewNewsLog(Convert.ToInt32(hddNewsGroupID.Value));
                AspNetCache.Reset();
            }


            break;
        }
    }
    protected void grvRelation_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int             Id = Convert.ToInt32(e.CommandArgument.ToString());
        NewsRelationBSO _newsRelationBSO = new NewsRelationBSO();
        NewsRelation    _newsRelation    = _newsRelationBSO.GetNewsRelationByID(Id, Convert.ToInt32(hddNewsID.Value));

        NewsGroupBSO newsGroupBSO = new NewsGroupBSO();
        NewsGroup    newsgroup    = newsGroupBSO.GetNewsGroupById(Id);

        string   nName    = e.CommandName.ToLower();
        AdminBSO adminBSO = new AdminBSO();
        Admin    admin    = new Admin();

        switch (nName)
        {
        case "_view":
            break;

        case "_edit":
            Response.Redirect("~/Admin/editnewsbyuser/" + newsgroup.GroupCate + "/" + Id + "/Default.aspx");
            break;

        case "_delete":
            _newsRelationBSO.DeleteNewsRelation(_newsRelation.Id);
            ViewNewsReleation(Convert.ToInt32(hddNewsID.Value));
            AspNetCache.Reset();

            break;
        }
    }
    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);
            }
        }
    }
Exemple #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["dll"]))
        {
            NavigationTitle(Request["dll"]);
        }

        AdminBSO adminBSO = new AdminBSO();

        //Admin admin = new Admin();
        //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

        if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
        {
            btn_editpage.Visible = true;
            btn_enable.Visible   = true;
            btn_disable.Visible  = true;
            btn_delall.Visible   = true;
        }
        else
        {
            btn_editpage.Visible = false;
            btn_enable.Visible   = false;
            btn_disable.Visible  = false;
            btn_delall.Visible   = false;
        }

        if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
        {
            btn_enable_approval.Visible  = true;
            btn_disable_approval.Visible = true;
        }
        else
        {
            btn_enable_approval.Visible  = false;
            btn_disable_approval.Visible = false;
        }

        int group = -1;

        //if (!String.IsNullOrEmpty(Request["group"]))
        //    if (!int.TryParse(Request["group"].Replace(",", ""), out group))
        //        Response.Redirect("~/Admin/home/Default.aspx");


        hddGroup.Value = Convert.ToString(group);

        if (!IsPostBack)
        {
            BindControl(group);
            ViewNewsGroup(group);
        }
    }
    protected void btn_GetPass_Click(object sender, EventArgs e)
    {
        string email = txtEmail.Text.Trim();

        AdminBSO adminBSO = new AdminBSO();
        Admin    admin    = adminBSO.GetAdminByEmail(email);


        if (admin != null)
        {
            SecurityBSO securityBSO = new SecurityBSO();
            string      oldpass     = admin.AdminPass;
            string      newpass     = securityBSO.DecPwd(oldpass);

            Config config = new Config();
            if (AspNetCache.CheckCache("Config_" + Language.language) == false)
            {
                ConfigBSO configBSO = new ConfigBSO();

                config = configBSO.GetAllConfig(Language.language);
                AspNetCache.SetCacheWithTime("Config_" + Language.language, config, 150);
            }
            else
            {
                config = (Config)AspNetCache.GetCache("Config_" + Language.language);
            }

            MailBSO mailBSO = new MailBSO();
            mailBSO.EmailFrom = config.Email_from;

            string subject = "Mật khẩu tài khoản quản trị - " + config.WebName;
            string body    = "Chào bạn :  " + admin.AdminFullName + "<br>";
            body += "Hệ thống quản trị - " + config.WebName + " thông báo mật khẩu hệ thống của bạn: <br>";
            body += "Tài khoản Email đăng nhập của bạn :  " + admin.AdminEmail + "<br>";
            body += "Mật khẩu đăng nhập hệ thống của bạn :  " + newpass;

            if (mailBSO.SendMail(email, subject, body) == true)
            {
                Tool.Message(this.Page, "Thông tin tài khoản đã được gửi tới Email của bạn!");
                return;
            }
            else
            {
                Tool.Message(this.Page, "Hệ thống Mail lỗi! Không thể gửi được thông tin tài khoản, vui lòng thử lại sau.");
                return;
            }
        }
        else
        {
            Tool.Message(this.Page, "Xin lỗi! Chúng tôi không tìm thấy tài khoản của bạn trong hệ thống");
            return;
        }
    }
    private void ViewCateAll()
    {
        AdminBSO  adminBSO  = new AdminBSO();
        DataTable datatable = adminBSO.GetAllAdmin();
        DataView  dataView  = new DataView(datatable);

        dataView.RowFilter = "Admin_Username not in ('administrator','Administrator')";
        dataView.Sort      = "Admin_UserName Asc";
        DataTable table = dataView.ToTable();

        grvUser.DataSource = table;
        grvUser.DataBind();
    }
    protected void ViewAdmin()
    {
        AdminBSO  adminBSO = new AdminBSO();
        DataTable table    = adminBSO.GetAllAdminRoles();
        DataView  dataView = new DataView(table);

        //dataView.RowFilter = "Admin_Username <> 'administrator' and Admin_Username <> 'Administrator'";
        dataView.RowFilter = "Admin_Username not in ('administrator','Administrator')";
        dataView.Sort      = "Admin_Username ASC";
        DataTable dataTable = dataView.ToTable();
        commonBSO commonBSO = new commonBSO();

        commonBSO.FillToGridView(grvAdmin, dataTable);
    }
Exemple #10
0
    protected void btn_add_Click(object sender, EventArgs e)
    {
        Admin admin = ReceiveHtml();

        try
        {
            AdminBSO adminBSO = new AdminBSO();
            if (adminBSO.CheckExist(admin.AdminName))
            {
                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.CheckExistEmail(admin.AdminEmail))
            {
                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
            {
                if (CheckedList().Equals(""))
                {
                    error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Lỗi: Phải lựa chọn ít nhất 1 quyền !</div>";
                }
                else
                {
                    int id = adminBSO.CreateAdmin(admin);

                    RolesBSO      rolesBSO      = new RolesBSO();
                    IRoles        roles         = rolesBSO.GetRolesByName("Guest");
                    AdminRolesBSO adminRolesBSO = new AdminRolesBSO();
                    AdminRoles    adminRoles    = new AdminRoles();

                    adminRoles.AdminUserName = admin.AdminName;
                    adminRoles.RolesID       = roles.RolesID;
                    adminRoles.UserName      = Session["Admin_UserName"].ToString();
                    adminRoles.Permission    = "";
                    adminRoles.Created       = DateTime.Now;
                    adminRolesBSO.CreateAdminRoles(adminRoles);

                    error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Thêm mới thành công !</div>";
                    initControl(id);
                }
            }
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
    protected void grvNewsComment_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        AdminBSO adminBSO = new AdminBSO();
        Admin    admin    = new Admin();

        int    Id    = Convert.ToInt32(e.CommandArgument.ToString());
        string cName = e.CommandName.ToLower();

        switch (cName)
        {
        case "_view":
            break;

        case "_edit":
            //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                Response.Redirect("~/Admin/editnewscomment/" + Id + "/Default.aspx");
            }
            else
            {
                //  Response.Redirect("~/Homepage.aspx?dll=listnews");
            }


            break;

        case "_delete":
            //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                NewsCommentBSO newsCommentBSO = new NewsCommentBSO();
                newsCommentBSO.DeleteNewsComment(Id);
                NewsCommentView(Convert.ToInt32(hddGroup.Value));
            }
            else
            {
                //  Response.Redirect("~/Homepage.aspx?dll=listnews");
            }

            break;
        }
    }
Exemple #12
0
    protected void btn_sumit1_Click1(object sender, EventArgs e)
    {
        if (CheckUserName() == true)
        {
            AdminBSO adminBSO = new AdminBSO();
            Admin    objUser  = adminBSO.GetAdminByAccountPass(txtAdminUser.Text.Trim(), txtAdminPass.Text.Trim());

            if (objUser != null)
            {
                if (objUser.AdminActive == false)
                {
                    Tool.Message(this.Page, "Tài khoản này chưa được kích hoạt! Xin liên hệ với quản trị hệ thống");
                    return;
                }
                else
                {
                    m_UserValidation.SignIn(txtAdminUser.Text.Trim(), objUser.AdminID.ToString(), objUser.AdminOrganizationId, Session.SessionID, ((objUser.AdminName == "administrator") ? true : false));

                    Session["Admin_Username"] = txtAdminUser.Text.Trim();
                    adminBSO.UpdateAdminLog(Session["Admin_Username"].ToString(), DateTime.Now);

                    HttpCookie cookie_lang = Request.Cookies["LangInfo_CMS"];
                    cookie_lang         = new HttpCookie("LangInfo_CMS");
                    cookie_lang["Lang"] = ddlLanguage.SelectedValue.ToString();
                    cookie_lang.Expires = DateTime.Now.AddDays(60);
                    Response.Cookies.Add(cookie_lang);

                    Language.language = ddlLanguage.SelectedValue.ToString();

                    Response.Redirect("~/Admin/home/Default.aspx");
                }
            }
            else
            {
                Tool.Message(this.Page, "Lỗi: Tài khoản hoặc mật khẩu không đúng! Xin vui lòng nhập lại");
                return;
            }
        }
        else
        {
            Tool.Message(this.Page, "Lỗi: Tài khoản không tồn tại! Xin vui lòng nhập lại");
            return;
        }
    }
    //void BindArea()
    //{
    //    IList<ProjectArea> list = new List<ProjectArea>();
    //    if (!AspNetCache.CheckCache(Constants.Cache_Project_Area_All))
    //    {
    //        list = new ProjectAreaService().FindAll();
    //        AspNetCache.SetCache(Constants.Cache_Project_Area_All, list);
    //    }
    //    else
    //        list = (IList<ProjectArea>)AspNetCache.GetCache(Constants.Cache_Project_Area_All);
    //    ddlArea.DataSource = list;
    //    ddlArea.DataTextField = "AreaName";
    //    ddlArea.DataValueField = "Id";
    //    ddlArea.DataBind();
    //    ddlArea.Items.Insert(0, new ListItem("---Chọn lĩnh vực---"));
    //}
    //void BindSubArea()
    //{
    //    IList<ProjectArea> list = new List<ProjectArea>();
    //    if (!AspNetCache.CheckCache(Constants.Cache_Project_Area_All))
    //    {
    //        list = new ProjectAreaService().FindAll();
    //        AspNetCache.SetCache(Constants.Cache_Project_Area_All, list);
    //    }
    //    else
    //        list = (IList<ProjectArea>)AspNetCache.GetCache(Constants.Cache_Project_Area_All);
    //    ddlSubArea.DataSource = list;
    //    ddlSubArea.DataTextField = "AreaName";
    //    ddlSubArea.DataValueField = "Id";
    //    ddlSubArea.DataBind();
    //    ddlSubArea.Items.Insert(0, new ListItem("---Chọn phân ngành---"));
    //}
    //void BindProvince()
    //{
    //    IList<Province> list = new List<Province>();
    //    if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_Provice_All))
    //    {
    //        list = new ProvinceService().FindAll();
    //        AspNetCache.SetCache(Constants.Cache_ReportFuel_Provice_All, list);
    //    }
    //    else
    //        list = (IList<Province>)AspNetCache.GetCache(Constants.Cache_ReportFuel_Provice_All);
    //    ddlProvince.DataSource = list;
    //    ddlProvince.DataTextField = "ProvinceName";
    //    ddlProvince.DataValueField = "Id";
    //    ddlProvince.DataBind();
    //    ddlProvince.Items.Insert(0, new ListItem("---Chọn Tỉnh/TP---"));

    //    ddlProvinceReporter.DataSource = list;
    //    ddlProvinceReporter.DataTextField = "ProvinceName";
    //    ddlProvinceReporter.DataValueField = "Id";
    //    ddlProvinceReporter.DataBind();
    //    ddlProvinceReporter.Items.Insert(0, new ListItem("---Chọn Tỉnh/TP---"));
    //}
    //void BindDistrict()
    //{
    //    IList<District> list = new List<District>();
    //    if (!AspNetCache.CheckCache(Constants.Cache_ReportFuel_District_All))
    //    {
    //        list = new DistrictService().FindAll();
    //        AspNetCache.SetCache(Constants.Cache_ReportFuel_District_All, list);
    //    }
    //    else
    //        list = (IList<District>)AspNetCache.GetCache(Constants.Cache_ReportFuel_District_All);
    //    ddlDistrict.DataSource = list;
    //    ddlDistrict.DataTextField = "DistrictName";
    //    ddlDistrict.DataValueField = "Id";
    //    ddlDistrict.DataBind();
    //    ddlDistrict.Items.Insert(0, new ListItem("---Chọn Quận/Huyện---"));

    //    ddlDistrictReporter.DataSource = list;
    //    ddlDistrictReporter.DataTextField = "DistrictName";
    //    ddlDistrictReporter.DataValueField = "Id";
    //    ddlDistrictReporter.DataBind();
    //    ddlDistrictReporter.Items.Insert(0, new ListItem("---Chọn Quận/Huyện---"));
    //}
    //void BindEnterprise()
    //{
    //    int EnterpriseId = 1;
    //    Enterprise enter = new Enterprise();
    //    enter = new EnterpriseService().FindByKey(EnterpriseId);
    //    if (enter != null)
    //    {
    //        txtEnterpriseName.Text = enter.Title;
    //        if (enter.SubAreaId > 0)
    //            ddlSubArea.SelectedValue = enter.SubAreaId.ToString();
    //        if (enter.AreaId > 0)
    //            ddlArea.SelectedValue = enter.AreaId.ToString();
    //        if (enter.ProvinceId > 0)
    //            ddlProvince.SelectedValue = enter.ProvinceId.ToString();
    //        if (enter.DistrictId > 0)
    //            ddlDistrict.SelectedValue = enter.DistrictId.ToString();
    //        txtAddress.Text = enter.Address;
    //        txtEmail.Text = enter.Email;
    //        txtFax.Text = enter.Fax;
    //        txtPhone.Text = enter.Phone;
    //        txtReportName.Text = enter.ManPerson;
    //        if (enter.ManProvinceId > 0)
    //            ddlProvinceReporter.SelectedValue = enter.ManProvinceId.ToString();
    //        if (enter.ManDistrictId > 0)
    //            ddlDistrictReporter.SelectedValue = enter.ManDistrictId.ToString();
    //        txtAddressReporter.Text = enter.ManAddress;
    //        txtEmail.Text = enter.ManEmail;
    //        txtFaxReporter.Text = enter.ManFax;
    //        txtPhoneReporter.Text = enter.ManPhone;
    //    }
    //}

    private void BindData()
    {
        ReportFuelService comBSO = new ReportFuelService();
        DataTable         list   = new DataTable();
        int AreaId    = 0;
        int SubAreaId = 0;
        int Year      = 0;

        if (ddlYear.SelectedIndex > 0)
        {
            Year = Convert.ToInt32(ddlYear.SelectedValue);
        }
        ePower.Core.PagingInfo paging = new ePower.Core.PagingInfo(PageSize, CurrentPage);
        Admin admin = new AdminBSO().GetAdminById(m_UserValidation.UserId);

        list = comBSO.FindList(false, AreaId, SubAreaId, admin.AdminOrganizationId, 0, 0, 0, 1, false, Year, null, null, "", paging);
        if (list != null && list.Rows.Count > 0)
        {
            paging.RowsCount   = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging.PageSize    = PageSize;
            Paging.CurrentPage = CurrentPage;
            Paging.TotalRecord = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging.DataLoad();
            if (paging.PagesCount <= 1)
            {
                ltNotice.Text  = "Có tổng số " + paging.RowsCount + " báo cáo";
                Paging.Visible = false;
            }
            else
            {
                ltNotice.Text  = "Có " + list.Rows.Count + " trong tổng số " + paging.RowsCount + " báo cáo";
                Paging.Visible = true;
            }
        }
        else
        {
            ltNotice.Text  = "";
            Paging.Visible = false;
        }
        rptNoFuelCurrent.DataSource = list;

        rptNoFuelCurrent.DataBind();
    }
    protected void btnAdmin_Click(object sender, EventArgs e)
    {
        if (CheckUserName(txtAdminUser11.Text.Trim()) == true)
        {
            AdminBSO adminBSO = new AdminBSO();
            //Admin admin = adminBSO.GetAdminById(txtAdminUser.Text.Trim());

            Admin objUser = adminBSO.GetAdminByAccountPass(txtAdminUser11.Text.Trim(), txtAdminPass11.Text.Trim());

            if (objUser != null)
            {
                if (objUser.AdminActive == false)
                {
                    error.Text = "<div class='alert alert-sm alert-danger bg-gradient p5 mbn '>Tài khoản này chưa được kích hoạt! Xin liên hệ với quản trị hệ thống.</div>";
                }
                else
                {
                    //m_UserValidation.SignIn(txtAdminUser11.Text.Trim(), objUser.AdminID.ToString(), objUser.AdminOrganizationId, Session.SessionID,false);

                    Session["Admin_Username"] = txtAdminUser11.Text.Trim();
                    adminBSO.UpdateAdminLog(Session["Admin_Username"].ToString(), DateTime.Now);

                    HttpCookie cookie_lang = Request.Cookies["LangInfo_CMS"];
                    cookie_lang         = new HttpCookie("LangInfo_CMS");
                    cookie_lang["Lang"] = "vi-VN";
                    Response.Cookies.Add(cookie_lang);

                    Language.language = "vi-VN";

                    Response.Redirect("~/Admin/home/Default.aspx");
                }
            }
            else
            {
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient p5 mbn '>Lỗi: Tài khoản hoặc mật khẩu không đúng! Xin vui lòng nhập lại.</div>";
            }
        }
        else
        {
            error.Text = "<div class='alert alert-sm alert-danger bg-gradient p5 mbn '>Lỗi: Tài khoản không tồn tại! Xin vui lòng nhập lại.</div>";
        }
    }
 protected void btn_Update_Click(object sender, EventArgs e)
 {
     try
     {
         AdminBSO adminBSO = new AdminBSO();
         int      ret      = adminBSO.ChangePass(new SecurityBSO().EncPwd(News_Pass.Text.Trim()), new SecurityBSO().EncPwd(txtOldPass.Text.Trim()), m_UserValidation.UserId);
         if (ret > 0)
         {
             clientview.Text = "<div class='alert alert-sm alert-success bg-gradient'>Đổi mật khẩu thành công !</div>";
         }
         else
         {
             clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Đổi mật khẩu không thành công. Vui lòng thử lại hoặc liên hệ bộ phận quản trị !</div>";
         }
         initControl();
     }
     catch (Exception ex)
     {
         clientview.Text = ex.Message.ToString();
     }
 }
Exemple #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string Id = "";

        if (!string.IsNullOrEmpty(Request["Id"]))
        {
            Id = Request["Id"].Replace(",", "");
        }
        if (!string.IsNullOrEmpty(Request["dll"]))
        {
            NavigationTitle(Request["dll"]);
        }

        hddUserName.Value = Id;
        AdminBSO adminBSO = new AdminBSO();

        if (!IsPostBack)
        {
            ltlTitle.Text = adminBSO.GetAdminById(Convert.ToInt32(Id)).AdminName;
            initControl(Id);
        }
    }
    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);
    }
    protected void initControl()
    {
        string   adminName = Session["Admin_Username"].ToString();
        AdminBSO adminBSO  = new AdminBSO();
        Admin    admin     = adminBSO.GetAdminById(adminName);

        /* if (admin.AdminLoginType)
         * {
         *   News_Pass.ReadOnly = false;
         *   Re_Pass.ReadOnly = false;
         * }
         * else
         * {
         *   News_Pass.ReadOnly = true;
         *   Re_Pass.ReadOnly = true;
         *   CompareValidator1.Visible = false;
         *   CompareValidator2.Visible = false;
         *   RequiredFieldValidator1.Visible = false;
         *   RequiredFieldValidator2.Visible = false;
         * }*/

        hddAdminLoginType.Value = Convert.ToString(admin.AdminLoginType);
        txtAdminUser.Text       = adminName;
        txtAdminEmail.Text      = admin.AdminEmail;
        hddRoles_ID.Value       = admin.RolesID.ToString();
        hddActied.Value         = admin.AdminActive.ToString();
        txtFullName.Text        = admin.AdminFullName;
        hdd_Created.Value       = admin.AdminCreated.ToString();
        hdd_log.Value           = admin.AdminLog.ToString();
        hddPermission.Value     = admin.AdminPermission;

        hddAddress.Value    = admin.AdminAddress;
        hddBirth.Value      = admin.AdminBirth.ToString();
        hddSex.Value        = admin.AdminSex.ToString();
        hddNickYahoo.Value  = admin.AdminNickYahoo;
        hddNickSkype.Value  = admin.AdminNickSkype;
        hddPhone.Value      = admin.AdminPhone;
        hddImageThumb.Value = admin.AdminAvatar;
    }
Exemple #19
0
    protected void grvAdmin_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        string aId   = e.CommandArgument.ToString();
        string aName = e.CommandName.ToLower();

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

        case "_edit":
            Response.Redirect("~/Admins/editadmin/" + aId + "/Default.aspx");
            break;

        case "_delete":
            AdminBSO adminBSO = new AdminBSO();
            adminBSO.DeleteAdmin(Convert.ToInt32(aId));
            ViewAdmin();
            break;
        }
    }
Exemple #20
0
    protected void btn_edit_Click(object sender, EventArgs e)
    {
        Admin admin = ReceiveHtml();

        try
        {
            if (CheckedList().Equals(""))
            {
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Lỗi: Phải lựa chọn ít nhất 1 quyền !</div>";
            }
            else
            {
                AdminBSO adminBSO = new AdminBSO();
                adminBSO.UpdateAdmin(admin);
                error.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật thành công !</div>";
                initControl(admin.AdminID);
            }
        }
        catch (Exception ex)
        {
            error.Text = ex.Message.ToString();
        }
    }
    private void initControl(int Id)
    {
        AdminBSO adminBSO = new AdminBSO();
        Admin    admin    = new Admin();

        if (Id > 0)
        {
            btn_add.Visible   = false;
            btn_edit.Visible  = true;
            btn_add2.Visible  = false;
            btn_add1.Visible  = false;
            btn_edit1.Visible = true;
            try
            {
                NewsGroup    newsgroup    = new NewsGroup();
                NewsGroupBSO newsgroupBSO = new NewsGroupBSO();
                newsgroup                 = newsgroupBSO.GetNewsGroupById(Id);
                hddNewsGroupID.Value      = Convert.ToString(newsgroup.NewsGroupID);
                ddlCateNews.SelectedValue = Convert.ToString(newsgroup.CateNewsID);
                hddParentNewsID.Value     = Convert.ToString(newsgroup.ParentNewsID);

                //rdbGroupCate.SelectedValue = Convert.ToString(newsgroup.GroupCate); //Thêm

                txtTitle.Text       = newsgroup.Title;
                txtRadShort.Text    = System.Net.WebUtility.HtmlDecode(newsgroup.ShortDescribe);
                txtRadFull.Text     = newsgroup.FullDescribe;
                hddImageThumb.Value = newsgroup.ImageThumb;
                hddImageLarge.Value = newsgroup.ImageLarge;

                txtimage4_3.Text  = newsgroup.ImageThumb;
                txtimage16_9.Text = newsgroup.ImageLarge;

                if (newsgroup.ImageThumb != "")
                {
                    img_thumb.Text = "<img src='" + newsgroup.ImageThumb + "' width='48px' valign='middle'>";
                }
                if (newsgroup.ImageLarge != "")
                {
                    img_large.Text = "<img src='" + newsgroup.ImageLarge + "' width='48px' valign='middle'>";
                }


                hddFileName.Value = newsgroup.FileName;

                txtAuthor.Text         = newsgroup.Author;
                txtRadDate.Text        = String.Format("{0:dd/MM/yyyy HH:mm}", newsgroup.PostDate); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString();
                hddPostDate.Value      = String.Format("{0:dd/MM/yyyy HH:mm}", newsgroup.PostDate); // "9/3/2008 16:05:07" .ToString();
                hddRelationTotal.Value = Convert.ToString(newsgroup.RelationTotal);
                rdbStatus.Checked      = newsgroup.Status;
                rdbIshot.Checked       = newsgroup.Ishot;
                rdbIshome.Checked      = newsgroup.Ishome;


                hddCommentTotal.Value     = Convert.ToString(newsgroup.CommentTotal);
                hddIsView.Value           = Convert.ToString(newsgroup.Isview);
                hddCreateUserName.Value   = newsgroup.CreatedUserName;
                hddApprovalUserName.Value = newsgroup.ApprovalUserName;
                hddApprovalDate.Value     = Convert.ToString(newsgroup.ApprovalDate);

                txtKeywords.Text = newsgroup.Keyword;
                txtTags.Text     = newsgroup.Tags;
                txtSlug.Text     = newsgroup.Slug;

                rdbComment.Checked = newsgroup.IsComment;

                rdbApproval.Checked = newsgroup.IsApproval;

                if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
                {
                    rdbApproval.Enabled = true;
                }
                else
                {
                    rdbApproval.Enabled = false;
                }

                //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

                //if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
                //{
                //    rdbApproval.Checked = newsgroup.IsApproval;
                //    rdbApproval.Enabled = true;
                //}
                //else
                //{
                //    rdbApproval.Checked = newsgroup.IsApproval;
                //    rdbApproval.Enabled = false;
                //}

                hddGroup.Value = newsgroup.GroupCate.ToString();
                BindToCateNews(newsgroup.GroupCate);
                ddlCateNewsGroup.SelectedValue = hddGroup.Value;
                ddlCateNews.SelectedValue      = Convert.ToString(newsgroup.CateNewsID);

                rdbTypeNews.Checked = newsgroup.TypeNews;

                txtShortTitle.Text = newsgroup.ShortTitle;
                chkUrl.Checked     = newsgroup.isUrl;
                txtUrl.Text        = newsgroup.Url;
                if (newsgroup.isUrl)
                {
                    txtUrl.Visible   = true;
                    panelUrl.Visible = true;
                }
                else
                {
                    txtUrl.Visible   = false;
                    panelUrl.Visible = false;
                }
                hddisDelete.Value = newsgroup.isDelete.ToString();
                BindListCate(newsgroup.NewsGroupID); //MultiCate
                ViewNewsLog(newsgroup.NewsGroupID);
            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }
        }
        else
        {
            txtRadDate.Text   = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString();
            hddPostDate.Value = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); // "9/3/2008 16:05:07" .ToString();

            txtUrl.Visible    = false;
            btn_add.Visible   = true;
            btn_edit.Visible  = false;
            btn_add2.Visible  = true;
            btn_add1.Visible  = true;
            btn_edit1.Visible = false;
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
            {
                rdbApproval.Enabled = true;
            }
            else
            {
                rdbApproval.Enabled = false;
            }
            txtUrl.Visible   = false;
            panelUrl.Visible = false;
            chkUrl.Checked   = false;
        }
    }
Exemple #22
0
    private void BindData()
    {
        ReportFuelService comBSO = new ReportFuelService();
        DataTable         list   = new DataTable();
        int  AreaId    = 0;
        int  SubAreaId = 0;
        int  Year      = 0;
        bool?status    = null;

        if (ddlStatus.SelectedIndex > 0)
        {
            status = (ddlStatus.SelectedValue == "1");
        }
        if (ddlYear.SelectedIndex > 0)
        {
            Year = Convert.ToInt32(ddlYear.SelectedValue);
        }
        int orgid = 0;

        if (ddlOrg.SelectedIndex > 0)
        {
            orgid = Convert.ToInt32(ddlOrg.SelectedValue);
        }
        if (ddlArea.SelectedIndex > 0)
        {
            AreaId = Convert.ToInt32(ddlArea.SelectedValue);
        }
        if (ddlSubArea.SelectedIndex > 0)
        {
            SubAreaId = Convert.ToInt32(ddlSubArea.SelectedValue);
        }
        Admin admin = new AdminBSO().GetAdminById(m_UserValidation.UserId);

        ePower.Core.PagingInfo paging = new ePower.Core.PagingInfo(PageSize, CurrentPage);
        list = comBSO.FindList(false, AreaId, SubAreaId, orgid, 0, 0, 0, -1, status, Year, null, null, txtKeyword.Text.Trim(), paging);
        if (list != null && list.Rows.Count > 0)
        {
            paging.RowsCount   = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging.PageSize    = PageSize;
            Paging.CurrentPage = CurrentPage;
            Paging.TotalRecord = Convert.ToInt32(list.Rows[0]["Total"]);
            Paging.DataLoad();
            if (paging.PagesCount <= 1)
            {
                ltNotice.Text  = "Có tổng số " + paging.RowsCount + " báo cáo";
                Paging.Visible = false;
            }
            else
            {
                ltNotice.Text  = "Có " + list.Rows.Count + " trong tổng số " + paging.RowsCount + " báo cáo";
                Paging.Visible = true;
            }
        }
        else
        {
            ltNotice.Text  = "";
            Paging.Visible = false;
        }
        rptNoFuelCurrent.DataSource = list;

        rptNoFuelCurrent.DataBind();
    }
Exemple #23
0
    protected void initControl(int Id)
    {
        if (Id > 0)
        {
            hddAdmin_Id.Value = Id.ToString();
            btn_add.Visible   = false;
            btn_edit.Visible  = true;

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


            try
            {
                AdminBSO adminBSO = new AdminBSO();
                Admin    admin    = adminBSO.GetAdminById(Id);

                hddAdmin_Username.Value = admin.AdminName;
                txtAdminName.Text       = admin.AdminName;
                txtAdminName.Enabled    = false;
                hddPass.Value           = admin.AdminPass;


                txtFullName.Text   = admin.AdminFullName;
                txtAdminEmail.Text = admin.AdminEmail;

                rdbList.Checked   = admin.AdminActive;
                hdd_Created.Value = admin.AdminCreated.ToString();
                hdd_log.Value     = admin.AdminLog.ToString();

                ViewPermission();
                string sPermission = admin.AdminPermission;
                if (!sPermission.Equals(""))
                {
                    string[] sSlip = sPermission.Split(new char[] { ',' });
                    foreach (string s in sSlip)
                    {
                        foreach (ListItem items in chklist.Items)
                        {
                            if (items.Value == s)
                            {
                                items.Selected = true;
                            }
                        }
                    }
                }

                txtAddress.Text   = admin.AdminAddress;
                txtBirth.Text     = String.Format("{0:dd/MM/yyyy HH:mm}", admin.AdminBirth);
                rdbSex.Checked    = admin.AdminSex;
                txtNickYahoo.Text = admin.AdminNickYahoo;
                txtNickSkype.Text = admin.AdminNickSkype;
                txtPhone.Text     = admin.AdminPhone;

                rdbLoginType.Checked = admin.AdminLoginType;
                rdbLoginType.Enabled = false;


                hddImageThumb.Value = admin.AdminAvatar;
                if (admin.AdminOrganizationId > 0)
                {
                    ddlOrg.SelectedValue = admin.AdminOrganizationId.ToString();
                }
                txtimage4_3.Text = admin.AdminAvatar;

                if (admin.AdminAvatar != "")
                {
                    img_thumb.Text = "<img src='" + admin.AdminAvatar + "' width='48px' valign='middle'>";
                }
            }
            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;

            ViewPermission();
        }
    }
Exemple #24
0
    protected void initControl(int Id)
    {
        //txtContent.DisableFilter(Telerik.Web.UI.EditorFilters.ConvertCharactersToEntities);

        AdminBSO adminBSO = new AdminBSO();
        Admin    admin    = new Admin();

        if (Id > 0)
        {
            btn_add.Visible  = false;
            btn_edit.Visible = true;

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

            hddCommentID.Value = Convert.ToString(Id);
            try
            {
                NewsCommentBSO newsCommentBSO = new NewsCommentBSO();
                NewsComment    newsComment    = newsCommentBSO.GetNewsCommentById(Id);
                txtTitle.Text       = newsComment.Title;
                txtFullName.Text    = newsComment.FullName;
                hddNewsID.Value     = Convert.ToString(newsComment.NewsID);
                txtContent.Text     = newsComment.Content;
                txtDateCreated.Text = String.Format("{0:dd/MM/yyyy HH:mm}", newsComment.DateCreated); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString();
                hddPostDate.Value   = String.Format("{0:dd/MM/yyyy HH:mm}", newsComment.DateCreated); // "9/3/2008 16:05:07" .ToString();

                txtEmail.Text = newsComment.Email;
                //       rdbActive.SelectedValue = newsComment.Actived.ToString();
                hddGroup.Value = newsComment.GroupCate.ToString();

                hddApprovalUserName.Value = newsComment.ApprovalUserName;
                hddApprovalDate.Value     = Convert.ToString(newsComment.ApprovalDate);

                admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

                if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
                {
                    rdbActive.Checked = newsComment.Actived;
                    rdbActive.Enabled = true;
                }
                else
                {
                    rdbActive.Checked = newsComment.Actived;
                    rdbActive.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }
        }
        else
        {
            btn_add.Visible  = true;
            btn_edit.Visible = false;

            btn_add1.Visible  = true;
            btn_edit1.Visible = false;
            //     hddNewsID = 0;
            txtDateCreated.Text = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); //DateTime.Parse(newsgroup.PostDate.ToString()).ToString("dd/MM/yyyy hh:mm", ci); // newsgroup.PostDate.ToString();
            hddPostDate.Value   = String.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Now); // "9/3/2008 16:05:07" .ToString();

            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
            {
                rdbActive.Enabled = true;
            }
            else
            {
                rdbActive.Enabled = false;
            }
        }
    }
Exemple #25
0
    protected void btn_sumit_Click(object sender, EventArgs e)
    {
        AdminBSO adminBSO = new AdminBSO();

        if (Session["LoginCount"] != null)
        {
            Session["LoginCount"] = Convert.ToInt32(Session["LoginCount"].ToString()) + 1;
        }
        int n = Convert.ToInt32(Session["LoginCount"].ToString());

        if (!txtAdminUser.Text.Contains("\\"))
        {
            Admin objUser = adminBSO.GetAdminByAccountPass(txtAdminUser.Text.Trim(), txtAdminPass.Text.Trim());

            if (objUser != null)
            {
                if (objUser.AdminActive == false)
                {
                    Tool.Message(this.Page, "Tài khoản này chưa được kích hoạt! Xin liên hệ với quản trị hệ thống");
                    return;
                }
                else
                {
                    //ducnmi - capcha
                    if (Convert.ToInt32(Session["LoginCount"].ToString()) > 3)
                    {
                        if (Session["Random"] != null && txtCapcha.Text.ToLower() == Session["Random"].ToString().ToLower())
                        {
                            Session["LoginCount"] = null;
                        }
                        else
                        {
                            Tool.Message(this.Page, "Mã xác nhận sai!");
                            return;
                        }
                    }

                    m_UserValidation.SignIn(txtAdminUser.Text.Trim(), objUser.AdminID.ToString(), objUser.AdminOrganizationId, Session.SessionID, ((objUser.AdminName == "administrator") ? true : false));

                    if (Request.QueryString["url"] != null && Request.QueryString["url"] != string.Empty)
                    {
                        Response.Redirect((Request.QueryString["url"]));
                    }
                    else
                    {
                        Response.Redirect(Request.RawUrl);
                    }
                }
            }
            else
            {
                Tool.Message(this.Page, "Tài khoản hoặc mật khẩu không đúng! Xin vui lòng nhập lại");
                return;
            }
        }
        else
        {
            if (ConfigurationManager.AppSettings.Get("isLDAP").ToString() == "1")
            {
                //Path to your LDAP directory server
                string adPath = ConfigurationManager.AppSettings.Get("LdapDomain").ToString();

                LdapAuthentication adAuth = new LdapAuthentication(adPath);
                try
                {
                    if (txtAdminUser.Text.IndexOf("\\") > 0)
                    {
                        string domainName = txtAdminUser.Text.Substring(0, txtAdminUser.Text.IndexOf("\\"));
                        if (adAuth.IsAuthenticated(txtAdminUser.Text.Substring(0, txtAdminUser.Text.IndexOf("\\")), txtAdminUser.Text.Substring(txtAdminUser.Text.IndexOf("\\") + 1), txtAdminPass.Text))
                        {
                            Admin user = adminBSO.GetAdminById(txtAdminUser.Text.Trim());
                            if (user != null)
                            {
                                //ducnmi - capcha
                                if (Convert.ToInt32(Session["LoginCount"].ToString()) > 3)
                                {
                                    if (txtCapcha.Text.ToLower() == Session["Random"].ToString().ToLower())
                                    {
                                        Session["LoginCount"] = null;
                                    }
                                    else
                                    {
                                        Tool.Message(this.Page, "Mã xác nhận sai!");
                                        return;
                                    }
                                }

                                m_UserValidation.SignIn(txtAdminUser.Text.Trim(), user.AdminID.ToString(), user.AdminOrganizationId, Session.SessionID, ((user.AdminName == "administrator") ? true : false));
                                //string groups = adAuth.GetGroups();
                                ////Create the ticket, and add the groups.
                                //bool isCookiePersistent = true;
                                //FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1,
                                //          txtAdminUser.Text.Substring(txtAdminUser.Text.IndexOf("\\") + 1), DateTime.Now, DateTime.Now.AddMinutes(60), isCookiePersistent, groups);

                                ////Encrypt the ticket.
                                //string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

                                ////Create a cookie, and then add the encrypted ticket to the cookie as data.
                                //HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

                                //if (true == isCookiePersistent)
                                //    authCookie.Expires = authTicket.Expiration;

                                ////Add the cookie to the outgoing cookies collection.
                                //Response.Cookies.Add(authCookie);

                                if (Request.QueryString["url"] != null && Request.QueryString["url"] != string.Empty)
                                {
                                    Response.Redirect((Request.QueryString["url"]));
                                }
                                else
                                {
                                    Response.Redirect(Request.RawUrl);
                                }
                            }
                            else
                            {
                                Tool.Message(this.Page, "Tài khoản hoặc mật khẩu không đúng! Xin vui lòng nhập lại");
                                return;
                            }
                        }
                        else
                        {
                            Tool.Message(this.Page, "Tài khoản hoặc mật khẩu không đúng! Xin vui lòng nhập lại");
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Tool.Message(this.Page, "Tài khoản hoặc mật khẩu không đúng! Xin vui lòng nhập lại");
                    return;
                }
            }
            else
            {
                string sTen_TCap = this.Get_DomainAccount();

                if (sTen_TCap != "")
                {
                    string text1 = this.txtAdminUser.Text;
                    string str   = "";
                    str = text1;
                    string[] strArray = text1.Split(new char[1] {
                        '\\'
                    });
                    string lpszDomain;
                    string lpszUsername;
                    if (strArray.Length == 2)
                    {
                        lpszDomain   = strArray[0];
                        lpszUsername = strArray[1];
                    }
                    else
                    {
                        lpszDomain   = ((object)ConfigurationManager.AppSettings.Get("DomainName")).ToString();
                        lpszUsername = text1;
                    }

                    //Tool.Message(this.Page, "TK1: " + lpszDomain +"\\"+lpszUsername );

                    Admin user = adminBSO.GetAdminById(txtAdminUser.Text.Trim());
                    // User user = new UserService().FindByUserName(this.txtAdminUser.Text);
                    if (user != null)
                    {
                        //ducnmi - capcha
                        if (Convert.ToInt32(Session["LoginCount"].ToString()) > 3)
                        {
                            if (txtCapcha.Text.ToLower() == Session["Random"].ToString().ToLower())
                            {
                                Session["LoginCount"] = null;
                            }
                            else
                            {
                                Tool.Message(this.Page, "Mã xác nhận sai!");
                                return;
                            }
                        }

                        m_UserValidation.SignIn(txtAdminUser.Text.Trim(), user.AdminID.ToString(), user.AdminOrganizationId, Session.SessionID, ((user.AdminName == "administrator") ? true : false));


                        if (Request.QueryString["url"] != null && Request.QueryString["url"] != string.Empty)
                        {
                            Response.Redirect((Request.QueryString["url"]));
                        }
                        else
                        {
                            Response.Redirect(Request.RawUrl);
                        }
                    }
                    else
                    {
                        Tool.Message(this.Page, "Tài khoản hoặc mật khẩu không đúng! Xin vui lòng nhập lại");
                        return;
                    }
                }
                else
                {
                    Tool.Message(this.Page, "Tài khoản hoặc mật khẩu không đúng! Xin vui lòng nhập lại");
                    return;
                }
            }
        }
    }
    protected void grvNewsGroup_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int          Id           = Convert.ToInt32(e.CommandArgument.ToString());
        NewsGroupBSO newsGroupBSO = new NewsGroupBSO();
        NewsGroup    newsgroup    = newsGroupBSO.GetNewsGroupById(Id);

        string   nName    = e.CommandName.ToLower();
        AdminBSO adminBSO = new AdminBSO();
        Admin    admin    = new Admin();

        switch (nName)
        {
        case "_listfiles":
            //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                Response.Redirect("~/Admin/listnewsfiles/" + Id + "/Default.aspx");
            }
            break;

        case "_addfiles":
            //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                Response.Redirect("~/Admin/editnewsfiles/" + Id + "/0/Default.aspx");
            }
            break;

        case "_relation":
            //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                Response.Redirect("~/Admin/EditNewsRelation/" + Id + "/Default.aspx");
            }
            break;

        case "_view":
            break;

        case "_edit":

            //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());
            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                Response.Redirect("~/Admin/editnewsbyuser/" + Id + "/Default.aspx");
            }
            break;

        case "_delete":
            //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
            {
                //newsGroupBSO.DeleteNewsGroup(Id);
                newsGroupBSO.UpdateNewsGroupisDelete(Id, "1");
                ViewNewsGroup(Convert.ToInt32(ddlCateNewsGroup.SelectedValue));

                //NewsCateBSO newscateBSO = new NewsCateBSO();

                //if (newscateBSO.GetNewsCateByNewsGroupID(Id).Rows.Count > 0)
                //    newscateBSO.DeleteNewsCatebyNewsID(Id);

                AspNetCache.Reset();
            }
            break;

        case "_approved":
            //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

            if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
            {
                newsGroupBSO.UpdateNewsGroupApproval(Id, "1", Session["Admin_Username"].ToString(), DateTime.Now);
                ViewNewsGroup(Convert.ToInt32(ddlCateNewsGroup.SelectedValue));

                AspNetCache.Reset();
            }
            break;

        case "_approvedcomment":
            break;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request["dll"]))
        {
            NavigationTitle(Request["dll"]);
        }

        int group = -1;

        if (!String.IsNullOrEmpty(Request["group"]))
        {
            int.TryParse(Request["group"].Replace(",", ""), out group);
        }
        hddGroup.Value = Convert.ToString(group);

        int Id = -1;

        if (!String.IsNullOrEmpty(Request["Id"]))
        {
            int.TryParse(Request["Id"].Replace(",", ""), out Id);
        }

        hddNewsID.Value = Convert.ToString(Id);

        //  ltllistnews.Text = "<asp:HyperLink ID='btn_listnews' runat='server' NavigateUrl='~/Homepage.aspx?dll=" + ((group == 1) ? "listnews" : "listannounce") + "'><img src='Admin_Theme/Icons/icon-danhsach.gif' /></asp:HyperLink>";
        //  ltleditcomment.Text = "<asp:HyperLink ID='btn_editnewscomment' runat='server' NavigateUrl='~/Homepage.aspx?dll=editnewscomment&group=" + Convert.ToString(group) + "' ><img src='Admin_Theme/Icons/icon-taomoi-small.gif' /></asp:HyperLink>";

        AdminBSO adminBSO = new AdminBSO();

        //Admin admin = new Admin();
        //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString());

        if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Edit") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Write"))
        {
            btn_editpage.Visible = true;

            btn_delall.Visible = true;
        }
        else
        {
            btn_editpage.Visible = false;

            btn_delall.Visible = false;
        }

        if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval"))
        {
            btn_enable.Visible  = true;
            btn_disable.Visible = true;
        }
        else
        {
            btn_enable.Visible  = false;
            btn_disable.Visible = false;
        }


        if (!IsPostBack)
        {
            NewsCommentView(group);
        }
    }
    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);
        }
    }
Exemple #29
0
    public bool CheckLogin()
    {
        AdminBSO adminBSO = new AdminBSO();

        return(adminBSO.CheckLoginAdmin(txtAdminUser.Text.Trim(), txtAdminPass.Text.Trim()));
    }
Exemple #30
0
    public bool CheckUserName()
    {
        AdminBSO adminBSO = new AdminBSO();

        return(adminBSO.CheckUserName(txtAdminUser.Text.Trim()));
    }