Esempio n. 1
0
        private void OnEditChiDinh()
        {
            if (_isChuyenBenhAn)
            {
                return;
            }
            if (dgChiTiet.SelectedRows == null || dgChiTiet.SelectedRows.Count <= 0)
            {
                MsgBox.Show(Application.ProductName, "Vui lòng chọn 1 chỉ định.", IconType.Information);
                return;
            }

            DataRow drChiDinh = (dgChiTiet.SelectedRows[0].DataBoundItem as DataRowView).Row;
            Result  result    = ChiDinhBus.GetChiTietChiDinhList(drChiDinh["ChiDinhGUID"].ToString());

            if (result.IsOK)
            {
                DataTable     dtChiTiet = result.QueryResult as DataTable;
                dlgAddChiDinh dlg       = new dlgAddChiDinh(_patientRow, drChiDinh, dtChiTiet, _dtDichVuChiDinh);
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    DisplayAsThread();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.GetChiTietChiDinhList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.GetChiTietChiDinhList"));
                return;
            }
        }
Esempio n. 2
0
        private void OnDisplayChiDinhList()
        {
            if (_patientRow == null)
            {
                return;
            }
            string patientGUID = _patientRow["PatientGUID"].ToString();
            Result result      = ChiDinhBus.GetChiTietChiDinhList2(patientGUID);

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    ClearChiTietChiDinh();
                    dgChiTiet.DataSource = result.QueryResult;
                    OnGetDichVuChiDinh(patientGUID);
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.GetChiTietChiDinhList2"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.GetChiTietChiDinhList2"));
            }
        }
Esempio n. 3
0
        private void OnDeleteChiDinh()
        {
            List <string>  deletedChiDinhList = new List <string>();
            List <DataRow> deletedRows        = new List <DataRow>();
            DataTable      dt = dgChiTiet.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    string chiTietChiDinhGUID = row["ChiTietChiDinhGUID"].ToString();
                    if (_dtDichVuChiDinh == null && _dtDichVuChiDinh.Rows.Count <= 0)
                    {
                        deletedChiDinhList.Add(chiTietChiDinhGUID);
                        deletedRows.Add(row);
                    }
                    else
                    {
                        DataRow[] rows = _dtDichVuChiDinh.Select(string.Format("ChiTietChiDinhGUID='{0}'", chiTietChiDinhGUID));
                        if (rows != null && rows.Length > 0)
                        {
                            MsgBox.Show(Application.ProductName, "Không thể xóa vì có 1 số chỉ định đã được xác nhận.", IconType.Information);
                            return;
                        }
                        else
                        {
                            deletedChiDinhList.Add(chiTietChiDinhGUID);
                            deletedRows.Add(row);
                        }
                    }
                }
            }

            if (deletedChiDinhList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những chỉ định mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    Result result = ChiDinhBus.DeleteChiTietChiDinhs(deletedChiDinhList);
                    if (result.IsOK)
                    {
                        foreach (DataRow row in deletedRows)
                        {
                            dt.Rows.Remove(row);
                        }
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.DeleteChiTietChiDinhs"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.DeleteChiTietChiDinhs"));
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những chỉ định cần xóa.", IconType.Information);
            }
        }
Esempio n. 4
0
        private void OnChuyenKetQuaKham()
        {
            if (!_isChuyenBenhAn)
            {
                return;
            }

            List <DataRow> deletedRows = new List <DataRow>();
            DataTable      dt          = dgChiTiet.DataSource as DataTable;

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

            if (dgChiTiet.RowCount <= 0 || deletedRows == null || deletedRows.Count <= 0)
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu ít nhất 1 chỉ định cần chuyển.", IconType.Information);
                return;
            }

            if (_patientRow2 == null)
            {
                MsgBox.Show(Application.ProductName, "Vui lòng chọn bệnh nhân nhận chỉ định chuyển đến.", IconType.Information);
                return;
            }

            string fileNum = _patientRow2["FileNum"].ToString();

            if (MsgBox.Question(Application.ProductName, string.Format("Bạn có muốn chuyển những chỉ định đã chọn đến bệnh nhân: '{0}'?", fileNum)) == DialogResult.No)
            {
                return;
            }

            Result result = ChiDinhBus.ChuyenBenhAn(_patientRow2["PatientGUID"].ToString(), deletedRows);

            if (result.IsOK)
            {
                DisplayAsThread();
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.ChuyenBenhAn"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.ChuyenBenhAn"));
            }
        }
Esempio n. 5
0
        private void GenerateCode()
        {
            Cursor.Current = Cursors.WaitCursor;
            Result result = ChiDinhBus.GetChiDinhCount();

            if (result.IsOK)
            {
                int count = Convert.ToInt32(result.QueryResult);
                txtMaChiDinh.Text = Utility.GetCode("CD", count + 1, 5);
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ChiDinhBus.GetChiDinhCount"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.GetChiDinhCount"));
            }
        }
Esempio n. 6
0
        public void OnGetDichVuChiDinh(string patientGUID)
        {
            Result result = ChiDinhBus.GetDichVuChiDinhList2(patientGUID);

            if (result.IsOK)
            {
                if (_dtDichVuChiDinh != null)
                {
                    _dtDichVuChiDinh.Rows.Clear();
                    _dtDichVuChiDinh.Clear();
                    _dtDichVuChiDinh = null;
                }

                _dtDichVuChiDinh = result.QueryResult as DataTable;
                if (_dtDichVuChiDinh == null && _dtDichVuChiDinh.Rows.Count <= 0)
                {
                    return;
                }

                foreach (DataGridViewRow row in dgChiTiet.Rows)
                {
                    DataRow r = (row.DataBoundItem as DataRowView).Row;
                    string  chiTietChiDinhGUID = r["ChiTietChiDinhGUID"].ToString();

                    DataRow[] rows = _dtDichVuChiDinh.Select(string.Format("ChiTietChiDinhGUID='{0}'", chiTietChiDinhGUID));
                    if (rows != null && rows.Length > 0)
                    {
                        //(row.Cells["Checked"] as DataGridViewDisableCheckBoxCell).Enabled = false;
                        row.DefaultCellStyle.BackColor = Color.LightSeaGreen;
                    }

                    r["Checked"] = false;
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.GetDichVuChiDinhList2"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.GetDichVuChiDinhList2"));
            }
        }
Esempio n. 7
0
        private bool CheckInfo()
        {
            if (cboDocStaff.SelectedValue == null || cboDocStaff.Text == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng chọn bác sĩ chỉ định", IconType.Information);
                cboDocStaff.Focus();
                return(false);
            }

            if (this.CheckedRows == null || this.CheckedRows.Count <= 0)
            {
                MsgBox.Show(this.Text, "Vui lòng chọn ít nhất 1 dịch vụ chỉ định.", IconType.Information);
                return(false);
            }

            string chiDinhGUID = _isNew ? string.Empty : _chiDinh.ChiDinhGUID.ToString();
            Result result      = ChiDinhBus.CheckChiDinhExistCode(chiDinhGUID, txtMaChiDinh.Text);

            if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST)
            {
                if (result.Error.Code == ErrorCode.EXIST)
                {
                    MsgBox.Show(this.Text, "Mã chỉ định này đã tồn tại rồi. Vui lòng nhập mã khác.", IconType.Information);
                    txtMaChiDinh.Focus();
                    return(false);
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ChiDinhBus.CheckChiDinhExistCode"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.CheckChiDinhExistCode"));
                return(false);
            }

            return(true);
        }
Esempio n. 8
0
        private void OnConfirmDichVuChiDinh()
        {
            List <DataRow> checkedRows = new List <DataRow>();
            DataTable      dt          = dgChiTiet.DataSource as DataTable;

            foreach (DataRow row in dt.Rows)
            {
                if (Boolean.Parse(row["Checked"].ToString()))
                {
                    string chiTietChiDinhGUID = row["ChiTietChiDinhGUID"].ToString();
                    if (_dtDichVuChiDinh == null && _dtDichVuChiDinh.Rows.Count <= 0)
                    {
                        checkedRows.Add(row);
                    }
                    else
                    {
                        DataRow[] rows = _dtDichVuChiDinh.Select(string.Format("ChiTietChiDinhGUID='{0}'", chiTietChiDinhGUID));
                        if (rows != null && rows.Length > 0)
                        {
                            MsgBox.Show(Application.ProductName, "Không thể xác nhận chỉ định vì có 1 số chỉ định đã được xác nhận rồi.", IconType.Information);
                            return;
                        }
                        else
                        {
                            checkedRows.Add(row);
                        }
                    }
                }
            }

            if (checkedRows.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xác nhận những dịch vụ chỉ định mà bạn đánh dấu ?") == DialogResult.Yes)
                {
                    foreach (DataRow row in checkedRows)
                    {
                        dlgAddServiceHistory dlg = new dlgAddServiceHistory(_patientRow["PatientGUID"].ToString());
                        dlg.ServiceGUID      = row["ServiceGUID"].ToString();
                        dlg.BacSiChiDinhGUID = row["BacSiChiDinhGUID"].ToString();
                        if (dlg.ShowDialog(this) == DialogResult.OK)
                        {
                            if (dlg.ServiceHistory.ServiceHistoryGUID == Guid.Empty)
                            {
                                return;
                            }

                            DichVuChiDinh dichVuChiDinh = new DichVuChiDinh();
                            dichVuChiDinh.ServiceHistoryGUID = dlg.ServiceHistory.ServiceHistoryGUID;
                            dichVuChiDinh.ChiTietChiDinhGUID = Guid.Parse(row["ChiTietChiDinhGUID"].ToString());
                            dichVuChiDinh.CreatedDate        = DateTime.Now;
                            dichVuChiDinh.CraetedBy          = Guid.Parse(Global.UserGUID);
                            dichVuChiDinh.Status             = (byte)Status.Actived;

                            Result result = ChiDinhBus.InsertDichVuChiDinh(dichVuChiDinh);
                            if (!result.IsOK)
                            {
                                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ChiDinhBus.InsertDichVuChiDinh"), IconType.Error);
                                Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.InsertDichVuChiDinh"));
                                return;
                            }
                        }
                    }

                    OnGetDichVuChiDinh(_patientRow["PatientGUID"].ToString());
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những dịch vụ chỉ định cần xác nhận.", IconType.Information);
            }
        }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        private void DisplayInfo(DataRow drServiceHistory)
        {
            try
            {
                cboService.SelectedValue = drServiceHistory["ServiceGUID"].ToString();
                cboDocStaff.SelectedValue = drServiceHistory["DocStaffGUID"].ToString();

                if (drServiceHistory["RootPatientGUID"] != null && drServiceHistory["RootPatientGUID"] != DBNull.Value)
                {
                    txtChuyenNhuong.Tag = drServiceHistory["RootPatientGUID"].ToString();
                    chkChuyenNhuong.Checked = true;
                }

                if (drServiceHistory["TenBenhNhanChuyenNhuong"] != null && drServiceHistory["TenBenhNhanChuyenNhuong"] != DBNull.Value)
                    txtChuyenNhuong.Text = drServiceHistory["TenBenhNhanChuyenNhuong"].ToString();

                bool isNormalOrNegative = Convert.ToBoolean(drServiceHistory["IsNormalOrNegative"]);
                bool normal = Convert.ToBoolean(drServiceHistory["Normal"]);
                bool abnormal = Convert.ToBoolean(drServiceHistory["Abnormal"]);
                bool negative = Convert.ToBoolean(drServiceHistory["Negative"]);
                bool positive = Convert.ToBoolean(drServiceHistory["Positive"]);

                raNormal.Checked = isNormalOrNegative;
                raNegative.Checked = !isNormalOrNegative;
                chkNormal.Checked = normal;
                chkAbnormal.Checked = abnormal;
                chkNegative.Checked = negative;
                chkPositive.Checked = positive;
                raKhamTuTuc.Checked = Convert.ToBoolean(drServiceHistory["KhamTuTuc"]);
                raKhamTheoHopDong.Checked = !raKhamTuTuc.Checked;

                numPrice.Value = (decimal)Double.Parse(drServiceHistory["FixedPrice"].ToString());
                numDiscount.Value = (decimal)Double.Parse(drServiceHistory["Discount"].ToString());
                numSoLuong.Value = (decimal)Int32.Parse(drServiceHistory["SoLuong"].ToString());
                txtDescription.Text = drServiceHistory["Note"] as string;
                _serviceHistory.ServiceHistoryGUID = Guid.Parse(drServiceHistory["ServiceHistoryGUID"].ToString());

                if (drServiceHistory["ActivedDate"] != null && drServiceHistory["ActivedDate"] != DBNull.Value)
                {
                    _serviceHistory.ActivedDate = Convert.ToDateTime(drServiceHistory["ActivedDate"]);
                    dtpkActiveDate.Value = _serviceHistory.ActivedDate.Value;
                }

                if (drServiceHistory["CreatedDate"] != null && drServiceHistory["CreatedDate"] != DBNull.Value)
                    _serviceHistory.CreatedDate = Convert.ToDateTime(drServiceHistory["CreatedDate"]);

                if (drServiceHistory["CreatedBy"] != null && drServiceHistory["CreatedBy"] != DBNull.Value)
                    _serviceHistory.CreatedBy = Guid.Parse(drServiceHistory["CreatedBy"].ToString());

                if (drServiceHistory["UpdatedDate"] != null && drServiceHistory["UpdatedDate"] != DBNull.Value)
                    _serviceHistory.UpdatedDate = Convert.ToDateTime(drServiceHistory["UpdatedDate"]);

                if (drServiceHistory["UpdatedBy"] != null && drServiceHistory["UpdatedBy"] != DBNull.Value)
                    _serviceHistory.UpdatedBy = Guid.Parse(drServiceHistory["UpdatedBy"].ToString());

                if (drServiceHistory["DeletedDate"] != null && drServiceHistory["DeletedDate"] != DBNull.Value)
                    _serviceHistory.DeletedDate = Convert.ToDateTime(drServiceHistory["DeletedDate"]);

                if (drServiceHistory["DeletedBy"] != null && drServiceHistory["DeletedBy"] != DBNull.Value)
                    _serviceHistory.DeletedBy = Guid.Parse(drServiceHistory["DeletedBy"].ToString());

                _serviceHistory.Status = Convert.ToByte(drServiceHistory["Status"]);

                Result result = ChiDinhBus.GetChiDinh(_serviceHistory.ServiceHistoryGUID.ToString());
                if (!result.IsOK)
                {
                    MsgBox.Show(this.Text, result.GetErrorAsString("ChiDinhBus.GetBacSiChiDinh"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("ChiDinhBus.GetBacSiChiDinh"));
                    return;
                }
                else if (result.QueryResult != null)
                {
                    _chiDinh = (ChiDinh)result.QueryResult;
                    cboBacSiChiDinh.SelectedValue = _chiDinh.BacSiChiDinhGUID.ToString();
                    chkBSCD.Checked = true;
                }

                if (!_allowEdit)
                {
                    btnOK.Enabled = _allowEdit;
                    groupBox1.Enabled = _allowEdit;
                }
            }
            catch (Exception e)
            {
                MsgBox.Show(this.Text, e.Message, IconType.Error);
                Utility.WriteToTraceLog(e.Message);
            }
        }
Esempio n. 11
0
        private void OnSaveInfo()
        {
            try
            {
                if (_isNew)
                {
                    _chiDinh             = new Databasae.ChiDinh();
                    _chiDinh.CreatedDate = DateTime.Now;
                    _chiDinh.CreatedBy   = Guid.Parse(Global.UserGUID);
                }
                else
                {
                    _chiDinh.UpdatedDate = DateTime.Now;
                    _chiDinh.UpdatedBy   = Guid.Parse(Global.UserGUID);
                }

                MethodInvoker method = delegate
                {
                    _chiDinh.MaChiDinh        = txtMaChiDinh.Text;
                    _chiDinh.BenhNhanGUID     = Guid.Parse(_patientRow["PatientGUID"].ToString());
                    _chiDinh.BacSiChiDinhGUID = Guid.Parse(cboDocStaff.SelectedValue.ToString());
                    _chiDinh.NgayChiDinh      = DateTime.Now;
                    _chiDinh.Status           = (byte)Status.Actived;

                    List <DataRow>        checkedRows = this.CheckedRows;
                    List <ChiTietChiDinh> addedList   = new List <ChiTietChiDinh>();
                    List <string>         deletedKeys = new List <string>();

                    foreach (DataRow row in checkedRows)
                    {
                        ChiTietChiDinh ctcd = new ChiTietChiDinh();
                        ctcd.CreatedDate = DateTime.Now;
                        ctcd.CreatedBy   = Guid.Parse(Global.UserGUID);
                        ctcd.ServiceGUID = Guid.Parse(row["ServiceGUID"].ToString());
                        addedList.Add(ctcd);
                    }

                    if (!_isNew)
                    {
                        foreach (DataRow row in _dtChiTietChiDinh.Rows)
                        {
                            bool isExist = false;
                            foreach (DataRow row2 in checkedRows)
                            {
                                if (row["ServiceGUID"].ToString() == row2["ServiceGUID"].ToString())
                                {
                                    isExist = true;
                                    break;
                                }
                            }

                            if (!isExist)
                            {
                                deletedKeys.Add(row["ChiTietChiDinhGUID"].ToString());
                            }
                        }
                    }

                    Result 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;
                    }
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            catch (Exception e)
            {
                MsgBox.Show(this.Text, e.Message, IconType.Error);
                Utility.WriteToTraceLog(e.Message);
            }
        }