Ejemplo n.º 1
0
        public ActionResult DeleteConfirmed(string id)
        {
            CSCOTX cSCOTX = db.CSCOTXes.Find(id);

            db.CSCOTXes.Remove(cSCOTX);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(string id, int row)
        {
            CSCOTX cSCOTX = db.CSCOTXes.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            try
            {
                db.CSCOTXes.Remove(cSCOTX);
                db.SaveChanges();
                return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOTX.CONO) }) + "#TaxAgent"));
            }
            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(cSCOTX));
        }
Ejemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "CONO,TXCODE,ADATE,RDATE,ENDDATE,REM,ROWNO,STAMP")] CSCOTX cSCOTX)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cSCOTX).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TXCODE = new SelectList(db.CSTXes, "TXCODE", "TXDESC", cSCOTX.TXCODE);
     return(View(cSCOTX));
 }
Ejemplo n.º 4
0
        // GET: CSCOTXes/Create
        public ActionResult Create(string id)
        {
            ViewBag.Parent = MyHtmlHelpers.ConvertByteStrToId(id);
            CSCOTX cSCOTX = new CSCOTX();

            cSCOTX.CONO     = ViewBag.Parent;
            cSCOTX.ADATE    = DateTime.Today;
            cSCOTX.ENDDATE  = new DateTime(3000, 1, 1);
            cSCOTX.CSCOMSTR = db.CSCOMSTRs.Find(cSCOTX.CONO);
            ViewBag.TXCODE  = new SelectList(db.CSTXes.OrderBy(x => x.TXDESC), "TXCODE", "TXDESC");
            return(View(cSCOTX));
        }
Ejemplo n.º 5
0
        // GET: CSCOTXes/Delete/5
        public ActionResult Delete(string id, int row)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOTX cSCOTX = db.CSCOTXes.Find(MyHtmlHelpers.ConvertByteStrToId(id), row);

            if (cSCOTX == null)
            {
                return(HttpNotFound());
            }
            return(View(cSCOTX));
        }
Ejemplo n.º 6
0
        // GET: CSCOTXes/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOTX cSCOTX = db.CSCOTXes.Find(id);

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

            if (cSCOTX == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TXCODE = new SelectList(db.CSTXes.OrderBy(x => x.TXDESC), "TXCODE", "TXDESC", cSCOTX.TXCODE);
            return(View(cSCOTX));
        }
Ejemplo n.º 8
0
        // GET: CSCOTXes/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CSCOTX cSCOTX = db.CSCOTXes.Find(id);

            if (cSCOTX == null)
            {
                return(HttpNotFound());
            }
            ViewBag.TXCODE = new SelectList(db.CSTXes, "TXCODE", "TXDESC", cSCOTX.TXCODE);
            return(View(cSCOTX));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "CONO,TXCODE,ADATE,RDATE,ENDDATE,REM,ROWNO,STAMP")] CSCOTX cSCOTX)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    int lastRowNo = 0;
                    try
                    {
                        lastRowNo = db.CSCOTXes.Where(m => m.CONO == cSCOTX.CONO).Max(n => n.ROWNO);
                    }
                    catch (Exception e) { lastRowNo = 0; }
                    finally { };

                    cSCOTX.ROWNO = lastRowNo + 1;
                    cSCOTX.STAMP = 0;
                    db.CSCOTXes.Add(cSCOTX);
                    db.SaveChanges();
                    return(new RedirectResult(Url.Action("Edit", "CSCOMSTRs", new { id = MyHtmlHelpers.ConvertIdToByteStr(cSCOTX.CONO) }) + "#TaxAgent"));
                }
                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);
                }
            }

            cSCOTX.CSCOMSTR = db.CSCOMSTRs.Find(cSCOTX.CONO);
            ViewBag.TXCODE  = new SelectList(db.CSTXes.OrderBy(x => x.TXDESC), "TXCODE", "TXDESC", cSCOTX.TXCODE);
            return(View(cSCOTX));
        }