Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(string id, int row)
        {
            CSCOBANK cSCOBANK = db.CSCOBANKs.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            try
            {
                db.CSCOBANKs.Remove(cSCOBANK);
                db.SaveChanges();
                return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOBANK.CONO) }) + "#Banker"));
            }
            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);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, e.Message);
            }

            return(View(cSCOBANK));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(string id)
        {
            CSCOBANK cSCOBANK = db.CSCOBANKs.Find(id);

            db.CSCOBANKs.Remove(cSCOBANK);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "CONO,BANKCODE,ACTYPE,EFFDATE,TERDATE,ENDDATE,REM,ROWNO,STAMP")] CSCOBANK cSCOBANK)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cSCOBANK).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BANKCODE = new SelectList(db.HKBANKs, "BANKCODE", "BANKDESC", cSCOBANK.BANKCODE);
     return(View(cSCOBANK));
 }
Ejemplo n.º 4
0
        // GET: CSCOBANKs/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOBANK cSCOBANK = db.CSCOBANKs.Find(id);

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

            if (cSCOBANK == null)
            {
                return(HttpNotFound());
            }
            return(View(cSCOBANK));
        }
Ejemplo n.º 6
0
        // GET: CSCOBANKs/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOBANK cSCOBANK = db.CSCOBANKs.Find(id);

            if (cSCOBANK == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BANKCODE = new SelectList(db.HKBANKs, "BANKCODE", "BANKDESC", cSCOBANK.BANKCODE);
            return(View(cSCOBANK));
        }
Ejemplo n.º 7
0
        // GET: CSCOBANKs/Details/5
        public ActionResult Details(string id, int row)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOBANK cSCOBANK = db.CSCOBANKs.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            if (cSCOBANK == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BANKCODE = new SelectList(db.HKBANKs, "BANKCODE", "BANKDESC", cSCOBANK.BANKCODE);
            return(View(cSCOBANK));
        }
Ejemplo n.º 8
0
        // GET: CSCOBANKs/Create
        public ActionResult Create(string id)
        {
            ViewBag.BANKCODE = new SelectList(db.HKBANKs, "BANKCODE", "BANKDESC");
            ViewBag.Parent   = MyHtmlHelpers.ConvertByteStrToId(id);
            string sid = ViewBag.Parent;

            CSCOBANK curRec = new CSCOBANK();

            curRec.CONO      = sid;
            curRec.EFFDATE   = DateTime.Today;
            curRec.ENDDATE   = new DateTime(3000, 1, 1);
            curRec.CSCOMSTR  = db.CSCOMSTRs.Find(curRec.CONO);
            ViewBag.BANKCODE = new SelectList(db.HKBANKs.OrderBy(x => x.BANKDESC), "BANKCODE", "BANKDESC");

            return(View(curRec));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "CONO,BANKCODE,ACTYPE,EFFDATE,TERDATE,ENDDATE,REM,ROWNO,STAMP")] CSCOBANK cSCOBANK)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    int lastRowNo = 0;
                    try
                    {
                        lastRowNo = db.CSCOBANKs.Where(m => m.CONO == cSCOBANK.CONO).Max(n => n.ROWNO);
                    }
                    catch (Exception e) { lastRowNo = 0; }
                    finally { };

                    cSCOBANK.STAMP = 0;
                    cSCOBANK.ROWNO = lastRowNo + 1;
                    db.CSCOBANKs.Add(cSCOBANK);
                    db.SaveChanges();
                    return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOBANK.CONO) }) + "#Banker"));
                }
                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);
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError(string.Empty, e.Message);
                }
            }
            cSCOBANK.CSCOMSTR = db.CSCOMSTRs.Find(cSCOBANK.CONO);
            ViewBag.BANKCODE  = new SelectList(db.HKBANKs, "BANKCODE", "BANKDESC", cSCOBANK.BANKCODE);
            return(View(cSCOBANK));
        }