private void btnXoa_Click(object sender, EventArgs e) { gridView1.DeleteSelectedRows(); txtTongTien.Text = ThanhToan_BUS.TinhTien(dt, spinEditGiamGia.Text); if (dt.Rows.Count == 0) { btnThanhToan.Enabled = false; btnXoa.Enabled = false; } }
private void btnThem_Click(object sender, EventArgs e) { if (comboBoxEditMH.Text != "") { if (spinEditSL.Value > 0) { DataRow r = dt.Rows.Find(ThanhToan_BUS.LoadMH().Rows[comboBoxEditMH.SelectedIndex][0]); if (r == null) { if (Convert.ToInt32(spinEditSL.Value) <= Convert.ToInt32(ThanhToan_BUS.LoadMH().Rows[comboBoxEditMH.SelectedIndex][6])) //kiểm tra số lượng còn lại có đủ yêu cầu mua hay không { gridControl1.DataSource = ThanhToan_BUS.Them(comboBoxEditMH.SelectedIndex, Convert.ToInt32(spinEditSL.Value), dt); } else { MessageBox.Show("Số lượng hàng hóa còn lại không đủ theo yêu cầu!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { int quantity = int.Parse(r[2].ToString()) + Convert.ToInt32(spinEditSL.Value); if (quantity <= Convert.ToInt32(ThanhToan_BUS.LoadMH().Rows[comboBoxEditMH.SelectedIndex][6])) { gridControl1.DataSource = ThanhToan_BUS.Them(comboBoxEditMH.SelectedIndex, Convert.ToInt32(spinEditSL.Value), dt); } else { MessageBox.Show("Số lượng hàng hóa còn lại không đủ theo yêu cầu!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } txtTongTien.Text = ThanhToan_BUS.TinhTien(dt, spinEditGiamGia.Text); btnThanhToan.Enabled = true; btnXoa.Enabled = true; } else { MessageBox.Show("Số lượng > 0!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Bạn phải chọn mặt hàng!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void spinEditGiamGia_EditValueChanged(object sender, EventArgs e) { txtTongTien.Text = ThanhToan_BUS.TinhTien(dt, spinEditGiamGia.Value.ToString()); }