//셀 더블클릭 시 글 내용 자세히 보는 창 띄우는 함수 private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { int w_num = int.Parse(dataGridView1[0, e.RowIndex].Value.ToString()); DataSet ds = new DataSet(); SqlConnection sqlcon = new SqlConnection(strconn); try { sqlcon.Open(); //글번호가 같은 데이터를 불러온 후 WriteDetail폼에 전달 SqlCommand cmd = new SqlCommand("select * from RECRUIT where W_NUM = @w_num", sqlcon); cmd.Parameters.AddWithValue("@w_num", w_num); SqlDataAdapter adpt = new SqlDataAdapter(cmd); adpt.Fill(ds); WriteDetail writedetail = new WriteDetail(ds); //조회수 증가 cmd = new SqlCommand("RecruitCountPlus", sqlcon); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@w_num", ds.Tables[0].Rows[0]["W_NUM"]); cmd.ExecuteNonQuery(); Log.printLog($"{w_num}번 글 조회"); writedetail.TopLevel = false; writedetail.FormBorderStyle = FormBorderStyle.None; writedetail.Dock = DockStyle.Fill; this.Controls.Add(writedetail); writedetail.BringToFront(); writedetail.Show(); } catch { MessageBox.Show("에러"); } finally { if (sqlcon != null) { sqlcon.Close(); } } }
// 자세히보기 버튼 클릭 Recruit 안 WriteDetail.cs 호출 private void show_detail(string num) { try { if (w_num != null) { SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; DataSet ds = new DataSet(); cmd.CommandText = "select * from RECRUIT where W_NUM= @W_NUM"; SqlDataAdapter adpt = new SqlDataAdapter(cmd); cmd.Parameters.AddWithValue("@W_NUM", w_num); adpt.Fill(ds); WriteDetail wd = new WriteDetail(ds); wd.MaximizeBox = false; // WriteDetail 호출시 최소화,최대화 버튼 삭제 wd.MinimizeBox = false; wd.TopLevel = false; wd.FormBorderStyle = FormBorderStyle.None; wd.Dock = DockStyle.Fill; this.Controls.Add(wd); wd.BringToFront(); wd.Show(); //wd.ShowDialog(); } } catch (Exception ex) { Console.WriteLine("btn_show_detail_click Error"); // 에러메세지 Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.Message); Console.WriteLine(ex.Source); } finally { conn.Close(); } }