private void Grid_Loaded(object sender, RoutedEventArgs e) { if (Edit) { Title.Source = new BitmapImage(new Uri("/images/editpin.png", UriKind.Relative)); Done_btn.Content = "Edit"; con.Open(); OracleCommand command = new OracleCommand(); command.Connection = con; command.CommandText = "select pin_name, pin_image, description, board_name from pin where pin_id=:pinId "; command.CommandType = CommandType.Text; command.Parameters.Add("pinId", pin_id_edit); OracleDataReader reader = command.ExecuteReader(); if (reader.Read()) { board_combx.SelectedItem = reader[3].ToString(); PinName_txt.Text = reader[0].ToString(); Description_txt.Text = reader[2].ToString(); byte[] im = (byte[])reader[1]; Pin_pic.Source = FixedValues.LoadImage(im); imageData = im; } reader.Close(); con.Close(); } }
private void Grid_Loaded(object sender, RoutedEventArgs e) { MessagesPanel.Children.Clear(); FriendsPanel.Children.Clear(); connection.Open(); /////////////////////////// ///////////////////////////////////// OracleCommand selectFriends = new OracleCommand(); selectFriends.Connection = connection; selectFriends.CommandText = "Select_Friend"; selectFriends.CommandType = CommandType.StoredProcedure; selectFriends.Parameters.Add("userID", Account.UserID); selectFriends.Parameters.Add("friendID", OracleDbType.RefCursor, ParameterDirection.Output); OracleDataReader FriendsIDData = selectFriends.ExecuteReader(); while (FriendsIDData.Read()) { int FriendIndex = 0; if (FriendsIDData[0].ToString().Equals(Account.UserID.ToString())) { FriendIndex = 1; } /////////////////////// A.2. one /////////////////////// OracleCommand FriendCommand = new OracleCommand(); FriendCommand.Connection = connection; FriendCommand.CommandText = "select user_name, profile_pic, login from PINTEREST_USER where user_id=:id"; FriendCommand.CommandType = CommandType.Text; FriendCommand.Parameters.Add("id", Convert.ToInt32(FriendsIDData[FriendIndex].ToString())); OracleDataReader UserReader = FriendCommand.ExecuteReader(); if (UserReader.Read()) { Pinterest_V2.UserControls.FriendsChatUserControl fcControl = new UserControls.FriendsChatUserControl(this.MessagesPanel); fcControl.Friend_Name.Text = UserReader[0].ToString(); byte[] image = (byte[])UserReader[1]; fcControl.ProfilePic.Fill = new ImageBrush(FixedValues.LoadImage(image)); if (UserReader[2].ToString().Equals("1")) { fcControl.OnlineCircle.Fill = Brushes.Green; } fcControl.FriendID = Convert.ToInt32(FriendsIDData[FriendIndex].ToString()); fcControl.Visibility = System.Windows.Visibility.Visible; FriendsPanel.Children.Add(fcControl); } UserReader.Close(); } FriendsIDData.Close(); connection.Close(); }
private void loadPage(object sender, RoutedEventArgs e) { ////////////////////////// B. 1. ////////////////////////////////////////////// string command = "select pin_name, pin_image, board_name, description from pin where pin_id= :pinid "; OracleDataAdapter adapter = new OracleDataAdapter(command, FixedValues.ordb); adapter.SelectCommand.Parameters.Add("pinid", pin_id); DataSet set = new DataSet(); adapter.Fill(set); byte[] image = (byte[])set.Tables[0].Rows[0].ItemArray[1]; Pin_pic.Source = FixedValues.LoadImage(image); PinName_txt.Text = set.Tables[0].Rows[0].ItemArray[0].ToString(); Description_txt.Text = set.Tables[0].Rows[0].ItemArray[3].ToString(); board_combx.Text = set.Tables[0].Rows[0].ItemArray[2].ToString(); }
private void Grid_Loaded(object sender, RoutedEventArgs e) { /////////////////////////////// A.2. /////////////////////////////////////// this.DataContext = this; users.Clear(); this.List_of_Follower.Items.Clear(); OracleCommand cmd = new OracleCommand(); cmd.Connection = connection; if (state.Equals("Follower")) { cmd.CommandText = "select user_id from user_following where user_following=:id"; } else if (state.Equals("Following")) { cmd.CommandText = "select user_following from user_following where user_id=:id"; } cmd.Parameters.Add("id", Account.UserID); OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string cmdstr = "select user_name, profile_pic from PINTEREST_USER where user_id=:id"; ProfileDataAdapter = new OracleDataAdapter(cmdstr, FixedValues.ordb); ProfileDataAdapter.SelectCommand.Parameters.Add("id", dr[0]); ProfileDataSet = new DataSet(); ProfileDataAdapter.Fill(ProfileDataSet); byte[] image = (byte[])ProfileDataSet.Tables[0].Rows[0][1]; BitmapImage ProfileImage = FixedValues.LoadImage(image); users.Add(new info_user { Name_user = ProfileDataSet.Tables[0].Rows[0][0].ToString(), Image_user = new ImageBrush(ProfileImage), Id_user = dr[0].ToString() }); } this.List_of_Follower.ItemsSource = users; }
private void Grid_Loaded(object sender, RoutedEventArgs e) { OracleConnection con = new OracleConnection(FixedValues.ordb); con.Open(); //initial coordinates... don't change double initLeft = 50; double initTop = 10; double initRight = 510; double initBottom = 10; if (Account.FirstLogin != 0) { selectedItems.Clear(); OracleCommand command2 = new OracleCommand(); command2.Connection = con; ////////////////////// A. 2. ///////////////////////// command2.CommandText = "select category_name from category c, user_category uc where c.category_id = uc.category_id and uc.user_id = :userId"; command2.CommandType = CommandType.Text; command2.Parameters.Add("userId", Account.UserID); OracleDataReader reader2 = command2.ExecuteReader(); while (reader2.Read()) { selectedItems.Add(reader2[0].ToString()); } reader2.Close(); //change this into number of remaining categories that user didn't choose } OracleCommand command = new OracleCommand(); command.Connection = con; ////////////////////// A. 1. ///////////////////////// command.CommandText = "select category_name, Category_Picture from category"; command.CommandType = CommandType.Text; OracleDataReader reader = command.ExecuteReader(); double d; int categoriesCounter = 0; int i = 0; categoryPanel.Children.Clear(); while (reader.Read()) { if ((i + 1) % 4 == 0) { initLeft = 50; initRight = 510; i = 0; } if (i >= 2) { d = 1; } else { d = i; } byte[] image = (byte[])reader[1]; Pinterest_V2.UserControls.CategoryUserControl categoriesControl = new UserControls.CategoryUserControl(); BitmapImage bitmapimage = FixedValues.LoadImage(image); ImageBrush buttonBrush = new ImageBrush(bitmapimage); if (selectedItems.Contains(reader[0].ToString())) { buttonBrush.Opacity = 0.6; categoriesControl.btn_clicked = true; } categoriesControl.categoryButton.Background = buttonBrush; categoriesControl.categoryButton.Foreground = Brushes.White; categoriesControl.categoryButton.Content = reader[0].ToString(); categoriesControl.Margin = new Thickness(initLeft + (i * 230), initTop - (d * 440), initRight - (i * 220), initBottom - 220 * d); categoryPanel.Children.Add(categoriesControl); categoriesCounter++; i++; } reader.Close(); con.Close(); }
private void Grid_Loaded(object sender, RoutedEventArgs e) { boardNameLabel.Content = board_name; con.Open(); OracleCommand command = new OracleCommand(); command.Connection = con; command.CommandText = "select pin_name, pin_image, pin_id from pin where user_id= :userid and board_name= :boardname"; command.CommandType = CommandType.Text; command.Parameters.Add("userid", Account.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) % 4 == 0) { initLeft = 20; initRight = 510; i = 0; } if (i >= 1) { d = 0.5; } else { d = i; } Pinterest_V2.UserControls.myPinUserControl myPinsControl = new UserControls.myPinUserControl(pinsPanel); myPinsControl.myPinButton.Content = reader[0]; byte[] image = (byte[])reader[1]; myPinsControl.myPinButton.Background = new ImageBrush(FixedValues.LoadImage(image)); myPinsControl.pin_id = Convert.ToInt32(reader[2]); myPinsControl.myPinButton.Foreground = Brushes.White; myPinsControl.moveIcon.Foreground = Brushes.White; myPinsControl.DeleteMyPin_btn_Icon.Foreground = Brushes.White; myPinsControl.EditMyPin_Icon.Foreground = Brushes.White; myPinsControl.Margin = new Thickness(initLeft + (i * 230), initTop - (d * 440), initRight - (i * 220), initBottom - 220 * d); pinsPanel.Children.Add(myPinsControl); i++; } reader.Close(); con.Close(); }
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 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 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"); } }
//################## SEARCH FUNCTION ##################\\ private void Search_User(string Search_txt) { /////////////////////////// b. 1. //////////////////////////////////// string cmdstr = @"Select user_id, user_name, profile_pic From pinterest_user Where lower(user_name) = lower(:SearchName) and user_id != :userID"; OracleDataAdapter 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.UserSearchUserControl OtherUserControl = new UserControls.UserSearchUserControl(); OtherUserControl.OtherUserID = Convert.ToInt32(SearchDS.Tables[0].Rows[j][0]); OtherUserControl.Profilbtn.Content = SearchDS.Tables[0].Rows[j][1]; byte[] image = (byte[])SearchDS.Tables[0].Rows[i][2]; OtherUserControl.Profilbtn.Background = new ImageBrush(FixedValues.LoadImage(image)); OtherUserControl.Profilbtn.Foreground = Brushes.White; OtherUserControl.Margin = new Thickness(initLeft + (i * 230), initTop - (d * 440), initRight - (i * 220), initBottom - 220 * d); HomePanel.Children.Add(OtherUserControl); i++; } if (SearchDS.Tables[0].Rows.Count == 0) { MessageBox.Show("No Result Found"); } }