Example #1
0
        public ActionResult ProductUpdate(MedicineModel medicine)
        {
            int result = 0;

            PractitionerProcess process = new PractitionerProcess();

            result = process.UpdateProduct(medicine);

            if (result == 0)
            {
                PractitionerBaseViewModel viewModel = new PractitionerBaseViewModel();
                viewModel.AccId         = medicine.PractitionerId;
                viewModel.MedicineModel = medicine;

                return(View(viewModel));
            }
            else
            {
                return(Content(@"<body>
                           <script type='text/javascript'>
                             if(confirm('Product update is updated successfully. Press Ok to close this tab.')){ window.close();window.opener.location.reload(); };
                           </script>
                         </body> "));
            }
        }
        // GET: Home/Delete/5
        public ActionResult Delete(int id)
        {
            MedicineModel model = new MedicineModel();

            model.delete(id);
            return(RedirectToAction("Catalog"));
        }
        // GET: Home/Details/5
        public ActionResult Details(int id)
        {
            MedicineModel model     = new MedicineModel();
            List <string> ListChart = model.GetMedicineChart(id);

            return(View(ListChart));
        }
Example #4
0
        // GET: Medicines
        public ActionResult Index()
        {
            MedicineModel medicineModel = new MedicineModel();
            var           medicines     = medicineModel.getMedicineVms();

            return(View(medicines));
        }
Example #5
0
        private void BtnSaveAll_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < dgvMedicine.RowCount - 1; i++)
                {
                    var model = new MedicineModel
                    {
                        MedicineName = Convert.ToString(dgvMedicine.Rows[i].Cells[0].Value),
                        Price        = Convert.ToDecimal(dgvMedicine.Rows[i].Cells[1].Value),
                        Qty          = Convert.ToInt32(dgvMedicine.Rows[i].Cells[2].Value)
                    };

                    medicineService.AddMedicine(model);

                    MessageBox.Show("Data has saved successfully!", "Success",
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearFields();
                    LoadMedicine();
                }
            }
            catch (Exception)
            {
            }
        }
        public ActionResult Edit(FormCollection collection)
        {
            var      doctor       = (Doctor)TempData["doctor"];
            var      patient      = (Patient)TempData["patient"];
            var      medicines    = (List <MedicineTimes>)TempData["medicines"];
            var      prescription = (Prescription)TempData["prescription"];
            string   MedicineName = collection.Get("name");
            DateTime start        = new DateTime();
            DateTime end          = new DateTime();

            if (!DateTime.TryParse(collection.Get("start"), out start) && !DateTime.TryParse(collection.Get("end"), out end) || MedicineName == "" && Request.Form["Add"] == null)
            {
                TempData["prescription"] = prescription;
                TempData["medicines"]    = medicines;
                return(RedirectToAction("Check", "Interactions"));
            }

            var               MedicinesNames    = (SelectList)TempData["MedicineNames"];
            MedicineModel     medicineModel     = new MedicineModel();
            PrescriptionModel prescriptionModel = new PrescriptionModel();
            MedicineTimes     medicine          = new MedicineTimes(medicineModel.GetMedicine(MedicineName), start, end);

            //PrescriptionMedicine rm = new PrescriptionMedicine(patient.TZ,MedicineNames, start, end);
            prescriptionModel.AddMedicine(medicines, medicine);
            PrescriptionViewModel viewModel = new PrescriptionViewModel(patient, doctor, medicines);

            ViewBag.MedicineNames = MedicinesNames;
            TempData["viewModel"] = viewModel;

            return(RedirectToAction("Edit"));
        }
Example #7
0
        private void GetTotalBill()
        {
            try
            {
                foreach (DataRow tableData in dataTable.Rows)
                {
                    var id   = Convert.ToInt32(tableData["Id"]);
                    var qty  = Convert.ToInt32(tableData["Qty"]);
                    var data = service.GetQty(id);

                    var updatedQty = Convert.ToInt32(data.Qty) - Convert.ToInt32(qty);

                    var model = new MedicineModel
                    {
                        Id           = id,
                        MedicineName = Convert.ToString(tableData["Medicine Name"]),
                        Price        = Convert.ToDecimal(tableData["Price"]),
                        Qty          = updatedQty,
                    };

                    service.UpdateQty(model);
                }
            }
            catch (Exception)
            {
            }
        }
Example #8
0
        public List <MedicineModel> ProductSearch(MedicineViewModel search)
        {
            List <MedicineModel> result = new List <MedicineModel>();

            try
            {
                SqlConnection conn = new SqlConnection(ConstantHelper.DBAppSettings.FYP);
                conn.Open();
                SqlCommand cmd = new SqlCommand(ConstantHelper.StoredProcedure.ProductSearch, conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter(ConstantHelper.StoredProcedure.Parameter.SearchText, search.SearchText));
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    MedicineModel medicine = new MedicineModel();
                    medicine.ProductCode       = reader[ConstantHelper.SQLColumn.ProductSearch.ProductCode].ToString();
                    medicine.ProductName       = reader[ConstantHelper.SQLColumn.ProductSearch.ProductName].ToString();
                    medicine.TotalAmount       = Convert.ToInt32(reader[ConstantHelper.SQLColumn.ProductSearch.TotalAmount].ToString());
                    medicine.CompanyId         = Guid.Parse(reader[ConstantHelper.SQLColumn.ProductSearch.CompanyId].ToString());
                    medicine.CompanyName       = reader[ConstantHelper.SQLColumn.ProductSearch.CompanyName].ToString();
                    medicine.CompanyPostalCode = reader[ConstantHelper.SQLColumn.ProductSearch.PostalCode].ToString();
                    medicine.CompanyState      = reader[ConstantHelper.SQLColumn.ProductSearch.State].ToString();

                    result.Add(medicine);
                }
            }
            catch (Exception err)
            {
                new LogHelper().LogMessage("PatientData.ProductSearch : " + err);
            }

            return(result);
        }
Example #9
0
        public async Task <IActionResult> AddMedicine(MedicineViewModel model)
        {
            if (model.ExpiryDate.Date <= DateTime.Now.Date)
            {
                return(_baseRepo.CustomResponce(statusCode: StatusCodes.Status400BadRequest, success: false, message: "ExpiryDate should be greater than today's date", data: ""));
            }

            MedicineModel medicine = new MedicineModel()
            {
                Id         = _generateID.GeneratID(),
                Brand      = model.Brand,
                ExpiryDate = model.ExpiryDate,
                Notes      = model.Notes,
                Price      = model.Price,
                Quantity   = model.Quantity
            };

            bool isAdded = await _repo.AddMedicine(model : medicine);

            if (isAdded)
            {
                return(_baseRepo.CustomResponce(statusCode: StatusCodes.Status200OK, success: true, message: SuccessContants.RecordAddedSuccessfully, data: ""));
            }
            else
            {
                return(_baseRepo.CustomResponce(statusCode: StatusCodes.Status200OK, success: false, message: ErrorContants.Techincalproblempleasetryagain, data: ""));
            }
        }
Example #10
0
        public async Task <IHttpActionResult> AddMedicine(MedicineModel medicine)
        {
            if (medicine == null)
            {
                return(BadRequest("Please provide valid inputs!"));
            }

            CommonResponse validatedResponse = await AuthService.ValidateUserAndToken();

            if (!validatedResponse.IsError)
            {
                if (await MedicineService.MedicineExist(medicine))
                {
                    return(BadRequest("Medicine Already Exists"));
                }
                else
                {
                    if (await MedicineService.AddMedicine(medicine))
                    {
                        return(Ok("Medicine Added Successfully!"));
                    }
                    else
                    {
                        return(BadRequest("Medicine Adding Failed!"));
                    }
                }
            }
            else
            {
                return(Unauthorized());
            }
        }//end of add
Example #11
0
        public async Task <IHttpActionResult> UpdateMedicine(MedicineModel medicine)
        {
            if (medicine == null)
            {
                return(BadRequest("Please provide valid inputs!"));
            }

            CommonResponse validatedResponse = await AuthService.ValidateUserAndToken();

            if (!validatedResponse.IsError)
            {
                if (await MedicineService.MedicineExist(medicine))
                {
                    if (await MedicineService.UpdateMedicine(medicine))
                    {
                        return(Ok("Medicine Updated Successfully!"));
                    }
                    else
                    {
                        return(BadRequest("Failed to Update Medicine!"));
                    }
                }
                else
                {
                    return(BadRequest("No Such Medicine Exisits!"));
                }
            }
            else
            {
                return(Unauthorized());
            }
        }//end of update
Example #12
0
        public ActionResult MedicineAdd(MedicineModel obj)
        {
            try
            {
                // TODO: Add insert logic here
                DB3Entities2 entity   = new DB3Entities2();
                var          medicine = new Medicine();
                medicine.Medicine_Name = obj.name;
                medicine.Mfg_Date      = obj.mfg_date;
                medicine.Exp_Date      = obj.exp_date;
                medicine.Type          = obj.type;
                medicine.Batch         = obj.batch;
                medicine.Price         = obj.price;
                var c = entity.Companies.Where(x => x.C_Name == obj.company_Name).First();
                medicine.CompanyID = c.Company_id;

                entity.Medicines.Add(medicine);
                entity.SaveChanges();



                return(RedirectToAction("MedicineList"));
            }
            catch
            {
                return(View());
            }
        }
Example #13
0
        public ActionResult Createproduct(MedicineModel newMedicine)
        {
            if (newMedicine != null)
            {
                PractitionerProcess process = new PractitionerProcess();
                int result = 0;
                result = process.CreateProduct(newMedicine);

                if (result != 0)
                {
                    return(Content(@"<body>
                        <script type='text/javascript'>
                            if(confirm('Product has been created successfully. Press Ok to close this tab.')){ window.close();window.opener.location.reload(); };
                        </script>
                    </body> "));
                }
                else
                {
                    return(Content(@"<body>
                        <script type='text/javascript'>
                            if(confirm('Product creation error. Press Ok to go back the view.')){ window.history.back(); };
                        </script>
                    </body> "));
                }
            }
            else
            {
                return(View());
            }
        }
Example #14
0
        public ActionResult CreateProduct(PractitionerBaseViewModel viewModel)
        {
            MedicineModel model = new MedicineModel();

            model.PractitionerId = viewModel.AccId;
            return(View(model));
        }
        internal static List <MedicineModel> GetMedicineList(int accountId)
        {
            List <MedicineModel> modelList = new List <MedicineModel>();

            using (DBConnector connector = new DBConnector("get_MedicineList", CommandType.StoredProcedure))
            {
                connector.Cmd.Parameters.AddWithValue("@AccountID", accountId);
                connector.Execute(DBOperation.GetWhileReader);

                if (connector.Rdr.HasRows)
                {
                    while (connector.Rdr.Read())
                    {
                        MedicineModel model = new MedicineModel();

                        model.MedicineID  = Convert.ToInt32(connector.Rdr["IDMedicine"]);
                        model.Name        = connector.Rdr["Name"].ToString();
                        model.Description = connector.Rdr["Description"].ToString();
                        model.MedImg      = connector.Rdr["MedImg"].ToString();
                        model.MedColor    = connector.Rdr["MedColor"].ToString();
                        model.MedType     = connector.Rdr["MedType"].ToString();
                        model.Quantity    = Convert.ToDecimal(connector.Rdr["Quantity"]);

                        modelList.Add(model);
                    }
                }
            }

            return(modelList);
        }
Example #16
0
        public IActionResult Edit(MedicineModel model)
        {
            Medicine medicineModel = new Medicine
            {
                Id                = model.MedicineId,
                Name              = model.Name,
                SKU               = model.SKU,
                ProductGUID       = model.ProductGUID,
                Price             = model.Price,
                Manufacturer      = model.Manufacturer,
                ManufacturingDate = model.ManufacturingDate,
                Description       = model.Description,
                //Image = model.Image,
                ExpiryDate = model.ExpiryDate,
                IsActive   = model.IsActive,
                IsDeleted  = false
            };
            var medicineModels = _medicineService.UpdateMedicine(medicineModel);

            if (medicineModels == null)
            {
                // Failed
                ViewBag.AddCategoryStatus = "Failed";
                return(RedirectToAction("Edit"));
            }
            else
            {
                // Success
                ViewBag.AddUserStatus = "Success";
                return(RedirectToAction("List"));
            }
        }
Example #17
0
        public ActionResult Add()
        {
            var model = new MedicineModel();

            model.LoadAllListData();
            return(View(model));
        }
Example #18
0
        public IActionResult List(int?page)
        {
            //get all medicine data.
            var medicineData = _medicineService.GetAllMedicines();
            var medicineList = new List <MedicineModel>();

            foreach (var item in medicineData)
            {
                var model = new MedicineModel();
                model.MedicineId   = item.Id;
                model.Name         = item.Name;
                model.SKU          = item.SKU;
                model.PictureStr   = item.PictureStr;
                model.ProductGUID  = item.ProductGUID;
                model.Price        = item.Price;
                model.Manufacturer = item.Manufacturer;
                model.ExpiryDate   = item.ExpiryDate;
                model.IsActive     = item.IsActive;
                model.IsDeleted    = false;
                medicineList.Add(model);
            }
            var pageNumber = page ?? 1;
            var pageSize   = 3;

            return(View(medicineList.ToPagedList(pageNumber, pageSize)));
        }
        // GET: Patient/Edit/5
        public ActionResult Create(FormCollection collection)
        {
            string MedicineName = collection.Get("name");
            var    patient      = (Patient)TempData["patient"];
            var    doctor       = (Doctor)TempData["doctor"];

            DateTime          start             = DateTime.Parse(collection.Get("start"));
            DateTime          end               = DateTime.Parse(collection.Get("end"));
            var               prescription      = (Prescription)TempData["prescription"];
            var               MedicinesNames    = (SelectList)TempData["MedicineNames"];
            MedicineModel     medicineModel     = new MedicineModel();
            PrescriptionModel prescriptionModel = new PrescriptionModel();

            MedicineTimes        medicine  = new MedicineTimes(medicineModel.GetMedicine(MedicineName), start, end);
            List <MedicineTimes> medicines = new List <MedicineTimes>();


            prescriptionModel.AddMedicine(medicines, medicine);
            PrescriptionViewModel viewModel = new PrescriptionViewModel(patient, doctor, medicines);

            ViewBag.MedicineNames    = MedicinesNames;
            TempData["viewModel"]    = viewModel;
            TempData["prescription"] = prescription;
            TempData["doctor"]       = doctor;
            TempData["medicines"]    = medicines;
            return(RedirectToAction("Edit"));
        }
Example #20
0
        public IActionResult Edit(int id)
        {
            var medicineModel = _medicineService.GetMedicineById(id);

            var        categories = _categoryService.GetAllCategories() /*.ToList()*/;
            SelectList list       = new SelectList(categories, "Id", "Name");

            ViewBag.categories = list;

            MedicineModel model = new MedicineModel
            {
                MedicineId        = medicineModel.Id,
                Name              = medicineModel.Name,
                SKU               = medicineModel.SKU,
                ProductGUID       = medicineModel.ProductGUID,
                Price             = medicineModel.Price,
                Manufacturer      = medicineModel.Manufacturer,
                ManufacturingDate = medicineModel.ManufacturingDate,
                Description       = medicineModel.Description,
                ExpiryDate        = medicineModel.ExpiryDate,
                IsActive          = medicineModel.IsActive,
                IsDeleted         = false,
                Stock             = medicineModel.Stock,
                CategoryName      = medicineModel.CategoryName,
            };

            return(View(model));
        }
        public void updateMedicines(MedicineModel medicine)
        {
            List <MedicineModel> medicineList = new List <MedicineModel>();

            try
            {
                var filePath = Path.Combine(_hostingEnvironment.ContentRootPath, $"wwwroot\\{"JsonFiles\\medicines.json"}");
                var json     = File.ReadAllText(filePath);

                medicineList = JsonConvert.DeserializeObject <List <MedicineModel> >(json);

                medicineList.ForEach((x) =>
                {
                    if (x.id == medicine.id)
                    {
                        x.fullName   = medicine.fullName;
                        x.price      = medicine.price;
                        x.quantity   = medicine.quantity;
                        x.expiryDate = medicine.expiryDate;
                        x.brand      = medicine.brand;
                    }
                    ;
                });

                string output = JsonConvert.SerializeObject(medicineList, Newtonsoft.Json.Formatting.Indented);
                File.WriteAllText(filePath, output);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #22
0
        public ActionResult SearchMedicine(string searchString)
        {
            // Get particular user data
            var medicineByName   = _medicineService.GetMedicineByName(searchString);
            var medicineNameList = new List <MedicineModel>();

            foreach (var item in medicineByName)
            {
                var lst = new MedicineModel();
                lst.MedicineId        = item.Id;
                lst.Name              = item.Name;
                lst.SKU               = item.SKU;
                lst.ProductGUID       = item.ProductGUID;
                lst.Manufacturer      = item.Manufacturer;
                lst.ManufacturingDate = item.ManufacturingDate;
                lst.ExpiryDate        = item.ExpiryDate;
                medicineNameList.Add(lst);
            }

            if (medicineNameList == null)
            {
                return(View("List", medicineNameList));
            }
            else
            {
                return(View("List", medicineNameList));
            }
        }
 public void AddNewMedicine()
 {
     SelectedMedicine = new MedicineModel()
     {
         CreatedDate = DateTime.Today
     };
 }
        // GET: MedicinesList
        public ActionResult Index()
        {
            MedicineModel     Model     = new MedicineModel();
            MedicineViewModel viewModel = new MedicineViewModel(Model.GetList());

            return(View(viewModel.GetList()));
        }
        public ActionResult Edit(int id)
        {
            MedicineModel model    = new MedicineModel();
            var           Medicine = model.GetMedicines().First(m => m.Id == id);

            return(View(Medicine));
        }
Example #26
0
        public async Task <ActionResult> Add(MedicineModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Medicine med = new Medicine();
                    med.CategoryId = model.Category;
                    med.Name       = model.Name;
                    med.Dosage     = model.Dosage;
                    await _context.Medicines.AddAsync(med);

                    await _context.SaveChangesAsync();
                }
                else
                {
                    TempData["message"] = ModelState.ErrorGathering();
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message;
                return(RedirectToAction(nameof(Index)));
            }
        }
        public ActionResult Catalog()
        {
            MedicineModel model     = new MedicineModel();
            var           Medicines = model.GetMedicines();

            return(View(Medicines));
        }
Example #28
0
        public async Task <ActionResult> Edit(MedicineModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    TempData["message"] = ModelState.ErrorGathering();
                }
                var med = await _context.Medicines.FirstOrDefaultAsync(x => x.Id.Equals(model.Id));

                if (med != null)
                {
                    med.Name   = model.Name;
                    med.Dosage = model.Dosage;
                    _context.Medicines.Update(med);
                    await _context.SaveChangesAsync();
                }
                else
                {
                    TempData["message"] = "Medicine not found.";
                }
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                TempData["message"] = ex.Message;
                return(View());
            }
        }
Example #29
0
        public ActionResult Prescription_(FormCollection collection)
        {
            var ID    = TempData["ID"];
            var first = TempData["first"];
            var last  = TempData["last"];

            //var ID = collection["PatientId"];
            if (DateTime.Parse(collection["BeginDate"]) > DateTime.Parse(collection["FinishDate"]))
            {
                ViewBag.errorDate = "Begin date should be before the finish date";
                TempData["ID"]    = ID;
                ViewBag.id        = ID;
                TempData["first"] = first;
                ViewBag.first     = first;
                TempData["last"]  = last;
                ViewBag.last      = last;
                MedicineModel model = new MedicineModel();
                return(View(model.GetMedicines()));
            }
            var medicines = new MedicineModel();

            return(RedirectToAction("AreYouSure", new Prescription
            {
                Id = int.Parse(ID.ToString()),
                DoctorFirstName = RouteConfig.user.FirstName,
                DoctorLastName = RouteConfig.user.LastName,
                Medicine = collection["Medicine"],
                BeginTime = DateTime.Parse(collection["BeginDate"]),
                FinishTime = DateTime.Parse(collection["FinishDate"]),
                Frequency = collection["Frequency"],
                Comments = collection["Comments"],
                Ndc = medicines.GetMedicines().Where(x => x.CommercialName == collection["Medicine"].ToString()).FirstOrDefault().NDC  //get current prescription ndc
            }));
        }
Example #30
0
        /// <summary>
        ///  更新体检中 中医体质辨识得分Key
        /// </summary>
        /// <param name="customerID"></param>
        /// <param name="ID"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateMediphysDist(string customerID, int ID, MedicineModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("UPDATE ARCHIVE_MEDI_PHYS_DIST D SET ");
            builder.Append("MedicineResultID=@MedicineResultID, ");
            builder.Append("Mild=@Mild,Faint=@Faint,");
            builder.Append("Yang=@Yang,Yin=@Yin,");
            builder.Append("PhlegmDamp=@PhlegmDamp,Muggy=@Muggy,");
            builder.Append("BloodStasis=@BloodStasis,QiConstraint=@QiConstraint,");
            builder.Append("Characteristic=@Characteristic ");
            builder.Append("WHERE OutKey=@OutKey");

            MySqlParameter[] cmdParms = new MySqlParameter[] {
                new MySqlParameter("@OutKey", customerID),
                new MySqlParameter("@MedicineResultID", ID),
                new MySqlParameter("@Mild", model.Mild),
                new MySqlParameter("@Faint", model.Faint),
                new MySqlParameter("@Yang", model.Yang),
                new MySqlParameter("@Yin", model.Yin),
                new MySqlParameter("@PhlegmDamp", model.PhlegmDamp),
                new MySqlParameter("@Muggy", model.Muggy),
                new MySqlParameter("@BloodStasis", model.BloodStasis),
                new MySqlParameter("@QiConstraint", model.QiConstraint),
                new MySqlParameter("@Characteristic", model.Characteristic)
            };

            return(MySQLHelper.ExecuteSql(builder.ToString(), cmdParms) > 0);
        }