private void Create_Pin() { int userId = Account.UserID; string BoardName = board_combx.SelectedItem.ToString().Trim(); string PinName = PinName_txt.Text; string description = Description_txt.Text.ToString(); if (PinName_txt.Text == "" || Description_txt.ToString() == "" || board_combx.SelectedItem.ToString() == "") { MessageBox.Show("Please Fill All Fields"); } else { con.Open(); OracleCommand command = new OracleCommand(); command.Connection = con; command.CommandText = "insert into pin values(pin_id.nextval, :pinName, :pinImage, :descrption, :boardname, :user_id, :pin_Date) "; command.CommandType = CommandType.Text; command.Parameters.Add("pinName", PinName); command.Parameters.Add("pinimage", imageData); command.Parameters.Add("descrption", description); command.Parameters.Add("boardname", BoardName); command.Parameters.Add("user_id", userId); command.Parameters.Add("pin_date", DateTime.Now); command.ExecuteNonQuery(); con.Close(); Close(); } }
private void update_pin() { int userId = Account.UserID; string BoardName = board_combx.SelectedItem.ToString().Trim(); string PinName = PinName_txt.Text; string description = Description_txt.Text.ToString(); if (PinName_txt.Text == "" || Description_txt.ToString() == "" || board_combx.SelectedItem.ToString() == "") { MessageBox.Show("Please Fill All Fields"); } else { // con.Open(); ///////////////////////// b. 3. update //////////////////////////////////// //////////////////////////////////////////////////////////////// string command = "select * from pin"; OracleDataAdapter adapter = new OracleDataAdapter(command, FixedValues.ordb); OracleCommandBuilder builder; DataSet set = new DataSet(); adapter.Fill(set); DataRow row = set.Tables[0].NewRow(); for (int i = 0; i < set.Tables[0].Rows.Count; i++) { if (set.Tables[0].Rows[i].ItemArray[0].ToString() == pin_id_edit.ToString()) { row = set.Tables[0].Rows[i]; break; } } row["pin_name"] = PinName; row["pin_image"] = imageData; row["description"] = description; row["board_name"] = BoardName; builder = new OracleCommandBuilder(adapter); adapter.Update(set.Tables[0]); //////////////////////////////////////////////////////////////////////////////// Close(); } }