Esempio n. 1
0
 public void UpdateRoute(int id, string tuyenDuong)
 {
     try
     {
         RouteDTO dto = new RouteDTO {
             Id = id, TuyenDuong = tuyenDuong
         };
         dao.Update(dto);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public bool EditRoute(Route model)
        {
            bool result = false;

            try
            {
                var route = _db.Get <Route>().Where(x => x.Id == model.Id).FirstOrDefault();
                if (route != null)
                {
                    route.Name        = model.Name;
                    route.CardPAN     = model.CardPAN;
                    route.Description = model.Description;
                    route.SinkNode    = model.SinkNode;
                    result            = _db.Update(route);
                    _db.Commit();
                }
                return(result);
            }
            catch (Exception)
            {
                _db.Rollback();
                throw;
            }
        }
Esempio n. 3
0
        public EditUI()
        {
            string msg = "";

            AddSection()
            .IsFramed()
            .WithTitle("Edit Route")
            .WithColumns(new List <Column>
            {
                new Column(
                    new List <IField> {
                    Map(x => x.Name)
                    .AsSectionField <TextBox>()
                    .WithLength(50).LabelTextIs("Name")
                    .Required().TextFormatIs("")
                    .TextFormatIs("^[ a-zA-Z0-9]+$"),
                    Map(x => x.BIN)
                    .AsSectionField <TextBox>()
                    .TextFormatIs(TextFormat.numeric)
                    .WithLength(6, 20).LabelTextIs("BIN").Required()
                    .TextFormatIs(TextFormat.numeric),
                    Map(x => x.Description)
                    .AsSectionField <TextBox>()
                    .WithLength(60)
                    .LabelTextIs("Description")
                    .Required()
                    .TextFormatIs("^[ a-zA-Z0-9]+$"),
                    Map(x => x.SinkNode).AsSectionField <DropDownList>()
                    .Of(() => { return(new SinkNodeDAO().Get().ToList()); })
                    .ListOf(x => x.Name, x => x.ID).WithEditableText()
                    .Required()
                    .LabelTextIs("Sink Node"),

                    Map(x => x.ID).AsSectionField <TextLabel>().ApplyMod <VisibilityMod>(m => m.Hide <Route>(h => { return(true); })),
                }),
            })
            .WithFields(new List <IField> {
                AddSectionButton()
                .SubmitTo(x =>
                {
                    try
                    {
                        RouteDAO routeDao = new RouteDAO();
                        Route route       = routeDao.GetById(x.ID);

                        //check for uniqueness
                        if (!routeDao.isUniqueName(route.Name, x.Name))
                        {
                            msg += "Route name must be unique";
                            return(false);
                        }
                        else if (!routeDao.isUniqueBIN(route.BIN, x.BIN))
                        {
                            msg += "PAN must be unique";
                            return(false);
                        }

                        route.Name         = x.Name;
                        route.BIN          = x.BIN;
                        route.Description  = x.Description;
                        route.SinkNode     = x.SinkNode;
                        route.DateModified = DateTime.Now;

                        routeDao.Update(route);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        msg          += "An error occured";
                        string logMsg = "Message= " + ex.Message + " Inner Exception= " + ex.InnerException;
                        MessageLogger.LogError(logMsg);
                        return(false);
                    }
                })
                .ConfirmWith(s => String.Format("Update Route type {0} ", s.Name)).WithText("Update")
                .OnSuccessDisplay(s => String.Format("Route \"{0}\" has been successfuly editted ", s.Name))
                .OnFailureDisplay(s => String.Format("Error editting!\n   {0} ", msg))
            });
        }
Esempio n. 4
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(RouteEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pTran);
 }