private void btnXoa_Click(object sender, EventArgs e) { DialogResult dlrTraloi; dlrTraloi = MessageBox.Show("Bạn chắc chắn muốn xóa ?" + lbTenTG.Text, "Trả Lời", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlrTraloi == DialogResult.OK) { if (ws.Xoa(id) > 0) { MessageBox.Show("Xóa thành công!"); DataTable s = ws.LayDanhSach(); dgvDSTG.DataSource = s; labelTen.Visible = false; txtTenTG.Visible = false; btnLuu.Enabled = false; lbTenTG.Visible = true; txtTenTG.Text = lbTenTG.Text = dgvDSTG.CurrentRow.Cells["clmTenTG"].Value.ToString(); txtSLTindo.Text = dgvDSTG.CurrentRow.Cells["clmSLTinDo"].Value.ToString(); rtbGioiThieu.Text = dgvDSTG.CurrentRow.Cells["clmGioiThieu"].Value.ToString(); hinhanh = dgvDSTG.CurrentRow.Cells["clmHinhAnh"].Value.ToString(); id = dgvDSTG.CurrentRow.Cells["clmID"].Value.ToString(); if (hinhanh != "") { FilesTransfer.FilesTransferSoapClient WSFile = new FilesTransfer.FilesTransferSoapClient(); System.IO.FileStream fs1 = null; byte[] b1 = null; b1 = WSFile.DownloadFile(hinhanh); fs1 = new FileStream(@"..\\..\\hinh_anh\\tongiao\\" + id + ".xml", FileMode.Create); fs1.Write(b1, 0, b1.Length); fs1.Close(); fs1 = null; pictureBox1.Image = Image.FromFile(@"..\\..\\hinh_anh\\tongiao\\" + id.ToString() + ".xml"); } } } else { MessageBox.Show("xóa không thành công!"); } }
private void dgvDSTG_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0 && e.ColumnIndex >= 0) { pictureBox1.Image = null; txtTenTG.Text = lbTenTG.Text = dgvDSTG.CurrentRow.Cells["clmTenTG"].Value.ToString(); XacDinhTinDoTheoTungTonGiao(txtTenTG.Text); txtSLTindo.Text = dgvDSTG.CurrentRow.Cells["clmSLTinDo"].Value.ToString(); rtbGioiThieu.Text = dgvDSTG.CurrentRow.Cells["clmGioiThieu"].Value.ToString(); hinhanh = dgvDSTG.CurrentRow.Cells["clmHinhAnh"].Value.ToString(); id = dgvDSTG.CurrentRow.Cells["clmID"].Value.ToString(); if (hinhanh != "") { FilesTransfer.FilesTransferSoapClient WSFile = new FilesTransfer.FilesTransferSoapClient(); System.IO.FileStream fs1 = null; byte[] b1 = null; string name = hinhanh.Substring(hinhanh.LastIndexOf("/") + 1); if (File.Exists(@"..\..\hinh_anh\tongiao\" + name + ".xml")) { } else { b1 = WSFile.DownloadFile(hinhanh); fs1 = new FileStream(@"..\..\hinh_anh\tongiao\" + name + ".xml", FileMode.Create); fs1.Write(b1, 0, b1.Length); fs1.Close(); fs1 = null; } pictureBox1.Image = Image.FromFile(@"..\..\hinh_anh\tongiao\" + name + ".xml"); } btnSua.Enabled = true; btnXoa.Enabled = true; btnLuu.Enabled = false; btnThemChucSac.Visible = true; btnThemToChuc.Visible = true; dgvChucSac.DataSource = ws.GetTable("select tenchucsac,gioithieu from tblChucSac where daxoa=0 and idtongiao=" + id, "tblChucSac"); dgvToChuc.DataSource = ws.GetTable("select tentochuc,gioithieu from tblTochucquantri where daxoa=0 and idtongiao=" + id, "tblToChucQuanTri"); // panelHinhAnh.BackgroundImage = global::service_quan_ly_ton_giao.Properties.Resources.user_login_icon; } }