Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MemberService service = new MemberService();
        _userlogin = (Member)Session[SessionKey.USERLOGIN];

        string nowip;
        nowip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (nowip == null)
        {
            nowip = Request.ServerVariables["REMOTE_ADDR"];
        }

        if (!Page.IsPostBack)
        {

            ViewWebSite v = new ViewWebSite();
            v.IP = nowip;
            v.Page = "aboutus.aspx";
            if (_userlogin == null)
            {
                v.User = "******";

            }
            else
            {
                v.User = _userlogin.UserName;
            }

            if (service.CreateViewWebSite(v))
            {
                Console.WriteLine("save view complate");
            }

        }
    }
Пример #2
0
    public bool CreateViewWebSite(ViewWebSite  _view)
    {
        bool result = false;

        try
        {
            Conn = db.openConn();
            tr = Conn.BeginTransaction();

            sb = new StringBuilder();

            sb.Remove(0, sb.Length);
            sb.Append("INSERT INTO tbView(IP,UserName,Page,VDate)");
            sb.Append(" VALUES (");
            sb.Append(" '" + _view.IP  + "',");
            sb.Append(" '" + _view.User + "',");
            sb.Append(" '" +  _view.Page  + "',");
            sb.Append("  now() )");

            string sqlSave;
            sqlSave = sb.ToString();

            com = new OleDbCommand();
            com.Connection = Conn;
            com.CommandText = sqlSave;
            com.Transaction = tr;
            com.Parameters.Clear();

            com.ExecuteNonQuery();
            tr.Commit();

            result = true;

        }
        catch (Exception ex)
        {
            tr.Rollback();
            Conn.Close();
            return result;
            throw ex;
        }
        finally
        {
            Conn.Close();
        }

        return result;
    }
Пример #3
0
    public List<ViewWebSite> loadViewWebAll()
    {
        List<ViewWebSite> viewWebSites = new List<ViewWebSite>();
        ViewWebSite viewWebSite = null;
        try
        {
            Conn = db.openConn();

            sb = new StringBuilder();

            sb.Remove(0, sb.Length);
            sb.Append(" SELECT ID,IP,UserName,Page,VDate FROM tbView ");

            string sql;
            sql = sb.ToString();

            com = new OleDbCommand();
            com.CommandText = sql;
            com.CommandType = CommandType.Text;
            com.Connection = Conn;
            dr = com.ExecuteReader();
            if (dr.HasRows)
            {

                DataTable dt = new DataTable();
                dt.Load(dr);
                foreach (DataRow drw in dt.Rows)
                {
                    viewWebSite = new ViewWebSite();
                    viewWebSite.ID = Convert.ToInt32(drw["ID"].ToString());
                    viewWebSite.IP = Convert.ToString(drw["IP"].ToString());
                    viewWebSite.User  = Convert.ToString(drw["UserName"].ToString());
                    viewWebSite.Page  = Convert.ToString(drw["Page"].ToString());
                    viewWebSite.VDate  = Convert.ToDateTime(drw["VDate"].ToString());
                    viewWebSites.Add(viewWebSite);

                }
            }

            dr.Close();

        }
        catch (Exception ex)
        {

            Conn.Close();
            return null;
            throw ex;
        }
        finally
        {
            Conn.Close();
        }

        return viewWebSites;
    }
Пример #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        _userlogin = (Member)Session[SessionKey.USERLOGIN];

        string nowip;
        nowip = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
        if (nowip == null)
        {
            nowip = Request.ServerVariables["REMOTE_ADDR"];
        }

        if (!Page.IsPostBack)
        {
            idspec.Style["display"] = "block";
            idstruct.Style["display"] = "none";
            idresource.Style["display"] = "none";
            idpayby.Style["display"] = "none";
            question.Style["display"] = "block";
            loadQuestion();
            Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString());

            ViewWebSite v = new ViewWebSite();
            v.IP = nowip;
            v.Page = "softwarestock.aspx";
            if (_userlogin == null)
            {
                v.User = "******";

            }
            else
            {
                v.User = _userlogin.UserName;
            }
            MemberService service = new MemberService();
            if (service.CreateViewWebSite(v))
            {
                Console.WriteLine("save view complate");
            }
        }
    }