Exemple #1
0
        private void OnDisplayPhieuThuThuocList()
        {
            Result result = PhieuThuThuocBus.GetPhieuThuThuocList(_isFromDateToDate, _fromDate, _toDate, _tenBenhNhan, _type, _type2);

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

                    ShowTongTien();
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuThuocBus.GetPhieuThuThuocList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuThuocBus.GetPhieuThuThuocList"));
            }
        }
        private void OnGetChiTietPhieuThuThuoc(string phieuThuThuocGUID)
        {
            Result result = PhieuThuThuocBus.GetChiTietPhieuThuThuoc(phieuThuThuocGUID);

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

                if (!_isNew)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        UpdateNgayHetHan(row);
                        UpdateSLTon(row);
                    }

                    gridPTT.DataSource = dt;
                    UpdateTongTien();
                }
                else
                {
                    gridPTT.DataSource = dt;
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuThuocBus.GetChiTietPhieuThuThuoc"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuThuocBus.GetChiTietPhieuThuThuoc"));
            }
        }
 private void dlgAddPhieuThuThuoc_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (this.DialogResult == System.Windows.Forms.DialogResult.OK)
     {
         if (_isNew)
         {
             if (CheckInfo())
             {
                 SaveInfoAsThread();
             }
             else
             {
                 e.Cancel = true;
             }
         }
         else //if (Global.StaffType == StaffType.Admin)
         {
             Result result = PhieuThuThuocBus.CapNhatTrangThaiPhieuThu(_phieuThuThuoc.PhieuThuThuocGUID.ToString(),
                                                                       chkDaXuatHD.Checked, chkDaThuTien.Checked, (byte)cboHinhThucThanhToan.SelectedIndex, txtGhiChu.Text);
             if (!result.IsOK)
             {
                 MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuThuocBus.CapNhatTrangThaiPhieuThu"), IconType.Error);
                 Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuThuocBus.CapNhatTrangThaiPhieuThu"));
                 e.Cancel = true;
             }
             else
             {
                 _drPhieuThu["IsExported"]           = chkDaXuatHD.Checked;
                 _drPhieuThu["DaThuTien"]            = chkDaThuTien.Checked;
                 _drPhieuThu["HinhThucThanhToan"]    = (byte)cboHinhThucThanhToan.SelectedIndex;
                 _drPhieuThu["HinhThucThanhToanStr"] = cboHinhThucThanhToan.Text;
                 _drPhieuThu["Notes"] = txtGhiChu.Text;
             }
         }
     }
     else
     {
         if (_isNew)
         {
             if (MsgBox.Question(this.Text, "Bạn có muốn lưu thông tin phiếu thu thuốc ?") == System.Windows.Forms.DialogResult.Yes)
             {
                 if (CheckInfo())
                 {
                     this.DialogResult = System.Windows.Forms.DialogResult.OK;
                     SaveInfoAsThread();
                 }
                 else
                 {
                     e.Cancel = true;
                 }
             }
         }
     }
 }
        private string GetGenerateCode()
        {
            Result result = PhieuThuThuocBus.GetPhieuThuThuocCount();

            if (result.IsOK)
            {
                int count = Convert.ToInt32(result.QueryResult);
                return(Utility.GetCode("PTT", count + 1, 7));
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuThuocBus.GetPhieuThuThuocCount"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuThuocBus.GetPhieuThuThuocCount"));
                return(string.Empty);
            }
        }
        private void GenerateCode()
        {
            Cursor.Current = Cursors.WaitCursor;
            Result result = PhieuThuThuocBus.GetPhieuThuThuocCount();

            if (result.IsOK)
            {
                int count = Convert.ToInt32(result.QueryResult);
                txtMaPhieuThu.Text = Utility.GetCode("PTT", count + 1, 7);
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuThuocBus.GetPhieuThuThuocCount"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuThuocBus.GetPhieuThuThuocCount"));
            }
        }
Exemple #6
0
 private void ShowTongTien()
 {
     if (!chkTongTien.Checked)
     {
         chkTongTien.Text = "Tổng tiền:";
     }
     else
     {
         Result result = PhieuThuThuocBus.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("PhieuThuThuocBus.GetTongTien"), IconType.Error);
             Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuThuocBus.GetTongTien"));
         }
     }
 }
        private void ViewPhieuThuThuoc(string phieuThuThuocGUID)
        {
            Result result = PhieuThuThuocBus.GetPhieuThuThuocAsDataTable(phieuThuThuocGUID);

            if (result.IsOK)
            {
                DataTable dt = result.QueryResult as DataTable;
                if (dt != null && dt.Rows.Count > 0)
                {
                    DataRow row = dt.Rows[0];
                    dlgAddPhieuThuThuoc2 dlg = new dlgAddPhieuThuThuoc2(row);
                    dlg.ShowDialog(this);
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuThuocBus.GetPhieuThuThuocAsDataTable"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuThuocBus.GetPhieuThuThuocAsDataTable"));
            }
        }
        private void OnSaveInfo()
        {
            try
            {
                MethodInvoker method = delegate
                {
                    _phieuThuThuoc.MaPhieuThuThuoc = txtMaPhieuThu.Text;
                    if (cboMaToaThuoc.SelectedValue != null && cboMaToaThuoc.SelectedValue.ToString() != Guid.Empty.ToString())
                    {
                        _phieuThuThuoc.ToaThuocGUID = Guid.Parse(cboMaToaThuoc.SelectedValue.ToString());
                    }
                    else
                    {
                        _phieuThuThuoc.ToaThuocGUID = Guid.Empty;
                    }

                    _phieuThuThuoc.NgayThu           = dtpkNgayThu.Value;
                    _phieuThuThuoc.MaBenhNhan        = txtMaBenhNhan.Text;
                    _phieuThuThuoc.TenBenhNhan       = txtTenBenhNhan.Text;
                    _phieuThuThuoc.DiaChi            = txtDiaChi.Text;
                    _phieuThuThuoc.TenCongTy         = _tenCongTy;
                    _phieuThuThuoc.Status            = (byte)Status.Actived;
                    _phieuThuThuoc.ChuaThuTien       = !chkDaThuTien.Checked;
                    _phieuThuThuoc.Notes             = txtGhiChu.Text;
                    _phieuThuThuoc.LyDoGiam          = txtLyDoGiam.Text;
                    _phieuThuThuoc.HinhThucThanhToan = (byte)cboHinhThucThanhToan.SelectedIndex;

                    if (_isNew)
                    {
                        _phieuThuThuoc.CreatedDate = DateTime.Now;
                        _phieuThuThuoc.CreatedBy   = Guid.Parse(Global.UserGUID);
                    }

                    List <ChiTietPhieuThuThuoc> addedList = new List <ChiTietPhieuThuThuoc>();
                    gridViewPTT.UpdateCurrentRow();
                    DataTable dt = (gridViewPTT.DataSource as DataView).Table;

                    foreach (DataRow row in dt.Rows)
                    {
                        ChiTietPhieuThuThuoc ctptt = new ChiTietPhieuThuThuoc();
                        ctptt.CreatedDate = DateTime.Now;
                        ctptt.CreatedBy   = Guid.Parse(Global.UserGUID);

                        ctptt.ThuocGUID = Guid.Parse(row["ThuocGUID"].ToString());
                        ctptt.DonGia    = Convert.ToDouble(row["DonGia"]);

                        if (row["SoLuong"] != null && row["SoLuong"] != DBNull.Value)
                        {
                            ctptt.SoLuong = Convert.ToDouble(row["SoLuong"]);
                        }
                        else
                        {
                            ctptt.SoLuong = 1;
                        }

                        if (row["Giam"] != null && row["Giam"] != DBNull.Value)
                        {
                            ctptt.Giam = Convert.ToDouble(row["Giam"]);
                        }
                        else
                        {
                            ctptt.Giam = 0;
                        }

                        double tienGiam  = Math.Round(((double)ctptt.SoLuong * (double)ctptt.DonGia * (double)ctptt.Giam) / (double)100);
                        double thanhTien = (double)ctptt.SoLuong * (double)ctptt.DonGia - tienGiam;

                        ctptt.ThanhTien = thanhTien;
                        ctptt.Status    = (byte)Status.Actived;
                        addedList.Add(ctptt);
                    }

                    string maPhieuThu = GetGenerateCode();
                    if (maPhieuThu == string.Empty)
                    {
                        return;
                    }
                    _phieuThuThuoc.MaPhieuThuThuoc = maPhieuThu;

                    Result result = PhieuThuThuocBus.InsertPhieuThuThuoc(_phieuThuThuoc, addedList);

                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("PhieuThuThuocBus.InsertPhieuThuThuoc"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuThuocBus.InsertPhieuThuThuoc"));
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    }
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            catch (Exception e)
            {
                MsgBox.Show(this.Text, e.Message, IconType.Error);
                Utility.WriteToTraceLog(e.Message);
            }
        }
Exemple #9
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()))
                {
                    //deletedPTThuocList.Add(row["PhieuThuThuocGUID"].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["MaPhieuThuThuoc"].ToString();
                        string phieuThuThuocGUID = row["PhieuThuThuocGUID"].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 = PhieuThuThuocBus.DeletePhieuThuThuoc(deletedPTThuocList, noteList);
                        if (result.IsOK)
                        {
                            foreach (DataRow row in deletedRows)
                            {
                                string phieuThuThuocGUID = row["PhieuThuThuocGUID"].ToString();
                                if (deletedPTThuocList.Contains(phieuThuThuocGUID))
                                {
                                    dt.Rows.Remove(row);
                                }
                            }
                        }
                        else
                        {
                            MsgBox.Show(Application.ProductName, result.GetErrorAsString("PhieuThuThuocBus.DeletePhieuThuThuoc"), IconType.Error);
                            Utility.WriteToTraceLog(result.GetErrorAsString("PhieuThuThuocBus.DeletePhieuThuThuoc"));
                        }
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những phiếu thu cần xóa.", IconType.Information);
            }
        }