示例#1
0
        /// <summary>
        /// method for reading the order
        /// </summary>
        public void Read()
        {
            // input and validation
            Console.WriteLine("Input code of record you want to view");
            bool isValid = int.TryParse(Console.ReadLine(), out int code);

            while (isValid == false)
            {
                Console.WriteLine("Wrong input, please try again.");
                isValid = int.TryParse(Console.ReadLine(), out code);
            }


            try
            {
                using (RestaurantBraticGacinovicEntities context = new RestaurantBraticGacinovicEntities())
                {
                    // finding the order in the database with ID
                    tblRecord       recordToView = (from x in context.tblRecords where x.Code == code select x).First();
                    List <tblOrder> list         = (from x in context.tblOrders where x.RecordID == recordToView.RecordID select x).ToList();

                    // displaying the order
                    foreach (var item in list)
                    {
                        Console.WriteLine(item.Article + " " + item.Quantity);
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error");
            }
        }
示例#2
0
        public List <tblRecord> getAllCash()
        {
            SqlDataReader    reader   = ReadData("delete from tblRecord");
            List <tblRecord> dsSaleRe = new List <tblRecord>();

            while (reader.Read())
            {
                string    id       = reader.GetString(0);
                string    descrip  = reader.GetString(1);
                string    price    = reader.GetString(2);
                string    quantity = reader.GetString(3);
                string    totalsum = reader.GetString(4);
                string    type     = reader.GetString(5);
                string    size     = reader.GetString(6);
                string    brand    = reader.GetString(7);
                DateTime  date     = reader.GetDateTime(8);
                tblRecord sale     = new tblRecord();
                sale.ID          = id;
                sale.Description = descrip;
                sale.Price       = price;
                sale.Quantity    = quantity;
                sale.TotalSum    = totalsum;
                sale.Type        = type;
                sale.Size        = size;
                sale.Brand       = brand;
                sale.DateTime    = date;
                dsSaleRe.Add(sale);
            }
            reader.Close();
            return(dsSaleRe);
        }
示例#3
0
        /// <summary>
        /// method for deleting the order
        /// </summary>
        public void Delete()
        {
            // inputs and validations
            Console.WriteLine("Input code of record you want to delete");
            bool isValid = int.TryParse(Console.ReadLine(), out int code);

            while (isValid == false)
            {
                Console.WriteLine("Wrong input, please try again.");
                isValid = int.TryParse(Console.ReadLine(), out code);
            }

            try
            {
                // finding the order and deleting it from the database
                using (RestaurantBraticGacinovicEntities context = new RestaurantBraticGacinovicEntities())
                {
                    tblRecord       recordToDelete = (from x in context.tblRecords where x.Code == code select x).First();
                    List <tblOrder> list           = (from x in context.tblOrders where x.RecordID == recordToDelete.RecordID select x).ToList();
                    context.tblOrders.RemoveRange(list);
                    context.tblRecords.Remove(recordToDelete);
                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error");
            }
        }
示例#4
0
        public List <tblRecord> search(string Desciption)
        {
            SqlDataReader    reader = ReadData("Select * from tblRecord where Description like '" + Desciption + "%' Order by DateTime DESC");
            List <tblRecord> dsSale = new List <tblRecord>();

            while (reader.Read())
            {
                string    id       = reader.GetString(0);
                string    descrip  = reader.GetString(1);
                string    price    = reader.GetString(2);
                string    quantity = reader.GetString(3);
                string    totalsum = reader.GetString(4);
                string    type     = reader.GetString(5);
                string    size     = reader.GetString(6);
                string    brand    = reader.GetString(7);
                DateTime  date     = reader.GetDateTime(8);
                tblRecord sale     = new tblRecord();
                sale.ID          = id;
                sale.Description = descrip;
                sale.Price       = price;
                sale.Quantity    = quantity;
                sale.TotalSum    = totalsum;
                sale.Type        = type;
                sale.Size        = size;
                sale.Brand       = brand;
                sale.DateTime    = date;
                dsSale.Add(sale);
            }
            reader.Close();
            return(dsSale);
        }
        public DetailsViewModel(tblRecord record, List <tblRating> ratings)
        {
            Record      = record;
            RatingsList = ratings;

            if (RatingsList.Count() >= 1)
            {
                OverallRating = RatingsList.Select(x => x.Rating).Sum() / RatingsList.Count();
            }
            else
            {
                OverallRating = 0;
            }
        }
示例#6
0
 public ActionResult Edit([Bind(Include = "RecordID, RecordName, RecordBio, ReleaseDate, ArtistSelected, GenreSelected, ImageSrc, ImageAlt")] tblRecord record, EditViewModel view)
 {
     if (ModelState.IsValid)
     {
         record.ArtistID             = int.Parse(view.ArtistSelected);
         record.GenreID              = int.Parse(view.GenreSelected);
         context.Entry(record).State = EntityState.Modified;
         context.SaveChanges();
         return(RedirectToAction("AdminIndex"));
     }
     else
     {
         return(View());
     }
 }
 private void AddToCartExecute()
 {
     try
     {
         AmountInt = Meal.Price * Convert.ToInt32(Amount) + AmountInt;
         tblRecord record = new tblRecord();
         record.MealID = Meal.MealID;
         record.Amount = Convert.ToInt32(Amount);
         recordList.Add(record);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#8
0
        public ActionResult Create(CreateViewModel createvm)
        {
            if (ModelState.IsValid)
            {
                string filename = Path.GetFileName(createvm.Image.FileName);
                createvm.ImageSrc = "~/Content/RecordImages/" + filename;
                filename          = Path.Combine(Server.MapPath("~/Content/RecordImages/"), filename);
                createvm.Image.SaveAs(filename);

                tblRecord record = new tblRecord(int.Parse(createvm.ArtistSelected), int.Parse(createvm.GenreSelected), createvm.RecordName, createvm.RecordBio, createvm.ReleaseDate, createvm.ImageSrc, createvm.ImageAlt);
                context.tblRecords.Add(record);
                context.SaveChanges();
                ModelState.Clear();

                CreateViewModel newcreatevm = new CreateViewModel();
                return(View(newcreatevm));
            }
            else
            {
                return(View());
            }
        }
示例#9
0
        public ActionResult Delete(DeleteViewModel view)
        {
            bool isPasswordValid = context.tblUsers
                                   .Any(x => x.UserName.ToLower() == User.Identity.Name.ToLower() &&
                                        x.Password == view.Password);

            if (isPasswordValid)
            {
                tblRecord record = context.tblRecords.Find(view.Record.RecordID);

                List <tblRating> ratingslist = context.tblRatings.Where(x => x.RecordID == record.RecordID).ToList();
                foreach (var item in ratingslist)
                {
                    context.tblRatings.Remove(item);
                }

                context.tblRecords.Remove(record);
                context.SaveChanges();
                return(RedirectToAction("AdminIndex"));
            }

            return(View());
        }
示例#10
0
        /// <summary>
        /// method for creating the order
        /// </summary>
        public void Create()
        {
            // dictionary for displaying the restaurant Menu
            Dictionary <int, string> RestaurantMenu = ShowMenu();

            try
            {
                using (RestaurantBraticGacinovicEntities context = new RestaurantBraticGacinovicEntities())
                {
                    tblRecord record = new tblRecord();
                    Random    rnd    = new Random();

                    // variables for creating record in table Records and taking random order code
                    record.OrderTime = DateTime.Now;
                    record.Code      = rnd.Next(1, 9999);
                    context.tblRecords.Add(record);

                    string exit = null;

                    // loop for creating the order
                    do
                    {
                        // inputs and validations
                        Console.WriteLine("Input ID of the article: ");
                        bool isValid = int.TryParse(Console.ReadLine(), out int id);

                        while (isValid == false)
                        {
                            Console.WriteLine("Wrong input, please try again.");
                            isValid = int.TryParse(Console.ReadLine(), out id);
                        }

                        // loop for checking if the article exists in the Menu
                        if (!RestaurantMenu.ContainsKey(id))
                        {
                            Console.WriteLine("The article does not exist.");
                            return;
                        }

                        Console.WriteLine("Input quantity: ");
                        bool inputQuantity = int.TryParse(Console.ReadLine(), out int quantity);

                        while (inputQuantity == false)
                        {
                            Console.WriteLine("Wrong input, please try again.");
                            inputQuantity = int.TryParse(Console.ReadLine(), out quantity);
                        }

                        // loop for checking if article exists and creating the order
                        if (RestaurantMenu.ContainsKey(id))
                        {
                            tblOrder order = new tblOrder();
                            order.Article  = RestaurantMenu[id];
                            order.Quantity = quantity;
                            order.RecordID = record.RecordID;
                            context.tblOrders.Add(order);
                        }


                        Console.WriteLine("If you want to finish order press 'x', or press 'enter' to continue.");
                        exit = Console.ReadLine();
                    } while (exit != "x");

                    Console.WriteLine("\nCode of your order: " + record.Code);


                    context.SaveChanges();
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error");
            }
        }
示例#11
0
        /// <summary>
        /// method for updating orders, deleting the order and creating new with the same code and ID
        /// </summary>
        public void Update()
        {
            // inputs and validations
            Console.Write("Please enter your order code: ");
            bool isValid = int.TryParse(Console.ReadLine(), out int code);

            while (isValid == false)
            {
                Console.WriteLine("Wrong input, please try again.");
                isValid = int.TryParse(Console.ReadLine(), out code);
            }

            // calling method for displaying the restaurant Menu
            Dictionary <int, string> RestaurantMenu = ShowMenu();

            try
            {
                using (RestaurantBraticGacinovicEntities context = new RestaurantBraticGacinovicEntities())
                {
                    tblRecord record = new tblRecord();

                    // finding order to edit
                    tblRecord       recordToEdit = (from x in context.tblRecords where x.Code == code select x).First();
                    List <tblOrder> list         = (from y in context.tblOrders where y.RecordID == recordToEdit.RecordID select y).ToList();

                    // deleting the order
                    context.tblOrders.RemoveRange(list);
                    if (recordToEdit != null)
                    {
                        string exit = null;

                        // loop for creating new order at the same code and ID
                        do
                        {
                            Console.WriteLine("Input ID of the article: ");
                            bool inputID = int.TryParse(Console.ReadLine(), out int id);

                            while (inputID == false)
                            {
                                Console.WriteLine("Wrong input, please try again.");
                                inputID = int.TryParse(Console.ReadLine(), out id);
                            }

                            Console.WriteLine("Input quantity: ");
                            bool inputQuantity = int.TryParse(Console.ReadLine(), out int quantity);

                            while (inputID == false)
                            {
                                Console.WriteLine("Wrong input, please try again.");
                                inputQuantity = int.TryParse(Console.ReadLine(), out quantity);
                            }

                            // creating new order
                            if (RestaurantMenu.ContainsKey(id))
                            {
                                tblOrder order = new tblOrder();
                                order.Article  = RestaurantMenu[id];
                                order.Quantity = quantity;
                                order.RecordID = recordToEdit.RecordID;
                                context.tblOrders.Add(order);
                            }
                            Console.WriteLine("\nIf you want to finish order press 'x', or press 'enter' to continue.");
                            exit = Console.ReadLine();
                        } while (exit != "x");

                        context.SaveChanges();
                    }
                    else
                    {
                        Console.WriteLine("\nYour order does not exist, please try again.");
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Error");
            }
        }
示例#12
0
 public DeleteViewModel(tblRecord record, List <tblRating> ratings)
 {
     Record      = record;
     RatingsList = ratings.Where(x => x.RecordID == Record.RecordID).ToList();
 }