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; }
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); } }
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(); } }
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 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; } } }
private void initControl(int Id) { //txtRadShort.DisableFilter(Telerik.Web.UI.EditorFilters.ConvertCharactersToEntities); //txtRadFull.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_add2.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; 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_add1.Visible = true; btn_add2.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; } }
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/editnews/" + 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, "0", Session["Admin_Username"].ToString(), DateTime.Now); ViewNewsGroup(Convert.ToInt32(ddlCateNewsGroup.SelectedValue)); AspNetCache.Reset(); } break; case "_lock": //admin = adminBSO.GetAdminById(Session["Admin_UserName"].ToString()); if (Session["Admin_UserName"].ToString().Equals("administrator") || adminBSO.CheckPermission(Session["Admin_UserName"].ToString(), "Approval")) { newsGroupBSO.UpdateNewsGroup(Id, "0"); ViewNewsGroup(Convert.ToInt32(ddlCateNewsGroup.SelectedValue)); AspNetCache.Reset(); } break; case "_approvedcomment": break; } }