コード例 #1
0
 public Chambre(int numero, types type, categories categories, int prix)
 {
     this.numero     = numero;
     this.type       = type;
     this.categories = categories;
     this.prix       = prix;
 }
コード例 #2
0
        public async Task <IActionResult> Edit(string id, [Bind("id,catname")] categories categories)
        {
            if (id != categories.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(categories);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!categoriesExists(categories.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(categories));
        }
コード例 #3
0
        private void BtnSearch_Click(object sender, RoutedEventArgs e)
        {
            dataAccess data  = new dataAccess();
            categories cat   = new categories();
            DataTable  table = new DataTable();

            if (Search.Text == null || Search.Text == "")
            {
                MessageBox.Show("Category Number required");
            }
            else
            {
                cat.CategoryID = int.Parse(Search.Text);
                table          = data.getCategory(cat);

                if (table.Rows.Count < 0)
                {
                    MessageBox.Show("Your Searched Category type does not exist !!");
                }
                else
                {
                    foreach (DataRow row in table.Rows)
                    {
                        CategoryNumber.Text      = row["CategoryID"].ToString();
                        CategoryName.Text        = row["CategoryName"].ToString();
                        CategoryDescription.Text = row["Description"].ToString();
                    }
                }
            }
        }
コード例 #4
0
ファイル: ProductAction.cs プロジェクト: markz12/InventoryMVC
 public async Task <ReturnData <int> > AddCategory(string category, string createdby)
 {
     return(await Task.Run(() =>
     {
         try
         {
             categories brand = new categories
             {
                 name = category,
                 createdby = createdby
             };
             string url = ApiUrl.apiUrl() + "products/AddCategory";
             string json = JsonConvert.SerializeObject(brand);
             using (var client = new WebClient())
             {
                 client.Headers.Add("content-type", "application/json");
                 var response = Encoding.ASCII.GetString(client.UploadData(url, "POST", Encoding.UTF8.GetBytes(json)));
                 return JsonConvert.DeserializeObject <ReturnData <int> >(response);
             }
         }
         catch (WebException ex) when(ex.Response is HttpWebResponse response)
         {
             ReturnData <int> err = new ReturnData <int>
             {
                 code = 500,
                 message = ex.Message
             };
             return err;
         }
     }));
 }
コード例 #5
0
        public void new_nav()
        {
            categories nav = new categories();

            PropertyBag["nav"] = nav;
            RenderView("../admin/nav/_editor");
        }
コード例 #6
0
ファイル: Categories.cs プロジェクト: nagyistge/Medical
    public categories GetRandomCat()
    {
        System.Array A        = System.Enum.GetValues(typeof(categories));
        categories   category = (categories)A.GetValue(UnityEngine.Random.Range(0, A.Length));

        return(category);
    }
コード例 #7
0
        public ActionResult Edit(int id)
        {
            BAL        bAL        = new BAL();
            categories categories = bAL.CategoryList.Single(c => c.categoryID == id);

            return(View(categories));
        }
コード例 #8
0
 public CategoryViewModel(categories category)
 {
     this.Id           = category.Id;
     this.Name         = category.name;
     this.Order        = category.status;
     this.articleTypes = category.articleTypes;
 }
コード例 #9
0
 public Chambre()
 {
     this.numero     = 0;
     this.type       = types.Individuelle;
     this.categories = categories.Confort;
     this.prix       = 0;
 }
コード例 #10
0
        public ActionResult Create(categories consulta, HttpPostedFileBase file)
        {
            consulta.created = DateTime.Now;
            consulta.updated = DateTime.Now;
            //consulta.status = Convert.ToInt32(Request.Form["status"]);

            //Preenche o campo Ordem da tabela de Categorias.
            var ultimoitem    = new categories();
            var consultaOrdem = (from ev in db.categories orderby ev.ordem ascending select ev).ToList();

            if (consultaOrdem.Count() > 0)
            {
                ultimoitem     = consultaOrdem[consultaOrdem.Count - 1];
                consulta.ordem = ultimoitem.ordem + 1;
            }
            else
            {
                consulta.ordem = 1;
            }

            //Cadastra a Categoria.
            if (ModelState.IsValid)
            {
                //Save Post
                db.categories.Add(consulta);
                db.SaveChanges();
                TempData["acao"] = "Dados inseridos com sucesso";
            }

            return(RedirectToAction("Index"));
        }
コード例 #11
0
        public IActionResult CreateCategory(CategoryViewModel newCat)
        {
            int?id = HttpContext.Session.GetInt32("Id");

            if (ModelState.IsValid)
            {
                categories checkingCat = _context.categories.Where(x => x.name == newCat.Name).FirstOrDefault();
                if (checkingCat != null)
                {
                    ModelState.AddModelError("name", "already in the database");
                    List <categories> category = _context.categories.OrderBy(x => x.name).ToList();
                    ViewBag.allCategories = category;
                    return(View("category"));
                }
                else
                {
                    categories newcat = new categories()
                    {
                        usersid    = (int)id,
                        name       = newCat.Name,
                        created_at = DateTime.Now,
                        updated_at = DateTime.Now
                    };
                    _context.Add(newcat);
                    _context.SaveChanges();
                    return(RedirectToAction("Categories"));
                }
            }
            List <categories> allCategories = _context.categories.OrderBy(x => x.name).ToList();

            ViewBag.allCategories = allCategories;
            return(View("category"));
        }
コード例 #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            categories category = _categoryManager.Find(x => x.id == id);

            _categoryManager.Delete(category);
            return(RedirectToAction("Index"));
        }
コード例 #13
0
        public IHttpActionResult Putcategories(int id, categories categories)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != categories.Id)
            {
                return(BadRequest());
            }

            db.Entry(categories).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!categoriesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #14
0
        public void edit_nav(int id)
        {
            HelperService.writelog("Editing nav categories", id);
            categories nav = ActiveRecordBase <categories> .Find(id);

            PropertyBag["nav"] = nav;
            RenderView("../admin/nav/_editor");
        }
コード例 #15
0
ファイル: Categories.cs プロジェクト: w88wins/ASP_KhachSan
    //cap nhat category
    public void updateCategory(categories ctg)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("update categories set cat_name=N'" + ctg.cat_name + "' where cat_id=" + ctg.cat_id + "", con);

        cmd.ExecuteNonQuery();
        con.Close();
    }
コード例 #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            categories categories = db.categories.Find(id);

            db.categories.Remove(categories);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #17
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         categories ct = (categories)Session["ctg"];
         txtcat_name.Text = ct.cat_name;
         DataBind();
     }
 }
コード例 #18
0
        public IActionResult CategoryDetail(int id)
        {
            categories      category    = _context.categories.Where(x => x.id == id).Include(x => x.CatPro).ThenInclude(x => x.product).FirstOrDefault();
            List <products> allProducts = _context.products.ToList();

            ViewBag.category    = category;
            ViewBag.allProducts = allProducts;
            return(View("categorydetail"));
        }
コード例 #19
0
        public void SearchModeKeywordBasicVisibilityTest()
        {
            var categories = new categories();

            var searchViewModel = Mediator.Index(null, ApprenticeshipSearchMode.Keyword, false).ViewModel;
            var view            = categories.RenderAsHtml(searchViewModel);

            view.GetElementbyId("categories").Attributes["class"].Value.Contains(" active").Should().BeFalse();
        }
コード例 #20
0
ファイル: Categories.cs プロジェクト: w88wins/ASP_KhachSan
    // Tạo thêm category
    public void addCategory(categories ctg)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand("insert into categories values(@cat_name)", con);

        cmd.Parameters.AddWithValue("cat_name", ctg.cat_name);
        cmd.ExecuteNonQuery();
        con.Close();
    }
コード例 #21
0
 public ActionResult Edit([Bind(Include = "categoryId,categoryName")] categories categories)
 {
     if (ModelState.IsValid)
     {
         db.Entry(categories).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categories));
 }
コード例 #22
0
 public ActionResult Create([Bind(Exclude = "categoryID")] categories categories)
 {
     if (ModelState.IsValid)
     {
         BAL bAL = new BAL();
         bAL.AddCategories(categories);
         return(RedirectToAction("Index"));
     }
     return(View(categories));
 }
コード例 #23
0
 protected void updateCategories_Command(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "updatecategories")
     {
         int        u  = Convert.ToInt16(e.CommandArgument);
         categories ct = ctg.get1Category(u);
         Session["ctg"] = ct;
         Response.Redirect("updateCategory.aspx");
     }
 }
コード例 #24
0
        public void SearchModeCategoryBasicVisibilityTest()
        {
            var categories = new categories();

            var searchViewModel = Mediator.Index(ApprenticeshipSearchMode.Category).ViewModel;
            var view            = categories.RenderAsHtml(searchViewModel);

            view.GetElementbyId("categories").Attributes["class"].Value.Contains(" active").Should().BeTrue();
            view.GetElementbyId("category-load-failed").Should().BeNull();
        }
コード例 #25
0
        public ActionResult Create([Bind(Include = "categoryId,categoryName")] categories categories)
        {
            if (ModelState.IsValid)
            {
                db.categories.Add(categories);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categories));
        }
コード例 #26
0
 public void setCategories(string a)
 {
     if (a == "Confort")
     {
         this.categories = categories.Confort;
     }
     if (a == "Luxe")
     {
         this.categories = categories.Luxe;
     }
 }
コード例 #27
0
        public void SearchModeCategoryNullCategoriesVisibilityTest()
        {
            ReferenceDataService.Setup(rds => rds.GetCategories());

            var categories = new categories();

            var searchViewModel = Mediator.Index(null, ApprenticeshipSearchMode.Category, false).ViewModel;
            var view            = categories.RenderAsHtml(searchViewModel);

            view.GetElementbyId("category-load-failed").Should().NotBeNull();
        }
コード例 #28
0
        public void CategorySelected()
        {
            var categories = new categories();

            var searchViewModel = Mediator.Index(null, ApprenticeshipSearchMode.Category, false).ViewModel;

            searchViewModel.Category = "3";
            var view = categories.RenderAsHtml(searchViewModel);

            view.GetElementbyId("category-" + searchViewModel.Category.ToLower()).Should().NotBeNull();
        }
コード例 #29
0
        public IHttpActionResult GetCategory(int id)
        {
            categories categories = db.categories.Find(id);

            if (categories == null)
            {
                return(NotFound());
            }

            return(Ok(categories));
        }
コード例 #30
0
        public ActionResult Create(categories category)
        {
            if (ModelState.IsValid)
            {
                category.id = null;
                _categoryManager.Insert(category);
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
コード例 #31
0
        //ADD
        public static bool AddCategory(categories c)
        {
            Context.categories.Add(c);
            try
            {
                Context.SaveChanges();
            }
            catch (DbUpdateException dbEx)
            {
                return false;
            }
            catch (DbEntityValidationException ex)
            {
                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry

                    DbEntityEntry entry = item.Entry;
                    string entityTypeName = entry.Entity.GetType().Name;

                    // Display or log error messages

                    foreach (DbValidationError subItem in item.ValidationErrors)
                    {
                        string message = string.Format("Error '{0}' occurred in {1} at {2}",
                                 subItem.ErrorMessage, entityTypeName, subItem.PropertyName);
                        Console.WriteLine(message);
                    }
                    // Rollback changes

                    switch (entry.State)
                    {
                        case EntityState.Added:
                            entry.State = EntityState.Detached;
                            break;
                        case EntityState.Modified:
                            entry.CurrentValues.SetValues(entry.OriginalValues);
                            entry.State = EntityState.Unchanged;
                            break;
                        case EntityState.Deleted:
                            entry.State = EntityState.Unchanged;
                            break;
                    }
                }

                return false;
            }
            Context.Entry(c).Reload();
            return true;
        }
コード例 #32
0
 public static List<subcategories> GetAllSubCategoryByCategory(categories cat)
 {
     return GetAllSubCategories().Where(sc => sc.categories_Id == (cat.Id)).ToList();
 }
コード例 #33
0
    protected void ddlexcellst_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            if (ddlexcellst.SelectedIndex == 0) {
                Label2.Visible = true;
            }
            else
            {
                Label2.Visible = false;
                OAuth2Parameters parameters_lst = oauthcredentials();
                GOAuth2RequestFactory requestFactory =
                     new GOAuth2RequestFactory(null, "Fusion-SpreadSheet", parameters_lst);
                SpreadsheetsService service = new SpreadsheetsService("Fusion-SpreadSheet");
                service.RequestFactory = requestFactory;

                service.RequestFactory = requestFactory;

                // TODO: Authorize the service object for a specific user (see other sections)

                // Instantiate a SpreadsheetQuery object to retrieve spreadsheets.
                SpreadsheetQuery query = new SpreadsheetQuery();

                // Make a request to the API and get all spreadsheets.
                SpreadsheetFeed feed = service.Query(query);

                if (feed.Entries.Count == 0)
                {
                    // TODO: There were no spreadsheets, act accordingly.
                }

                // TODO: Choose a spreadsheet more intelligently based on your
                // app's needs.
                SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[Convert.ToInt32(ddlexcellst.SelectedIndex) - 1];
                //Response.Write(spreadsheet.Title.Text + "\n");

                // Get the first worksheet of the first spreadsheet.
                // TODO: Choose a worksheet more intelligently based on your
                // app's needs.
                WorksheetFeed wsFeed = spreadsheet.Worksheets;
                WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];

                // Define the URL to request the list feed of the worksheet.
                AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

                // Fetch the list feed of the worksheet.

                ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
                listQuery.StartIndex = 0;
                ListFeed listFeed = service.Query(listQuery);

                // Iterate through each row, printing its cell values.

                List<category> chart_categories = new List<category>();
                ChartModels result = new ChartModels();
                categories final_categories = new categories();
                List<categories> list_categories = new List<categories>();
                List<dataset> collect_dataset = new List<dataset>();
                foreach (ListEntry row in listFeed.Entries)
                {
                    // Print the first column's cell value
                    TableRow tr = new TableRow();
                    //  Response.Write(row.Title.Text + "\n");
                    // Iterate over the remaining columns, and print each cell value
                    dataset final_dataset = new dataset();
                    List<data> collect_data = new List<data>();
                    foreach (ListEntry.Custom element in row.Elements)
                    {
                        if (row.Title.Text == "Row: 2")
                        {
                            category chart_category = new category();
                            chart_category.label = element.Value.ToString();
                            chart_categories.Add(chart_category);
                        }
                        else
                        {
                            data data_value = new data();
                            final_dataset.seriesname = row.Title.Text;
                            int n;
                            bool isNumeric = int.TryParse(element.Value, out n);
                            if (isNumeric)
                            {
                                data_value.value = element.Value.ToString();
                                collect_data.Add(data_value);
                            }
                        }
                        // Response.Write(element.Value + "\n");

                        TableCell tc = new TableCell();
                        if (row.Title.Text == "Row: 2")
                        {
                            tc.Text = "";
                        }
                        else
                            tc.Text = element.Value;
                        tr.Cells.Add(tc);
                    }
                    Table1.Rows.Add(tr);
                    if (collect_data.Count != 0)
                    {
                        final_dataset.data = collect_data;
                        collect_dataset.Add(final_dataset);
                    }
                }
                final_categories.category = chart_categories;
                result.dataset = collect_dataset;
                list_categories.Add(final_categories);
                result.categories = list_categories;

                JavaScriptSerializer js = new JavaScriptSerializer();
                string res = js.Serialize(result);
                string chartjson = JsonConvert.SerializeObject(result.categories);

                StringBuilder strJson = new StringBuilder();

                strJson.Append("{" +
                        "'chart': {" +
                              "'caption': 'Quarterly revenue'," +
                              "'subCaption':'Last year'," +
                              "'xAxisName':'Quarter (Click to drill down)'," +
                              "'subcaptionFontColor':'#0075c2'," +
                              "'numberPrefix': '$'," +
                              "'formatNumberScale': '1'," +
                              "'placeValuesInside': '1'," +
                              "'decimals': '0'" +
                                   "},");
                strJson.Append("'categories':");

                strJson.Append(chartjson);
                strJson.Append(",");
                strJson.Append("'dataset':");
                string chartdatajson = JsonConvert.SerializeObject(result.dataset);
                strJson.Append(chartdatajson);
                strJson.Append("}");

                // Initialize the chart.
                Chart sales = new Chart("mscolumn3d", "myChart", "600", "350", "json", strJson.ToString());

                // Render the chart.
                Label1.Text = sales.Render();
            }
        }
        catch (Exception)
        {
            Response.Redirect("Default.aspx");
        }
    }
コード例 #34
0
        //UPDATE
        public static int UpdateCategory(categories category)
        {
            categories categoryToUpdate = GetCategoryById(category.Id);

            categoryToUpdate.Name = category.Name;
            categoryToUpdate.associations = category.associations;
            categoryToUpdate.subcategories = category.subcategories;

            int affectedRows;

            try
            {
                affectedRows = Context.SaveChanges();
            }
            catch (DbEntityValidationException ex)
            {
                foreach (DbEntityValidationResult item in ex.EntityValidationErrors)
                {
                    // Get entry

                    DbEntityEntry entry = item.Entry;
                    string entityTypeName = entry.Entity.GetType().Name;

                    // Display or log error messages

                    foreach (DbValidationError subItem in item.ValidationErrors)
                    {
                        string message = string.Format("Error '{0}' occurred in {1} at {2}",
                                 subItem.ErrorMessage, entityTypeName, subItem.PropertyName);
                        Console.WriteLine(message);
                    }
                    // Rollback changes

                    switch (entry.State)
                    {
                        case EntityState.Added:
                            entry.State = EntityState.Detached;
                            break;
                        case EntityState.Modified:
                            entry.CurrentValues.SetValues(entry.OriginalValues);
                            entry.State = EntityState.Unchanged;
                            break;
                        case EntityState.Deleted:
                            entry.State = EntityState.Unchanged;
                            break;
                    }
                }

                return affectedRows = 0;
            }
            Context.Entry(categoryToUpdate).Reload();
            return affectedRows;
        }
コード例 #35
0
ファイル: EventDB.cs プロジェクト: Dailyman/attraktiva-toarp
        public static List<events> FilterEvents(DateTime? sT, DateTime? eT, communities c, associations a, categories cat, subcategories subCat, string word)
        {
            List<events> resultList = GetAllEvents();

            if (sT != null)
            {
                resultList = resultList.Where(e => e.StartDate >= sT).ToList();
            }

            if (eT != null)
            {
                resultList = resultList.Where(e => e.EndDate <= eT).ToList();
            }

            if (c != null)
            {

                var preResultList = new List<events>();

                preResultList.AddRange(resultList.Where(e => e.communities.Contains(c)).ToList());

                List<events> list = resultList;
                foreach (var ev in c.associations.SelectMany(asso => list.Where(e => e.associations.Contains(asso)).Where(ev => !preResultList.Contains(ev))))
                {
                    preResultList.Add(ev);
                }

                resultList = preResultList;
            }

            if (a != null)
            {
                resultList = resultList.Where(e => e.associations.Contains(a)).ToList();
            }

            if (cat != null)
            {
                List<events> eventsInAsso = new List<events>();
                foreach (var asso in cat.associations)
                {
                        eventsInAsso.AddRange(resultList.Where(e => e.associations.Contains(asso)));
                }

                resultList = eventsInAsso;

            }

            if (subCat != null)
            {
                resultList = resultList.Where(e => e.subcategories.Contains(subCat)).ToList();
            }

            if (!String.IsNullOrWhiteSpace(word))
            {
                resultList = GetEventsFromListBySearchWord(resultList, word);
            }

            return resultList;
        }