示例#1
0
    private List <PhotoData> GetUserPhotosFromDb()
    {
        var photosDataList = new List <PhotoData>();
        var userId         = (int)MyUtils.GetUserField("id_user");

        DataSet userData   = db.GetDataSet(string.Format("select * from users where id_user={0}", userId));
        DataSet photosData = db.GetDataSet(string.Format("select * from photos where id_user={0}", userId));

        var userPhotoId = userData.Tables[0].Rows[0]["id_photo"];

        if (photosData.Tables.Count > 0)
        {
            DataTable photosTable = photosData.Tables[0];

            for (int i = 0; i < photosTable.Rows.Count; i++)
            {
                var pd = new PhotoData
                {
                    GuidPhoto   = Guid.Parse(photosTable.Rows[i]["GUID"].ToString()),
                    idPhoto     = (int)photosTable.Rows[i]["id_photo"],
                    idUser      = (int)photosTable.Rows[i]["id_user"],
                    isApproved  = (bool)photosTable.Rows[i]["is_approved"],
                    isPrivate   = (bool)photosTable.Rows[i]["is_private"],
                    isMainPhoto = !(userPhotoId is DBNull) && (int)userPhotoId == (int)photosTable.Rows[i]["id_photo"]
                };

                photosDataList.Add(pd);
            }
        }

        return(photosDataList);
    }
示例#2
0
    private DataSet GetUsers(string sql, MyUtils.ImageSize sz = MyUtils.ImageSize.SMALL, bool deleterows = true)
    {
        DataSet d = db.GetDataSet(sql);

        MixInFeatured(d, deleterows);


        d.Tables[0].Columns.Add("mainphoto_");
        d.Tables[0].Columns.Add("online");
        foreach (DataRow r in d.Tables[0].Rows)
        {
            r["mainphoto_"] = MyUtils.GetImageUrl(r, sz);
            r["online"]     = MyUtils.IsOnline((int)r["id_user"]) ? "1" : "0";// ..GetImageUrl(r, MyUtils.ImageSize.MEDIUM);
        }
        d.Tables[0].Columns.Remove("mainphoto");
        d.Tables[0].Columns["mainphoto_"].ColumnName = "MainPhoto";

        d.Tables[0].TableName = "U";
        //DataTable t = new DataTable();
        //t.TableName = "filter";
        //t.Columns.Add("json");
        //t.Rows.Add(t.NewRow());
        //t.Rows[0]["json"] = f.ToString();
        //d.Tables.Add(t);
        return(d);
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string t = TYPE = Request.QueryString["t"];

        if (t != "favorites" && t != "viewed" && t != "favorited" && t != "blocked")
        {
            return;
        }
        sql = "exec SEARCH_USERS 1, 500, 0, " + MyUtils.ID_USER + ", '', 1, '*', 'users.id_user desc', '" + t + "'";
        DataSet d = db.GetDataSet(sql);

        Repeater1.DataSource = d;
        Repeater1.DataBind();
        if (d.Tables[0].Rows.Count == 0)
        {
            norecords.Visible = true;
            if (t == "favorites")
            {
                norecords.Text = "You don't have any favorites yet.";
            }
            if (t == "viewed")
            {
                norecords.Text = "Nobody viewed your profile yet.";
            }
            if (t == "favorited")
            {
                norecords.Text = "Nobody favorited your profile yet.";
            }
            if (t == "blocked")
            {
                norecords.Text = "You don't have any blocked users.";
            }
        }
    }
示例#4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var SendMessageTo = Request.QueryString["SendMessageTo"];

        if (!string.IsNullOrEmpty(SendMessageTo))
        {
            int id       = Convert.ToInt32(SendMessageTo);
            int id_offer = GetIdOffer(id);

            if (Request.QueryString["confirmed"] == "1" || MyUtils.IsFemale)
            {
                Utils.GoToSendMessage(id_offer);
                return;
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "showconfirm", "<script type='text/javascript'>ConfirmUnlock(" + id + ");</script>", false);
            }
        }

        DataSet d = db.GetDataSet("exec GET_MESSAGE_LIST " + MyUtils.ID_USER);

        QuickStart.Visible = d.Tables[0].Rows.Count == 0;
        if (QuickStart.Visible)
        {
            NormalHeadline.Visible = false;
            QuickStart.Title       = "<h2>You have no messages yet</h2>";
        }
        Repeater1.DataSource = d;
        Repeater1.DataBind();
    }
示例#5
0
    /// <summary>
    /// Gets user personal data from DB using dbo.GET_USER_PROFILE
    /// </summary>
    /// <param name="userPhotos">user's personal photos</param>
    /// <returns>user's personal data</returns>
    private DataRow GetUserData(out DataTable userPhotos)
    {
        sql = string.Format("exec Get_User_Profile {0},{1},1", (int)MyUtils.GetUserField("id_user"), currentUser);
        DataSet ds      = db.GetDataSet(sql);
        DataRow userRow = null;

        userPhotos = null;

        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
        {
            userRow = ds.Tables[0].Rows[0];
            var photos = ds.Tables[1].Select("IsMainPhoto <> 1");
            userPhotos = photos.Length > 0 ? photos.CopyToDataTable() : null;
        }

        return(userRow);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        DB_Helper db = new DB_Helper();
        int id = Convert.ToInt32(Request.QueryString["id"]);

        DataSet ds= db.GetDataSet("select dbo.CalculateCredits2Unlock(amount) as credits from offers  where (id_user_from=" + id + " and id_user_to=" + MyUtils.ID_USER + ") or (id_user_from=" + MyUtils.ID_USER + " and id_user_to=" + id + ");select username from users where id_user=" + id);
        cr = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
        user = Convert.ToString(ds.Tables[1].Rows[0][0]);

        bool not_enough_credits = cr > MyUtils.Credits;

        nocredits.Visible = not_enough_credits;
        confirm.Visible = !nocredits.Visible;
    }
示例#7
0
    static DataTable GetMessagesForUser(int id_user, int id_user_with, int start_with_id = 0)
    {
        //IsFromMe gives 1 if the message was sent my me.
        DB_Helper db = new DB_Helper();

        string sql = "select " +
                     "(SELECT top 1 [username] FROM [dbo].[Users] where [id_user] = m.id_user_from) FromUser," +
                     "(SELECT top 1 [username] FROM[dbo].[Users] where[id_user] = m.id_user_to) ToUser, " +
                     "case when id_user_from=" + id_user +
                     " then 1 else 0 end as IsFromMe, * from messages m where ((id_user_from=" +
                     id_user + " and id_user_to=" + id_user_with + ") or (id_user_to=" + id_user + " and id_user_from=" + id_user_with + ")) and m.[id_message] >= " + start_with_id + " order by [time] desc";

        sql += "; update messages set is_new = 0 where id_user_to =" + id_user + " and id_user_from = " + id_user_with + " and is_new = 1 and [id_message] >= " + start_with_id;
        return(db.GetDataSet(sql).Tables[0]);
    }
示例#8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        DB_Helper db = new DB_Helper();
        int       id = Convert.ToInt32(Request.QueryString["id"]);

        DataSet ds = db.GetDataSet("select dbo.CalculateCredits2Unlock(amount) as credits from offers  where (id_user_from=" + id + " and id_user_to=" + MyUtils.ID_USER + ") or (id_user_from=" + MyUtils.ID_USER + " and id_user_to=" + id + ");select username from users where id_user=" + id);

        cr   = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
        user = Convert.ToString(ds.Tables[1].Rows[0][0]);

        bool not_enough_credits = cr > MyUtils.Credits;

        nocredits.Visible = not_enough_credits;
        confirm.Visible   = !nocredits.Visible;
    }
示例#9
0
    static DataTable SaveMessage2DBAndSelect(int id_user_from, int id_user_to, string message, string gift_list, int id_offer)
    {
        DB_Helper db = new DB_Helper();
        string    s  = "";

        if (MyUtils.IsFemale)
        {
            s = "select female_sent_msg from offers where id_offer=" + id_offer;
            int female_sent_msg = db.ExecuteScalarIntCache(s, 0, 5);
            if (female_sent_msg == 0)
            {
                db.Execute("update offers set female_sent_msg=1 where isnull(female_sent_msg,0)=0 and id_offer=" + id_offer + "; ");
                DB_Helper.InvalidateCache("SQL_" + s);
            }
        }
        return(db.GetDataSet("insert into messages (id_user_from,id_user_to,text,gift_list,id_offer) OUTPUT inserted.* values (" + id_user_from + "," + id_user_to + "," + MyUtils.safe(message) + "," + MyUtils.safe(gift_list) + "," + id_offer + ");").Tables[0]);
    }
示例#10
0
    private static DataSet GetUsers(int index, string filter, out string sql)
    {
        //index = 1;
        DB_Helper db = new DB_Helper();

        int id_user = (int)MyUtils.GetUserField("id_user");  //currently logged in user

        if (string.IsNullOrEmpty(filter))
        {
            filter = db.ExecuteScalarString("select isnull(filter,'DEFAULT') from users where id_user="******"mainphoto_");
        d.Tables[0].Columns.Add("online");
        d.Tables[0].Columns.Add("button_switch");
        foreach (DataRow r in d.Tables[0].Rows)
        {
            r["button_switch"] = GetButtonSwitch(r);
            r["mainphoto_"]    = MyUtils.GetImageUrl(r, MyUtils.ImageSize.MEDIUM);
            r["online"]        = MyUtils.IsOnline((int)r["id_user"]) ? "1" : "0";// ..GetImageUrl(r, MyUtils.ImageSize.MEDIUM);
        }
        d.Tables[0].Columns.Remove("mainphoto");
        d.Tables[0].Columns["mainphoto_"].ColumnName = "MainPhoto";

        d.Tables[0].TableName = "U";
        DataTable t = new DataTable();

        t.TableName = "filter";
        t.Columns.Add("json");
        t.Rows.Add(t.NewRow());
        t.Rows[0]["json"] = f.ToString();
        d.Tables.Add(t);
        return(d);
    }
示例#11
0
    private string GetUserPhotoUrl()
    {
        string photoGuid = null;

        if (Session["MainPhotoGuid"] == null)
        {
            var mainPhotoRow = db.GetRow(string.Format("select * from users where id_user = {0}", MyUtils.ID_USER));
            if (mainPhotoRow != null)
            {
                var mainPhotoId = mainPhotoRow["id_photo"];

                if (!(mainPhotoId is DBNull))
                {
                    DataSet photoData = db.GetDataSet(string.Format("select * from photos where id_photo={0}", mainPhotoId.ToString()));
                    if (photoData.Tables.Count > 0 && photoData.Tables[0].Rows.Count > 0)
                    {
                        photoGuid = photoData.Tables[0].Rows[0]["GUID"].ToString();
                        Session["MainPhotoGuid"] = photoGuid;
                    }
                }
            }
        }
        else
        {
            photoGuid = Session["MainPhotoGuid"].ToString();
        }

        if (!string.IsNullOrEmpty(photoGuid))
        {
            return(MyUtils.GetImageUrl(photoGuid, MyUtils.ImageSize.TINY));
        }



        return("/img/NoPhoto" + MyUtils.GetUserField("sex") + "-s.jpg");
    }
示例#12
0
    private static DataSet GetUsers(int index, string filter, out string sql)
    {
        //index = 1;
        DB_Helper db = new DB_Helper();

        int id_user = (int) MyUtils.GetUserField("id_user"); //currently logged in user

        if (string.IsNullOrEmpty(filter)) filter = db.ExecuteScalarString("select isnull(filter,'DEFAULT') from users where id_user="******"mainphoto_");
        d.Tables[0].Columns.Add("online");
        d.Tables[0].Columns.Add("button_switch");
        foreach (DataRow r in d.Tables[0].Rows)
        {
            r["button_switch"] = GetButtonSwitch(r);
            r["mainphoto_"] = MyUtils.GetImageUrl(r, MyUtils.ImageSize.MEDIUM);
            r["online"] = MyUtils.IsOnline((int)r["id_user"]) ? "1" : "0";// ..GetImageUrl(r, MyUtils.ImageSize.MEDIUM);
        }
        d.Tables[0].Columns.Remove("mainphoto");
        d.Tables[0].Columns["mainphoto_"].ColumnName = "MainPhoto";

        d.Tables[0].TableName = "U";
        DataTable t = new DataTable();
        t.TableName = "filter";
        t.Columns.Add("json");
        t.Rows.Add(t.NewRow());
        t.Rows[0]["json"] = f.ToString();
        d.Tables.Add(t);
        return d;
    }