Esempio n. 1
0
        public ActionResult AddOrder(int id)
        {
            TMedication medication = db.TMedications.Where(x => x.intMedicationID == id).FirstOrDefault();

            OrderMedication orderMedication = new OrderMedication()
            {
                dtmDateOfOrder     = DateTime.Now,
                intMedicationId    = medication.intMedicationID,
                strMedicationName  = medication.strMedicationName,
                dblUnitCost        = medication.dblCost,
                intCurrentQuantity = medication.intQuantity,
                intOrderQuantity   = 0,
                dblTotal           = 0,
                strNotes           = ""
            };

            ViewBag.intMedicationId = new SelectList(db.TMedications, "intMedicationID", "strMedicationName");
            return(View(orderMedication));
        }
Esempio n. 2
0
        public ActionResult AddOrder(OrderMedication order)
        {
            TMedication medication = db.TMedications.Where(x => x.intMedicationID == order.intMedicationId).FirstOrDefault();

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@intMedicationID", medication.intMedicationID),
                new SqlParameter("@strMedicationName", medication.strMedicationName),
                new SqlParameter("@strMedicationDesc", medication.strMedicationDesc),
                new SqlParameter("@dblCost", medication.dblCost),
                new SqlParameter("@dblPrice", medication.dblPrice),
                new SqlParameter("@strNotes", medication.strNotes),
                new SqlParameter("@intQuantity", medication.intQuantity + order.intOrderQuantity),
                new SqlParameter("@intMethodID", medication.intMethodID),
            };

            db.uspAddMedicationOrder(order.dtmDateOfOrder, medication.intMedicationID, medication.strMedicationName, medication.dblCost, order.intOrderQuantity, medication.dblCost * order.intOrderQuantity, order.strNotes);
            db.Database.ExecuteSqlCommand("uspUpdateMedication @intMedicationID, @strMedicationName, @strMedicationDesc,@dblCost, @dblPrice,@strNotes,@intQuantity, @intMethodID ", param);
            return(RedirectToAction("Index"));
        }