示例#1
0
        public static watershed_crop GetCrop(BOM.watershed_crop crop)
        {
            watershedEntities db = new watershedEntities();
            var st = (from u in db.watershed_crop where (u.cname == crop.cname && u.type == crop.type) select u).SingleOrDefault();

            return(st);
        }
 public ActionResult AddCrop(BOM.watershed_crop crop)
 {
     WaterShed.WaterShedservice.Service1Client service = new WaterShed.WaterShedservice.Service1Client();
     bool status = service.doAddCrop(crop);
     String msg = "";
     if (status)
     {
         msg = "add";
     }
     else
     {
         msg = "not";
     }
     TempData.Add("msg", msg);
     return View();
 }
示例#3
0
        public static bool AddCrop(BOM.watershed_crop crop)
        {
            watershedEntities db = new watershedEntities();

            if (null == GetCrop(crop))
            {
                try
                {
                    db.watershed_crop.Add(crop);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    return(false);
                }
            }
            return(true);
        }
示例#4
0
        public static bool RemoveCrop(BOM.watershed_crop cr)
        {
            watershedEntities db = new watershedEntities();

            try {
                BOM.watershed_crop crop = db.watershed_crop.Remove(cr);
                db.SaveChanges();
                if (null == crop)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }catch (DbEntityValidationException ex)
            {
                return(false);
            }
        }