Ejemplo n.º 1
0
        // GET: CSGRPMs/Create
        public ActionResult Create()
        {
            CSGRPM cSGRPM = new CSGRPM();

            cSGRPM.STAMP = 0;
            return(View(cSGRPM));
        }
Ejemplo n.º 2
0
        public ActionResult Create([Bind(Include = "GRPCODE,GRPDESC,STAMP")] CSGRPM cSGRPM)
        {
            cSGRPM.STAMP = 0;
            if (ModelState.IsValid)
            {
                try
                {
                    db.CSGRPMs.Add(cSGRPM);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                catch (DbEntityValidationException 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
                            ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage);
                        }
                    }
                }
                catch (DbUpdateException ex)
                {
                    UpdateException updateException = (UpdateException)ex.InnerException;
                    if (updateException != null)
                    {
                        if (updateException.InnerException != null)
                        {
                            var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException;

                            foreach (var error in sqlException.Errors)
                            {
                                if (error.Message != null)
                                {
                                    ModelState.AddModelError(string.Empty, error.Message);
                                }
                            }
                        }
                        else
                        {
                            ModelState.AddModelError(string.Empty, updateException.Message);
                        }
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, updateException.Message);
                    }
                }
            }

            return(View(cSGRPM));
        }
Ejemplo n.º 3
0
        // GET: CSGRPMs/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSGRPM cSGRPM = db.CSGRPMs.Find(MyHtmlHelpers.ConvertByteStrToId(id));

            if (cSGRPM == null)
            {
                return(HttpNotFound());
            }
            return(View(cSGRPM));
        }
Ejemplo n.º 4
0
        public ActionResult DeleteConfirmed(string id)
        {
            CSGRPM cSGRPM = db.CSGRPMs.Find(MyHtmlHelpers.ConvertByteStrToId(id));

            try
            {
                var myList = cSGRPM.CSGRPDs.ToList();
                foreach (var item in myList)
                {
                    var csDel = db.CSGRPDs.Find(item.GRPCODE, item.CONO);
                    db.CSGRPDs.Remove(csDel);
                }

                db.CSGRPMs.Remove(cSGRPM);


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException 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
                        ModelState.AddModelError(validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
            }
            catch (DbUpdateException ex)
            {
                UpdateException updateException = (UpdateException)ex.InnerException;
                if (updateException != null)
                {
                    if (updateException.InnerException != null)
                    {
                        var sqlException = (FirebirdSql.Data.FirebirdClient.FbException)updateException.InnerException;

                        foreach (var error in sqlException.Errors)
                        {
                            if (error.Message != null)
                            {
                                ModelState.AddModelError(string.Empty, error.Message);
                            }
                        }
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, updateException.Message);
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, updateException.Message);
                }
            }

            return(View(cSGRPM));
        }