コード例 #1
0
ファイル: uHuyThuocList.cs プロジェクト: itcthienkhiem/LIS
        private void OnDisplayHuyThuocList()
        {
            lock (ThisLock)
            {
                Result result = HuyThuocBus.GetHuyThuocList(_name, _tuNgay, _denNgay);
                if (result.IsOK)
                {
                    dgHuyThuoc.Invoke(new MethodInvoker(delegate()
                    {
                        ClearData();

                        DataTable dt = result.QueryResult as DataTable;
                        if (_dtTemp == null)
                        {
                            _dtTemp = dt.Clone();
                        }
                        UpdateChecked(dt);
                        dgHuyThuoc.DataSource = dt;
                    }));
                }
                else
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("HuyThuocBus.GetHuyThuocList"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("HuyThuocBus.GetHuyThuocList"));
                }
            }
        }
コード例 #2
0
ファイル: uHuyThuocList.cs プロジェクト: itcthienkhiem/LIS
        private void OnDelete()
        {
            if (_dictHuyThuoc == null)
            {
                return;
            }
            List <string>  deletedHuyThuocList = new List <string>();
            List <DataRow> deletedRows         = _dictHuyThuoc.Values.ToList();

            if (deletedRows.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những hủy thuốc mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    foreach (DataRow row in deletedRows)
                    {
                        string huyThuocGUID = row["HuyThuocGUID"].ToString();
                        deletedHuyThuocList.Add(huyThuocGUID);
                    }

                    Result result = HuyThuocBus.DeleteHuyThuoc(deletedHuyThuocList);
                    if (result.IsOK)
                    {
                        DataTable dt = dgHuyThuoc.DataSource as DataTable;
                        if (dt == null || dt.Rows.Count <= 0)
                        {
                            return;
                        }

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

                            _dictHuyThuoc.Remove(key);
                            rows = _dtTemp.Select(string.Format("HuyThuocGUID='{0}'", key));
                            if (rows != null && rows.Length > 0)
                            {
                                _dtTemp.Rows.Remove(rows[0]);
                            }
                        }
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("HuyThuocBus.DeleteHuyThuoc"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("HuyThuocBus.DeleteHuyThuoc"));
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những hủy thuốc cần xóa.", IconType.Information);
            }
        }
コード例 #3
0
        private void DisplayThuocTonKho(string thuocGUID)
        {
            Result result = HuyThuocBus.GetThuocTonKho(thuocGUID);

            if (result.IsOK)
            {
                if (result.QueryResult != null)
                {
                    int soLuongTon = Convert.ToInt32(result.QueryResult);
                    numSoLuongTon.Value = soLuongTon;
                }
                else
                {
                    numSoLuongTon.Value = 0;
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("HuyThuocBus.GetNgayHetHanCuaThuoc"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("HuyThuocBus.GetNgayHetHanCuaThuoc"));
            }
        }
コード例 #4
0
        private void OnSaveInfo()
        {
            try
            {
                MethodInvoker method = delegate
                {
                    _huyThuoc.CreatedBy   = Guid.Parse(Global.UserGUID);
                    _huyThuoc.CreatedDate = DateTime.Now;
                    _huyThuoc.ThuocGUID   = Guid.Parse(cboThuoc.SelectedValue.ToString());
                    _huyThuoc.SoLuong     = (int)numSoLuong.Value;
                    _huyThuoc.NgayHuy     = dtpkNgayHuy.Value;
                    _huyThuoc.Note        = txtGhiChu.Text;

                    Result result = HuyThuocBus.InsertHuyThuoc(_huyThuoc);

                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("HuyThuocBus.InsertHuyThuoc"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("HuyThuocBus.InsertHuyThuoc"));
                        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);
            }
        }
コード例 #5
0
        private bool CheckInfo()
        {
            if (cboThuoc.Text.Trim() == string.Empty)
            {
                MsgBox.Show(this.Text, "Vui lòng chọn 1 thuốc.", IconType.Information);
                cboThuoc.Focus();
                return(false);
            }

            string thuocGUID = cboThuoc.SelectedValue.ToString();
            Result result    = HuyThuocBus.GetThuocTonKho(thuocGUID);

            if (result.IsOK)
            {
                int soLuongTon = 0;
                if (result.QueryResult != null)
                {
                    soLuongTon = Convert.ToInt32(result.QueryResult);
                }

                if ((int)numSoLuong.Value > soLuongTon)
                {
                    MsgBox.Show(this.Text, "Số lượng hủy lớn hơn số lượng thuốc còn trong kho. Vui lòng kiểm tra lại.", IconType.Information);
                    numSoLuong.Focus();
                    return(false);
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("HuyThuocBus.GetNgayHetHanCuaThuoc"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("HuyThuocBus.GetNgayHetHanCuaThuoc"));
                return(false);
            }

            return(true);
        }