Ejemplo n.º 1
0
        public ActionResult Insert(ConveyanceInOut convInOut, bool wantClose)
        {
            //ConveyanceInOut convInOut = new ConveyanceInOut();
            this.convInOutRepo.CurrentUserName = HttpContext.User.Identity.Name;
            try
            {
                convInOutRepo.DoNewRecord(convInOut);
                UpdateModel(convInOut);
                convInOutRepo.DoSave(convInOut, true);
                TempData.AddInfo(Resources.Messages.SaveSuccess);
                if (!wantClose)
                {
                    return(RedirectToAction("Edit", new { id = convInOut.Id }));
                }
                return(RedirectToAction("Index2"));
            }
            catch (RulesException ex)
            {
                ex.CopyTo(ModelState);
                TempData.AddWarning(Resources.Messages.SaveError + ex.ExMessage());
            }
            catch (Exception ex)
            {
                TempData.AddWarning(Resources.Messages.SaveError + ex.ExMessage());
            }

            return(doInsert(convInOut));
        }
Ejemplo n.º 2
0
        public ActionResult Delete(int id)
        {
            ConveyanceInOut convInOut = convInOutRepo.GetOne(id);

            if (convInOut != null)
            {
                try
                {
                    //Delete the record
                    convInOutRepo.DoDelete(convInOut);
                    new RecordDeletedEvent("ConveyanceInOut", convInOut.Id, 0, convInOut.Code, convInOut.Conveyance.Name, null).Raise();
                    TempData.AddInfo(Resources.Messages.DeleteSuccess + " (" + convInOut.Code + "-" + convInOut.Conveyance.Name + ")");
                }
                catch (Exception ex)
                {
                    TempData.AddError(ex.ExMessage());
                    return(RedirectToAction("Edit", new { id = id }));
                }
            }
            else
            {
                TempData.AddError(Resources.Messages.NotFoundData);
            }

            return(RedirectToAction("Index2"));
        }
Ejemplo n.º 3
0
        private ActionResult doInsert(ConveyanceInOut convInOut)
        {
            ToolbarMenuHelpers.SetToolBar(ViewData,
                                          new { Save = "btnSave", New = "Insert", Close = "Index2" }, "ConveyanceInOut");

            //makeReferenceViewData();
            convInOut.Code = convInOutRepo.GetNewCode();
            return(View(convInOut));
        }
Ejemplo n.º 4
0
        private ActionResult doEdit(ConveyanceInOut convInOut, bool?backToSearch = null)
        {
            ToolbarMenuHelpers.SetToolBar(ViewData,
                                          new { Save = "btnSave", New = "Insert", GiveUp = "btnDelete", Close = "Index2" }, "ConveyanceInOut", new { backToSearch });

            //ส่งผ่านตัวแปรเพื่อทำ combobox
            //makeReferenceViewData();

            if (convInOut != null)
            {
                return(View(convInOut));
            }
            else
            {
                TempData.AddError(Resources.Messages.NotFoundData);
                return(RedirectToAction("Index2"));
            }
        }