示例#1
0
        private List <double> GetGiaThuoc(string thuocGUID)
        {
            Result        result       = GiaThuocBus.GetGiaThuocMoiNhat(thuocGUID);
            List <double> giaThuocList = new List <double>();

            if (result.IsOK)
            {
                DataTable dt = result.QueryResult as DataTable;
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        giaThuocList.Add(Convert.ToDouble(row["GiaBan"]));
                    }

                    giaThuocList.Sort();
                }
            }
            else
            {
                MsgBox.Show(this.Text, result.GetErrorAsString("GiaThuocBus.GetGiaThuocMoiNhat"), IconType.Error);
                Utility.WriteToTraceLog(result.GetErrorAsString("GiaThuocBus.GetGiaThuocMoiNhat"));
            }

            return(giaThuocList);
        }
示例#2
0
        private void OnDisplayGiaThuocList()
        {
            lock (ThisLock)
            {
                Result result = GiaThuocBus.GetGiaThuocList(_name, _type);
                if (result.IsOK)
                {
                    dgGiaThuoc.Invoke(new MethodInvoker(delegate()
                    {
                        ClearData();

                        DataTable dt = result.QueryResult as DataTable;
                        if (_dtTemp == null)
                        {
                            _dtTemp = dt.Clone();
                        }
                        UpdateChecked(dt);
                        dgGiaThuoc.DataSource = dt;
                    }));
                }
                else
                {
                    MsgBox.Show(Application.ProductName, result.GetErrorAsString("GiaThuocBus.GetGiaThuocList"), IconType.Error);
                    Utility.WriteToTraceLog(result.GetErrorAsString("GiaThuocBus.GetGiaThuocList"));
                }
            }
        }
示例#3
0
        private void OnDeleteGiaThuoc()
        {
            if (_dictGiaThuoc == null)
            {
                return;
            }
            List <string>  deletedGiaThuocList = new List <string>();
            List <DataRow> deletedRows         = _dictGiaThuoc.Values.ToList();

            foreach (DataRow row in deletedRows)
            {
                string giaThuocGUID = row["GiaThuocGUID"].ToString();
                deletedGiaThuocList.Add(giaThuocGUID);
            }

            if (deletedGiaThuocList.Count > 0)
            {
                if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những giá thuốc mà bạn đã đánh dấu ?") == DialogResult.Yes)
                {
                    Result result = GiaThuocBus.DeleteGiaThuoc(deletedGiaThuocList);
                    if (result.IsOK)
                    {
                        DataTable dt = dgGiaThuoc.DataSource as DataTable;
                        if (dt == null || dt.Rows.Count <= 0)
                        {
                            return;
                        }
                        foreach (string key in deletedGiaThuocList)
                        {
                            DataRow[] rows = dt.Select(string.Format("GiaThuocGUID='{0}'", key));
                            if (rows == null || rows.Length <= 0)
                            {
                                continue;
                            }
                            dt.Rows.Remove(rows[0]);
                        }

                        _dictGiaThuoc.Clear();
                        _dtTemp.Rows.Clear();
                    }
                    else
                    {
                        MsgBox.Show(Application.ProductName, result.GetErrorAsString("GiaThuocBus.DeleteGiaThuoc"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("GiaThuocBus.DeleteGiaThuoc"));
                    }
                }
            }
            else
            {
                MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những giá thuốc cần xóa.", IconType.Information);
            }
        }
示例#4
0
        private void OnSaveInfo()
        {
            try
            {
                MethodInvoker method = delegate
                {
                    _giaThuoc.ThuocGUID  = Guid.Parse(cboThuoc.SelectedValue.ToString());
                    _giaThuoc.GiaBan     = (double)numGiaBan.Value;
                    _giaThuoc.NgayApDung = new DateTime(dtpkNgayApDung.Value.Year, dtpkNgayApDung.Value.Month,
                                                        dtpkNgayApDung.Value.Day, 0, 0, 0, 0);
                    _giaThuoc.Status = (byte)Status.Actived;

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

                    Result result = GiaThuocBus.InsertGiaThuoc(_giaThuoc);

                    if (!result.IsOK)
                    {
                        MsgBox.Show(this.Text, result.GetErrorAsString("GiaThuocBus.InsertGiaThuoc"), IconType.Error);
                        Utility.WriteToTraceLog(result.GetErrorAsString("GiaThuocBus.InsertGiaThuoc"));
                        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);
            }
        }