예제 #1
0
        public ActionResult Index(PatBasicInfor pat)
        {
            PatOperation pto = new PatOperation();

            string PID = Request.Form["门诊号"];
            if (string.IsNullOrEmpty(pat.Name) || string.IsNullOrEmpty(pat.Sex) || string.IsNullOrEmpty(pat.Age) || string.IsNullOrEmpty(pat.Phone))
            {
                ModelState.AddModelError("", "带*的输入项不能为空");
            }
            else
            {
                Regex reg = new Regex("^[0-9]+$");
                Match ma1 = reg.Match(pat.Age);
                Match ma2 = reg.Match(pat.Phone);
                if (ma1.Success && ma2.Success)
                {
                }
                else
                {
                    ModelState.AddModelError("", "手机和年龄必须为数字");
                }
            }
            if (ModelState.IsValid)
            {
                string user;
                user = HttpContext.Request.Cookies["username"].Value.ToString();
                //pto.InsertPat(pat, PID, user);
                VisitDataOperation vr = new VisitDataOperation();
                mPatInfo p =new mPatInfo();
               p.Name=pat.Name;
                p.Sex=pat.Sex;
                p.Age=pat.Age;
                p.Phone=pat.Phone;
                p.Address = pat.Address;
                p.Education = pat.Education;
                p.Height = pat.Height;
                p.Weight = pat.Weight;
                p.Job = pat.Job;
                string pid=vr.InsertPat(p,user);
                return RedirectToAction("Index", "Diagnosis", new { ID = pid});
            }
            else
            {
                return View();
            }
        }
예제 #2
0
        public string InsertPat(mPatInfo pat, string User)
        {
            MongoServer server = ConnectDB();
             var db = server.GetDatabase("hdb");
             string pid = "";
            try
            {
                using (server.RequestStart(db))
                {

                    var Usercollection = db.GetCollection<mUser>("Users");

                    var query = new QueryDocument("UserName", User);
                    //mUser u = new mUser();
                    //u.UserName = "******";
                    //u.PassWord = "******";
                    mUser entity = Usercollection.FindOne(query);
                    MongoDBRef r = new MongoDBRef("Users", entity.Id);

                    var PatCollection = db.GetCollection<mPatInfo>("Pats");
                    pat.Doctor = r;
                    PatCollection.Insert(pat);
                    pid = pat.PatId.ToString();
                    //collection.Remove(query);

                }
                return pid;
            }
            catch (System.Exception ex)
            {
                return pid;
            }
        }