Ejemplo n.º 1
0
        public int AddPrescrip(Case_PrescripTionsModel model)
        {
            using (Entities db = new Entities())
            {
                case_prescriptions cpmodel = db.case_prescriptions.FirstOrDefault(a => a.workid == model.workid);
                if (cpmodel != null)
                {
                    return(0);
                }
                else
                {
                    cpmodel        = new case_prescriptions();
                    cpmodel.preid  = model.preid;
                    cpmodel.term   = model.term;
                    cpmodel.workid = model.workid;
                    db.case_prescriptions.Add(cpmodel);

                    return(db.SaveChanges());
                }
            }
        }
Ejemplo n.º 2
0
        public int EditPrescrip(Case_PrescripTionsModel model)
        {
            using (Entities db = new Entities())
            {
                case_prescriptions cpmodel = db.case_prescriptions.FirstOrDefault(a => a.preid == model.preid);

                if (cpmodel != null)
                {
                    if (cpmodel.workid != model.workid)
                    {
                        case_prescriptions cptmodel = db.case_prescriptions.FirstOrDefault(a => a.workid == model.workid);
                        if (cptmodel != null)
                        {
                            return(0);
                        }
                    }
                    cpmodel.preid  = model.preid;
                    cpmodel.term   = model.term;
                    cpmodel.workid = model.workid;
                }
                return(db.SaveChanges());
            }
        }