private void button2_Click(object sender, EventArgs e) { try { Loai loai = GetInputForm(); loai.SuaLoai(); loai.SuaLoai(); loai.SuaLoai(); loai.SuaLoai(); loai.SuaLoai(); LoadDanhSachLoai(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnThemLoai_Click(object sender, EventArgs e) { try { LoaiSua.TenLoai = txtTenLoai.Text; LoaiSua.MoTa = txtMoTa.Text; LoaiSua.Hinh = string.Format("loai-{0}.jpg", LoaiSua.MaLoai); LoaiSua.SuaLoai(); bool exists = System.IO.Directory.Exists(Application.StartupPath + "/images"); if (!exists) { System.IO.Directory.CreateDirectory(Application.StartupPath + "/images"); } string fileName = String.Format(@"{0}/images/loai-{1}.jpg", Application.StartupPath, LoaiSua.MaLoai); pictureBox1.Image.Save(fileName); DialogResult = DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message); } }