コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var catBL = new CatBL(false);
            var catsList = catBL.GetAllCats();

            var dt = new DataTable();
            var dcBreed = new DataColumn("Breed", typeof(string));
            var dcCountry = new DataColumn("Country", typeof(string));
            var dcOrigin = new DataColumn("Origin", typeof(string));
            var dcBodyType = new DataColumn("Body Type", typeof(string));
            var dcCoat = new DataColumn("Coat", typeof(string));
            var dcPattern = new DataColumn("Pattern", typeof(string));
            var dcImage = new DataColumn("Image", typeof(string));

            dt.Columns.AddRange(new[] { dcBreed, dcCountry, dcOrigin, dcBodyType, dcCoat, dcPattern, dcImage });

            for (var i = 0; i < catsList.Count; i++)
            {
                dt.Rows.Add(new object[]
                    {
                        catsList.ElementAt(i).GetBreed().Trim(), catsList.ElementAt(i).GetCountry().Trim(),
                        catsList.ElementAt(i).GetOrigin().Trim(), catsList.ElementAt(i).GetBodyType().Trim(),
                        catsList.ElementAt(i).GetCoat().Trim(), catsList.ElementAt(i).GetPattern().Trim(),
                        ResolveUrl(catsList.ElementAt(i).GetImage().Trim())
                    });
            }

            AllBreedGrid.DataSource = dt;
            AllBreedGrid.DataBind();
        }
コード例 #2
0
ファイル: CatBL.cs プロジェクト: vnovikov746/Crazy-Cat-Lady
 public Boolean AddCat(Cat cat, string changes)
 {
     var catBl = new CatBL(_admin);
     if (!_admin && catBl.IsCatExist(cat.GetBreed().Trim()))
     {
         return false;
     }
     _catDal.AddCat(cat, changes);
     return true;
 }
コード例 #3
0
        protected void Page_Init(object sender, EventArgs e)
        {
            _catBL = new CatBL(!_admin);
            _userCatBL = new CatBL(false);

            var catsList = _userCatBL.GetAllCats();
            ChooseBreedDownList.Items.Add("Choose Breed");
            foreach (var cat in catsList)
            {
                ChooseBreedDownList.Items.Add(cat.GetBreed());
            }
        }
コード例 #4
0
        protected void Page_Init(object sender, EventArgs e)
        {
            _catBL = new CatBL(_admin);
            _userCatBL = new CatBL(false);

            var dt = new DataTable();

            dt.Rows.Add();
            SearchCatGrid.DataSource = dt;
            SearchCatGrid.DataBind();

            var breedList = _userCatBL.GetListOfSpecification("Breed");
            var bodyTypeList = _userCatBL.GetListOfSpecification("Body type");
            var coatList = _userCatBL.GetListOfSpecification("Coat");
            var patternList = _userCatBL.GetListOfSpecification("Pattern");

            var breed = new DropDownList();
            var bodyType = new DropDownList();
            var coat = new DropDownList();
            var pattern = new DropDownList();
            breed.Items.Add(new ListItem("Choose Breed"));
            bodyType.Items.Add(new ListItem("Choose Body Type"));
            coat.Items.Add(new ListItem("Choose Coat"));
            pattern.Items.Add(new ListItem("Choose Pattern"));

            foreach (var node in breedList)
            {
                breed.Items.Add(new ListItem(node.Trim()));
            }
            foreach (var node in bodyTypeList)
            {
                bodyType.Items.Add(new ListItem(node.Trim()));
            }
            foreach (var node in coatList)
            {
                coat.Items.Add(new ListItem(node.Trim()));
            }
            foreach (var node in patternList)
            {
                pattern.Items.Add(new ListItem(node.Trim()));
            }

            SearchCatGrid.Rows[0].Cells[0].Controls.Add(breed);
            SearchCatGrid.Rows[0].Cells[1].Controls.Add(bodyType);
            SearchCatGrid.Rows[0].Cells[2].Controls.Add(coat);
            SearchCatGrid.Rows[0].Cells[3].Controls.Add(pattern);
        }
コード例 #5
0
 protected void Page_Init(object sender, EventArgs e)
 {
     _admin = Convert.ToBoolean(Request.QueryString["admin"]);
     _catBL = new CatBL(!_admin);
 }
コード例 #6
0
 protected void SubmitButton_Click(object sender, EventArgs e)
 {
     var replace = EditTextBox.Text.Trim();
     replace = replace.Replace("##", "<");
     replace = replace.Replace("**", ">");
     textDiv.InnerHtml = replace;
     CatImage.Visible = true;
     CatBreedName.Visible = true;
     EditTextButton.Visible = true;
     var cat = _userCatBL.GetCat(CatBreedName.Text.Trim());
     _catBL = new CatBL(!_admin);
     if (_admin == false)
     {
         _catBL.AddCat(new Cat(cat.GetBreed(), cat.GetCountry(), cat.GetOrigin(), cat.GetBodyType(), cat.GetCoat(), cat.GetPattern(), cat.GetImage(), EditTextBox.Text.Trim()), "information");
     }
     else
     {
         _userCatBL.AddSpecificationToBreed(CatBreedName.Text, "Information", EditTextBox.Text.Trim());
     }
     textDiv.Visible = true;
     Response.Write(_admin
         ? "<script>alert('You successfully edited the information of the breed');</script>"
         : "<script>alert('You successfully edited the information of the breed, the changes are waiting for the approval of the administrator');</script>");
 }