private void AddOneRecord(Object record)
        {
            if (record == null)
            {
                return;
            }

            // entidad Base seleccionada
            ClassEntity entitySel = View.ClassEntityCmb.SelectedItem as ClassEntity;

            if (entitySel == null)
            {
                return;
            }

            try
            {
                int entityRowId = 0;
                switch (entitySel.Name)
                {
                case "Account":
                    entityRowId = ((Account)record).AccountID;
                    // el registro ya existe en la lista destino?
                    if (View.CriteriaListReg.ItemsSource.Cast <Account>().Where(f => f.AccountID == entityRowId).Count() != 0)
                    {
                        return;
                    }
                    break;

                case "Product":
                    entityRowId = ((Product)record).ProductID;
                    // el registro ya existe en la lista destino?
                    if (View.CriteriaListReg.ItemsSource.Cast <Product>().Where(f => f.ProductID == entityRowId).Count() != 0)
                    {
                        return;
                    }
                    break;

                default: break;
                }

                ZoneEntityRelation zoneEnt = new ZoneEntityRelation
                {
                    Zone         = View.Model.Record,
                    Entity       = entitySel,
                    Rank         = 0,
                    EntityRowID  = entityRowId,
                    CreatedBy    = App.curUser.UserName,
                    CreationDate = DateTime.Today
                };

                service.SaveZoneEntityRelation(zoneEnt);
                //View.CriteriaListReg.Items.Add(record);
                //View.CriteriaList.Items.Remove(record);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public IList <ZoneEntityRelation> Select(ZoneEntityRelation data)
        {
            IList <ZoneEntityRelation> datos = new List <ZoneEntityRelation>();

            datos = GetHsql(data).List <ZoneEntityRelation>();
            if (!Factory.IsTransactional)
            {
                Factory.Commit();
            }
            return(datos);
        }
        private void RemoveOneRecord(Object record)
        {
            if (record == null)
            {
                return;
            }

            // entidad Base seleccionada
            ClassEntity entitySel = View.ClassEntityCmb.SelectedItem as ClassEntity;

            if (entitySel == null)
            {
                return;
            }

            try
            {
                int entityRowId = 0;
                switch (entitySel.Name)
                {
                case "Account":
                    entityRowId = ((Account)record).AccountID;
                    break;

                case "Product":
                    entityRowId = ((Product)record).ProductID;
                    break;

                default: break;
                }

                ZoneEntityRelation zoneEnt = service.GetZoneEntityRelation(new ZoneEntityRelation
                {
                    Zone         = View.Model.Record,
                    Entity       = entitySel,
                    EntityRowID  = entityRowId,
                    CreatedBy    = App.curUser.UserName,
                    CreationDate = DateTime.Today
                }).First();

                service.DeleteZoneEntityRelation(zoneEnt);
                //View.CriteriaListReg.Items.Remove(record);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        public override IQuery GetHsql(Object data)
        {
            StringBuilder      sql     = new StringBuilder("select a from ZoneEntityRelation a    where  ");
            ZoneEntityRelation zoneRel = (ZoneEntityRelation)data;

            if (zoneRel != null)
            {
                Parms = new List <Object[]>();
                if (zoneRel.Zone != null && zoneRel.Zone.ZoneID != 0)
                {
                    sql.Append(" a.Zone.ZoneID = :id     and   ");
                    Parms.Add(new Object[] { "id", zoneRel.Zone.ZoneID });
                }

                if (zoneRel.Entity != null && zoneRel.Entity.ClassEntityID != 0)
                {
                    sql.Append(" a.Entity.ClassEntityID = :id1     and   ");
                    Parms.Add(new Object[] { "id1", zoneRel.Entity.ClassEntityID });
                }

                if (zoneRel.EntityRowID != 0)
                {
                    sql.Append(" a.EntityRowID = :id2     and   ");
                    Parms.Add(new Object[] { "id2", zoneRel.EntityRowID });
                }


                if (zoneRel.Forced != null)
                {
                    sql.Append(" a.Forced = :idf     and   ");
                    Parms.Add(new Object[] { "idf", zoneRel.Forced });
                }
            }

            sql = new StringBuilder(sql.ToString());
            sql.Append(" 1=1 order by a.Rank asc ");
            IQuery query = Factory.Session.CreateQuery(sql.ToString());

            SetParameters(query);
            return(query);
        }
Пример #5
0
 public void DeleteZoneEntityRelation(ZoneEntityRelation data)
 {
     try {
     SetService();  SerClient.DeleteZoneEntityRelation(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
Пример #6
0
 public ZoneEntityRelation SaveZoneEntityRelation(ZoneEntityRelation data)
 {
     try {
     SetService();  return SerClient.SaveZoneEntityRelation(data); }
     finally
     {
         SerClient.Close();
         if (SerClient.State == CommunicationState.Faulted)
         SerClient.Abort(); 
     }
 }
Пример #7
0
 public ZoneEntityRelation SelectById(ZoneEntityRelation data)
 {
     return((ZoneEntityRelation)base.SelectById(data));
 }
Пример #8
0
 public Boolean Delete(ZoneEntityRelation data)
 {
     return(base.Delete(data));
 }
Пример #9
0
 public Boolean Update(ZoneEntityRelation data)
 {
     return(base.Update(data));
 }
Пример #10
0
 public ZoneEntityRelation Save(ZoneEntityRelation data)
 {
     return((ZoneEntityRelation)base.Save(data));
 }
Пример #11
0
        private void AddOneRecord(Object record)
        {
            if (record == null)
                return;

            // entidad Base seleccionada
            ClassEntity entitySel = View.ClassEntityCmb.SelectedItem as ClassEntity;
            if (entitySel == null)
                return;

            try
            {
                int entityRowId=0;
                switch (entitySel.Name)
                {
                    case "Account":
                        entityRowId = ((Account)record).AccountID;
                        // el registro ya existe en la lista destino?
                        if (View.CriteriaListReg.ItemsSource.Cast<Account>().Where(f => f.AccountID == entityRowId).Count() != 0)
                            return;  
                        break;
                    case "Product":
                        entityRowId = ((Product)record).ProductID;
                        // el registro ya existe en la lista destino?
                        if (View.CriteriaListReg.ItemsSource.Cast<Product>().Where(f => f.ProductID  == entityRowId).Count() != 0)
                            return;  
                        break;
                    default: break;
                }

                ZoneEntityRelation zoneEnt = new ZoneEntityRelation
                {
                    Zone = View.Model.Record,
                    Entity = entitySel,
                    Rank = 0, 
                    EntityRowID = entityRowId,
                    CreatedBy = App.curUser.UserName,
                    CreationDate = DateTime.Today
                };

                service.SaveZoneEntityRelation(zoneEnt);
                //View.CriteriaListReg.Items.Add(record);
                //View.CriteriaList.Items.Remove(record);
            }
            catch (Exception ex)
            {
                throw ex;
            }

        }