示例#1
0
        private void OnDisplayThuocList()
        {
            lock (ThisLock)
            {
                Result result = ThuocBus.GetThuocList(_name);
                if (result.IsOK)
                {
                    dgThuoc.Invoke(new MethodInvoker(delegate()
                    {
                        ClearData();

                        DataTable dt = result.QueryResult as DataTable;
                        if (_dtTemp == null)
                        {
                            _dtTemp = dt.Clone();
                        }
                        UpdateChecked(dt);
                        dgThuoc.DataSource = dt;
                    }));
                }
                else
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThuocBus.GetThuocList"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.GetThuocList"));
                }
            }
        }
示例#2
0
        private void InitData()
        {
            Cursor.Current = Cursors.WaitCursor;
            Result result = ThuocBus.GetThuocList();

            if (result.IsOK)
            {
                DataTable dt     = result.QueryResult as DataTable;
                DataRow   newRow = dt.NewRow();
                newRow["ThuocGUID"] = Guid.Empty;
                newRow["TenThuoc"]  = string.Empty;
                dt.Rows.InsertAt(newRow, 0);
                cboThuoc.DataSource = dt;
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThuocBus.GetThuocList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.GetThuocList"));
            }

            if (_type == LoaiToaThuoc.Chung)
            {
                gbToaChung.Enabled   = true;
                gbToaSanKhoa.Enabled = false;
            }
            else
            {
                gbToaChung.Enabled   = false;
                gbToaSanKhoa.Enabled = true;
            }
        }
示例#3
0
        private void OnDisplayThuocList()
        {
            Result result = ThuocBus.GetThuocListNotInNhomThuoc(_nhomThuocGUID);

            if (result.IsOK)
            {
                MethodInvoker method = delegate
                {
                    DataTable dataSource = GetDataSource((DataTable)result.QueryResult);//result.QueryResult as DataTable;
                    dgThuoc.DataSource = dataSource;
                };

                if (InvokeRequired)
                {
                    BeginInvoke(method);
                }
                else
                {
                    method.Invoke();
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThuocBus.GetThuocList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.GetThuocList"));
            }
        }
示例#4
0
        private void OnDeleteThuoc()
        {
            if (_dictThuoc == null)
            {
                return;
            }

            List <string>  deletedThuocList = new List <string>();
            List <DataRow> deletedRows      = _dictThuoc.Values.ToList();

            foreach (DataRow row in deletedRows)
            {
                deletedThuocList.Add(row["ThuocGUID"].ToString());
            }

            if (deletedThuocList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những thuốc mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    Result result = ThuocBus.DeleteThuoc(deletedThuocList);
                    if (result.IsOK)
                    {
                        DataTable dt = dgThuoc.DataSource as DataTable;
                        if (dt == null || dt.Rows.Count <= 0)
                        {
                            return;
                        }

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

                        _dictThuoc.Clear();
                        _dtTemp.Rows.Clear();
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("ThuocBus.DeleteThuoc"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.DeleteThuoc"));
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những thuốc cần xóa.", IconType.Information);
            }
        }
示例#5
0
        private void OnSaveInfo()
        {
            try
            {
                _thuoc.MaThuoc  = txtMaThuoc.Text;
                _thuoc.TenThuoc = txtTenThuoc.Text;
                _thuoc.BietDuoc = txtBietDuoc.Text;
                _thuoc.HamLuong = txtHamLuong.Text;
                _thuoc.HoatChat = txtHoatChat.Text;
                _thuoc.Note     = txtNote.Text;
                _thuoc.Status   = (byte)Status.Actived;

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

                MethodInvoker method = delegate
                {
                    _thuoc.DonViTinh = cboDonViTinh.Text;
                    Result result = ThuocBus.InsertThuoc(_thuoc);

                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("ThuocBus.InsertThuoc"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.InsertThuoc"));
                        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);
            }
        }
示例#6
0
        private void OnDisplayThuoc()
        {
            Result result = ThuocBus.GetThuocList();

            if (result.IsOK)
            {
                repositoryItemLookUpEditTenThuoc.DataSource = result.QueryResult;
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThuocBus.GetThuocList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.GetThuocList"));
            }
        }
示例#7
0
        private void OnDisplayThuocList()
        {
            Cursor.Current = Cursors.WaitCursor;
            Result result = ThuocBus.GetThuocList();

            if (result.IsOK)
            {
                cboThuoc.DataSource = result.QueryResult;
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThuocBus.GetThuocList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.GetThuocList"));
            }
        }
        public void InitData()
        {
            Cursor.Current = Cursors.WaitCursor;
            Result result = ThuocBus.GetThuocList();

            if (result.IsOK)
            {
                _dtThuoc = result.QueryResult as DataTable;
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThuocBus.GetThuocList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.GetThuocList"));
            }
        }
示例#9
0
        private void GenerateCode()
        {
            Cursor.Current = Cursors.WaitCursor;
            Result result = ThuocBus.GetThuocCount();

            if (result.IsOK)
            {
                int count = Convert.ToInt32(result.QueryResult);
                txtMaThuoc.Text = Utility.GetCode("TH", count + 1, 5);
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThuocBus.GetThuocCount"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.GetThuocCount"));
            }
        }
示例#10
0
        private void InitData()
        {
            dtpkNgayHuy.Value = DateTime.Now;

            Cursor.Current = Cursors.WaitCursor;
            Result result = ThuocBus.GetThuocList();

            if (result.IsOK)
            {
                DataTable dt     = result.QueryResult as DataTable;
                DataRow   newRow = dt.NewRow();
                newRow["ThuocGUID"] = Guid.Empty;
                newRow["TenThuoc"]  = string.Empty;
                dt.Rows.InsertAt(newRow, 0);
                cboThuoc.DataSource = dt;
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThuocBus.GetThuocList"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("ThuocBus.GetThuocList"));
            }
        }
示例#11
0
        private bool CheckInfo()
        {
            if (txtMaThuoc.Text.Trim() == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng nhập mã thuốc.", IconType.Information);
                txtMaThuoc.Focus();
                return(false);
            }

            if (txtTenThuoc.Text.Trim() == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng nhập tên thuốc.", IconType.Information);
                txtTenThuoc.Focus();
                return(false);
            }

            string thuocGUID = _isNew ? string.Empty : _thuoc.ThuocGUID.ToString();
            Result result    = ThuocBus.CheckThuocExistCode(thuocGUID, txtMaThuoc.Text);

            if (result.Error.Code == ErrorCode.EXIST || result.Error.Code == ErrorCode.NOT_EXIST)
            {
                if (result.Error.Code == ErrorCode.EXIST)
                {
                    MsgBox.Show(this.Text, "Mã thuốc này đã tồn tại rồi. Vui lòng nhập mã khác.", IconType.Information);
                    txtMaThuoc.Focus();
                    return(false);
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("ThuocBus.CheckThuocExistCode"), IconType.Error);
                return(false);
            }

            return(true);
        }