示例#1
0
    protected void Button_Save1_Click(object sender, EventArgs e)
    {
        string ls_ip = this.txtip.Text;

        if (ls_ip != "")
        {
            if (ls_ip.Contains(",") == true)
            {
                Response.Write("<script>alert('您输入的IP地址不正确!');</script>");
            }
            else
            {
                HyoaClass_conn.Hyoa_nbheyi Hyoa_nbheyi = new HyoaClass_conn.Hyoa_nbheyi();
                DataTable dt = Hyoa_nbheyi.Getfirstnbheyi();
                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["hy_ips"].ToString() == "")
                    {
                        Hyoa_nbheyi.hy_ips = this.txtip.Text;
                    }
                    else
                    {
                        //判断是否存在
                        if (("," + dt.Rows[0]["hy_ips"].ToString() + ",").Contains("," + this.txtip.Text + ",") == true)
                            Hyoa_nbheyi.hy_ips = dt.Rows[0]["hy_ips"].ToString();
                        else
                            Hyoa_nbheyi.hy_ips = dt.Rows[0]["hy_ips"].ToString() + "," + this.txtip.Text;
                    }
                    Hyoa_nbheyi.hy_key = dt.Rows[0]["hy_key"].ToString();
                    Hyoa_nbheyi.hy_date = System.DateTime.Now.ToString();
                    Hyoa_nbheyi.hy_pj = dt.Rows[0]["hy_pj"].ToString();
                    Hyoa_nbheyi.hy_tag = dt.Rows[0]["hy_tag"].ToString();
                    Hyoa_nbheyi.hy_usernum = int.Parse(dt.Rows[0]["hy_usernum"].ToString());
                    Hyoa_nbheyi.Update();
                    Response.Write("<script>alert('更新成功!');window.location='getjqm.aspx';</script>");
                }
                else
                {
                    Hyoa_nbheyi.hy_ips = this.txtip.Text;
                    Hyoa_nbheyi.hy_key = "";
                    Hyoa_nbheyi.hy_pj = "";
                    Hyoa_nbheyi.hy_tag = "";
                    Hyoa_nbheyi.hy_usernum = 0;
                    Hyoa_nbheyi.Insert();
                    Response.Write("<script>alert('提交成功!');window.location='getjqm.aspx';</script>");
                }
            }
        }
    }