Ejemplo n.º 1
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(TextBox1.Text) || string.IsNullOrEmpty(TextBox2.Text))
        {
            return;
        }

        List <OleDbParameter> _params = new List <OleDbParameter>();

        _params.Add(new OleDbParameter()
        {
            ParameterName = "V001", Value = TextBox1.Text
        });
        _params.Add(new OleDbParameter()
        {
            ParameterName = "V002", Value = TextBox2.Text
        });
        _params.Add(new OleDbParameter()
        {
            ParameterName = "V003", Value = DropDownList1.SelectedValue
        });
        _params.Add(new OleDbParameter()
        {
            ParameterName = "V004", Value = CheckBox1.Checked ? "1" : "0"
        });
        _params.Add(new OleDbParameter()
        {
            ParameterName = "V005", Value = TextBox3.Text
        });
        _params.Add(new OleDbParameter()
        {
            ParameterName = "V006", Value = CheckBox2.Checked ? "1" : "0"
        });

        string _sql = string.Empty;

        if (_dr == null)
        {
            _sql = "INSERT INTO HTN_SQL (SQLKey, SQLVal, SQLType, SQLIs, SQLPk, SQLUp) VALUES (:V001, :V002, :V003, :V004, :V005, :V006)";
        }
        else
        {
            _sql = "UPDATE HTN_SQL SET SQLKey = :V001, SQLVal = :V002, SQLType = :V003, SQLIs = :V004, SQLPk = :V005, SQLUp = :V006 WHERE ID = " + _dr.Str("ID");
        }

        bool _is = HtnData.ExecNonQuery(_sql, _params) == 1;

        if (_is)
        {
            //Response.Write("成功!");
            HtnData.InitSource();
            InitPage();
        }
        else
        {
            //Response.Write("失败!");
        }
    }
Ejemplo n.º 2
0
        public string RegUser()
        {
            string    _openid = Params["OpenId"];
            string    _sql    = string.Format("SELECT * FROM WX_User WHERE OpenId = '{0}'", _openid);
            DataTable _dt     = HtnData.Query(_sql);

            if (_dt != null && _dt.Rows.Count > 0)
            {
                return(_openid + "|" + HtnData.DataToWx(_dt));
            }


            string    _nickName  = Params["nickName"];
            string    _suffname  = Params["suffname"];
            string    _suffphone = Params["suffphone"];
            DataTable _suffdt    = null;
            string    _suffsql   = string.Empty;

            if (!string.IsNullOrEmpty(_suffphone))
            {
                _suffsql = string.Format("select * from htn_sufferer where handphone = '{0}'", _suffphone);
                _suffdt  = HtnData.Query(_suffsql);
                if (_suffdt == null || _suffdt.Rows.Count == 0)
                {
                    _suffsql = string.Format("select * from htn_sufferer where sufferername = '{0}'", _suffname);
                    _suffdt  = HtnData.Query(_suffsql);
                }
            }
            else if (!string.IsNullOrEmpty(_suffname))
            {
                _suffsql = string.Format("select * from htn_sufferer where sufferername = '{0}'", _suffname);
                _suffdt  = HtnData.Query(_suffsql);
            }

            List <OleDbParameter> _sqlparams = new List <OleDbParameter>();

            _sqlparams.Add(new OleDbParameter()
            {
                ParameterName = "V001", Value = _nickName
            });
            _sqlparams.Add(new OleDbParameter()
            {
                ParameterName = "V002", Value = Params["gender"]
            });
            _sqlparams.Add(new OleDbParameter()
            {
                ParameterName = "V003", Value = Params["city"]
            });
            _sqlparams.Add(new OleDbParameter()
            {
                ParameterName = "V004", Value = _openid
            });


            if (_suffdt == null || _suffdt.Rows.Count == 0)
            {
                _sqlparams.Add(new OleDbParameter()
                {
                    ParameterName = "V005", Value = ""
                });
                _sqlparams.Add(new OleDbParameter()
                {
                    ParameterName = "V006", Value = ""
                });
                _sqlparams.Add(new OleDbParameter()
                {
                    ParameterName = "V007", Value = ""
                });
            }
            else
            {
                DataRow _dr = _suffdt.Rows[0];
                _sqlparams.Add(new OleDbParameter()
                {
                    ParameterName = "V005", Value = _dr.Str("BarCode")
                });
                _sqlparams.Add(new OleDbParameter()
                {
                    ParameterName = "V006", Value = (_dr.Str("SuffererName") == "" ? _suffname : _dr.Str("SuffererName"))
                });
                _sqlparams.Add(new OleDbParameter()
                {
                    ParameterName = "V007", Value = (_dr.Str("HandPhone") == "" ? _suffphone : _dr.Str("HandPhone"))
                });
            }

            _sql = "insert into WX_User (nickName, gender, city, OpenId, BarCode, SuffName, SuffPhone) values (:V001, :V002, :V003, :V004, :V005, :V006, :V007 )";

            int i = HtnData.ExecNonQuery(_sql, _sqlparams);

            if (i > 0)
            {
                _sql = string.Format("SELECT * FROM WX_User WHERE OpenId = '{0}'", _openid);
                _dt  = HtnData.Query(_sql);
                return(_openid + "|" + HtnData.DataToWx(_dt));
            }

            return("");
        }