Esempio n. 1
0
        private void dgvSanPham_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgvSanPham.Columns[e.ColumnIndex].Name == "colMua" && e.RowIndex != -1)
            {
                int iSL = Convert.ToInt16(dgvSanPham.SelectedRows[0].Cells["colSoLuong"].Value.ToString());

                if (iSL > 0)
                {
                    int    iSLMua  = 0;
                    string strMaSP = dgvSanPham.SelectedRows[0].Cells["colMaSP"].Value.ToString();
                    foreach (DataGridViewRow dgvRow in dgvBanHang.Rows)
                    {
                        if (dgvRow.Cells["colMaSanPham"].Value.ToString() == strMaSP)
                        {
                            iSLMua = Convert.ToInt16(dgvRow.Cells["colSL"].Value.ToString());
                        }
                    }
                    frmThemSLSP frm = new frmThemSLSP(strMaSP, iSLMua, frmThemSLSP.Loai.Them);
                    frm.ShowDialog();
                    if (frm.LaySoLuong() > 0)
                    {
                        ThemSanPhamVaoHoaDon(strMaSP, frm.LaySoLuong());
                    }
                }
                else
                {
                    FormMessage.Show("Sản phẩm không đủ!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 2
0
 private void dgvBanHang_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvBanHang.Columns[e.ColumnIndex].Name == "colChinhSua")
     {
         int         iSL     = Convert.ToUInt16(dgvBanHang.SelectedRows[0].Cells["colSL"].Value.ToString());
         string      strMaSP = dgvBanHang.SelectedRows[0].Cells["colMaSanPham"].Value.ToString();
         frmThemSLSP frm     = new frmThemSLSP(strMaSP, iSL, frmThemSLSP.Loai.ChinhSua);
         frm.ShowDialog();
         if (frm.LaySoLuong() > 0)
         {
             ThemSanPhamVaoHoaDon(strMaSP, frm.LaySoLuong());
         }
     }
     if (dgvBanHang.Columns[e.ColumnIndex].Name == "colXoa")
     {
         dgvBanHang.Rows.RemoveAt(dgvBanHang.SelectedRows[0].Index);
     }
 }
Esempio n. 3
0
 private void dgvSanPham_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (dgvSanPham.Columns[e.ColumnIndex].Name == "colThem" && e.RowIndex != -1)
     {
         int    iSLMua  = 0;
         string strMaSP = dgvSanPham.SelectedRows[0].Cells["colMaSP"].Value.ToString();
         foreach (DataGridViewRow dgvRow in dgvNhapHang.Rows)
         {
             if (dgvRow.Cells["colMaSanPham"].Value.ToString() == strMaSP)
             {
                 iSLMua = Convert.ToInt16(dgvRow.Cells["colSL"].Value.ToString());
             }
         }
         frmThemSLSP frm = new frmThemSLSP(strMaSP, iSLMua, frmThemSLSP.Loai.Mua);
         frm.ShowDialog();
         if (frm.LaySoLuong() > 0)
         {
             ThemSanPhamVaoHoaDon(strMaSP, frm.LaySoLuong());
         }
     }
 }