Exemple #1
0
        private void OnDeleteInvoice()
        {
            List <string>  deletedInvoiceList = new List <string>();
            List <DataRow> deletedRows        = new List <DataRow>();
            DataTable      dt = dgInvoice.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    deletedRows.Add(row);
                }
            }

            if (deletedRows.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những hóa đơn mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    List <string> noteList = new List <string>();

                    foreach (DataRow row in deletedRows)
                    {
                        string invoiceCode = row["InvoiceCode"].ToString();
                        string invoiceGUID = row["InvoiceGUID"].ToString();

                        dlgLyDoXoa dlg = new dlgLyDoXoa(invoiceCode, 1);
                        if (dlg.ShowDialog(this) == DialogResult.OK)
                        {
                            noteList.Add(dlg.Notes);
                            deletedInvoiceList.Add(invoiceGUID);
                        }
                    }

                    if (deletedInvoiceList.Count > 0)
                    {
                        Result result = InvoiceBus.DeleteInvoices(deletedInvoiceList, noteList);
                        if (result.IsOK)
                        {
                            foreach (DataRow row in deletedRows)
                            {
                                string invoiceGUID = row["InvoiceGUID"].ToString();
                                if (deletedInvoiceList.Contains(invoiceGUID))
                                {
                                    dt.Rows.Remove(row);
                                }
                            }
                        }
                        else
                        {
                            MsgBox.Show(Application.ProductName, result.GetErrorAsString("InvoiceBus.DeleteInvoices"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("InvoiceBus.DeleteInvoices"));
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những hóa đơn cần xóa.", IconType.Information);
            }
        }
Exemple #2
0
        private void OnDisplayInvoiceList()
        {
            Result result = InvoiceBus.GetInvoiceList(_fromDate, _toDate, _tenBenhNhan, _tenDonVi, _maSoThue, _type);

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    ClearData();
                    dgInvoice.DataSource = result.QueryResult;
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("InvoiceBus.GetInvoiceList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("InvoiceBus.GetInvoiceList"));
            }
        }