示例#1
0
        public virtual TypeBLL GetTypeBLLByName(string name)
        {
            TypeBLL type    = new TypeBLL();
            TypeDAL typeDal = uow.Types.GetOne(o => o.NameType == name);

            if (typeDal != null)
            {
                type.Id        = typeDal.Id;
                type.MaxLength = typeDal.MaxLength;
                type.MinLength = typeDal.MinLength;

                typeDal.Attributes = uow.StrAttribure.Get(o => o.TypeDALId == typeDal.Id);
                typeDal.Required   = uow.StringRequired.Get(o => o.TypeDALId == typeDal.Id);
                List <string> Att = new List <string>();
                List <string> Req = new List <string>();
                foreach (var g in typeDal.Attributes)
                {
                    Att.Add(g.Attribute);
                }
                foreach (var g in typeDal.Required)
                {
                    Req.Add(g.Required);
                }
                type.Required   = Req;
                type.Attributes = Att;
                return(type);
            }
            else
            {
                throw new TypeNotFoundException(string.Format("Type \"{0}\" not found.", name));
            }
        }
示例#2
0
    private void BindTeleTypeDropdownList()
    {
        string  id = "2"; //case type
        DataSet ds = new BLL.TypeBLL().GetTypeDataListByTypeID(id);

        ddlTeleType.DataSource = ds;

        ddlTeleType.DataTextField  = "FTypeValue";
        ddlTeleType.DataValueField = "ID";
        ddlTeleType.DataBind();
    }
示例#3
0
 public virtual bool AddType(TypeBLL New)
 {
     if (uow.Types.GetOne(x => (x.NameType.ToLower() == New.NameType.ToLower())) == null)
     {
         uow.Types.Create(Check(New));
         uow.Save();
         return(true);
     }
     else
     {
         throw new TypeDuplicateException(string.Format("Type \"{0}\" already exist.", New.NameType.ToLower()));
     }
 }
    private void BindGrid()
    {
        string id = this.txtTypeID.Text;

        if (id == string.Empty)
        {
            return;
        }
        DataSet ds = new BLL.TypeBLL().GetTypeDataListByTypeID(id);

        this.GridView1.DataSource = ds;
        this.GridView1.DataBind();
    }
示例#5
0
 public virtual bool ChangeType(TypeBLL New)
 {
     if (uow.Types.GetOne(o => o.Id == New.Id) != null)
     {
         TypeDAL type = Check(New);
         uow.Types.Remove(uow.Types.GetOne(o => o.Id == New.Id));
         uow.Save();
         uow.Types.Create(type);
         uow.Save();
         return(true);
     }
     else
     {
         throw new TypeNotFoundException(string.Format("Type with this \"{0}\" ID not Found.", New.Id));
     }
 }
示例#6
0
        private EntityDAL Check(EntityBLL New)
        {
            TypeBLL type = TA.GetTypeBLLByName(New.NameEntity.ToLower());

            if (type != null)
            {
                if (type.Required != null)
                {
                    foreach (var t in type.Required)
                    {
                        object attribute = new object();
                        New.Attributes.TryGetValue(t, out attribute);
                        if (attribute == null || attribute.ToString() == "")
                        {
                            throw new ErrorRequiredException(string.Format("Required field \"{0}\" is empty.", t));
                        }
                    }
                }

                if (type.MaxLength.Count != 0)
                {
                    foreach (var t in type.MaxLength)
                    {
                        bool check = New.Attributes[t.Key].ToString().Length > int.Parse(type.MaxLength[t.Key]);
                        if (check == true)
                        {
                            throw new OutOfMaxLengthException(string.Format("The field \"{0}\" accepts no more than {1} characters.", t, int.Parse(type.MaxLength[t.Key])));
                        }
                    }
                }
                if (type.MinLength.Count != 0)
                {
                    foreach (var t in type.MinLength)
                    {
                        bool check = New.Attributes[t.Key].ToString().Length < int.Parse(type.MinLength[t.Key]);
                        if (check == true)
                        {
                            throw new OutOfMinLengthException(string.Format("The field \"{0}\" accepts no less than {1} characters.", t, int.Parse(type.MinLength[t.Key])));
                        }
                    }
                }
                if (type.Attributes != null)
                {
                    Dictionary <string, AttributeDAL> AttributesDal = new Dictionary <string, AttributeDAL>();

                    foreach (var t in type.Attributes)
                    {
                        if (New.Attributes.ContainsKey(t))
                        {
                            AttributesDal.Add(t.ToLower(), new AttributeDAL()
                            {
                                Item = New.Attributes[t]
                            });
                        }
                    }

                    return(new EntityDAL {
                        NameEntity = New.NameEntity, Attributes = AttributesDal
                    });
                }
                else
                {
                    throw new AttributesNotFoundException("Attributes Not Found.");
                }
            }
            else
            {
                throw new TypeNotFoundException(string.Format("Type \"{0}\" not found", New.NameEntity.ToLower()));
            }
        }
示例#7
0
        private TypeDAL Check(TypeBLL value)
        {
            TypeDAL type = new TypeDAL();
            List <StringRequired>  Req = new List <StringRequired>();
            List <StringAttribute> Att = new List <StringAttribute>();

            if (value.Required != null)
            {
                foreach (var t in value.Required)
                {
                    if (!value.Attributes.Contains(t))
                    {
                        throw new IncorrectTypingException(string.Format("Attribute \"{0}\" not found", t));
                    }

                    Req.Add(new StringRequired()
                    {
                        Required = t, TypeDALId = value.Id
                    });
                }
            }
            if (value.Attributes != null)
            {
                foreach (var t in value.Attributes)
                {
                    Att.Add(new StringAttribute()
                    {
                        Attribute = t, TypeDALId = value.Id
                    });
                }
            }
            if (value.MaxLength.Count != 0)
            {
                foreach (var t in value.MaxLength)
                {
                    if (!value.Attributes.Contains(t.Key))
                    {
                        throw new IncorrectTypingException(string.Format("Attribute \"{0}\" not found", t.Key));
                    }

                    if (value.MinLength.ContainsKey(t.Key))
                    {
                        if (int.Parse(value.MinLength[t.Key]) >= int.Parse(t.Value))
                        {
                            throw new IncorrectTypingException(string.Format("Min value > Max value. In this \"{0}\" attribute", t.Key));
                        }
                    }
                }
            }
            if (value.MinLength.Count != 0)
            {
                foreach (var t in value.MinLength)
                {
                    if (!value.Attributes.Contains(t.Key))
                    {
                        throw new IncorrectTypingException(string.Format("Attribute \"{0}\" not found", t.Key));
                    }
                }
            }
            type.Required   = Req;
            type.NameType   = value.NameType.ToLower();
            type.MaxLength  = value.MaxLength;
            type.MinLength  = value.MinLength;
            type.Attributes = Att;
            return(type);
        }