//保存 protected void Button_Save_Click(object sender, EventArgs e) { if (this.Session["hyuid"].ToString() == "") this.Response.Redirect("/login.aspx"); string ls_tip = "保存成功!"; //新文档时 HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); HyoaClass.Hyoa_license Hyoa_license = new HyoaClass.Hyoa_license(); if (this.txtop.Value == "add") { Hyoa_license.ID = Hyoa_global.GetRandom(); Hyoa_license.hy_sqrid = this.txthy_sqrid.Value; Hyoa_license.hy_sqrname = this.txthy_sqrname.Text; Hyoa_license.hy_starttime = this.txthy_starttime.Value; Hyoa_license.hy_endtime = this.txthy_endtime.Value; Hyoa_license.hy_bsqrid = this.txthy_bsqrid.Value; Hyoa_license.hy_bsqrname = this.txthy_bsqrname.Value; Hyoa_license.hy_isenabled = this.ddlisenabled.SelectedValue; Hyoa_license.hy_createtime = System.DateTime.Now.ToString(); Hyoa_license.Insert(); } else { Hyoa_license.ID = this.txtdocid.Value; Hyoa_license.hy_isenabled = this.ddlisenabled.SelectedValue; Hyoa_license.Update(); } //处理完成后的提示及跳转 if (this.txtifpop.Value == "") { Response.Write("<script>alert('" + ls_tip + "');window.location='" + this.txturl.Value + "'</script>"); } else { Response.Write("<script>alert('" + ls_tip + "');self.close();</script>"); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { if (this.Session["hyuid"].ToString() != "") { HyoaClass.Hyoa_license Hyoa_license = new HyoaClass.Hyoa_license(); DataTable dtlicense = Hyoa_license.Getlicensesbybsquseridanddate(this.Session["hyuid"].ToString()); if (dtlicense.Rows.Count > 0) { this.rdsqyh.DataSource = dtlicense; this.rdsqyh.DataTextField = "hy_sqrname"; this.rdsqyh.DataValueField = "hy_sqrid"; this.rdsqyh.DataBind(); this.rdsqyh.Items.Insert(0, new ListItem(this.Session["hyuname"].ToString(), this.Session["hyuid"].ToString())); this.rdsqyh.SelectedIndex = 0; } } } }
//protected string IPlimted() //{ //IP限制 //string lscurip, configip, lsflag; //lsflag = "0"; //lscurip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; ////return; //MagicPortalClass.DAO dbconfigip = new MagicPortalClass.DAO(); //DataTable dtconfigip = dbconfigip.GetDataTable("select * from JpConfig where fdtype='ip'"); //configip = dtconfigip.Rows[0]["fdname"].ToString(); //dtconfigip.Clear(); //dbconfigip.Close(); //string[] lvconfigip = configip.Split(','); //for (var i = 0; i < lvconfigip.Length; i++) //{ // if (lvconfigip[i].Contains("-") == true) // { // string[] lvconfigipsub = lvconfigip[i].Split('-'); // string[] lvconfigipsub1 = lvconfigipsub[0].Split('.'); // string[] lvconfigipsub2 = lvconfigipsub[1].Split('.'); // string[] lvcurip = lscurip.Split('.'); // if (lvcurip[0] == lvconfigipsub1[0] & lvcurip[1] == lvconfigipsub1[1] & lvcurip[2] == lvconfigipsub1[2] & lvcurip[0] == lvconfigipsub2[0] & lvcurip[1] == lvconfigipsub2[1] & lvcurip[2] == lvconfigipsub2[2]) // { // if ((int.Parse(lvcurip[3]) >= int.Parse(lvconfigipsub1[3]) & int.Parse(lvcurip[3]) <= int.Parse(lvconfigipsub2[3]))) // { // lsflag = "1"; // break; // } // else // { // continue; // } // } // else // { // continue; // } // } // else // { // if (lvconfigip[i] == lscurip) // { // lsflag = "1"; // break; // } // } //} //return lsflag; ////this.aaaa.Value = lscurip; ///////////IP限制结束 //} protected void btnLogin_Click(object sender, EventArgs e) { //if (Session["checkcode"].ToString().Equals(this.txt_checkcode.Value)) //{ String password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_password.Value, "MD5"); HyoaClass.Hyoa_user Users = new HyoaClass.Hyoa_user(); //Response.Write("<script>alert('aaaa');</script>"); if (Users.Login(this.txt_username.Value, password)) { // Response.Write("<script>alert('bbb');</script>"); DataTable dt = Users.Getuserallinfo(this.txt_username.Value); if (dt.Rows.Count > 0) { Session["hyuid"] = this.txt_username.Value; Session["hyuname"] = dt.Rows[0]["hy_username"].ToString(); Session["hydeptid"] = dt.Rows[0]["hy_deptid"].ToString(); Session["hydeptname"] = dt.Rows[0]["hy_deptname"].ToString(); //登录日志 start string ls_oppcontent = this.Session["hyuname"].ToString() + "登录"; HyoaClass.Hyoa_log Hyoa_log = new HyoaClass.Hyoa_log(); Hyoa_log.ID = System.Guid.NewGuid().ToString(); Hyoa_log.hy_createtime = System.DateTime.Now.ToString(); string userip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (userip == null || userip == "") { userip = Request.ServerVariables["REMOTE_ADDR"]; } Hyoa_log.hy_oppip = userip; Hyoa_log.hy_opptype = "登录"; Hyoa_log.hy_oppcontent = ls_oppcontent; Hyoa_log.hy_oppuserid = this.Session["hyuid"].ToString(); Hyoa_log.hy_oppusername = this.Session["hyuname"].ToString(); Hyoa_log.Insert(); //登录日志 end HyoaClass.Hyoa_license Hyoa_license = new HyoaClass.Hyoa_license(); DataTable dtlicense = Hyoa_license.Getlicensesbybsquseridanddate(this.Session["hyuid"].ToString()); if (dtlicense.Rows.Count > 0) { this.rdsqyh.DataSource = dtlicense; this.rdsqyh.DataTextField = "hy_sqrname"; this.rdsqyh.DataValueField = "hy_sqrid"; this.rdsqyh.DataBind(); this.rdsqyh.Items.Insert(0, new ListItem(this.Session["hyuname"].ToString(), this.Session["hyuid"].ToString())); this.rdsqyh.SelectedIndex = 0; this.table3.Visible = true; } else { this.Response.Redirect(this.lblurl.Text); } } dt.Clear(); } else { this.RegisterClientScriptBlock("scripterror", "<script language=javascript>alert('输入的用户名或者密码不正确!')</script>"); return; } }
private void DataPlay() { this.ddlisenabled.Items.Insert(0, "是"); this.ddlisenabled.Items.Insert(1, "否"); if (this.Request.QueryString["op"] != null) { this.txtop.Value = this.Request.QueryString["op"].ToString(); //新增还是修改 ////判断当前用户是否有保存的权限 //HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global(); //if (Hyoa_global.isHaveRole("Role9999", this.Session["hyuid"].ToString())) //{ this.btn_submit.Visible = true; //保存 //} //else //{ // this.btn_submit.Visible = false; //保存 //} if (this.Request.QueryString["op"] == "add") { HyoaClass.Hyoa_user Hyoa_user = new HyoaClass.Hyoa_user(); DataTable dt2 = Hyoa_user.Getuser(this.Session["hyuid"].ToString()); this.txthy_sqrid.Value = this.Session["hyuid"].ToString(); this.txthy_sqrname.Text = dt2.Rows[0]["hy_username"].ToString(); this.txtcurdate.Value = System.DateTime.Now.ToString("yyyy-MM-dd"); dt2.Clear(); } //旧文档 if (this.Request.QueryString["op"] == "modify") { if (this.Request.QueryString["id"] != null) { //根据id得到信息 this.txtdocid.Value = this.Request.QueryString["id"].ToString(); HyoaClass.Hyoa_license Hyoa_license = new HyoaClass.Hyoa_license(); DataTable dt = Hyoa_license.Getlicense(this.txtdocid.Value); if (dt.Rows.Count > 0) { this.txthy_sqrid.Value = dt.Rows[0]["hy_sqrid"].ToString(); this.txthy_sqrname.Text = dt.Rows[0]["hy_sqrname"].ToString(); this.txthy_bsqrid.Value = dt.Rows[0]["hy_bsqrid"].ToString(); this.txthy_bsqrname.Value = dt.Rows[0]["hy_bsqrname"].ToString(); this.txthy_starttime.Value = Convert.ToDateTime(dt.Rows[0]["hy_starttime"].ToString()).ToString("yyyy-MM-dd"); this.txthy_endtime.Value = Convert.ToDateTime(dt.Rows[0]["hy_endtime"].ToString()).ToString("yyyy-MM-dd"); if (dt.Rows[0]["hy_isenabled"].ToString() == "是") this.ddlisenabled.SelectedIndex = 0; else this.ddlisenabled.SelectedIndex = 1; } //this.txthy_bsqrname.Enabled = false; //this.txthy_starttime.Enabled = false; //this.txthy_endtime.Enabled = false; this.btnstartdate.Visible = false; this.btnenddate.Visible = false; //this.bt this.btnseluser.Visible = false; dt.Clear(); } } } }
private void DataPlay(int PageNo) { this.isrole.Value = "1"; this.tdnewdoc.Visible = true; //新建 //得到当前页号 this.curpage.Text = PageNo.ToString(); HyoaClass.Hyoa_license Hyoa_license = new HyoaClass.Hyoa_license(); DataTable dt; dt = Hyoa_license.Getlicensesbyuserid (this.Session["hyuid"].ToString()); DataTable tempTable = dt.Clone(); for (int i = (PageNo - 1) * System.Int32.Parse(PageSize.Text); i < PageNo * System.Int32.Parse(PageSize.Text); i++) { if (i > dt.Rows.Count - 1) break; DataRow dr = tempTable.NewRow(); for (int j = 0; j < dt.Columns.Count; j++) { dr[dt.Columns[j].ColumnName] = dt.Rows[i][j]; } tempTable.Rows.Add(dr); } int TotalRecord = dt.Rows.Count; this.sumts.Text = TotalRecord.ToString(); this.sumts2.Text = TotalRecord.ToString(); this.ShowTotalRecord.Text = TotalRecord.ToString(); //计算及显示总页数 int TotalPage; if (TotalRecord < System.Int32.Parse(PageSize.Text)) { TotalPage = 1; } else { if (TotalRecord % System.Int32.Parse(PageSize.Text) != 0) { TotalPage = TotalRecord / System.Int32.Parse(PageSize.Text) + 1; } else { TotalPage = TotalRecord / System.Int32.Parse(PageSize.Text); } } this.ShowTotalPage.Text = TotalPage.ToString(); this.rptlist.DataSource = tempTable; this.rptlist.DataBind(); dt.Clear(); }
/// <summary> /// 认证模式,密码是明码格式还是MD5格式 /// pi_type 0:密码是明码格式 1:密码是MD5格式 /// </summary> /// <param name="pi_type"></param> private void LoginCommand(string pi_type) { //if (Session["checkcode"].ToString().Equals(this.txt_checkcode.Value)) String password = ""; if (pi_type == "0") { password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txt_password.Value, "MD5"); } if (pi_type == "1") { password = this.txt_password.Value.ToUpper(); } HyoaClass.Hyoa_user Users = new HyoaClass.Hyoa_user(); if (Users.Login(this.txt_username.Value.ToLower(), password)) { DataTable dt = Users.Getuserallinfobyloginid(this.txt_username.Value.ToLower()); if (dt.Rows.Count > 0) { if (dt.Rows[0]["hy_isenabled"].ToString() == "否") { //账号被禁用了 Response.Write("<script>alert('该账号已被禁用,请联系管理员!');</script>"); } else { Session["hyuid"] = this.txt_username.Value.ToLower(); Session["hyuname"] = dt.Rows[0]["hy_username"].ToString(); Session["hydeptid"] = dt.Rows[0]["hy_deptid"].ToString(); Session["hydeptname"] = dt.Rows[0]["hy_deptname"].ToString(); Session["hypost"] = dt.Rows[0]["hy_post"].ToString(); //得到兼职 DataTable dt_jz = Users.Getjzinfobyuserid(this.txt_username.Value.ToLower()); if (dt_jz.Rows.Count > 0) { Session["hydeptids_jz"] = ""; Session["hydeptnames_jz"] = ""; for (int i = 0; i < dt_jz.Rows.Count; i++) { if (Session["hydeptids_jz"] == "") { Session["hydeptids_jz"] = dt_jz.Rows[i]["hy_deptid"].ToString(); Session["hydeptnames_jz"] = dt_jz.Rows[i]["hy_deptname"].ToString(); } else { Session["hydeptids_jz"] += "," + dt_jz.Rows[i]["hy_deptid"].ToString(); Session["hydeptnames_jz"] += "," + dt_jz.Rows[i]["hy_deptname"].ToString(); } } } //得到风格 HyoaClass.Hyoa_mystyle Hyoa_mystyle = new HyoaClass.Hyoa_mystyle(); DataTable dt_mystyle = Hyoa_mystyle.Getstylebyuserid(this.txt_username.Value.ToLower()); if (dt_mystyle.Rows.Count > 0 && dt_mystyle.Rows[0]["hy_style"].ToString() != "") Session["mystyle"] = dt_mystyle.Rows[0]["hy_style"].ToString(); else Session["mystyle"] = "/hyhtml/images/"; HyoaClass.Hyoa_license Hyoa_license = new HyoaClass.Hyoa_license(); DataTable dtlicense = Hyoa_license.Getlicensesbybsquseridanddate(this.Session["hyuid"].ToString()); if (dtlicense.Rows.Count > 0) { ifshowopengwsq.Text = "1"; } else { //////为用户创建一个票证,并将其放入cookie或者url中(具体看你怎么设置票证的保存方式) ////FormsAuthentication.SetAuthCookie(this.txt_username.Value, true); this.Response.Redirect(this.lblurl.Text); } } } dt.Clear(); } else { this.RegisterClientScriptBlock("scripterror", "<script language=javascript>alert('输入的用户名或者密码不正确!')</script>"); return; } }