private void Load_Pins() { int i = 0; string command1 = "select c.category_id from category c, user_category uc, pinterest_user pu where c.category_id = uc.category_id and uc.user_id = pu.user_id and pu.user_id =: userId "; OracleDataAdapter adapter1 = new OracleDataAdapter(command1, FixedValues.ordb); adapter1.SelectCommand.Parameters.Add("userid", Account.UserID); DataSet set1 = new DataSet(); adapter1.Fill(set1); int[] categories_user = new int[set1.Tables[0].Rows.Count]; for (int k = 0; k < set1.Tables[0].Rows.Count; k++) { categories_user[k] = Convert.ToInt32(set1.Tables[0].Rows[k]["category_id"].ToString()); string command = "select pin_name, pin_image, pin_id from pin , board where board.board_name=pin.board_name and board.user_Id=pin.user_id and pin.user_id !=:userid and board.privacy='0' and category_id=:categoryID "; OracleDataAdapter adapter = new OracleDataAdapter(command, FixedValues.ordb); adapter.SelectCommand.Parameters.Add("userid", Account.UserID); adapter.SelectCommand.Parameters.Add("categoryID", categories_user[k]); DataSet set = new DataSet(); adapter.Fill(set); //initial coordinates... don't change double initLeft = 50; double initTop = 20; double initRight = 510; double initBottom = 10; //for first login only.. don't change double d; for (int j = 0; j < set.Tables[0].Rows.Count; j++) { if ((i + 1) % 5 == 0) { initLeft = 20; initRight = 510; i = 0; } if (i >= 1) { d = 0.5; } else { d = i; } connection.Open(); OracleCommand c = new OracleCommand(); c.Connection = connection; c.CommandText = "select react_type from user_react where pin_id=:pin_id and user_id=:user_id"; c.CommandType = CommandType.Text; c.Parameters.Add("pin_id", set.Tables[0].Rows[i].ItemArray[2]); c.Parameters.Add("user_id", Account.UserID); OracleDataReader dr = c.ExecuteReader(); string react = ""; if (dr.Read()) { react = dr[0].ToString(); } dr.Close(); connection.Close(); Pinterest_V2.UserControls.othersPinUserControl othersPinsControl = new UserControls.othersPinUserControl(); byte[] image = (byte[])set.Tables[0].Rows[j].ItemArray[1]; othersPinsControl.otherPinPhoto.Source = FixedValues.LoadImage(image); othersPinsControl.pin_id = Convert.ToInt32(set.Tables[0].Rows[j].ItemArray[2]); othersPinsControl.addIcon.Foreground = Brushes.White; if (react.Equals("likes")) { othersPinsControl.likeIcon.Foreground = Brushes.Gray; } else { othersPinsControl.likeIcon.Foreground = Brushes.White; } if (react.Equals("dislikes")) { othersPinsControl.dislikeIcon.Foreground = Brushes.Gray; } else { othersPinsControl.dislikeIcon.Foreground = Brushes.White; } othersPinsControl.Margin = new Thickness(initLeft + (i * 230), initTop - (d * 440), initRight - (i * 220), initBottom - 220 * d); HomePanel.Children.Add(othersPinsControl); i++; } } }
private void ScrollViewer_Loaded(object sender, RoutedEventArgs e) { connection.Open(); OracleCommand command = new OracleCommand(); command.Connection = connection; command.CommandText = "select p.pin_image, p.pin_id from pin p, board b where p.board_name = b.board_name and p.user_id = :board_userID and b.board_name = :boardName"; command.CommandType = CommandType.Text; command.Parameters.Add("board_userID", board_USERID); command.Parameters.Add("boardName", board_Name); OracleDataReader reader = command.ExecuteReader(); //initial coordinates... don't change double initLeft = 20; double initTop = 10; double initRight = 510; double initBottom = 10; //for first login only.. don't change double d; int i = 0; while (reader.Read()) { if ((i + 1) % 3 == 0) { initLeft = 20; initRight = 510; i = 0; } if (i >= 1) { d = 0.5; } else { d = i; } Pinterest_V2.UserControls.othersPinUserControl OtherPinsControl = new UserControls.othersPinUserControl(); byte[] image = (byte[])reader[0]; OtherPinsControl.otherPinPhoto.Source = FixedValues.LoadImage(image); OtherPinsControl.pin_id = Convert.ToInt32(reader[1]); OtherPinsControl.addPinToBoard_btn.Foreground = Brushes.White; OtherPinsControl.like_btn.Foreground = Brushes.White; OtherPinsControl.dislike_btn.Foreground = Brushes.White; OtherPinsControl.pin_id = Convert.ToInt32(reader[1]); OtherPinsControl.Margin = new Thickness(initLeft + (i * 230), initTop - (d * 440), initRight - (i * 220), initBottom - 220 * d); BoardsPanel.Children.Add(OtherPinsControl); i++; } reader.Close(); connection.Close(); }
private void Search_Pin(string Search_txt) { /////////////////////////// b. 1. //////////////////////////////////// string cmdstr = @"Select p.pin_id, p.pin_name, p.pin_image From Pin p , board b Where p.board_name = b.board_name and b.privacy = 0 and lower(p.pin_name) = lower(:SearchName) and p.user_id != :userID"; SearchAdapter = new OracleDataAdapter(cmdstr, FixedValues.ordb); SearchAdapter.SelectCommand.Parameters.Add("SearchName", Search_txt); SearchAdapter.SelectCommand.Parameters.Add("userID", Account.UserID); DataSet SearchDS = new DataSet(); SearchAdapter.Fill(SearchDS); DataRow row = SearchDS.Tables[0].NewRow(); //initial coordinates... don't change double initLeft = 50; double initTop = 50; double initRight = 510; double initBottom = 10; double d; int i = 0; for (int j = 0; j < SearchDS.Tables[0].Rows.Count; j++) { if ((i + 1) % 5 == 0) { initLeft = 20; initRight = 510; i = 0; } if (i >= 1) { d = 0.5; } else { d = i; } row = SearchDS.Tables[0].Rows[j]; Pinterest_V2.UserControls.othersPinUserControl OtherPinControl = new UserControls.othersPinUserControl(); OtherPinControl.pin_id = Convert.ToInt32(SearchDS.Tables[0].Rows[j][0]); byte[] image = (byte[])SearchDS.Tables[0].Rows[j][2]; OtherPinControl.otherPinPhoto.Source = FixedValues.LoadImage(image); OtherPinControl.Margin = new Thickness(initLeft + (i * 230), initTop - (d * 440), initRight - (i * 220), initBottom - 220 * d); HomePanel.Children.Add(OtherPinControl); i++; } if (SearchDS.Tables[0].Rows.Count == 0) { MessageBox.Show("No Result Found"); } }