public ActionResult DeleteCardiologicalCPB([DataSourceRequest] DataSourceRequest request, int?id)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    using (var db = new StoreContext())
                    {
                        var item = new CardiologicalCPB()
                        {
                            CardiologicalCPBId = Convert.ToInt32(id),
                        };
                        db.CardiologicalCPBS.Attach(item);
                        db.CardiologicalCPBS.Remove(item);

                        db.SaveChanges();
                    }
                }
                return(Json("1", JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Save(CardiologicalCPB cardiologicalCPB)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(this.Json(new { statuscode = -1, message = General.msgInvalidModel }, JsonRequestBehavior.AllowGet));
                }

                using (var db = new StoreContext())
                {
                    // եթե 2-րդ մակարդակի աղյուսակի տողը նոր գրառումա ավելացնում ենք
                    if (cardiologicalCPB.CardiologicalCPBId == 0)
                    {
                        //ավելացնել
                        db.CardiologicalCPBS.Add(cardiologicalCPB);
                    }
                    else
                    {
                        //Վերջում խմբագրում ենք 2-րդ մակարդակի աղյուսակի գրառումը
                        CardiologicalCPB mCardiologicalCPB = db.CardiologicalCPBS.Find(cardiologicalCPB.CardiologicalCPBId);
                        mCardiologicalCPB.ResidentId        = cardiologicalCPB.ResidentId;
                        mCardiologicalCPB.CPBDate           = cardiologicalCPB.CPBDate;
                        mCardiologicalCPB.CPBTime           = cardiologicalCPB.CPBTime;
                        mCardiologicalCPB.SampleTypeId      = cardiologicalCPB.SampleTypeId;
                        mCardiologicalCPB.MAP               = cardiologicalCPB.MAP;
                        mCardiologicalCPB.RectalTemperature = cardiologicalCPB.RectalTemperature;
                        mCardiologicalCPB.ACT               = cardiologicalCPB.ACT;
                        mCardiologicalCPB.FiO2              = cardiologicalCPB.FiO2;
                        mCardiologicalCPB.pH        = cardiologicalCPB.pH;
                        mCardiologicalCPB.pO2       = cardiologicalCPB.pO2;
                        mCardiologicalCPB.pCO2      = cardiologicalCPB.pCO2;
                        mCardiologicalCPB.SO2       = cardiologicalCPB.SO2;
                        mCardiologicalCPB.Ht        = cardiologicalCPB.Ht;
                        mCardiologicalCPB.Hb        = cardiologicalCPB.Hb;
                        mCardiologicalCPB.Na        = cardiologicalCPB.Na;
                        mCardiologicalCPB.K         = cardiologicalCPB.K;
                        mCardiologicalCPB.Cl        = cardiologicalCPB.Cl;
                        mCardiologicalCPB.Ca        = cardiologicalCPB.Ca;
                        mCardiologicalCPB.Mg        = cardiologicalCPB.Mg;
                        mCardiologicalCPB.BebTypeId = cardiologicalCPB.BebTypeId;
                        mCardiologicalCPB.BEB       = cardiologicalCPB.BEB;
                        mCardiologicalCPB.HCO3      = cardiologicalCPB.HCO3;
                        mCardiologicalCPB.BUN       = cardiologicalCPB.BUN;
                        mCardiologicalCPB.Lactosa   = cardiologicalCPB.Lactosa;
                        mCardiologicalCPB.Glucosa   = cardiologicalCPB.Glucosa;
                        mCardiologicalCPB.IonGap    = cardiologicalCPB.IonGap;


                        db.Entry(mCardiologicalCPB).State = EntityState.Modified;
                    }
                    db.SaveChanges();
                    return(this.Json(new { statuscode = 1, message = "" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(View("Error", new HandleErrorInfo(ex, "CardiologicalCPB", "Save")));
            }
        }