private void Form1_Load(object sender, EventArgs e) { BookDB db = new BookDB(); dt = db.GetEveryData(); dgvMember.DataSource = dt; }
private void Form3_Load(object sender, EventArgs e) { InitCart(); BookDB db = new BookDB(); DataTable dt = db.GetEveryData(); int idx = 1; for (int i = 0; i < dt.Rows.Count; i++) { UserControl1 ucon = new UserControl1(); ucon.Name = $"conn{idx}"; ucon.Location = new Point(3, (i * 200) + 10); ucon.Size = new Size(566, 33); ucon.Bookid = Convert.ToInt32(dt.Rows[i]["bookid"].ToString()); ucon.Bookname = dt.Rows[i]["bookname"].ToString(); // ucon.Bookprice = ; 가격은 스킵 ucon.Bookimage = dt.Rows[i]["bookimage"].ToString(); ucon.AddCart += Ucon_AddCart; panel1.Controls.Add(ucon); idx++; } db.Dispose(); }
private void button3_Click(object sender, EventArgs e) { try { string sPath = $"bookImage/{bookid}/"; string localfile = pictureBox1.Tag.ToString(); string sExt = localfile.Substring(localfile.LastIndexOf(".")); string newfilename = DateTime.Now.ToString("yyyyMMddHHmmssfff") + sExt; string destfilename = Path.Combine(sPath, newfilename); DirectoryInfo dir = new DirectoryInfo(sPath); if (!dir.Exists) { dir.Create(); } File.Copy(localfile, destfilename, true); BookDB db = new BookDB(); bool result = db.UpdateBookImage(bookid, textBox2.Text, destfilename); if (result) { MessageBox.Show("이미지 추가가 완료되었습니다."); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("이미지 저장에 실패하였습니다. 다시 시도하여 주십시오."); } } catch (Exception) { } }