private void dgvListInvoice_CellClick(object sender, DataGridViewCellEventArgs e) { int row = e.RowIndex; try { int idBill = Convert.ToInt32(dgvListInvoice.Rows[row].Cells[10].Value); if (e.ColumnIndex == dgvListInvoice.Columns["dgvButtonView"].Index && row >= 0) { FrmPrintBill f = new FrmPrintBill(); f.GetReport(idBill); f.ShowDialog(); } } catch { } }
private void dgvListInvoice_CellClick(object sender, DataGridViewCellEventArgs e) { row = e.RowIndex; try { idBill = Convert.ToInt32(dgvListInvoice.Rows[row].Cells[11].Value); InvoiceNumber = dgvListInvoice.Rows[row].Cells[1].Value.ToString(); if (e.ColumnIndex == dgvListInvoice.Columns["dgvButtonView"].Index && row >= 0) { FrmPrintBill f = new FrmPrintBill(); f.GetReport(idBill); f.ShowDialog(); } else if (e.ColumnIndex == dgvListInvoice.Columns["dgvButtonDelete"].Index && row >= 0 && dgvListInvoice.Rows[row].Cells[7].Value.ToString() != "Xóa bỏ") { FrmDeleteInvoice f = new FrmDeleteInvoice(LoadData, idBill, InvoiceNumber); f.ShowDialog(); } } catch { } }
private void btCreateAndPrintInvoice_Click(object sender, EventArgs e) { List <ItemTemp> itemTemps = Invoice_DAO.Instance.GetListItemTemp(userInvoiceTemp()); if (itemTemps.Count == 0) { lbNotification.Text = "Bảng hàng hóa không được để trống!"; i = 5; timerResetNtf.Enabled = true; } else { try { if (TotalAmount >= 0) { int totalLineNumber = 0; for (int j = 0; j < itemTemps.Count; j++) { string idproduct = itemTemps[j].IdItemCode; float unitPrice = itemTemps[j].UnitPrice; string unitName = itemTemps[j].UnitName; int exchangeValue = itemTemps[j].ExchangeValue; float quantity = itemTemps[j].Quantity; if (Invoice_DAO.Instance.InsertDetailBill(idproduct, unitName, exchangeValue, quantity, unitPrice)) { totalLineNumber += 1; } } if (totalLineNumber == itemTemps.Count) { string creator = FrmLogin.username; int discount = Convert.ToInt32(nbDisCount.Value); float totalAmount = TotalAmount; string note = rtbNote.Text; string amountInWord = rtbAmountInWord.Text; string buyerCode = cbBuyerCode.SelectedValue.ToString(); if (buyerCode == null || buyerCode == "") { buyerCode = "nguoi_mua_khong_lay_hoa_don"; } if (Invoice_DAO.Instance.InsertBill(creator, lbSellerTaxCode.Text, buyerCode, totalAmount, discount, amountInWord, note)) { string invoiceNumber = lbIdBill.Text; //string mail = lbBuyerEmail.Text.Trim().ToLower().ToString(); FrmCreateInvoice_Load(sender, e); lbNotification.Text = "Lập HĐ " + invoiceNumber + " thành công!"; i = 5; timerResetNtf.Enabled = true; FrmPrintBill f = new FrmPrintBill(); f.GetReport(Convert.ToInt32(invoiceNumber)); f.ShowDialog(); //if (mail != "") //{ // if (Email_DAO.Instance.isEmail(mail)) // { // SendMail(mail, Convert.ToInt32(invoiceNumber), invoiceNumber); // } //} } else { lbNotification.Text = "Có lỗi kết nối! Vui lòng thử lại!"; i = 5; timerResetNtf.Enabled = true; } } else { lbNotification.Text = "Có lỗi kết nối! Vui lòng thử lại!"; i = 5; timerResetNtf.Enabled = true; } } else { lbNotification.Text = "Tổng tiền của hóa đơn phải lớn hơn hoặc bằng 0 !"; i = 5; timerResetNtf.Enabled = true; } } catch /*(Exception ex)*/ { lbNotification.Text = "Có lỗi kết nối! Vui lòng thử lại!"; i = 5; timerResetNtf.Enabled = true; } } }