Exemplo n.º 1
0
        public void GetMedicineDetailTest()
        {
            MedicineDetails details = new MedicineDetails
            {
                Id         = 1,
                FullName   = "Aspirin",
                Brand      = "Ranbaxy",
                ExpiryDate = new DateTime(2020, 09, 1),
                Quantity   = 10,
                Price      = 10.05
            };
            ViewMedicineViewModel viewparams = new ViewMedicineViewModel
            {
                FullName = "Aspirin"
            };

            //Mock the data access
            var _medicineAcces = new Mock <IMedicineService>();
            var _medicineRepo  = new Mock <IMedicineRepository>();

            _medicineAcces.Setup(x => x.GetMedicineDetails(viewparams)).Returns(details);
            var firstName = GetMedicineDetail(_medicineRepo.Object, viewparams);

            Assert.Equal(details.FullName, firstName);
        }
Exemplo n.º 2
0
        public ActionResult ManageMedicineDetails(MedicineDetails MD)
        {
            try
            {
                AdminDetails admObj = (AdminDetails)Session["UserDetails"];
                if (MD.MedicineType != "OTH")
                {
                    MD.MedicineName = MD.MedicineType + " " + MD.MedicineName;
                }
                else
                {
                    MD.MedicineName = MD.MedicineName;
                }
                MD.CreatedBy  = admObj.UserId.ToString();
                MD.HospitalId = admObj.HospitalId;

                int Flag = BL.ManageMedicineDetails(MD);

                MD = BL.ViewAllMedicine(admObj.HospitalId);
                ModelState.Clear();
                return(View("MedicineDetails", MD));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public MedicineDetails ViewAllMedicine(int hId)
        {
            try
            {
                SqlParameter[] sqlparam;
                sqlparam    = new SqlParameter[2];
                sqlparam[0] = new SqlParameter("@Flag", "1");
                //sqlparam[1] = new SqlParameter("@MedicineId", 0);
                sqlparam[1] = new SqlParameter("@HospitalId", hId);
                DataSet                ds  = CommonFunction.GetDataSet("USP_Get_MedicineDetails", sqlparam, "");
                MedicineDetails        MD  = new MedicineDetails();
                List <MedicineDetails> lst = new List <MedicineDetails>();
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    DataTable dt = ds.Tables[0];

                    foreach (DataRow dr in dt.Rows)
                    {
                        MedicineDetails Model = new MedicineDetails();
                        CommonFunction.ReflectSingleData(Model, dr);
                        lst.Add(Model);
                    }
                }
                MD.lst = lst;
                return(MD);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
        public int ManageMedicineDetails(MedicineDetails MD)
        {
            try
            {
                SqlParameter[] sqlparam;
                sqlparam    = new SqlParameter[11];
                sqlparam[0] = new SqlParameter("@MedicineId", MD.MedicineId);
                sqlparam[1] = new SqlParameter("@MedicineName", MD.MedicineName);
                sqlparam[2] = new SqlParameter("@MedicineType", MD.MedicineType);
                sqlparam[3] = new SqlParameter("@GenericName", MD.GenericName);
                sqlparam[4] = new SqlParameter("@CompanyName", MD.CompanyName);
                sqlparam[5] = new SqlParameter("@Range", MD.Range);
                sqlparam[6] = new SqlParameter("@Other", MD.Other);
                sqlparam[7] = new SqlParameter("@CreatedBy", MD.CreatedBy);
                //sqlparam[8] = new SqlParameter("@CreatedDate",null);
                sqlparam[8] = new SqlParameter("@ModifiedBy", MD.ModifiedBy);
                //sqlparam[9] = new SqlParameter("@ModifiedDate", null);
                sqlparam[9]  = new SqlParameter("@IsAcive", 1);
                sqlparam[10] = new SqlParameter("@HospitalId", MD.HospitalId);

                return(CommonFunction.Save("USP_MedicineDetails", sqlparam, ""));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 5
0
 public IActionResult EditDetails(MedicineDetails medicineDetails)
 {
     if (ModelState.IsValid)
     {
         dbContext.Update(medicineDetails);
         dbContext.SaveChanges();
         return(RedirectToAction("Details", new { id = medicineDetails.MedicineRefId }));
     }
     return(View(medicineDetails));
 }
Exemplo n.º 6
0
        public JsonResult GetMedicineName(string str)
        {
            AdminDetails    admObj = (AdminDetails)Session["UserDetails"];
            MedicineDetails MD     = new MedicineDetails();

            MD = BL.ViewAllMedicine(admObj.HospitalId);
            var mName = (from x in MD.lst where x.MedicineName.StartsWith(str) select new { label = x.MedicineName }).ToList();

            return(Json(mName));
        }
Exemplo n.º 7
0
        public ActionResult DeleteMedicine(int Id)
        {
            AdminDetails    admObj = (AdminDetails)Session["UserDetails"];
            MedicineDetails MD     = new MedicineDetails();
            // MD = BL.ViewAllMedicine();
            int Flag1 = BL.DeleteMedicine(Id);

            MD = BL.ViewAllMedicine(admObj.HospitalId);

            return(View("MedicineDetails", MD));
        }
Exemplo n.º 8
0
        public ActionResult Med(string Prefix)
        {
            Bal_MedicineDetails    BL  = new Bal_MedicineDetails();
            MedicineDetails        MD  = new MedicineDetails();
            List <MedicineDetails> lst = new List <MedicineDetails>();

            AdminDetails admObj = (AdminDetails)Session["UserDetails"];

            MD = BL.ViewAllMedicine(admObj.HospitalId);
            //lst = MD.lst;
            lst = MD.lst.Where(x => x.MedicineName.ToUpper().Contains(Prefix.ToUpper())).ToList();
            return(Json(lst, JsonRequestBehavior.AllowGet));
        }
        /*THIS FUNCTION WILL TRIGGER EVERYTIME TEXT OF COMBOX IS CHNAGED*/
        private void CheckValidityAndChangeAccordingly(string eleName)
        {
            MedicineBatchUpdateControl childControl = (MedicineBatchUpdateControl)ControlsHolderPanel.FindName(eleName);
            MedicineDetails            medDClass    = new MedicineDetails(childControl.medName);

            validityIndicationState(childControl);
            childControl.cuurtBatc = medDClass.MED_CUR_BATCH();
            childControl.onHold    = medDClass.MED_CUR_HOLD();
            childControl.expDate   = DateTime.Now.Date.AddMonths(medDClass.MED_EXP_MONTH_DURATION());
            childControl.manfName  = medDClass.MED_MANUF_NAME();
            childControl.price     = medDClass.MED_CUR_PRICE();
            UpdateAllCounters();
        }
Exemplo n.º 10
0
 public ActionResult ViewAllMedicine()
 {
     try
     {
         AdminDetails    admObj = (AdminDetails)Session["UserDetails"];
         MedicineDetails MD     = new MedicineDetails();
         MD = BL.ViewAllMedicine(admObj.HospitalId);
         return(View("MedicineDetails", MD));
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemplo n.º 11
0
        //Get- CreateDetails
        public IActionResult CreateDetail(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var medicine = dbContext.Medicine.Find(id);

            if (medicine == null)
            {
                return(NotFound());
            }
            MedicineDetails medicineDetails = new MedicineDetails {
                MedicineRefId = (int)id
            };

            return(View(medicineDetails));
        }
Exemplo n.º 12
0
        public ActionResult GetMedicineById(int Id, int hId)
        {
            AdminDetails    admObj = (AdminDetails)Session["UserDetails"];
            MedicineDetails MD     = new MedicineDetails();

            MD = BL.ViewAllMedicine(hId);
            if (hId != 0)
            {
                var v = MD.lst.FirstOrDefault(x => x.MedicineId == Id);
                MD.MedicineId   = v.MedicineId;
                MD.MedicineName = v.MedicineName;
                MD.MedicineType = v.MedicineType;
                MD.GenericName  = v.GenericName;
                MD.CompanyName  = v.CompanyName;
                MD.Range        = v.Range;
                MD.Other        = v.Other;
            }

            return(View("MedicineDetails", MD));
        }
Exemplo n.º 13
0
        public bool AddMedicineDetails(MedicineViewModel medicine)
        {
            try
            {
                double price;
                if (double.TryParse(medicine.Price, out price))
                {
                    price = Math.Round(price, 2);
                }

                var medicineDetails = new MedicineDetails
                {
                    FullName   = medicine.FullName,
                    Brand      = medicine.Brand,
                    Price      = price,
                    ExpiryDate = medicine.ExpiryDate,
                    Notes      = medicine.Notes,
                    Quantity   = medicine.Quantity
                };
                return(_repository.AddMedicineDetails(medicineDetails));

                //else
                //{
                //    medExists.Price = price;
                //    medExists.ExpiryDate = medicine.ExpiryDate;
                //    medExists.Notes = medicine.Notes;
                //    medExists.Quantity = medicine.Quantity;
                //    _context.MedicineDetails.Update(medExists);
                //    _context.SaveChanges();
                //    return true;
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 14
0
 public int ManageMedicineDetails(MedicineDetails MD)
 {
     return(DP.ManageMedicineDetails(MD));
 }