Exemplo n.º 1
0
 private void btnSuaSP_Click(object sender, EventArgs e)
 {
     if (kttxtSP())
     {
         DialogResult dlr = MessageBox.Show("Bạn có chắc muốn sửa thông tin sản phẩm này?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
         if (dlr == DialogResult.Yes)
         {
             String sql = "update sanpham set tensp = N'" + txtTenSP.Text.Trim() + "', gia = " + Decimal.Parse(txtGia.Text.Trim()) + ", maloai = '" + LOAISANPHAMDAO.MaLoaiSPTheoTenLSP(QuanLyHangHoa.dsLSP, cbboxTenLSP.SelectedItem.ToString().Trim()) + "' where masp = '" + txtMaSP.Text.Trim() + "'";
             cn.themxoasua(sql);
             SANPHAM sp = new SANPHAM(txtMaSP.Text.Trim(), txtTenSP.Text.Trim(), Decimal.Parse(txtGia.Text.Trim()), 0, LOAISANPHAMDAO.MaLoaiSPTheoTenLSP(QuanLyHangHoa.dsLSP, cbboxTenLSP.SelectedItem.ToString().Trim()));
             SANPHAMDAO.SuaSP(dsSP, sp);
             DataGridViewRow row = dgvSP.Rows[indexSP];
             row.Cells[1].Value = txtTenSP.Text.Trim();
             row.Cells[2].Value = txtGia.Text.Trim();
             row.Cells[3].Value = cbboxTenLSP.SelectedItem.ToString().Trim();
             MessageBox.Show("Sửa thành công");
         }
     }
 }