예제 #1
0
 private void btnAddInListBookDetail_Click(object sender, EventArgs e)
 {
     if (lkCustomerName.Text == "")
     {
         XtraCustomMessageBox.Show("Thông tin khách hàng khồng thể để trống!", "Lỗi", true);
         lkCustomerName.Focus();
         return;
     }
     if (spQuantity.Value == 0)
     {
         XtraCustomMessageBox.Show("Số lượng bán phải lớn hơn 0", "Lỗi", true);
         spQuantity.Focus();
         return;
     }
     try
     {
         if (m_DeliveryNoteDetailExecute.checkQuantityDelivery((int)spQuantity.Value, txtBookId.Text))
         {
             DataRow _rowValue = m_DeliveryNoteDetailData.NewRow();
             _rowValue["MaSach"]    = txtBookId.Text;
             _rowValue["TenSach"]   = txtBookName.Text;
             _rowValue["TenTL"]     = txtBookGenre.Text;
             _rowValue["TenNXB"]    = txtPublisherName.Text;
             _rowValue["NhomTG"]    = txtAuthorName.Text;
             _rowValue["SoLuong"]   = spQuantity.Value;
             _rowValue["DonGia"]    = spPrices.Value;
             _rowValue["ThanhTien"] = spAmount.Value;
             if (m_DeliveryNoteDetailData.Rows.Count != 0)
             {
                 if (m_DeliveryNoteDetailData.Rows.Contains(txtBookId.Text))
                 {
                     if (XtraMessageBox.Show("Cuốn sách này đã tồn tại trong danh sách!\nBạn có muốn cập nhật thông tin hay không?",
                                             "Thông báo",
                                             MessageBoxButtons.YesNo,
                                             MessageBoxIcon.Warning).Equals(DialogResult.Yes))
                     {
                         m_DeliveryNoteDetailData.Rows.Remove(m_DeliveryNoteDetailData.Rows.Find(txtBookId.Text));
                     }
                     else
                     {
                         return;
                     }
                 }
             }
             m_DeliveryNoteDetailData.Rows.Add(_rowValue);
             grdListDeliveryBook.DataSource = m_DeliveryNoteDetailData;
             updateEnableButtonAndResetValueOfControl(ref btnAddInListBookDetail);
         }
     }
     catch (System.Exception) { }
 }
 private void btnAddInListBookDetail_Click(object sender, EventArgs e)
 {
     if (m_DeliveryNoteDetailExecute.checkQuantityDelivery((int)spQuantity.Value, txtBookId.Text))
     {
         DataRow _rowValue = m_DeliveryNoteDetailData.NewRow();
         _rowValue["MaSach"]    = txtBookId.Text;
         _rowValue["TenSach"]   = txtBookName.Text;
         _rowValue["TenTL"]     = txtBookGenre.Text;
         _rowValue["TenNXB"]    = txtPublisherName.Text;
         _rowValue["NhomTG"]    = txtAuthorName.Text;
         _rowValue["SoLuong"]   = spQuantity.Value;
         _rowValue["DonGia"]    = spPrices.Value;
         _rowValue["ThanhTien"] = spAmount.Value;
         if (m_DeliveryNoteDetailData.Rows.Count != 0)
         {
             if (m_DeliveryNoteDetailData.Rows.Contains(txtBookId.Text))
             {
                 if (XtraMessageBox.Show("Cuốn sách này đã tồn tại trong danh sách!\nBạn có muốn cập nhật thông tin hay không?",
                                         "Thông báo",
                                         MessageBoxButtons.YesNo,
                                         MessageBoxIcon.Warning).Equals(DialogResult.Yes))
                 {
                     m_DeliveryNoteDetailData.Rows.Remove(m_DeliveryNoteDetailData.Rows.Find(txtBookId.Text));
                 }
                 else
                 {
                     return;
                 }
             }
         }
         m_DeliveryNoteDetailData.Rows.Add(_rowValue);
         grdListDeliveryBook.DataSource = m_DeliveryNoteDetailData;
         txtBookId.Text        = null;
         txtBookName.Text      = null;
         txtBookGenre.Text     = null;
         txtPublisherName.Text = null;
         txtAuthorName.Text    = null;
         spQuantity.Value      = 0;
         spPrices.Value        = 0;
         spAmount.Value        = 0;
         btnAdd.Enabled        = true;
         btnDelete.Enabled     = true;
     }
 }