예제 #1
0
        public ActionResult Edit(TapEntity objTap)
        {
            if (ModelState.IsValid)
            {
                objTap.BaseRemoteIp = RemoteIp;
                objTap.BaseIdUser   = LoggedUserName;
                int result = proxy.UpdateTap(objTap);
                if (result == -1)
                {
                    TapEntity objTapOld = proxy.GetTap(objTap.IdTap);

                    AssingMessageScript("El Tap ya existe en el sistema, .", "error", "Error", true);
                    CheckNotify();
                    return(View(objTap));
                }
                if (result > 0)
                {
                    AssingMessageScript("El Tap se modifico en el sistema.", "success", "Éxito", true);
                    CheckNotify();
                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("Index"));
            }
            return(View(objTap));
        }
예제 #2
0
        /// <summary>
        /// Converts data from reader to entity
        /// </summary>
        protected virtual TapEntity GetTapFromReader(IDataReader reader)
        {
            TapEntity entity_Tap = null;

            try
            {
                entity_Tap               = new TapEntity();
                entity_Tap.IdTap         = (int?)(GetFromReader(reader, "IdTap"));
                entity_Tap.Clv_Sector    = (int?)(GetFromReader(reader, "Clv_Sector"));
                entity_Tap.Clv_Colonia   = (int?)(GetFromReader(reader, "Clv_Colonia"));
                entity_Tap.Clv_Calle     = (int?)(GetFromReader(reader, "Clv_Calle"));
                entity_Tap.IdPoste       = (int?)(GetFromReader(reader, "IdPoste"));
                entity_Tap.Ingenieria    = (int?)(GetFromReader(reader, "Ingenieria"));
                entity_Tap.Salidas       = (int?)(GetFromReader(reader, "Salidas"));
                entity_Tap.Clave         = (String)(GetFromReader(reader, "Clave", IsString: true));
                entity_Tap.NoCasas       = (int?)(GetFromReader(reader, "NoCasas"));
                entity_Tap.NoNegocios    = (int?)(GetFromReader(reader, "NoNegocios"));
                entity_Tap.NoLotes       = (int?)(GetFromReader(reader, "NoLotes"));
                entity_Tap.NoServicios   = (int?)(GetFromReader(reader, "NoServicios"));
                entity_Tap.FrenteANumero = (String)(GetFromReader(reader, "FrenteANumero", IsString: true));
            }
            catch (Exception ex)
            {
                throw new Exception("Error converting Tap data to entity", ex);
            }
            return(entity_Tap);
        }
예제 #3
0
        public Tap ReplaceKeg(int tapId, Keg keg)
        {
            //Get tap by Id
            TapEntity tapEntity = _unitOfWork.TapRepository.GetByID(tapId);

            if (tapEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    //Get Keg by TapId
                    var oldKeg = _unitOfWork.KegRepository.GetFirst(k => k.TapId == tapId);
                    if (oldKeg != null)
                    {
                        //Update the Old Keg
                        oldKeg.TapId = null;
                        _unitOfWork.KegRepository.Update(oldKeg);
                    }
                    //Update the Tap with the new Keg
                    Mapper.CreateMap <Keg, KegEntity>();
                    var kegModel = Mapper.Map <Keg, KegEntity>(keg);
                    tapEntity.Keg = kegModel;


                    //Add new Keg
                    _unitOfWork.KegRepository.Insert(kegModel);


                    _unitOfWork.Save();
                    scope.Complete();
                }
            }

            return(GetTapById(tapId));
        }
예제 #4
0
        /// <summary>
        /// Edits a Tap
        ///</summary>
        /// <param name="Tap"> Objeto Tap a editar </param>
        public override int EditTap(TapEntity entity_Tap)
        {
            int result = 0;

            using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.Tap.ConnectionString))
            {
                SqlCommand comandoSql = CreateCommand("Softv_TapEdit", connection);

                AssingParameter(comandoSql, "@IdTap", entity_Tap.IdTap);

                AssingParameter(comandoSql, "@Clv_Sector", entity_Tap.Clv_Sector);

                AssingParameter(comandoSql, "@Clv_Colonia", entity_Tap.Clv_Colonia);

                AssingParameter(comandoSql, "@Clv_Calle", entity_Tap.Clv_Calle);

                AssingParameter(comandoSql, "@IdPoste", entity_Tap.IdPoste);

                AssingParameter(comandoSql, "@Ingenieria", entity_Tap.Ingenieria);

                AssingParameter(comandoSql, "@Salidas", entity_Tap.Salidas);

                AssingParameter(comandoSql, "@Clave", entity_Tap.Clave);

                AssingParameter(comandoSql, "@NoCasas", entity_Tap.NoCasas);

                AssingParameter(comandoSql, "@NoNegocios", entity_Tap.NoNegocios);

                AssingParameter(comandoSql, "@NoLotes", entity_Tap.NoLotes);

                AssingParameter(comandoSql, "@NoServicios", entity_Tap.NoServicios);

                AssingParameter(comandoSql, "@FrenteANumero", entity_Tap.FrenteANumero);

                try
                {
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }

                    result = int.Parse(ExecuteNonQuery(comandoSql).ToString());
                }
                catch (Exception ex)
                {
                    throw new Exception("Error updating Tap " + ex.Message, ex);
                }
                finally
                {
                    if (connection != null)
                    {
                        connection.Close();
                    }
                }
            }
            return(result);
        }
예제 #5
0
        public ActionResult Details(int id = 0)
        {
            TapEntity objTap = proxy.GetTap(id);

            if (objTap == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(objTap));
        }
예제 #6
0
        /// <summary>
        ///</summary>
        /// <param name="Tap"> Object Tap added to List</param>
        public override int AddTap(TapEntity entity_Tap)
        {
            int result = 0;

            using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.Tap.ConnectionString))
            {
                SqlCommand comandoSql = CreateCommand("Softv_TapAdd", connection);

                AssingParameter(comandoSql, "@IdTap", null, pd: ParameterDirection.Output, IsKey: true);

                AssingParameter(comandoSql, "@Clv_Sector", entity_Tap.Clv_Sector);

                AssingParameter(comandoSql, "@Clv_Colonia", entity_Tap.Clv_Colonia);

                AssingParameter(comandoSql, "@Clv_Calle", entity_Tap.Clv_Calle);

                AssingParameter(comandoSql, "@IdPoste", entity_Tap.IdPoste);

                AssingParameter(comandoSql, "@Ingenieria", entity_Tap.Ingenieria);

                AssingParameter(comandoSql, "@Salidas", entity_Tap.Salidas);

                AssingParameter(comandoSql, "@Clave", entity_Tap.Clave);

                AssingParameter(comandoSql, "@NoCasas", entity_Tap.NoCasas);

                AssingParameter(comandoSql, "@NoNegocios", entity_Tap.NoNegocios);

                AssingParameter(comandoSql, "@NoLotes", entity_Tap.NoLotes);

                AssingParameter(comandoSql, "@NoServicios", entity_Tap.NoServicios);

                AssingParameter(comandoSql, "@FrenteANumero", entity_Tap.FrenteANumero);

                try
                {
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    result = ExecuteNonQuery(comandoSql);
                }
                catch (Exception ex)
                {
                    throw new Exception("Error adding Tap " + ex.Message, ex);
                }
                finally
                {
                    connection.Close();
                }
                result = (int)comandoSql.Parameters["@IdTap"].Value;
            }
            return(result);
        }
예제 #7
0
        public ActionResult Edit(int id = 0)
        {
            PermisosAccesoDeniedEdit("Tap");
            ViewBag.CustomScriptsPageValid = BuildScriptPageValid();
            TapEntity objTap = proxy.GetTap(id);

            if (objTap == null)
            {
                return(HttpNotFound());
            }
            return(View(objTap));
        }
예제 #8
0
        /// <summary>
        /// Gets Tap by
        ///</summary>
        public override TapEntity GetTapById(int?IdTap)
        {
            using (SqlConnection connection = new SqlConnection(SoftvSettings.Settings.Tap.ConnectionString))
            {
                SqlCommand comandoSql = CreateCommand("Softv_TapGetById", connection);
                TapEntity  entity_Tap = null;


                AssingParameter(comandoSql, "@IdTap", IdTap);

                IDataReader rd = null;
                try
                {
                    if (connection.State == ConnectionState.Closed)
                    {
                        connection.Open();
                    }
                    rd = ExecuteReader(comandoSql, CommandBehavior.SingleRow);
                    if (rd.Read())
                    {
                        entity_Tap = GetTapFromReader(rd);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Error getting data Tap " + ex.Message, ex);
                }
                finally
                {
                    if (connection != null)
                    {
                        connection.Close();
                    }
                    if (rd != null)
                    {
                        rd.Close();
                    }
                }
                return(entity_Tap);
            }
        }
예제 #9
0
 public ActionResult Create(TapEntity objTap)
 {
     if (ModelState.IsValid)
     {
         objTap.BaseRemoteIp = RemoteIp;
         objTap.BaseIdUser   = LoggedUserName;
         int result = proxy.AddTap(objTap);
         if (result == -1)
         {
             AssingMessageScript("El Tap ya existe en el sistema.", "error", "Error", true);
             CheckNotify();
             return(View(objTap));
         }
         if (result > 0)
         {
             AssingMessageScript("Se dio de alta el Tap en el sistema.", "success", "Éxito", true);
             return(RedirectToAction("Index"));
         }
     }
     return(View(objTap));
 }
예제 #10
0
        public static int Edit(TapEntity objTap)
        {
            int result = ProviderSoftv.Tap.EditTap(objTap);

            return(result);
        }
예제 #11
0
        public ActionResult QuickIndex(int?page, int?pageSize, int?Clv_Sector, int?Clv_Colonia, int?Clv_Calle, int?IdPoste, int?Ingenieria, int?Salidas, String Clave, int?NoCasas, int?NoNegocios, int?NoLotes, int?NoServicios, String FrenteANumero)
        {
            int pageNumber = (page ?? 1);
            int pSize      = pageSize ?? SoftvMVC.Properties.Settings.Default.pagnum;
            SoftvList <TapEntity> listResult = null;
            List <TapEntity>      listTap    = new List <TapEntity>();
            TapEntity             objTap     = new TapEntity();
            TapEntity             objGetTap  = new TapEntity();


            if ((Clv_Sector != null))
            {
                objTap.Clv_Sector = Clv_Sector;
            }

            if ((Clv_Colonia != null))
            {
                objTap.Clv_Colonia = Clv_Colonia;
            }

            if ((Clv_Calle != null))
            {
                objTap.Clv_Calle = Clv_Calle;
            }

            if ((IdPoste != null))
            {
                objTap.IdPoste = IdPoste;
            }

            if ((Ingenieria != null))
            {
                objTap.Ingenieria = Ingenieria;
            }

            if ((Salidas != null))
            {
                objTap.Salidas = Salidas;
            }

            if ((Clave != null && Clave.ToString() != ""))
            {
                objTap.Clave = Clave;
            }

            if ((NoCasas != null))
            {
                objTap.NoCasas = NoCasas;
            }

            if ((NoNegocios != null))
            {
                objTap.NoNegocios = NoNegocios;
            }

            if ((NoLotes != null))
            {
                objTap.NoLotes = NoLotes;
            }

            if ((NoServicios != null))
            {
                objTap.NoServicios = NoServicios;
            }

            if ((FrenteANumero != null && FrenteANumero.ToString() != ""))
            {
                objTap.FrenteANumero = FrenteANumero;
            }

            pageNumber = pageNumber == 0 ? 1 : pageNumber;
            listResult = proxy.GetTapPagedListXml(pageNumber, pSize, Globals.SerializeTool.Serialize(objTap));
            if (listResult.Count == 0)
            {
                int tempPageNumber = (int)(listResult.totalCount / pSize);
                pageNumber = (int)(listResult.totalCount / pSize) == 0 ? 1 : tempPageNumber;
                listResult = proxy.GetTapPagedListXml(pageNumber, pSize, Globals.SerializeTool.Serialize(objTap));
            }
            listResult.ToList().ForEach(x => listTap.Add(x));

            var TapAsIPagedList = new StaticPagedList <TapEntity>(listTap, pageNumber, pSize, listResult.totalCount);

            if (TapAsIPagedList.Count > 0)
            {
                return(PartialView(TapAsIPagedList));
            }
            else
            {
                var result = new { tipomsj = "warning", titulomsj = "Aviso", Success = "False", Message = "No se encontraron registros con los criterios de búsqueda ingresados." };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
예제 #12
0
 public int UpdateTap(TapEntity objTap)
 {
     return(Tap.Edit(objTap));
 }
예제 #13
0
 public int AddTap(TapEntity objTap)
 {
     return(Tap.Add(objTap));
 }
예제 #14
0
        public static TapEntity GetOne(int?IdTap)
        {
            TapEntity result = ProviderSoftv.Tap.GetTapById(IdTap);

            return(result);
        }
예제 #15
0
 /// <summary>
 /// Abstract method to add Tap
 ///  /summary>
 /// <param name="Tap"></param>
 /// <returns></returns>
 public abstract int AddTap(TapEntity entity_Tap);
예제 #16
0
 /// <summary>
 /// Abstract method to update Tap
 /// </summary>
 public abstract int EditTap(TapEntity entity_Tap);
예제 #17
0
        public static int Add(TapEntity objTap)
        {
            int result = ProviderSoftv.Tap.AddTap(objTap);

            return(result);
        }