Ejemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "PRSCODE,ADDRID,MAILADDR,MAILADDRBool,ADDRTYPE,ADDR1,ADDR2,ADDR3,POSTAL,CITYCODE,STATECODE,CTRYCODE,PHONE1,PHONE2,FAX1,FAX2,REM,STAMP")] CSPRSADDR cSPRSADDR)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    cSPRSADDR.STAMP           = cSPRSADDR.STAMP + 1;
                    db.Entry(cSPRSADDR).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Edit", "CSPRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSPRSADDR.PRSCODE) }));
                }
                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);
                    }
                }
            }
            ViewBag.ADDRTYPE  = cSPRSADDR.addrtypeList;
            ViewBag.CITYCODE  = new SelectList(db.HKCITies.OrderBy(x => x.CITYCODE), "CITYCODE", "CITYDESC", cSPRSADDR.CITYCODE);
            ViewBag.STATECODE = new SelectList(db.HKSTATEs.OrderBy(x => x.STATECODE), "STATECODE", "STATEDESC", cSPRSADDR.STATECODE);
            ViewBag.CTRYCODE  = new SelectList(db.HKCTRies.OrderBy(x => x.CTRYCODE), "CTRYCODE", "CTRYDESC", cSPRSADDR.CTRYCODE);
            return(View(cSPRSADDR));
        }
Ejemplo n.º 2
0
        // GET: CSPRSADDRs/Create
        public ActionResult Create(string id)
        {
            var cSPRSADDR = new CSPRSADDR();

            cSPRSADDR.PRSCODE = MyHtmlHelpers.ConvertByteStrToId(id);
            ViewBag.ADDRTYPE  = cSPRSADDR.addrtypeList;
            ViewBag.CITYCODE  = new SelectList(db.HKCITies.OrderBy(x => x.CITYCODE), "CITYCODE", "CITYDESC", cSPRSADDR.CITYCODE);
            ViewBag.STATECODE = new SelectList(db.HKSTATEs.OrderBy(x => x.STATECODE), "STATECODE", "STATEDESC", cSPRSADDR.STATECODE);
            ViewBag.CTRYCODE  = new SelectList(db.HKCTRies.OrderBy(x => x.CTRYCODE), "CTRYCODE", "CTRYDESC", cSPRSADDR.CTRYCODE);
            return(View(cSPRSADDR));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(string id, int row)
        {
            CSPRSADDR cSPRSADDR = db.CSPRSADDRs.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            try
            {
                db.CSPRSADDRs.Remove(cSPRSADDR);
                db.SaveChanges();
                return(RedirectToAction("Edit", "CSPRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSPRSADDR.PRSCODE) }));
            }
            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(cSPRSADDR));
        }
Ejemplo n.º 4
0
        // GET: CSPRSADDRs/Delete/5
        public ActionResult Delete(string id, int row)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSPRSADDR cSPRSADDR = db.CSPRSADDRs.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            if (cSPRSADDR == null)
            {
                return(HttpNotFound());
            }
            return(View(cSPRSADDR));
        }
Ejemplo n.º 5
0
        // GET: CSPRSADDRs/Details/5
        public ActionResult Details(string id, int row)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSPRSADDR cSPRSADDR = db.CSPRSADDRs.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            if (cSPRSADDR == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ADDRTYPE  = cSPRSADDR.addrtypeList;
            ViewBag.CITYCODE  = new SelectList(db.HKCITies.OrderBy(x => x.CITYCODE), "CITYCODE", "CITYDESC", cSPRSADDR.CITYCODE);
            ViewBag.STATECODE = new SelectList(db.HKSTATEs.OrderBy(x => x.STATECODE), "STATECODE", "STATEDESC", cSPRSADDR.STATECODE);
            ViewBag.CTRYCODE  = new SelectList(db.HKCTRies.OrderBy(x => x.CTRYCODE), "CTRYCODE", "CTRYDESC", cSPRSADDR.CTRYCODE);
            return(View(cSPRSADDR));
        }