コード例 #1
0
        public D_MedicineDetailForm(BaseDAO <MedicineDetail> medDetailDAO, Action <MedicineDetail> onOK,
                                    Medicine medicine = null, MedicineDetail medDetail = null)
        {
            InitializeComponent();

            MedDetailDAO = medDetailDAO;
            OnOK         = onOK;
            Medicine     = medicine;
            MedDetail    = medDetail;

            if (medDetail != null)
            {
                numQuantity.Value       = medDetail.Quantity;
                txtPrice.Text           = medDetail.UnitPrice.ToString();
                dtpAddedDate.Value      = medDetail.AddedDate;
                dtpExpiredDate.Value    = medDetail.ExpirationDate;
                cbSupplier.SelectedItem = medDetail.MedicineSupplier.Name;

                numQuantity.ReadOnly   = true;
                txtPrice.Enabled       = false;
                dtpAddedDate.Enabled   = false;
                dtpExpiredDate.Enabled = false;
                cbSupplier.Enabled     = false;
            }
        }
コード例 #2
0
        public ActionResult Create(MedicineDetail medicineDetail, HttpPostedFileBase file)
        {
            if (file != null)
            {
                string pic  = System.IO.Path.GetFileName(file.FileName);
                string path = System.IO.Path.Combine(
                    Server.MapPath("~/Content/img/"), pic);
                file.SaveAs(path);
                // file is uploaded
                MedicineDetail newRecord = new MedicineDetail();
                newRecord.Dosage           = medicineDetail.Dosage;
                newRecord.ExpiredDate      = medicineDetail.ExpiredDate;
                newRecord.ManufacturedDate = medicineDetail.ManufacturedDate;
                newRecord.Image            = path;
                newRecord.MedicineName     = medicineDetail.MedicineName;
                newRecord.CategoryID       = medicineDetail.CategoryID;
                db.MedicineDetails.Add(newRecord);
                db.SaveChanges();


                // save the image path path to the database or you can send image
                // directly to database
                // in-case if you want to store byte[] ie. for DB
                using (MemoryStream ms = new MemoryStream())
                {
                    file.InputStream.CopyTo(ms);
                    byte[] array = ms.GetBuffer();
                }
            }
            // after successfully uploading redirect the user
            return(RedirectToAction("Index", "Home"));
        }
コード例 #3
0
        public void ThemDonThuoc(int medicineID, int medicalrecordID, string among, string usage)
        {
            MedicineDetail dt = new MedicineDetail();

            dt.MedicalRecordID = medicalrecordID;
            dt.MedicineID      = medicineID;
            dt.Usage           = usage;
            dt.Among           = among;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseAddress1);

                //HTTP POST
                var postTask = client.PostAsJsonAsync <MedicineDetail>("MedicineDetail", dt);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    MessageBox.Show("Quang bảo thêm được rồi! ");
                }
                else
                {
                    MessageBox.Show("Quang bảo chưa thêm được! ");
                }
            }
        }
コード例 #4
0
        public ActionResult Edit([Bind(Include = "M_ID,ManufacturedDate,ExpiredDate,Dosage,Image,MedicineName,CategoryID,Price,Description,Quantity")] MedicineDetail medicineDetail)
        {
            if (medicineDetail == null)
            {
                ViewData["Exception"] = "Datas are Not Exists";
                return(View("CommonError"));
            }

            if (ModelState.IsValid)
            {
                db.Entry(medicineDetail).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (Exception)
                {
                    ViewData["Exception"] = "Cant Update";
                    //return View("CommonError");
                }
            }
            ViewBag.CategoryID = new SelectList(db.CategoryDiseases, "C_ID", "CategoryName", medicineDetail.CategoryID);
            return(View(medicineDetail));
        }
コード例 #5
0
        public ActionResult DeleteConfirmed(short id)
        {
            MedicineDetail medicineDetail = db.MedicineDetails.Find(id);

            db.MedicineDetails.Remove(medicineDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #6
0
 public ActionResult Edit([Bind(Include = "M_ID,Location,ManufacturedDate,ExpiredDate,Dosage,Image,MedicineName,CategoryID")] MedicineDetail medicineDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(medicineDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryID = new SelectList(db.CategoryDiseases, "C_ID", "CategoryName", medicineDetail.CategoryID);
     return(View(medicineDetail));
 }
コード例 #7
0
        public ActionResult Create(MedicineDetail medicineDetail, HttpPostedFileBase file)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                if (file != null)
                {
                    string pic      = System.IO.Path.GetFileName(file.FileName);
                    string savePath = Server.MapPath("~/Content/img/");
                    //string path = System.IO.Path.Combine(Server.MapPath( pic));
                    // file is uploaded
                    MedicineDetail s = new MedicineDetail();

                    s.ManufacturedDate = medicineDetail.ManufacturedDate;
                    s.ExpiredDate      = medicineDetail.ExpiredDate;
                    s.Dosage           = medicineDetail.Dosage;
                    s.MedicineName     = medicineDetail.MedicineName;
                    s.CategoryID       = medicineDetail.CategoryID;
                    s.Price            = medicineDetail.Price;
                    s.Description      = medicineDetail.Description;
                    s.Quantity         = medicineDetail.Quantity;
                    s.AddMonth         = DateTime.Now.ToString("MMMM");

                    s.Image = pic;
                    file.SaveAs(Path.Combine(savePath, pic));
                    //file.SaveAs(pic);
                    db.MedicineDetails.Add(s);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception)
                    {
                        return(View());
                    }


                    return(RedirectToAction("Index"));
                }
                // }

                ViewBag.CategoryID = new SelectList(db.CategoryDiseases, "C_ID", "CategoryName", medicineDetail.CategoryID);
                return(View(medicineDetail));
            }
            catch (Exception)
            {
                ViewData["Exception"] = "Cant Create";
                //return View("CommonError");
            }
            ViewBag.CategoryID = new SelectList(db.CategoryDiseases, "C_ID", "CategoryName", medicineDetail.CategoryID);
            return(View(medicineDetail));
        }
コード例 #8
0
        public JsonResult DeleteInPopup(int m_ID)
        {
            MedicineDetail medicine = db.MedicineDetails.SingleOrDefault(x => x.IsDeleted == false && x.M_ID == m_ID);
            bool           result   = false;

            if (medicine != null)
            {
                medicine.IsDeleted = true;
                db.SaveChanges();
                result = true;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
コード例 #9
0
        public IHttpActionResult PostChiTietDichVu([FromBody] MedicineDetail DT)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            if (dao.Post_DonThuoc(DT) == false)
            {
                return(BadRequest("Not a valid model"));
            }

            return(Ok());
        }
コード例 #10
0
        // GET: Image/Details/5
        public ActionResult Details(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MedicineDetail medicineDetail = db.MedicineDetails.Find(id);

            if (medicineDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(medicineDetail));
        }
コード例 #11
0
        //public ActionResult FileUpload(HttpPostedFileBase file)
        //{
        //    UniversityDatasEntities db = new UniversityDatasEntities();
        //    if (file != null)
        //    {
        //        string pic = System.IO.Path.GetFileName(file.FileName);
        //        string path = System.IO.Path.Combine(
        //                               Server.MapPath("~/Content/images/"), pic);
        //        // file is uploaded
        //        sample s = new sample();
        //        s.path = path;
        //        db.samples.Add(s);
        //        db.SaveChanges();
        //        file.SaveAs(path);

        //        // save the image path path to the database or you can send image
        //        // directly to database
        //        // in-case if you want to store byte[] ie. for DB
        //        using (MemoryStream ms = new MemoryStream())
        //        {

        //            file.InputStream.CopyTo(ms);
        //            byte[] array = ms.GetBuffer();
        //        }

        //    }
        //    // after successfully uploading redirect the user
        //    return RedirectToAction("Index", "Home");
        //}
        // GET: Image/Edit/5
        public ActionResult Edit(short?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MedicineDetail medicineDetail = db.MedicineDetails.Find(id);

            if (medicineDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryID = new SelectList(db.CategoryDiseases, "C_ID", "CategoryName", medicineDetail.CategoryID);
            return(View(medicineDetail));
        }
コード例 #12
0
        // GET: Medicines/Details/5
        public ActionResult Details(short?id)
        {
            if (id == null)
            {
                ViewData["Exception"] = "Datas are Not Exists";
                return(View("CommonError"));
            }
            MedicineDetail medicineDetail = db.MedicineDetails.Find(id);

            if (medicineDetail == null)
            {
                ViewData["Exception"] = "Datas are Not Exist";
                return(View("CommonError"));
            }
            return(View(medicineDetail));
        }
コード例 #13
0
        public ActionResult DeleteConfirmed(short id)
        {
            MedicineDetail medicineDetail = db.MedicineDetails.Find(id);

            try
            {
                db.MedicineDetails.Remove(medicineDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                ViewData["Exception"] = "Cant deleted";
                return(View("CommonError"));
            }
        }
コード例 #14
0
        // GET: Medicines/Edit/5
        public ActionResult Edit(short?id)
        {
            if (id == null)
            {
                ViewData["Exception"] = "Datas are Not Exists";
                return(View("CommonError"));
            }
            MedicineDetail medicineDetail = db.MedicineDetails.Find(id);

            if (medicineDetail == null)
            {
                ViewData["Exception"] = "Datas are Not Exists";
                return(View("CommonError"));
            }
            ViewBag.CategoryID = new SelectList(db.CategoryDiseases, "C_ID", "CategoryName", medicineDetail.CategoryID);
            return(View(medicineDetail));
        }
コード例 #15
0
        public ActionResult FileUpload(HttpPostedFileBase file)
        {
            if (file != null)
            {
                string ImageName    = System.IO.Path.GetFileName(file.FileName);
                string physicalPath = Server.MapPath("~/Content/img/" + ImageName);

                // save image in folder
                file.SaveAs(physicalPath);

                //save new record in database
                MedicineDetail newRecord = new MedicineDetail();
                newRecord.Dosage           = Request.Form["Dosage"];
                newRecord.ExpiredDate      = DateTime.Parse(Request.Form["ExpiredDate"]);
                newRecord.ManufacturedDate = DateTime.Parse(Request.Form["ManufacturedDate"]);
                newRecord.Image            = physicalPath;
                newRecord.MedicineName     = Request.Form["MedicineName"];
                newRecord.CategoryID       = int.Parse(Request.Form["ID"]);

                db.MedicineDetails.Add(newRecord);
                try
                {
                    db.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
            }
            //Display records
            return(RedirectToAction("Index", "Medicines"));
        }
コード例 #16
0
        public bool Post_DonThuoc(MedicineDetail dt)
        {
            const string proc = "SP_ThemDonThuoc";

            List <SqlParameter> para = new List <SqlParameter>()
            {
                new SqlParameter("MEDICALRECORDID", dt.MedicalRecordID),
                new SqlParameter("MEDICINEID", dt.MedicineID),
                new SqlParameter("AMONG", dt.Among),
                new SqlParameter("USAGE", dt.Usage)
            };

            int res = DataProvider.ExecuteNonQuery(proc, para);

            if (res > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #17
0
        /// <summary>
        /// 药品分页查询
        /// </summary>
        /// <param name="pNumber">所在页数</param>
        /// <param name="pRows">每页显示条数</param>
        /// <param name="values">药品信息</param>
        /// <param name="msg">出错信息</param>
        /// <returns>0:成功  大于0:出错  小于0:异常</returns>
        public int DB_PageMedicine(int pNumber, int pRows, out ArrayList values, out string msg)
        {
            msg = "";

            OracleConnection connection = new OracleConnection(WebConfigParameter.ConnectionHisString);
            OracleDataReader dr         = null;

            values = new ArrayList();

            try
            {
                int  ret = -99;
                long maxrow;
                long minrow;
                General.CalculatePage(pNumber, pRows, out maxrow, out minrow);

                bool _flag = false;

                string findId1 = _builder.GetMedicinePage(maxrow, minrow, out _flag, out msg);

                if (!_flag)
                {
                    return(10);
                }

                dr = DbHelperOra.ExecuteReader(findId1, connection);

                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        MedicineDetail pd = new MedicineDetail();

                        pd.lx = !dr.IsDBNull(0) ? dr.GetString(0) : "";
                        pd.mc = !dr.IsDBNull(1) ? dr.GetString(1) : "";
                        pd.dw = !dr.IsDBNull(2) ? dr.GetString(2) : "";
                        pd.gg = !dr.IsDBNull(3) ? dr.GetString(3) : "";
                        pd.cd = !dr.IsDBNull(4) ? dr.GetString(4) : "";
                        pd.jg = !dr.IsDBNull(5) ? dr.GetDouble(5) : 0;


                        values.Add(pd);
                    }
                    ret = 0;
                }
                else
                {
                    msg    = "亲,没有记录";
                    values = null;
                    ret    = 2;
                }

                dr.Close();
                return(ret);
            }
            catch (Exception ex)
            {
                UtilLog.GetInstance().WriteProgramLog(System.Reflection.MethodBase.GetCurrentMethod().Name, ex);

                msg    = GetExceptionInfo(ex);
                values = null;
                return(-1);
            }
            finally
            {
                if (null != dr)
                {
                    dr.Close();
                }
                connection.Close();
            }
        }