Exemplo n.º 1
0
        // function to insert medicine
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            var medicine = new Framework.Database.Medicine
            {
                Name = txtName.Text,
                Price = Convert.ToDouble(txtPrice.Text),
                Stock = Convert.ToInt32(txtStock.Text),
                Description = txtDescription.Text,
                CategoryId = TextHelper.ToInteger(ddl_category.SelectedValue) ?? 1,
                Active = TextHelper.ToBool(ddl_active.SelectedValue) ?? false

            };

               var medicineObj = new Medicine();

            if (!medicineObj.Insert(medicine))
            {

            }
            else
            {
                Redirect("AddMedicine.aspx");
            }

            lblError.Text = "Medicine Saved";
            Reset();
            refreshGridView();
        }
Exemplo n.º 2
0
        public static void AddRow(Medicine medicine, MainWindow mainWindow, int index, RoutedEventHandler onClickCheckBox)
        {
            _mainWindow = mainWindow;
            _grid = mainWindow.DrugsGrid;

            int col = 0;

            AddTextBlock(col, _rowCount, index.ToString());
            AddTextBlock(++col, _rowCount, medicine.Name);
            AddTextBlock(++col, _rowCount, medicine.Date.ToShortDateString());
            AddCountTextBlock(++col, _rowCount, "1", $"count_{medicine.Code}");
            AddTextBlock(++col, _rowCount, $"{medicine.Price}$");

            if (File.Exists(medicine.ImagePath))
            {
                AddImage(++col, _rowCount, medicine.ImagePath);
            }

            AddTextBlock(++col, _rowCount, medicine.Code.ToString());
            AddCheckBox(++col, _rowCount, $"check_{medicine.Code}", onClickCheckBox);

            _rowSpan += 1;

            _rowCount += 1;

            AddLineInTable();

            ExpandColums();
        }
Exemplo n.º 3
0
 public static Medicine GetMedicineByID(int id)
 {
     Medicine medicine = new Medicine();
     SqlMedicineProvider sqlMedicineProvider = new SqlMedicineProvider();
     medicine = sqlMedicineProvider.GetMedicineByID(id);
     return medicine;
 }
Exemplo n.º 4
0
        private void OnOk(object sender, RoutedEventArgs e)
        {
            var medicineName = MedicineName.Text;
            var medicineCode = string.IsNullOrEmpty(MedicineCode.Text) ? 0 : long.Parse(MedicineCode.Text);
            var medicineDate = MedicineDate.SelectedDate ?? MedicineDate.DisplayDate;
            Medicine medicine = new Medicine(medicineName, medicineDate, medicineCode);

            medicine.ImagePath = txtEditor.Text;

            medicine.UserDesc = new TextRange(UsagesByUser.Document.ContentStart, UsagesByUser.Document.ContentEnd).Text;
            medicine.DangersDesc = new TextRange(DangersByUser.Document.ContentStart, DangersByUser.Document.ContentEnd).Text;

            List<Medicine> medicines = MainWindow.Dict;
            Predicate<Medicine> medicineFinder = (Medicine m) => { return m.Code == medicineCode; };
            if (medicines.Exists(medicineFinder))
            {
                MainWindow.UpdateCounter(medicine, _mainWindow);

                return;
            }

            medicines.Add(medicine);

            RowAdder.AddRow(medicine, _mainWindow, medicines.Count, MainWindow.OnClickCheckBox);
        }
Exemplo n.º 5
0
        private MedicineState this[Medicine medicine]
        {
            get
            {
                if (!this.medicines.ContainsKey(medicine))
                {
                    this.medicines[medicine] = new MedicineState();
                }

                return this.medicines[medicine];
            }
        }
Exemplo n.º 6
0
        public Core.GeneralDatabaseResponse Save(Core.Medicine data)
        {
            using (OMSDataContext omsDataContext = new OMSDataContext())
            {
                if (data.MedicineId == 0)//Add Mode
                {
                    try
                    {
                        var medicines = new Medicine();
                        medicines.CompanyName = data.CompanyName;
                        medicines.GenericName = data.GenericName;
                        medicines.IsDeleted = data.IsDeleted;
                        medicines.IsPrescriptionRequired = data.IsPrescriptionRequired;
                        medicines.MedicineName = data.MedicineName;
                        medicines.ToBeDisplayedInFrontEnd = data.ToBeDisplayedInFrontEnd;
                        medicines.CreatedAt = DateTime.Now;
                        medicines.CreatedBy = data.CreatedBy;
                        omsDataContext.Medicines.InsertOnSubmit(medicines);
                        omsDataContext.SubmitChanges();
                        return GeneralDatabaseResponse.SuccessfullInsert;
                    }
                    catch (Exception)
                    {
                        return GeneralDatabaseResponse.UnsuccessfullInsert;
                    }
                }
                else //Edit Mode
                {
                    try
                    {
                        var medicine = (from med in omsDataContext.Medicines
                                             where med.Id == data.MedicineId
                                             select med).FirstOrDefault();

                        medicine.CompanyName = data.CompanyName;
                        medicine.GenericName = data.GenericName;
                        medicine.IsDeleted = data.IsDeleted;
                        medicine.IsPrescriptionRequired = data.IsPrescriptionRequired;
                        medicine.MedicineName = data.MedicineName;
                        medicine.ToBeDisplayedInFrontEnd = data.ToBeDisplayedInFrontEnd;
                        medicine.UpdatedAt = DateTime.Now;
                        medicine.UpdatedBy = data.UpdatedBy;
                        omsDataContext.SubmitChanges();
                        return GeneralDatabaseResponse.SuccessfullUpdate;
                    }
                    catch (Exception)
                    {
                        return GeneralDatabaseResponse.UnsuccessfullUpdate;
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void btnInputMedicineNewOk_Click(object sender, EventArgs e)
        {
            if (txtBoxInputMedicineNewName.Text.Contains(','))
            {
                MessageBox.Show("Tên thuốc không được chứa dấu phẩy .Gợi ý: dấu chấm ");
                return;
            }
            string strCommand = "Select Name From medicine  Where Name = " + Helper.ConvertToSqlString(this.txtBoxInputMedicineNewName.Text);
            using (DbDataReader reader = db.ExecuteReader(strCommand, null) as DbDataReader)
            {
                reader.Read();
                if (reader.HasRows == true) //level 2
                {
                    MessageBox.Show("Ten Thuoc Bi Trung, Xin Nhap Lai Ten Khac");
                    return;
                }
            }

            Medicine medicine = new Medicine();
            medicine.Name = txtBoxInputMedicineNewName.Text.Trim();
            medicine.InputDay = dateTimePicker3.Value;
            try
            {
                medicine.CostOut = int.Parse(txtBoxInputMedicineNewCostOut.Text);
                medicine.CostIn = int.Parse(txtBoxInputMedicineNewCostIn.Text);
                medicine.Count = int.Parse(txtBoxInputMedicineNewCount.Text);
                medicine.Id = lblInputMedicineNewId.Text;
                medicine.HDSD = textBoxMedicineHdsd.Text;
            }
            catch (Exception)
            {
            }

            if (medicine.CostOut < medicine.CostIn)
            {
                MessageBox.Show("Giá Out không thể nhỏ hơn giá In!", "Lỗi");
                return;
            }

            List<string> columns = new List<string>() { "Name", "Count", "CostIn", "CostOut", "InputDay", "ID", "Hdsd" };
            List<string> values = new List<string>() { medicine.Name, medicine.Count.ToString(), medicine.CostIn.ToString(), medicine.CostOut.ToString(), medicine.InputDay.ToString("yyyy-MM-dd"), medicine.Id, medicine.HDSD };
            db.InsertRowToTable("Medicine", columns, values);
            MessageBox.Show("Thêm mới thuốc thành công");
            //InitInputMedicineMySql();
            //InitComboboxMedicinesMySql();
            RefreshIdOfNewMedicine();
            ClearInputNewMedicine();
            TuThuocForm_Load(sender, e);
        }
Exemplo n.º 8
0
        private void btn_search_Click(object sender, EventArgs e)
        {
            Medicine m1 = new Medicine();
            m1 = ml.search_med(textBox1.Text);

            if (m1 != null)
            {
                textBox1.Text = m1.name;
                textBox2.Text = m1.type;
                textBox3.Text = m1.price;
                dateTimePicker1.Value = m1.date;
                textBox4.Text = m1.shift;
            }

        }
Exemplo n.º 9
0
 public Medicine GetMedicineFromReader(IDataReader reader)
 {
     try
     {
         Medicine medicine = new Medicine
             (
                 (int)reader["MedicineID"],
                 reader["MedicineName"].ToString()
             );
          return medicine;
     }
     catch(Exception ex)
     {
         return null;
     }
 }
Exemplo n.º 10
0
        public static void InsertToTable(Medicine medicine)
        {
            var medicineToInsert = new MedicineEntity(medicine.Code.ToString(), medicine.Name)
            {
                Date = medicine.Date.ToString("d"),
                DangersDesc = medicine.DangersDesc,
                UserDesc = medicine.UserDesc,
                ImagePath = medicine.ImagePath,
                Price = medicine.Price
            };

            // Create the TableOperation object that inserts the customer entity.
            TableOperation insertOperation = TableOperation.Insert(medicineToInsert);

            // Execute the insert operation.
            _table.Execute(insertOperation);
        }
Exemplo n.º 11
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex != -1)
            {
                String mName = listBox1.SelectedItem.ToString();
                Medicine m = new Medicine();
                m = ml.search_med(mName);

                if (m != null)
                {
                    textBox1.Text = m.name;
                    textBox2.Text = m.type;
                    textBox3.Text = m.price;
                    dateTimePicker1.Value = m.date;
                    textBox4.Text = m.shift;
                }
            }
        }
Exemplo n.º 12
0
        public Medicine search_med(string n)
        {
            Medicine found = new Medicine();

                for (int i = 0; i < last_med; i++)
                {
                    if (medlist[i] != null)
                    {
                        if (medlist[i].name == n)
                        {
                            found = medlist[i];
                            break;
                        }
                    }
                }

                return found;
        }
Exemplo n.º 13
0
 private void FillMedicineInfo(Medicine medicine)
 {
     if (medicine != null)
     {
         textEditName.Text             = medicine.Name;
         comboBoxEditType.SelectedItem = medicine.Type.GetEnumDescription();
         if (medicine.Ssi == null)
         {
             radioGroupSsi.SelectedIndex = 0;
         }
         else if (medicine.Ssi == true)
         {
             radioGroupSsi.SelectedIndex = 1;
         }
         else
         {
             radioGroupSsi.SelectedIndex = 2;
         }
         memoEditDescription.Text = medicine.Description;
     }
 }
        public void TestIsMedicineAlreadyExistFalse()
        {
            var med = new Medicine()
            {
                Manufacturer = "test",
                Name         = "test",
                ProductForm  = "test"
            };

            IRepository <Medicine> medRep =
                Mock.Of <IRepository <Medicine> >(d => d.GetAll() == new List <Medicine>()
            {
                new Medicine()
                {
                    Name = "test1", Manufacturer = "test1", ProductForm = "test"
                }
            }.AsQueryable()
                                                  );

            Assert.IsFalse(ValidationClass.IsMedicineAlreadyExist(med, medRep));
        }
Exemplo n.º 15
0
        private static IPrescriptionRepository CreateStubRepository()
        {
            var stubRepository = new Mock <IPrescriptionRepository>();

            var prescriptions = new List <Prescription>();

            List <Medicine> medicines = new List <Medicine>();
            Medicine        medicine  = new Medicine(1, "Medicine Name", 1, "Description", new List <ModelRoom>(), 1, true, 1);

            medicines.Add(medicine);

            Prescription prescription1 = new Prescription(1, 1, medicines, true, "Comment", 1);
            Prescription prescription2 = new Prescription(2, 1, new List <Medicine>(), true, "Some text", 1);

            prescriptions.Add(prescription1);
            prescriptions.Add(prescription2);

            stubRepository.Setup(m => m.GetPrescriptionsForPatient(1)).Returns(prescriptions);

            return(stubRepository.Object);
        }
        public List <Medicine> GetAllMedicine()
        {
            string query = "SELECT *FROM tbl_medicine";

            ASqlConnection.Open();
            ASqlCommand    = new SqlCommand(query, ASqlConnection);
            ASqlDataReader = ASqlCommand.ExecuteReader();
            List <Medicine> aMedicineList = new List <Medicine>();

            while (ASqlDataReader.Read())
            {
                Medicine aMedicine = new Medicine();
                aMedicine.Id       = Convert.ToInt32(ASqlDataReader["id"]);
                aMedicine.Name     = ASqlDataReader["Name"].ToString();
                aMedicine.Quantity = ASqlDataReader["mg_ml"].ToString();
                aMedicineList.Add(aMedicine);
            }
            ASqlDataReader.Close();
            ASqlConnection.Close();
            return(aMedicineList);
        }
        public async Task <IActionResult> PostPurchaseOrder([FromBody] PurchaseOrder purchaseOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _purchaseOrderRepository.CreateAsync(purchaseOrder);

            foreach (var medicinePurchaseOrder in purchaseOrder.MedicinePurchaseOrders)
            {
                Medicine medicine = await _medicineRepository.FindAsync(medicinePurchaseOrder.MedicineId);

                medicine.Stock += medicinePurchaseOrder.Quantity;
                _medicineRepository.Update(medicine);
            }

            await _purchaseOrderRepository.SaveChangesAsync();

            return(CreatedAtAction("GetPurchaseOrders", new { id = purchaseOrder.Id }, purchaseOrder));
        }
        private Dictionary <Medicine, TherapyDose> GetMedicines(string v)
        {
            string[] tokens = v.Split(_listDelimiter.ToCharArray());
            Dictionary <Medicine, TherapyDose> retVal = new Dictionary <Medicine, TherapyDose>();

            foreach (string token in tokens)
            {
                string[] medicineTokens = token.Split(_secondaryListDelimiter.ToCharArray());

                if (string.IsNullOrEmpty(medicineTokens[0]))
                {
                    break;
                }

                Medicine    medicine    = new Medicine(long.Parse(medicineTokens[0]));
                TherapyDose therapyDose = GetTherapyDose(medicineTokens[1]);
                retVal.Add(medicine, therapyDose);
            }

            return(retVal);
        }
        public async Task <ActionResult <Medicine> > PostMedicine(Medicine medicine)
        {
            _context.Medicine.Add(medicine);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (MedicineExists(medicine.Mid))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetMedicine", new { id = medicine.Mid }, medicine));
        }
Exemplo n.º 20
0
    public void Treat(Medicine medicine)
    {
        var inBed = GetComponent <InBed>();

        if (medicine.currentMedicine == inBed.firstTreatment)
        {
            inBed.firstTreatment = -1;
        }
        else if (medicine.currentMedicine == inBed.secondTreatment)
        {
            inBed.secondTreatment = -1;
        }

        if (inBed.firstTreatment == -1 && inBed.secondTreatment == -1)
        {
            GetComponent <InBed>().enabled       = false;
            GetComponent <InTreatment>().enabled = true;
        }

        GameObject.Destroy(medicine.gameObject);
    }
        public async static void InsertMedicine(Medicine medicine, Patient patient)
        {
            MySqlConnection con = InitConnection();

            try
            {
                con.Open();
                String query = $"INSERT INTO medicine VALUES('{medicine.ID}', '{medicine.Name}', " +
                               $"'{medicine.StartingDate.ToString("yyyy-MM-dd")}', '{medicine.EndingDate.ToString("yyyy-MM-dd")}', '{patient.ID}')";
                MySqlCommand command = new MySqlCommand(query, con);
                await command.ExecuteNonQueryAsync();
            }
            catch
            {
                Console.WriteLine("Error Inserting Medicine.");
            }
            finally
            {
                con.Close();
            }
        }
 private void FillMedicineInfo(Medicine medicine)
 {
     textEditMedicineName.Text = medicine.Name;
     textEditMedicineType.Text = BLLHelper.GetEnumDescription(medicine.Type);
     if (!medicine.Ssi.HasValue)
     {
         textEditMedicineSsi.Text = "Bilinmiyor";
     }
     else
     {
         if (medicine.Ssi == true)
         {
             textEditMedicineSsi.Text = "Evet";
         }
         else
         {
             textEditMedicineSsi.Text = "Hayır";
         }
     }
     memoEditMedicineDescription.Text = medicine.Description;
 }
Exemplo n.º 23
0
        public int Insert(Medicine m)
        {
            DateTime date = DateTime.Now;
            string   sql  = "INSERT INTO Medicines (BrandName, GenericId, FormulationId, DosageId, ManufacturerId, Quantity, UnitPrice, SellingPrice, ExpireDate) VALUES (@brandName, @genericId, @formulationId, @dosageId, @manufacturerId, @quantity, @unitPrice, @sellingPrice, @expiredate)";

            this.command = new SqlCommand(sql, this.db.Conn);
            this.command.Parameters.AddWithValue("@brandName", m.BrandName);
            this.command.Parameters.AddWithValue("@genericId", m.GenericId);
            this.command.Parameters.AddWithValue("@formulationId", m.FormulationId);
            this.command.Parameters.AddWithValue("@dosageId", m.DosageId);
            this.command.Parameters.AddWithValue("@manufacturerId", m.ManufacturerId);
            this.command.Parameters.AddWithValue("@quantity", m.Qty);
            this.command.Parameters.AddWithValue("@unitPrice", m.UnitPrice);
            this.command.Parameters.AddWithValue("@sellingPrice", m.SellingPrice);
            this.command.Parameters.AddWithValue("@expireDate", m.ExpireDate);
            this.db.Conn.Open();
            int affectedRows = this.command.ExecuteNonQuery();

            this.db.Close();
            return(affectedRows);
        }
        public Medicine select(int id)
        {
            DataTable dataTable = new DataTable();

            using (SqlConnection conn = new SqlConnection(cs))
            {
                string         query          = "select * from medicine where id=" + id;
                SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(query, conn);
                sqlDataAdapter.Fill(dataTable);
                DataRow  row      = dataTable.Rows[0];
                Medicine medicine = new Medicine
                {
                    id    = Convert.ToInt32(row[0].ToString()),
                    name  = row[1].ToString(),
                    stock = Convert.ToInt32(row[2].ToString()),
                    price = Convert.ToDecimal(row[3].ToString()),
                    brand = row[4].ToString()
                };
                return(medicine);
            }
        }
Exemplo n.º 25
0
        private void VideoCaptureDevice_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            Bitmap        bitmap = (Bitmap)eventArgs.Frame.Clone();
            BarcodeReader reader = new BarcodeReader();
            var           result = reader.Decode(bitmap);

            if (result != null)
            {
                txtBarcode.Invoke(new MethodInvoker(delegate()
                {
                    txtBarcode.Text  = result.ToString();
                    selectedMedicine = _context.Medicines.FirstOrDefault(m => m.Barcode == txtBarcode.Text);
                    if (selectedMedicine != null)
                    {
                        SellMedicinePanel.Visible = true;
                        txtBuyMedName.Text        = selectedMedicine.Name;
                    }
                }));
            }
            pictureBox.Image = bitmap;
        }
Exemplo n.º 26
0
        private bool Check()
        {
            using (MyDbContext context = new MyDbContext())
            {
                foreach (Medicine medicine in medicines)
                {
                    Medicine medicineInDb = context.Medicines.Find(medicine.Id);
                    if (medicineInDb != null)
                    {
                        medicineInDb.Ammount--;
                        context.SaveChanges();
                    }
                    else
                    {
                        MessageBox.Show("ЫыыЫ");
                    }
                }
            }

            return(false);
        }
Exemplo n.º 27
0
        public IEnumerable <Diagnosis> GetDiagnosisByMedicine(Medicine medicine)
        {
            List <Diagnosis> retVal = new List <Diagnosis>();

            IEnumerable <Diagnosis> allDiagnosis = GetAllEager();

            foreach (Diagnosis diagnosis in allDiagnosis)
            {
                IEnumerable <Therapy> therapiesForDiagnosis = diagnosis.Therapies; //Therapy contains information about prescriptions.

                foreach (Therapy therapy in therapiesForDiagnosis)
                {
                    if (therapy.Prescription.Medicine.Keys.Contains(medicine)) //Prescription has information about medicine that is given to the patient.
                    {
                        retVal.Add(diagnosis);
                    }
                }
            }

            return(retVal);
        }
Exemplo n.º 28
0
        //Only Short Details
        void GenerateShortDetailsList()
        {
            MySqlCommand    cmd    = new MySqlCommand("select * from FullMedicineStatusViewAdvance", globalCon);
            MySqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                string   name        = reader.GetString(0);
                int      stocked     = reader.GetInt16(1);
                int      stockedExpB = reader.GetInt16(2);
                int      batchs      = reader.GetInt16(3);
                int      price       = reader.GetInt16(4);
                int      onSchedule  = reader.GetInt16(5);
                Medicine medicine    = BindData(name, stocked, stockedExpB, batchs, price, onSchedule);
                if (!medicines.Contains(medicine))
                {
                    medicines.Add(medicine);
                }
            }
            reader.Close();
        }
 public static void TryTendToRandomPawn(Caravan caravan)
 {
     CaravanTendUtility.FindPawnsNeedingTend(caravan, CaravanTendUtility.tmpPawnsNeedingTreatment);
     if (CaravanTendUtility.tmpPawnsNeedingTreatment.Any <Pawn>())
     {
         Pawn patient = CaravanTendUtility.tmpPawnsNeedingTreatment.RandomElement <Pawn>();
         Pawn pawn    = CaravanTendUtility.FindBestDoctor(caravan, patient);
         if (pawn != null)
         {
             Medicine medicine = null;
             Pawn     pawn2    = null;
             CaravanInventoryUtility.TryGetBestMedicine(caravan, patient, out medicine, out pawn2);
             TendUtility.DoTend(pawn, patient, medicine);
             if (medicine != null && medicine.Destroyed && pawn2 != null)
             {
                 pawn2.inventory.innerContainer.Remove(medicine);
             }
             CaravanTendUtility.tmpPawnsNeedingTreatment.Clear();
         }
     }
 }
Exemplo n.º 30
0
        public Medicine GetMedicineById(int medicineId)
        {
            var query    = from c in context.Medicines where c.Id == medicineId select c;
            var medicine = query.FirstOrDefault();
            var model    = new Medicine()
            {
                Id                = medicine.Id,
                Name              = medicine.Name,
                SKU               = medicine.SKU,
                ProductGUID       = medicine.ProductGUID,
                Price             = medicine.Price,
                Manufacturer      = medicine.Manufacturer,
                ManufacturingDate = medicine.ManufacturingDate,
                Description       = medicine.Description,
                ExpiryDate        = medicine.ExpiryDate,
                IsActive          = medicine.IsActive,
                IsDeleted         = false
            };

            return(model);
        }
Exemplo n.º 31
0
        public List <Medicine> Search_Thuoc(string Category) // Tìm Kiếm thuoc theo danh mục
        {
            string          query  = $"select * from MEDICINE where Category LIKE N'%{Category}%'";
            List <Medicine> res    = new List <Medicine>();
            IDataReader     reader = DataProvider.ExecuteReaderQuery(query);

            Medicine thuoc;

            while (reader.Read())
            {
                thuoc              = new Medicine();
                thuoc.MedicineID   = Convert.ToInt32(reader["MedicineID"]);
                thuoc.MedicineName = Convert.ToString(reader["MedicineName"]);
                thuoc.Category     = Convert.ToString(reader["Category"]);


                res.Add(thuoc);
            }

            return(res);
        }
Exemplo n.º 32
0
        public List <Medicine> GetAll()
        {
            SqlQuery        = "SELECT * FROM tbl_medicines;";
            DbSqlConnection = new SqlConnection(ConnectionString);
            DbSqlConnection.Open();
            DbSqlCommand    = new SqlCommand(SqlQuery, DbSqlConnection);
            DbSqlDataReader = DbSqlCommand.ExecuteReader();
            List <Medicine> medicines = new List <Medicine>();

            while (DbSqlDataReader.Read())
            {
                Medicine aMedicine = new Medicine();
                aMedicine.Name  = DbSqlDataReader["name"].ToString();
                aMedicine.Id    = Convert.ToInt32(DbSqlDataReader["id"]);
                aMedicine.Power = DbSqlDataReader["power"].ToString();
                aMedicine.Type  = DbSqlDataReader["type"].ToString();
                medicines.Add(aMedicine);
            }
            DbSqlConnection.Close();
            return(medicines);
        }
Exemplo n.º 33
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string   medicineName   = txtName.Text;
            decimal  Price          = nmPrice.Value;
            int      Quantity       = (int)nmQuantity.Value;
            string   barcode        = txtBarcode.Text;
            string   description    = rtbDescription.Text;
            DateTime productionDate = dtProductionDate.Value;
            DateTime experienceDate = dtExperienceDate.Value;
            string   firms          = cmbFirms.Text;
            string   tags           = cmbTags.Text;

            if (Utilities.IsEmpty(medicineName, barcode, firms))
            {
                lblError.Visible = false;
                int      firmId   = FindFirm(firms);
                Medicine medicine = _context.Medicines.Add(new Medicine()
                {
                    Medicine_Name   = medicineName,
                    Barcode         = barcode,
                    Price           = Price,
                    Quantity        = Quantity,
                    Production_Date = productionDate,
                    Experience_Date = experienceDate,
                    IsReceipt       = ckReceipt.Checked ? true : false,
                    Description     = description,
                    FirmId          = firmId
                });

                _context.SaveChanges();
                MedecineAddTag(medicine.Id);
                ClearAllField();
                FillMedicineDataGridView();
            }
            else
            {
                lblError.Text    = "Please, fill all field!";
                lblError.Visible = true;
            }
        }
Exemplo n.º 34
0
        /// <summary>
        /// 补药
        /// </summary>
        /// <param name="medicine"></param>
        /// <param name="amount"></param>
        /// <returns>
        /// 0 成功
        /// 1 药盒的通信地址不存在
        /// 2
        /// </returns>
        public int addMedicine(Medicine medicine, int amount)
        {
            //1 获取通信地址

            AddressMapping mapping = addressMappingDAL.findMappingByGuid(medicine.Address.Guid);

            if (mapping == null)
            {
                return(1);
            }

            RequestMessage requestMessage = new RequestMessage();

            requestMessage.Length    = 0;
            requestMessage.Guid      = ConvertCom.IntToChar4((int)medicine.Id);
            requestMessage.ShortAddr = ConvertCom.StringToChar4(mapping.Addr);
            // "ADME"
            requestMessage.Command = ConvertCom.StringToChar4("ADME");
            requestMessage.Length  = requestMessage.setValue(amount);

            Cache.Guid  = 0;
            Cache.State = EleTagResponseState.NONE;
            serialCom.write(requestMessage.getMessageByte(), 0, 14 + requestMessage.Length);
            // 等待成消息返回
            // 最长等待时间10s,循环判断时间间隔10ms
            int count = 1000;

            while (count > 0)
            {
                if (Cache.Guid == (int)medicine.Id &&
                    (Cache.State == EleTagResponseState.ADDING ||
                     Cache.State == EleTagResponseState.ADDING_ERROR))
                {
                    count = 0;
                }
                Thread.Sleep(10);
                count--;
            }
            return(0);
        }
Exemplo n.º 35
0
        public String Post(Medicine med)
        {
            DataTable table = new DataTable();

            SqlConnection cn  = new SqlConnection(ConfigurationManager.ConnectionStrings["MedicineAppDB"].ConnectionString);
            SqlCommand    cmd = new SqlCommand("addMed", cn);

            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.AddWithValue("@MedicineName", med.MedicineName);
            cmd.Parameters.AddWithValue("@Brand", med.Brand);
            cmd.Parameters.AddWithValue("@Price", med.Price);
            cmd.Parameters.AddWithValue("@Quantity", med.Quantity);
            cmd.Parameters.AddWithValue("@ExpiryDate", med.ExpiryDate);
            cmd.Parameters.AddWithValue("@Notes", med.Notes);

            cn.Open();
            cmd.ExecuteNonQuery();
            cn.Close();
            //try
            // {

            //string query = @"
            //            insert into dbo.medicines (MedicineName,Brand, Price, Quantity, ExpiryDate, Notes) Values
            //            ('"+med.MedicineName + @"'
            //            ,'" +med.Brand + @"'
            //             ,'" +med.Price + @"'
            //             , '"+med.Quantity +@"'
            //             ,'"+med.ExpiryDate +@"'
            //             , '"+med.Notes +@"')";

            //using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["MedicineAppDB"].ConnectionString))
            //using (var cmd = new SqlCommand(query, con))
            //using (var da = new SqlDataAdapter(cmd))
            //{
            //    cmd.CommandType = CommandType.Text;
            //    da.Fill(table);
            //}
            return("Added Succesfuly");
        }
        private void SetupSpinner()
        {
            spinner = FindViewById <Spinner>(Resource.Id.spinner);
            spinner.ItemSelected += delegate(object sender, AdapterView.ItemSelectedEventArgs args)
            {
                // Contract.Requires(sender != null);
                intervalZi = args.Position + 1;
                if (listmode)
                {
                    SetIntervalOfHours(args.Position);
                }

                if (!listmode)
                {
                    listmode = true;
                }

                if (medicament == null)
                {
                    medicament      = new Medicine(etMedicamentName.Text);
                    medicament.Date = getCurrentDate();
                }

                hourAdapter.NotifyDataSetChanged();
            };

            var categories = new List <string>();

            categories.Add("o data pe zi");
            for (var i = 2; i < 13; i++)
            {
                categories.Add("de " + i + " ori pe zi");
            }

            var dataAdapter = new ArrayAdapter <string>(Context,
                                                        Android.Resource.Layout.SimpleSpinnerItem, categories);

            dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter = dataAdapter;
        }
Exemplo n.º 37
0
        public List <Medicine> GetAllDetails()
        {
            string sql = "SELECT [Medicines].[Id], [Medicines].[BrandName], [Generics].[GenericName], [Formulations].[FormulationType], [Dosages].[DosageAmount], [Manufacturers].[CompanyName], [Medicines].[UnitPrice], [Medicines].[SellingPrice], [Medicines].[Quantity], [Medicines].[ExpireDate] "
                         + "FROM [Medicines] "
                         + "INNER JOIN [Generics] ON "
                         + "[Medicines].[GenericId] = [Generics].[Id] "
                         + "INNER JOIN [Formulations] ON "
                         + "[Medicines].[FormulationId] = [Formulations].[Id] "
                         + "INNER JOIN [Dosages] ON "
                         + "[Medicines].[DosageId] = [Dosages].[Id] "
                         + "INNER JOIN [Manufacturers] ON"
                         + "[Medicines].[ManufacturerId] = [Manufacturers].[Id]";

            this.command = new SqlCommand(sql, this.db.Conn);
            this.db.Conn.Open();
            SqlDataReader reader = this.command.ExecuteReader();

            List <Medicine> mlist = new List <Medicine>();

            while (reader.Read())
            {
                Medicine m = new Medicine();

                m.Id              = Convert.ToInt32(reader["Id"]);
                m.BrandName       = reader["BrandName"].ToString();
                m.GenericName     = reader["GenericName"].ToString();
                m.FormulationType = reader["FormulationType"].ToString();
                m.DosageAmount    = reader["DosageAmount"].ToString();
                m.Manufacturer    = reader["CompanyName"].ToString();
                m.UnitPrice       = Convert.ToDouble(reader["UnitPrice"]);
                m.SellingPrice    = Convert.ToDouble(reader["SellingPrice"]);
                m.Qty             = Convert.ToInt32(reader["Quantity"]);
                m.ExpireDate      = Convert.ToDateTime(reader["ExpireDate"]);

                mlist.Add(m);
            }

            this.db.Close();
            return(mlist);
        }
Exemplo n.º 38
0
        public async Task <ActionResult <Medicine> > PostMedicine(Medicine medicine)
        {
            if (string.IsNullOrEmpty(medicine.Name) ||
                string.IsNullOrEmpty(medicine.DosageUnit)

                )
            {
                return(BadRequest("Name and DosageUnit are required."));
            }

            string strMaxTblSize = _configuration["MaxTableSize"];

            if (!string.IsNullOrEmpty(strMaxTblSize) && _context.Medicines.Count() > Convert.ToInt32(strMaxTblSize))
            {
                return(BadRequest($"Number of records exceeded {strMaxTblSize}."));
            }

            medicine.Name       = System.Net.WebUtility.HtmlEncode(medicine.Name);
            medicine.DosageUnit = System.Net.WebUtility.HtmlEncode(medicine.DosageUnit);

            _context.Medicines.Add(medicine);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (MedicineExists(medicine.MedicineId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetMedicine", new { id = medicine.MedicineId }, medicine));
        }
Exemplo n.º 39
0
 public IActionResult Create(Medicine medicine, int?Id)
 {
     if (Id == null)
     {
         if (ModelState.IsValid)
         {
             _context.Add(medicine);
             _context.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     else
     {
         if (ModelState.IsValid)
         {
             _context.Update(medicine);
             _context.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View(medicine));
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Medicine medicine = db.Medicines.FirstOrDefault(u => u.CategoryID == (id));

            if (medicine == null)
            {
                SqlCommand cmd = new SqlCommand("DELETE FROM Categories WHERE Category_Id= " + id + ";", con);
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                cmd.ExecuteNonQuery();

                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("Category_Name", "This Category can not be Deleted Because some medicines has this Category.");
                return(View());
            }
        }
        private void dataGridLekovi_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SastojciLeka.Items.Clear();
            Medicine selectedMedicine = (Medicine)dataGridLekovi.SelectedItem;

            if (selectedMedicine.IngredientsList != null)
            {
                foreach (Ingredient ingredient in selectedMedicine.IngredientsList)
                {
                    SastojciLeka.Items.Add(ingredient);
                }
            }

            /*SastojciLeka.Items.Clear();
             * Medicine selectedMedicine = (Medicine)dataGridLekovi.SelectedItem;
             * foreach(Ingredient ingredient in selectedMedicine.IngredientsList)
             * {
             *  SastojciLeka.Items.Add(ingredient);
             * }
             * /*List<Ingredient> ingredients = _medicineController.GetMedicineIngredients(selectedMedicine);
             * SastojciLeka.ItemsSource = ingredients;*/
        }
Exemplo n.º 42
0
        public async Task <IActionResult> Create(IFormFile fileobj, [Bind("Medicine_ID,Medicine_Name,Medicine_Price,Medicine_Brand,Medicine_Strip_Tablets,Medicine_Image,Medicine_Content,Medicine_Description")] Medicine mi)
        {
            var imgext = Path.GetExtension(fileobj.FileName);

            if (imgext == ".jpg" || imgext == ".png")
            {
                var uploadimg = Path.Combine("wwwroot", "Medicine_Main_Image", fileobj.FileName);
                var stream    = new FileStream(uploadimg, FileMode.Create);

                await fileobj.CopyToAsync(stream);

                stream.Close();

                //mi.Medicine_ID = 1;
                mi.Medicine_Image = fileobj.FileName;
                await _context.MEDICINETB.AddAsync(mi);

                await _context.SaveChangesAsync();
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 43
0
        public static MedicineList ReadFromTable()
        {
            // Construct the query operation for all customer entities where PartitionKey="Smith".
            TableQuery<MedicineEntity> query = new TableQuery<MedicineEntity>();//.Where(/*TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Smith")*/);

            MedicineList medicineList = new MedicineList();
            // Print the fields for each customer.
            foreach (MedicineEntity entity in _table.ExecuteQuery(query))
            {
                Medicine medicineToAdd = new Medicine();
                medicineToAdd.Code = long.Parse(entity.RowKey);
                medicineToAdd.Name = entity.PartitionKey;
                medicineToAdd.DangersDesc = entity.DangersDesc;
                medicineToAdd.UserDesc = entity.UserDesc;
                medicineToAdd.Price = entity.Price;
                medicineToAdd.ImagePath = entity.ImagePath;
                medicineToAdd.Date = DateTime.Parse(entity.Date);
                medicineList.MedicineVal.Add(medicineToAdd);
            }

            return medicineList;
        }
Exemplo n.º 44
0
        public void Bug_MixedValuesInJson()
        {
            // arrange
            var dx = new Medicine("DX");
            var p = new Medicine("P");
            var d5 = new Medicine("D5");
            var d3 = new Medicine("D3");

            var original = new Supplies();

            original.AddDosage(dx, new DateTime(2013, 12, 21), new CountPerDayDosage(3));
            original.AddDosage(p, new DateTime(2013, 12, 21), new CountPerDayDosage(1));
            original.AddDosage(d5, new DateTime(2013, 12, 21), new CountPerDayDosage(2));
            original.AddDosage(d3, new DateTime(2013, 11, 27), new CountPerDayDosage(1));

            original.Refill(new Dictionary<Medicine, Stock>
            {
                {dx, new Stock(205, new DateTime(2013, 12, 21))},
                {p, new Stock(60, new DateTime(2013, 12, 21))},
                {d5, new Stock(181, new DateTime(2013, 12, 21))},
                {d3, new Stock(100, new DateTime(2013, 11, 27))},
            });

            var repo = new Repository();

            // act
            var json = repo.DumpJson(original);
            var restored = repo.ReadJson(json);

            // assert
            Console.WriteLine(json);
            foreach (var medicine in original.GetMedicines())
            {
                Assert.That(restored.CurrentStock(medicine), Is.EqualTo(original.CurrentStock(medicine)), "CurrentStock: " + medicine.Name);
                Assert.That(restored.ExhaustionOf(medicine), Is.EqualTo(original.ExhaustionOf(medicine)), "ExhaustionDate: " + medicine.Name);
                Assert.That(restored.RemainingStock(medicine, DateTime.Today), Is.EqualTo(original.RemainingStock(medicine, DateTime.Today)), "RemainingStock: " + medicine.Name);
            }
        }
Exemplo n.º 45
0
 void DisplayButtons()
 {
     if (showNewItemDetails)
     {
         if (GUILayout.Button("Save"))
         {
             database.Add(medicine);
             
             showNewItemDetails = false;
             medicine = null;
         }
         if (GUILayout.Button("Cancel"))
         {
             showNewItemDetails = false;
             medicine = null;
         }
     }
     else
         if (GUILayout.Button("Create Item"))
         {
             medicine = new Medicine();
             showNewItemDetails = true;
         }
 }
Exemplo n.º 46
0
 public static bool UpdateMedicine(Medicine medicine)
 {
     SqlMedicineProvider sqlMedicineProvider = new SqlMedicineProvider();
     return sqlMedicineProvider.UpdateMedicine(medicine);
 }
Exemplo n.º 47
0
        internal static List<Medicine> CompareTwoListMedicineToUpdate(List<Medicine> listMedicineFromHistory, List<Medicine> listMedicines)
        {
            List<Medicine> result = new List<Medicine>();
            foreach (Medicine medicine in listMedicines)
            {
                Medicine medicineFromHistory= listMedicineFromHistory.Where(i => i.Name == medicine.Name).FirstOrDefault();
                if (medicineFromHistory != null)
                {
                    int offset = medicine.Number - medicineFromHistory.Number;
                    Medicine medicineUpdate = new Medicine();
                    medicineUpdate.Name = medicine.Name;
                    medicineUpdate.Id = medicine.Id;
                    medicineUpdate.Number = offset;
                    result.Add(medicineUpdate);
                }
                else // new
                {

                    Medicine medicineUpdate = new Medicine();
                    medicineUpdate.Name = medicine.Name;
                    medicineUpdate.Id = medicine.Id;
                    medicineUpdate.Number = medicine.Number;
                    result.Add(medicineUpdate);
                }
            }

            //case: delete row so we must add medicine again
            foreach (Medicine medicine in listMedicineFromHistory)
            {
                Medicine medicineFromNew = listMedicines.Where(i => i.Name == medicine.Name).FirstOrDefault();
                if (medicineFromNew == null)
                {
                    Medicine medicineUpdate = new Medicine();
                    medicineUpdate.Name = medicine.Name;

                    medicineUpdate.Id = medicine.Id;
                    medicineUpdate.Number = 0-medicine.Number;
                    result.Add(medicineUpdate);
                }
            }

            return result;
        }
Exemplo n.º 48
0
 internal static List<Medicine> GetMedicinesFromHistory(IDatabase db,string IdPatient, string datetime, ref bool isNew )
 {
     List<Medicine> result = new List<Medicine>();
     string strCommand = "Select Medicines from history where Id = " + IdPatient + " And Day=" + ConvertToSqlString(datetime);
     using (DbDataReader reader = db.ExecuteReader(strCommand, null) as DbDataReader)
     {
         reader.Read();
         if (reader.HasRows)
         {
             string medicines = reader[DatabaseContants.history.Medicines].ToString();
             if (medicines == "Dd nhập bệnh nhân mới,!"|| medicines =="Dd nh?p b?nh nhân m?i,!")
             {
                 isNew = true;
                 return result;
             }
             string[] medicineAndCount = new string[] { };
             if (!string.IsNullOrEmpty(medicines))
             {
                 medicineAndCount = medicines.Split(',');
                 for (int i = 0; i < medicineAndCount.Length; i = i + 2)
                 {
                     Medicine medicine = new Medicine();
                     medicine.Name = medicineAndCount[i];
                     reader.Close();
                     medicine.Id = GetIdMedicineFromName(db, medicine.Name);
                     medicine.Number = int.Parse(medicineAndCount[i + 1]);
                     result.Add(medicine);
                 }
             }
         }
     }
     return result;
 }
Exemplo n.º 49
0
    public bool UpdateMedicine(Medicine medicine)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("AL_UpdateMedicine", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MedicineID", SqlDbType.Int).Value = medicine.MedicineID;
            cmd.Parameters.Add("@MedicineName", SqlDbType.NVarChar).Value = medicine.MedicineName;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return result == 1;
        }
    }
Exemplo n.º 50
0
        public bool AddMedicalProcedure(Medicine medicine, Animal animal, string name, DateTime nextDate)
        {
            var newMedicalProcedure = new MedicalProcedure
            {
                AnimalID = animal.AnimalID,
                MedicineID = medicine.MedicineID,
                Name = name,
                AddDate = DateTime.Now,
                NextDate = nextDate,
            };

            using (var db = new ZooMasterDBEntities())
            {
                db.MedicalProcedures.Add(newMedicalProcedure);
                return db.SaveChanges() == 1;
            }
        }
Exemplo n.º 51
0
 public DateTime ExhaustionOf(Medicine medicine)
 {
     return this[medicine].Plan.CalculateExhaustionDate(this[medicine].Stock);
 }
Exemplo n.º 52
0
        public void Refill(Medicine medicine, Stock stockToAdd)
        {
            var remainingFromCurrentStock = this[medicine].Plan.CalculateRemaining(this[medicine].Stock, stockToAdd.AsOfDate);

            this[medicine].Stock = remainingFromCurrentStock.Add(stockToAdd);
        }
Exemplo n.º 53
0
 public void add_med(string n, string t, string p, DateTime d, string s)
 {
     medlist[last_med] = new Medicine(n, t, p, d, s);
         last_med += 1;
 }
Exemplo n.º 54
0
 public Stock RemainingStock(Medicine medicine, DateTime asof)
 {
     return this[medicine].Plan.CalculateRemaining(this[medicine].Stock, asof);
 }
Exemplo n.º 55
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Medicine objMedicine = new Medicine();
     dtlView.DataSource = objMedicine.SelectAll();
     dtlView.DataBind();
 }
Exemplo n.º 56
0
        internal static List<Medicine> GetAllMedicinesFromDataGrid(IDatabase db, System.Windows.Forms.DataGridView dataGridView)
        {
            //List<int> listCountMedicines = new List<int>();
            List<Medicine> result = new List<Medicine>();

            for (int i = 0; i < dataGridView.Rows.Count - 1; i++)
            {
                Medicine medic = new Medicine();
                medic.Id = dataGridView[DatabaseContants.IdColumnInDataGridViewMedicines, i].Value.ToString();
                medic.Number = int.Parse(dataGridView[DatabaseContants.CountColumnInDataGridViewMedicines, i].Value.ToString());
                medic.Name = dataGridView[DatabaseContants.NameColumnInDataGridViewMedicines, i].Value.ToString();
                medic.HDSD = dataGridView[DatabaseContants.HDSDColumnInDataGridViewMedicines, i].Value.ToString();
                medic.CostOut = int.Parse(dataGridView[DatabaseContants.MoneyColumnInDataGridViewMedicines, i].Value.ToString());
                result.Add(medic);

            }

            return result;
        }
Exemplo n.º 57
0
 public void RemoveMedicine(Medicine medicine)
 {
     this.medicines.Remove(medicine);
 }
Exemplo n.º 58
0
    public int InsertMedicine(Medicine medicine)
    {
        using (SqlConnection connection = new SqlConnection(this.ConnectionString))
        {
            SqlCommand cmd = new SqlCommand("AL_InsertMedicine", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@MedicineID", SqlDbType.Int).Direction = ParameterDirection.Output;
            cmd.Parameters.Add("@MedicineName", SqlDbType.NVarChar).Value = medicine.MedicineName;
            connection.Open();

            int result = cmd.ExecuteNonQuery();
            return (int)cmd.Parameters["@MedicineID"].Value;
        }
    }
Exemplo n.º 59
0
 public static int InsertMedicine(Medicine medicine)
 {
     SqlMedicineProvider sqlMedicineProvider = new SqlMedicineProvider();
     return sqlMedicineProvider.InsertMedicine(medicine);
 }
Exemplo n.º 60
0
 public void refreshGridView()
 {
     Medicine objMedicine = new Medicine();
     gridView.DataSource = objMedicine.SelectAll();
     gridView.DataBind();
 }