Exemplo n.º 1
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text != String.Empty || txtDesc.Text != String.Empty || txtPrice.Text != String.Empty)
            {
                int n;
                if (int.TryParse(txtPrice.Text, out n))
                {
                    string name  = txtName.Text;
                    string desc  = txtDesc.Text;
                    int    price = int.Parse(txtPrice.Text);
                    int    val   = cmbType.SelectedIndex;
                    string type  = typeList[val].SupplyType;

                    MedicalSupply ms = new MedicalSupply(name, type, desc, price);

                    if (ms.InsertMedicalSupply(ms))
                    {
                        notifier.success("Medical Supply added succesfully");

                        AboutUsWindow main = new AboutUsWindow();
                        Content = main;
                    }
                    else
                    {
                        notifier.error("Error adding Medical supply");
                    }
                }
                else
                {
                    notifier.error("Price must be a number");
                }
            }
            else
            {
                notifier.error("Fields cannot be empty");
            }
        }
Exemplo n.º 2
0
        private void cmbOrderList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            GeoCoordinate loc;

            if (orderdelievered)
            {
                GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
                watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
                Thread.Sleep(1000);
                loc = watcher.Position.Location;

                notify.success("you order has now been delievered to : " + loc.ToString());
            }

            gOrderInfo.Visibility = Visibility.Visible;
            orderInfo             = " ";
            txtOrderInfo.Text     = orderInfo;
            int index = cmbOrderList.SelectedIndex;

            order = refinedOrderNum[index].OrderNum;
            List <MedicalSupply> medicalSupplyList = new List <MedicalSupply>();
            MedicalSupply        ms = new MedicalSupply();

            foreach (OrderRequest item in orderRequestsList)
            {
                if (item.OrderNum == order)
                {
                    medicalSupplyList.Add(ms.readMedicalSuppliesByID(item.MedicalSupplyID));
                }
            }

            orderInfo = orderInfo + " ============================ \n";

            foreach (MedicalSupply item in medicalSupplyList)
            {
                orderInfo = orderInfo + item.SupplyName + "\t " + item.SupplyPrice;
                orderInfo = orderInfo + " ============================ \n";
            }

            foreach (MedicalSupply item in medicalSupplyList)
            {
                total = total + item.SupplyPrice;
            }
            orderInfo         = orderInfo + "Total : " + total + "\n";
            txtOrderInfo.Text = orderInfo;
            int status = 0;

            foreach (OrderRequest item in orderRequestsList)
            {
                if (item.OrderNum == refinedOrderNum[index].OrderNum)
                {
                    status = item.OrderStatus;
                }
            }

            switch (status)
            {
            case 0:

                lblStatus.Content = "Pending";


                break;

            case 1:

                lblStatus.Content = "In Progress";

                break;

            case 2:

                lblStatus.Content = "Completed";

                break;

            default:
                lblStatus.Content = "Error";
                break;
            }
        }
        public JsonResult CreateOrEdit(MedicalSupply input, AttachmentAssign assign, bool isEdit)
        {
            try
            {
                if (input.Amount <= 0)
                {
                    return(Json(new { status = false, mess = "Lỗi số lượng" }));
                }
                using (var workScope = new UnitOfWork(new PatientManagementDbContext()))
                {
                    var item            = workScope.Items.FirstOrDefault(x => x.Id == input.ItemId);
                    var medicalSupplies = workScope.MedicalSupplies.Query(x => x.ItemId == input.ItemId).ToList();

                    var hireCount         = medicalSupplies.Where(x => x.Status == StatusMedical.Hired).Sum(x => x.Amount);
                    var availabilityCount = medicalSupplies.Where(x => x.Status == StatusMedical.Availability).Sum(x => x.Amount);
                    var expiredCount      = medicalSupplies.Where(x => x.Status == StatusMedical.Expired).Sum(x => x.Amount);
                    var unavailableCount  = medicalSupplies.Where(x => x.Status == StatusMedical.Unavailable).Sum(x => x.Amount);
                    var maintenanceCount  = medicalSupplies.Where(x => x.Status == StatusMedical.Maintenance).Sum(x => x.Amount);

                    var availabilityItem = item.Amount - hireCount - expiredCount - unavailableCount - maintenanceCount;

                    if (availabilityItem < 0)
                    {
                        return(Json(new { status = false, mess = "Lỗi, dữ liệu âm" + KeyElement }));
                    }

                    if (input.Amount > availabilityItem)
                    {
                        return(Json(new { status = false, mess = $"Lỗi, kho đã hết" + KeyElement }));
                    }
                    if (isEdit)
                    {
                        var elm = workScope.MedicalSupplies.Get(input.Id);

                        if (elm != null) //update
                        {
                            elm = input;
                            workScope.MedicalSupplies.Put(elm, elm.Id);
                            workScope.Complete();

                            return(Json(new { status = true, mess = "Cập nhập thành công " }));
                        }
                        else
                        {
                            return(Json(new { status = false, mess = "Không tồn tại " + KeyElement }));
                        }
                    }
                    else
                    {
                        input.Id = Guid.NewGuid();

                        workScope.MedicalSupplies.Add(input);
                        workScope.Complete();

                        return(Json(new { status = true, mess = "Thêm thành công " + KeyElement }));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, mess = "Có lỗi xảy ra: " + ex.Message }));
            }
        }
Exemplo n.º 4
0
 public MedicalSupply Remove(MedicalSupply medicalSupply)
 {
     return(_medicalSupplyService.Remove(medicalSupply.Id));
 }
Exemplo n.º 5
0
 public MedicalSupply Add(MedicalSupply medicalSupply)
 {
     return(_medicalSupplyService.Add(medicalSupply));
 }
Exemplo n.º 6
0
 public MedicalSupply Update(MedicalSupply medicalSupply)
 {
     return(_medicalSupplyService.Update(medicalSupply));
 }
Exemplo n.º 7
0
 public SupplyView(MedicalSupply medicalSupply)
 {
     this.Id    = medicalSupply.Id;
     this.Type  = medicalSupply.Name;
     this.Count = medicalSupply.Count;
 }
Exemplo n.º 8
0
 internal MedicalSupply Add(MedicalSupply medicalSupply)
 => _medicalSupplyRepository.Add(medicalSupply);
Exemplo n.º 9
0
 internal MedicalSupply Update(MedicalSupply medicalSupply)
 => _medicalSupplyRepository.Update(medicalSupply);
 public MedicalSupply AddMedicalSupply(MedicalSupply medicalSupply)
 {
     throw new NotImplementedException();
 }