private void btExportToPDF_Click(object sender, EventArgs e) { FolderBrowserDialog dl = new FolderBrowserDialog(); if (dl.ShowDialog(this) == DialogResult.OK) { string filePath = dl.SelectedPath; List <Invoice> list = Invoice_DAO.Instance.GetListInvoiceWithTime(dateTimeFrom.Value, dateTimeTo.Value); FrmPrintBill f = new FrmPrintBill(Notification, list, filePath); } }
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 { } }
//public static string filePath; private void btSend_Click(object sender, EventArgs e) { string toMail = tbToEmail.Text.Trim().ToLower().ToString(); if (toMail != "") { if (Email_DAO.Instance.isEmail(toMail)) { lbNotification.Text = "Hệ thống đã thực hiện gửi mail."; FrmPrintBill f = new FrmPrintBill(idBill, invoiceNumber, toMail); //d = 1; //timer1.Enabled = true; this.Close(); //filePath = f.GetFileInvoice(idBill,invoiceNumber); //try //{ // if (File.Exists(filePath)) // { // Thread thread = new Thread(() => // { // if (Email_DAO.Instance.SendInvoiceToMail(toMail, new Attachment(filePath))) // { // //DeleteFileAfterSendMail(filePath); // } // else lbNotification.Text = "Gửi mail thất bại"; // //CloseF(); // } // ); // thread.Start(); // this.Close(); // } //} //catch { } } else { lbNotification.Text = "Email không đúng định dạng!"; d = 5; timer1.Enabled = true; tbToEmail.Text = ""; } } }
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 SendMail(string toMail, int idBill, string invoiceNumber) { FrmPrintBill f = new FrmPrintBill(null); string filePath = f.GetFileInvoice(idBill, invoiceNumber); try { if (File.Exists(filePath)) { Thread thread = new Thread(() => { if (Email_DAO.Instance.SendInvoiceToMail(toMail, new Attachment(filePath))) { //DeleteFileAfterSendMail(filePath); } //CloseF(); } ); thread.Start(); } } 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; } } }