Esempio n. 1
0
 private void dlgReceiptDetail_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (Global.StaffType == StaffType.Admin)
     {
         if (this.DialogResult == System.Windows.Forms.DialogResult.OK)
         {
             Result result = ReceiptBus.CapNhatTrangThaiPhieuThu(_drReceipt["ReceiptGUID"].ToString(), chkDaXuatHD.Checked,
                                                                 chkDaThuTien.Checked, (byte)cboHinhThucThanhToan.SelectedIndex, chkTrongGoiKham.Checked);
             if (!result.IsOK)
             {
                 MsgBox.Show(Application.ProductName, result.GetErrorAsString("ReceiptBus.CapNhatTrangThaiPhieuThu"), IconType.Error);
                 Utility.WriteToTraceLog(result.GetErrorAsString("ReceiptBus.CapNhatTrangThaiPhieuThu"));
                 e.Cancel = true;
             }
             else
             {
                 _drReceipt["IsExportedInVoice"]    = chkDaXuatHD.Checked;
                 _drReceipt["DaThuTien"]            = chkDaThuTien.Checked;
                 _drReceipt["HinhThucThanhToan"]    = (byte)cboHinhThucThanhToan.SelectedIndex;
                 _drReceipt["HinhThucThanhToanStr"] = cboHinhThucThanhToan.Text;
                 _drReceipt["TrongGoiKham"]         = chkTrongGoiKham.Checked;
             }
         }
     }
 }
        private void OnDisplayChTietPhieuThuDichVuList()
        {
            Result result = ReceiptBus.GetChiTietPhieuThuDichVuList(_isFromDateToDate, _fromDate, _toDate, _tenBenhNhan);

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    ClearData();
                    DataTable dt = result.QueryResult as DataTable;
                    dgChiTiet.DataSource = result.QueryResult;
                    lbKetQuaTimDuoc.Text = string.Format("Kết quả tìm được: {0}", dt.Rows.Count);
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ReceiptBus.GetChiTietPhieuThuDichVuList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ReceiptBus.GetChiTietPhieuThuDichVuList"));
            }
        }
Esempio n. 3
0
        private void DisplayInfo(DataRow drReceipt)
        {
            Cursor.Current      = Cursors.WaitCursor;
            txtPatientName.Text = drReceipt["FullName"].ToString();
            txtFileNum.Text     = drReceipt["FileNum"].ToString();

            if (drReceipt["Address"] != null && drReceipt["Address"] != DBNull.Value)
            {
                txtAddress.Text = drReceipt["Address"].ToString();
            }

            txtReceiptDate.Text = Convert.ToDateTime(drReceipt["ReceiptDate"]).ToString("dd/MM/yyyy HH:mm:ss");

            chkDaXuatHD.Checked     = Convert.ToBoolean(drReceipt["IsExportedInVoice"]);
            chkDaThuTien.Checked    = Convert.ToBoolean(drReceipt["DaThuTien"]);
            chkTrongGoiKham.Checked = Convert.ToBoolean(drReceipt["TrongGoiKham"]);

            if (drReceipt["LyDoGiam"] != null && drReceipt["LyDoGiam"] != DBNull.Value)
            {
                txtLyDoGiam.Text = drReceipt["LyDoGiam"].ToString();
            }

            cboHinhThucThanhToan.SelectedIndex = Convert.ToInt32(drReceipt["HinhThucThanhToan"]);

            lbTotalPrice.Text = "Tổng tiền: 0 (VNĐ)";

            Result result = ReceiptBus.GetReceiptDetailList(drReceipt["receiptGUID"].ToString());

            if (result.IsOK)
            {
                DataTable dt = result.QueryResult as DataTable;
                dgReceiptDetail.DataSource = dt;

                double totalPrice = 0;
                foreach (DataRow row in dt.Rows)
                {
                    double amount = Convert.ToDouble(row["Amount"]);
                    totalPrice += amount;
                }

                if (totalPrice > 0)
                {
                    lbTotalPrice.Text = string.Format("Tổng tiền: {0:#,###} (VNĐ)", totalPrice);
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ReceiptBus.GetReceiptDetailList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ReceiptBus.GetReceiptDetailList"));
            }
        }
Esempio n. 4
0
        private string GenerateCode()
        {
            Cursor.Current = Cursors.WaitCursor;
            Result result = ReceiptBus.GetReceiptCount();

            if (result.IsOK)
            {
                int count = Convert.ToInt32(result.QueryResult);
                return(Utility.GetCode("PT", count + 1, 4));
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ReceiptBus.GetReceiptCount"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ReceiptBus.GetReceiptCount"));
                return(string.Empty);
            }
        }
Esempio n. 5
0
 private void ShowTongTien()
 {
     if (!chkTongTien.Checked)
     {
         chkTongTien.Text = "Tổng tiền:";
     }
     else
     {
         Result result = ReceiptBus.GetTongTien(_isFromDateToDate, _fromDate, _toDate, _tenBenhNhan, _type, _type2);
         if (result.IsOK)
         {
             chkTongTien.Text = string.Format("Tổng tiền: {0:N0} VNĐ", result.QueryResult);
         }
         else
         {
             MsgBox.Show(Application.ProductName, result.GetErrorAsString("ReceiptBus.GetTongTien"), IconType.Error);
             Utility.WriteToTraceLog(result.GetErrorAsString("ReceiptBus.GetTongTien"));
         }
     }
 }
Esempio n. 6
0
        private void OnExportReceipt()
        {
            List <DataRow> paidServiceList   = new List <DataRow>();
            List <DataRow> noPaidServiceList = new List <DataRow>();
            List <DataRow> checkedRows       = CheckedServiceRows;

            foreach (DataRow row in checkedRows)
            {
                bool   isKhamTuTuc = Convert.ToBoolean(row["KhamTuTuc"]);
                string serviceName = row["Name"].ToString();
                if (!isKhamTuTuc)
                {
                    MsgBox.Show(Application.ProductName, string.Format("Dich vụ: '{0}' được khám theo hợp đồng nên không thể xuất phiếu thu. Vui lòng kiểm tra lại.", serviceName), IconType.Information);
                    return;
                }

                bool isExported = Convert.ToBoolean(row["IsExported"]);
                if (!isExported)
                {
                    noPaidServiceList.Add(row);
                }
                else
                {
                    paidServiceList.Add(row);
                }
            }

            if (paidServiceList.Count > 0)
            {
                MsgBox.Show(Application.ProductName, "(Một số) dịch vụ đã xuất phiếu thu rồi. Vui lòng kiểm tra lại.", IconType.Information);
                return;
            }

            if (MsgBox.Question(Application.ProductName, "Bạn có muốn xuất phiếu thu ?") == DialogResult.No)
            {
                return;
            }

            dlgConfirmThuTien dlg = new dlgConfirmThuTien(noPaidServiceList);

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                if (paidServiceList.Count <= 0)
                {
                    List <ReceiptDetail> receiptDetails = new List <ReceiptDetail>();
                    foreach (DataGridViewRow row in dlg.DataGridViewDetail.Rows)
                    {
                        ReceiptDetail detail = new ReceiptDetail();
                        detail.ServiceHistoryGUID = Guid.Parse(row.Tag.ToString());
                        detail.SoLuong            = Convert.ToInt32(row.Cells[2].Value);
                        detail.CreatedDate        = DateTime.Now;
                        detail.CreatedBy          = Guid.Parse(Global.UserGUID);
                        detail.Status             = (byte)Status.Actived;
                        receiptDetails.Add(detail);
                    }

                    Receipt receipt = new Receipt();
                    receipt.ReceiptCode       = GenerateCode();
                    receipt.PatientGUID       = Guid.Parse(_patientGUID);
                    receipt.ReceiptDate       = dlg.NgayXuat;
                    receipt.Status            = (byte)Status.Actived;
                    receipt.CreatedDate       = DateTime.Now;
                    receipt.CreatedBy         = Guid.Parse(Global.UserGUID);
                    receipt.IsExportedInVoice = false;
                    receipt.ChuaThuTien       = !dlg.DaThuTien;
                    receipt.Notes             = dlg.GhiChu;
                    receipt.LyDoGiam          = dlg.LyDoGiam;
                    receipt.HinhThucThanhToan = (byte)dlg.HinhThucThanhToan;
                    receipt.TrongGoiKham      = dlg.TrongGoiKham;

                    Result result = ReceiptBus.InsertReceipt(receipt, receiptDetails);
                    if (result.IsOK)
                    {
                        base.RaiseExportReceiptChanged();
                        DisplayAsThread();

                        if (Global.AllowPrintPhieuThuDichVu)
                        {
                            if (MsgBox.Question(Application.ProductName, "Bạn có muốn in phiếu thu ?") == DialogResult.Yes)
                            {
                                OnPrint(receipt.ReceiptGUID.ToString());
                            }
                        }
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ReceiptBus.InsertReceipt"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ReceiptBus.InsertReceipt"));
                    }
                }
            }
        }
Esempio n. 7
0
        private void CalculateTotalPrice()
        {
            if (!Global.AllowShowServiePrice)
            {
                return;
            }

            double    totalPrice        = 0;
            double    totalPriceReceipt = 0;
            int       count             = 0;
            DataTable dt = dgServiceHistory.DataSource as DataTable;

            if (dt == null || dt.Rows.Count <= 0)
            {
                lbTotalPrice.Text   = "Tổng tiền: 0 (VNĐ)";
                lbTotalReceipt.Text = "Tổng tiền thu (dịch vụ chưa thu tiền): 0 (VNĐ)";
                lbCount.Text        = "Còn lại 0 dịch vụ chưa thu tiền";
            }
            else
            {
                foreach (DataRow row in dt.Rows)
                {
                    double price    = Convert.ToDouble(row["Amount"]);
                    bool   isExport = Convert.ToBoolean(row["IsExported"]);
                    totalPrice += price;

                    if (!isExport)
                    {
                        totalPriceReceipt += price;
                        count++;
                    }
                    else
                    {
                        string serviceHistoryGUID = row["ServiceHistoryGUID"].ToString();
                        Result result             = ReceiptBus.GetReceiptByServiceHistoryGUID(serviceHistoryGUID);
                        if (result.IsOK)
                        {
                            Receipt receipt = result.QueryResult as Receipt;
                            if (receipt == null || receipt.Status == (byte)Status.Deactived)
                            {
                                totalPriceReceipt += price;
                                count++;
                            }
                            else if (receipt.ChuaThuTien)
                            {
                                totalPriceReceipt += price;
                                count++;
                            }
                        }
                        else
                        {
                            MsgBox.Show(this.Text, result.GetErrorAsString("ReceiptBus.GetReceiptByServiceHistoryGUID"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("ReceiptBus.GetReceiptByServiceHistoryGUID"));
                            return;
                        }
                    }
                }

                lbTotalPrice.Text = string.Format("Tổng tiền: {0:#,###} (VNĐ)", totalPrice);

                if (totalPriceReceipt > 0)
                {
                    lbTotalReceipt.Text = string.Format("Tổng tiền thu (dịch vụ chưa thu tiền): {0:#,###} (VNĐ)", totalPriceReceipt);
                    lbCount.Text        = string.Format("Còn lại {0} dịch vụ chưa thu tiền", count);
                }
                else
                {
                    lbTotalReceipt.Text = "Tổng tiền thu (dịch vụ chưa thu tiền): 0 (VNĐ)";
                    lbCount.Text        = "Còn lại 0 dịch vụ chưa thu tiền";
                }
            }
        }
Esempio n. 8
0
        private void OnDeleteReceipt()
        {
            List <string>  deletedReceiptList = new List <string>();
            List <DataRow> deletedRows        = new List <DataRow>();
            DataTable      dt = dgReceipt.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    //deletedReceiptList.Add(row["ReceiptGUID"].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 receiptCode = row["ReceiptCode"].ToString();
                        string receiptGUID = row["ReceiptGUID"].ToString();

                        dlgLyDoXoa dlg = new dlgLyDoXoa(receiptCode, 0);
                        if (dlg.ShowDialog(this) == DialogResult.OK)
                        {
                            noteList.Add(dlg.Notes);
                            deletedReceiptList.Add(receiptGUID);
                        }
                    }

                    if (deletedReceiptList.Count > 0)
                    {
                        Result result = ReceiptBus.DeleteReceipts(deletedReceiptList, noteList);
                        if (result.IsOK)
                        {
                            foreach (DataRow row in deletedRows)
                            {
                                string receiptGUID = row["ReceiptGUID"].ToString();
                                if (deletedReceiptList.Contains(receiptGUID))
                                {
                                    dt.Rows.Remove(row);
                                }
                            }
                        }
                        else
                        {
                            MsgBox.Show(Application.ProductName, result.GetErrorAsString("ReceiptBus.DeleteReceipts"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("ReceiptBus.DeleteReceipts"));
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những phiếu thu cần xóa.", IconType.Information);
            }
        }