Пример #1
0
        private void OnDisplayGiaVonDichVuList()
        {
            Result result = GiaVonDichVuBus.GetGiaVonDichVuList(_isFromDateToDate, _fromDate, _toDate, _tenDichVu);

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

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("GiaVonDichVuBus.GetGiaThuocList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("GiaVonDichVuBus.GetGiaThuocList"));
            }
        }
Пример #2
0
        private void OnSaveInfo()
        {
            try
            {
                MethodInvoker method = delegate
                {
                    _giaVonDichVu.ServiceGUID = Guid.Parse(cboService.SelectedValue.ToString());
                    _giaVonDichVu.GiaVon      = (double)numGiaBan.Value;
                    _giaVonDichVu.NgayApDung  = dtpkNgayApDung.Value;
                    _giaVonDichVu.Status      = (byte)Status.Actived;

                    if (_isNew)
                    {
                        _giaVonDichVu.CreatedDate = DateTime.Now;
                        _giaVonDichVu.CreatedBy   = Guid.Parse(Global.UserGUID);
                    }
                    else
                    {
                        _giaVonDichVu.UpdatedDate = DateTime.Now;
                        _giaVonDichVu.UpdatedBy   = Guid.Parse(Global.UserGUID);
                    }

                    Result result = GiaVonDichVuBus.InsertGiaVonDichVu(_giaVonDichVu);

                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("GiaVonDichVuBus.InsertGiaVonDichVu"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("GiaVonDichVuBus.InsertGiaVonDichVu"));
                        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);
            }
        }
Пример #3
0
        private void OnDeleteGiaVonDichVu()
        {
            List <string>  deletedGiaVonList = new List <string>();
            List <DataRow> deletedRows       = new List <DataRow>();
            DataTable      dt = dgGiaVonDichVu.DataSource as DataTable;

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

            if (deletedGiaVonList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những giá vốn dịch vụ mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    Result result = GiaVonDichVuBus.DeleteGiaVonDichVu(deletedGiaVonList);
                    if (result.IsOK)
                    {
                        foreach (DataRow row in deletedRows)
                        {
                            dt.Rows.Remove(row);
                        }
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("GiaVonDichVuBus.DeleteGiaVonDichVu"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("GiaVonDichVuBus.DeleteGiaVonDichVu"));
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những giá vốn dịch vụ cần xóa.", IconType.Information);
            }
        }
Пример #4
0
        private void OnSaveInfo()
        {
            try
            {
                if (_isNew)
                {
                    _serviceHistory.CreatedDate = DateTime.Now;
                    _serviceHistory.CreatedBy = Guid.Parse(Global.UserGUID);
                }
                else
                {
                    _serviceHistory.UpdatedDate = DateTime.Now;
                    _serviceHistory.UpdatedBy = Guid.Parse(Global.UserGUID);
                }

                _serviceHistory.PatientGUID = Guid.Parse(_patientGUID);
                _serviceHistory.Note = txtDescription.Text;

                MethodInvoker method = delegate
                {
                    _serviceHistory.ActivedDate = dtpkActiveDate.Value;
                    _serviceHistory.KhamTuTuc = raKhamTuTuc.Checked;

                    if (cboDocStaff.SelectedValue != null && cboDocStaff.Text.Trim() != string.Empty)
                        _serviceHistory.DocStaffGUID = Guid.Parse(cboDocStaff.SelectedValue.ToString());
                    else
                        _serviceHistory.DocStaffGUID = null;

                    if (chkChuyenNhuong.Checked)
                        _serviceHistory.RootPatientGUID = Guid.Parse(txtChuyenNhuong.Tag.ToString());
                    else
                        _serviceHistory.RootPatientGUID = null;

                    _serviceHistory.ServiceGUID = Guid.Parse(cboService.SelectedValue.ToString());

                    _serviceHistory.Price = (double)numPrice.Value;
                    _serviceHistory.Discount = (double)numDiscount.Value;
                    _serviceHistory.SoLuong = Convert.ToInt32(numSoLuong.Value);

                    _serviceHistory.IsNormalOrNegative = raNormal.Checked;
                    if (raNormal.Checked)
                    {
                        _serviceHistory.Normal = chkNormal.Checked;
                        _serviceHistory.Abnormal = chkAbnormal.Checked;
                        _serviceHistory.Negative = false;
                        _serviceHistory.Positive = false;
                    }
                    else
                    {
                        _serviceHistory.Normal = false;
                        _serviceHistory.Abnormal = false;
                        _serviceHistory.Negative = chkNegative.Checked;
                        _serviceHistory.Positive = chkPositive.Checked;
                    }

                    if (_hopDongGUID != string.Empty)
                        _serviceHistory.HopDongGUID = Guid.Parse(_hopDongGUID);

                    Result result = GiaVonDichVuBus.GetGiaVonDichVuMoiNhat(_serviceHistory.ServiceGUID.ToString(), _serviceHistory.ActivedDate.Value);
                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("GiaVonDichVuBus.GetGiaVonDichVuMoiNhat"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("GiaVonDichVuBus.GetGiaVonDichVuMoiNhat"));
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                        return;
                    }

                    DataTable dt = result.QueryResult as DataTable;
                    if (dt != null && dt.Rows.Count > 0)
                        _serviceHistory.GiaVon = Convert.ToDouble(dt.Rows[0]["GiaVon"]);

                    result = ServiceHistoryBus.InsertServiceHistory(_serviceHistory);
                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("ServiceHistoryBus.InsertServiceHistory"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ServiceHistoryBus.InsertServiceHistory"));
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                    }
                    else if (_serviceGUID == string.Empty)
                    {
                        if (chkBSCD.Checked)
                        {
                            if (_chiDinh == null)
                            {
                                _chiDinh = new ChiDinh();
                                string maChiDinh = GenerateCode();
                                if (maChiDinh == string.Empty) return;

                                //Insert chỉ định
                                _chiDinh.CreatedDate = DateTime.Now;
                                _chiDinh.CreatedBy = Guid.Parse(Global.UserGUID);
                                _chiDinh.MaChiDinh = maChiDinh;
                                _chiDinh.BenhNhanGUID = Guid.Parse(_patientGUID);
                                _chiDinh.BacSiChiDinhGUID = Guid.Parse(cboBacSiChiDinh.SelectedValue.ToString());
                                _chiDinh.NgayChiDinh = DateTime.Now;
                                _chiDinh.Status = (byte)Status.Actived;

                                List<ChiTietChiDinh> addedList = new List<ChiTietChiDinh>();
                                List<string> deletedKeys = new List<string>();
                                ChiTietChiDinh ctcd = new ChiTietChiDinh();
                                ctcd.CreatedDate = DateTime.Now;
                                ctcd.CreatedBy = Guid.Parse(Global.UserGUID);
                                ctcd.ServiceGUID = _serviceHistory.ServiceGUID.Value;
                                addedList.Add(ctcd);

                                result = ChiDinhBus.InsertChiDinh(_chiDinh, addedList, deletedKeys);
                                if (!result.IsOK)
                                {
                                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.InsertChiDinh"), IconType.Error);
                                    Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.InsertChiDinh"));
                                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                                }
                                else
                                {
                                    DichVuChiDinh dichVuChiDinh = new DichVuChiDinh();
                                    dichVuChiDinh.ServiceHistoryGUID = _serviceHistory.ServiceHistoryGUID;
                                    dichVuChiDinh.ChiTietChiDinhGUID = ctcd.ChiTietChiDinhGUID;
                                    dichVuChiDinh.CreatedDate = DateTime.Now;
                                    dichVuChiDinh.CraetedBy = Guid.Parse(Global.UserGUID);
                                    dichVuChiDinh.Status = (byte)Status.Actived;

                                    result = ChiDinhBus.InsertDichVuChiDinh(dichVuChiDinh);
                                    if (!result.IsOK)
                                    {
                                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.InsertDichVuChiDinh"), IconType.Error);
                                        Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.InsertDichVuChiDinh"));
                                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                                    }
                                }
                            }
                            else
                            {
                                _chiDinh.UpdatedDate = DateTime.Now;
                                _chiDinh.UpdatedBy = Guid.Parse(Global.UserGUID);
                                _chiDinh.Status = (byte)Status.Actived;

                                _chiDinh.BacSiChiDinhGUID = Guid.Parse(cboBacSiChiDinh.SelectedValue.ToString());
                                result = ChiDinhBus.UpdateChiDinh(_chiDinh, cboService.SelectedValue.ToString());
                                if (!result.IsOK)
                                {
                                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.UpdateChiDinh"), IconType.Error);
                                    Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.UpdateChiDinh"));
                                    this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                                }
                            }
                        }
                        else if (_chiDinh != null)
                        {
                            List<string> keys = new List<string>();
                            keys.Add(_chiDinh.ChiDinhGUID.ToString());
                            result = ChiDinhBus.DeleteChiDinhs(keys);
                            if (!result.IsOK)
                            {
                                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.DeleteChiDinhs"), IconType.Error);
                                Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.DeleteChiDinhs"));
                                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);
            }
        }