Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        private void OnDeletePhieuThu()
        {
            List <string>  deletedPTThuocList = new List <string>();
            List <DataRow> deletedRows        = new List <DataRow>();
            DataTable      dt = dgPhieuThu.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 phiếu thu mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    List <string> noteList = new List <string>();

                    foreach (DataRow row in deletedRows)
                    {
                        string maPhieuThuThuoc   = row["MaPhieuThuCapCuu"].ToString();
                        string phieuThuThuocGUID = row["PhieuThuCapCuuGUID"].ToString();

                        dlgLyDoXoa dlg = new dlgLyDoXoa(maPhieuThuThuoc, 0);
                        if (dlg.ShowDialog(this) == DialogResult.OK)
                        {
                            noteList.Add(dlg.Notes);
                            deletedPTThuocList.Add(phieuThuThuocGUID);
                        }
                    }

                    if (deletedPTThuocList.Count > 0)
                    {
                        Result result = PhieuThuCapCuuBus.DeletePhieuThuCapCuu(deletedPTThuocList, noteList);
                        if (result.IsOK)
                        {
                            foreach (DataRow row in deletedRows)
                            {
                                string phieuThuThuocGUID = row["PhieuThuCapCuuGUID"].ToString();
                                if (deletedPTThuocList.Contains(phieuThuThuocGUID))
                                {
                                    dt.Rows.Remove(row);
                                }
                            }
                        }
                        else
                        {
                            MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuCapCuuBus.DeletePhieuThuCapCuu"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuCapCuuBus.DeletePhieuThuCapCuu"));
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những phiếu thu cần xóa.", IconType.Information);
            }
        }
Exemplo n.º 3
0
        private void OnDeleteService()
        {
            if (_dictServices == null)
            {
                return;
            }

            List <DataRow> checkedRows = _dictServices.Values.ToList <DataRow>();

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

                    foreach (DataRow row in checkedRows)
                    {
                        string serviceCode = row["Code"].ToString();
                        string serviceGUID = row["ServiceGUID"].ToString();

                        dlgLyDoXoa dlg = new dlgLyDoXoa(serviceCode, 2);
                        if (dlg.ShowDialog(this) == DialogResult.OK)
                        {
                            noteList.Add(dlg.Notes);
                            deletedServiceList.Add(serviceGUID);
                        }
                    }

                    if (deletedServiceList.Count > 0)
                    {
                        Result result = ServicesBus.DeleteServices(deletedServiceList, noteList);
                        if (result.IsOK)
                        {
                            DataTable dt = dgService.DataSource as DataTable;
                            if (dt == null || dt.Rows.Count <= 0)
                            {
                                return;
                            }
                            foreach (string key in deletedServiceList)
                            {
                                DataRow[] rows = dt.Select(string.Format("ServiceGUID='{0}'", key));
                                if (rows == null || rows.Length <= 0)
                                {
                                    continue;
                                }
                                dt.Rows.Remove(rows[0]);
                            }

                            _dictServices.Clear();
                            _dtTemp.Rows.Clear();
                        }
                        else
                        {
                            MsgBox.Show(Application.ProductName, result.GetErrorAsString("ServicesBus.DeleteServices"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("ServicesBus.DeleteServices"));
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những dịch vụ cần xóa.", IconType.Information);
            }
        }
Exemplo n.º 4
0
        private void OnDeleteLoThuoc()
        {
            if (_dictLoThuoc == null)
            {
                return;
            }
            List <string>  deletedLoThuocList = new List <string>();
            List <DataRow> deletedRows        = _dictLoThuoc.Values.ToList();

            if (deletedRows.Count > 0)
            {
                foreach (DataRow row in deletedRows)
                {
                    string key = row["LoThuocGUID"].ToString();
                    Result rs  = LoThuocBus.GetLoThuoc(key);
                    if (!rs.IsOK)
                    {
                        MsgBox.Show(Application.ProductName, rs.GetErrorAsString("LoThuocBus.GetLoThuoc"), IconType.Error);
                        Utility.WriteToTraceLog(rs.GetErrorAsString("LoThuocBus.GetLoThuoc"));
                        return;
                    }

                    LoThuoc lt = rs.QueryResult as LoThuoc;
                    if (lt.SoLuongXuat > 0)
                    {
                        MsgBox.Show(Application.ProductName, string.Format("Lô thuốc: '{0}' này đã xuất rồi không thể xóa.", lt.TenLoThuoc),
                                    IconType.Information);
                        return;
                    }
                }

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

                    foreach (DataRow row in deletedRows)
                    {
                        string     loThuocGUID = row["LoThuocGUID"].ToString();
                        string     maLoThuoc   = row["MaLoThuoc"].ToString();
                        dlgLyDoXoa dlg         = new dlgLyDoXoa(maLoThuoc, 3);
                        if (dlg.ShowDialog(this) == DialogResult.OK)
                        {
                            noteList.Add(dlg.Notes);
                            deletedLoThuocList.Add(loThuocGUID);
                        }
                    }

                    if (deletedLoThuocList.Count > 0)
                    {
                        Result result = LoThuocBus.DeleteLoThuoc(deletedLoThuocList, noteList);
                        if (result.IsOK)
                        {
                            DataTable dt = dgLoThuoc.DataSource as DataTable;
                            if (dt == null || dt.Rows.Count <= 0)
                            {
                                return;
                            }

                            foreach (string key in deletedLoThuocList)
                            {
                                DataRow[] rows = dt.Select(string.Format("LoThuocGUID='{0}'", key));
                                if (rows == null || rows.Length <= 0)
                                {
                                    continue;
                                }
                                dt.Rows.Remove(rows[0]);

                                _dictLoThuoc.Remove(key);
                                rows = _dtTemp.Select(string.Format("LoThuocGUID='{0}'", key));
                                if (rows != null && rows.Length > 0)
                                {
                                    _dtTemp.Rows.Remove(rows[0]);
                                }
                            }
                        }
                        else
                        {
                            MsgBox.Show(Application.ProductName, result.GetErrorAsString("LoThuocBus.DeleteLoThuoc"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("LoThuocBus.DeleteLoThuoc"));
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những lô thuốc cần xóa.", IconType.Information);
            }
        }