β beginner here!
i have to end a project as soon as possible to present in 2 weeks in my school. I struggle with basic things and I need help to configure an admin account! The registration and login already works. I'm doing kind of a mcdonalds type app in visual studio. I need to make an admin account and make it be able to add burgers and drinks etc (images into picturebox and names and prices into labels) into the menu and remove them, make it active or not active as my teacher said to do it that way. I dont have much time so I dont have much more help from them. (the current menu doesnt work, i didnt know it wasnt that way, i rlly need help asap! i know nothing about sql π )
149 Replies
nome = name
tipo = type (drink, food, chips)
preço = price
estado = state, if its active or not
foto means foto
in the tabpage2 i would need to show the orders of what each user bought and when
So what is it exactly, what you need help with? We cannot write the app for you .
From what I could gather, it seems you need help with sql. But where exactly?
We kinda need more details here. Maybe even the requirements of the task. That way we can give better advice, push you in the right direction, etc
i need to understand how do I put items into the menu by putting it into the database
there's not much i can say besides that
So you have food in that one form. What I understand now is, that you wanna have that food in your database and in the app, you wanna retrieve all the food items and display them in your app. Is that correct?
more or less
like
the food in the menu
ignore it
i need to be able to put the food by the admin form
for example
i put the name, price, etc
foto
and it needs to appear in the menu
Ah, so if you are an admin, you can add new food
yesss
Okay, that's a start. So what you wanna do is
1. in the function that should add the new food, you need create a new object with all the information in that form. I take it that you have some sort of
Menu
or Food
object.
2. you probably have some sort of collection for your food. you need to add the new object there.
3. update ui
4. save the new data in your database (given that your food is in a database)hmmm
Is there anything that is unclear?
im confused
where should I do that exactly
Do what?
the code itself
into the add button? or outside it
Well, the add button should create object and add it to the collection of your food
Without further information about your code, we just have to guess.
it has nothing in the admin form
π
But you know how to add an event to a button?
just this
Right
im guessing double click
if not idk
Nay
Button2 is this?
technically doubleclick would work, but it might be an idea to learn how to use the Properties window π
button2
Yes, button2. I'm just blind lol
idek where the button1 is
The code would go in that
button2_Click
eventooooh right
button1 might be your red arrow thing.
Not sure
its a picture box
ah
i think i deleted the button1
then you can also search for it in the properties window, as pobiega said ^^
deleted it yea
no button 1
Aight. Anyway, the code will go in that button2_Click event
aight
and i create a function
and then an object
Try it out. If you are stuck, ask again π
ill try
@pobiega
Oh it's this thread
yea
suffering still
So, where are you stuck?
in the same place
idek how to create a function at this
What
its supposed to create a function right
If you don't know what a method is, you're in over your head
a method
"it"?
it?
β
wait huh
oh
wait so
method and function are the same thing
Yup
In C# we call them methods
i thought it was like something (something){
something
}
But they are used fairly interchangeable
Sure, that's roughly the syntax
is it
the thing is
idek what to put in there
im completely noob
Then you need to figure that iut
add(string something){
something idk
}
if its not that
then idk at all
What exactly are you working on right now?
The add product button?
yes
save the info into the database and load it into the menu form
instead of the things in the menu already
So, tell me what you want to happen when that button is clicked
when the button is clicked it will save the info put into the admin form into the menu in the format of the examples
like it will save the name into the table of the burgers inside the name column
the price, image etc
and load it into the menu if this makes sense
Okay. Do you currently have a database or similar ?
yes
the database is made with the tables and needed columns
Okay
just the regist and login works
So, write some code in the add button handler to add a new row to your products table
what think its better if i go get my work and database and screenshot it
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/Use this if there's code to show π
I don't know what database you use, or how you connect to it
ikik
we use the sql inside the visual basic
What
we connect via dal
What
and do something in
Stop using onion terms
its the name of the things π
It's not.
what is the name of it then
dal and bll
omg its better if i send it all
Dal is just a piece of your code that is responsible for database work. That doesn't tell me anything at sll
huh
Is it ado.net? Ef core? Dapper?
none of that?
IDKKK
Then find out
we just click in add database
inside visual studio
and use the sql
inside it
Asking the other way around: How do you register new users? How are those saved in your database?
You can't just "add an item to a database".
You said registering is working
via code
Show code
omg im confused now
i cant rn im at the cafe
ill show everything as soon as I can
You will likely need to add some methods to your "Dal" so it can add new products
Then call that method from your form
we do that in bll
Okay.
Then do that?
this is getting even more confusing
the thing is in the bll it just does something that idk
we need to do specific codes into the buttons outside the bll for it to work
ill show later
I'm calling a strict no spoonfeeding on this thread.
dal and bll are codes pre made that our teacher gave us and make us work with that
I see.
That would have been good to start with
Since its critical to your issue
i didnt know im so sorry
Go get your code.
i thought it was all this way
We can't do anything until you do
ill go get it hopefully they will let me get into the classroom
or else ill need to wait for tomorrow
this is a mess
You said you still have 2 weeks. So stay calm, grab your code when you can, and then we'll see
2 weeks and i still have so much to do
next monday ill make a pre presentation
i swear i hate this class
i could have this already made
Did something prevent you?
yes
it was supposed to be made in groups
my classmate decided to work alone in the middle of it so i had to start over alone
+ health issues
i hate hate hate this all
Does your teacher know about it?
yes
they know
i always make group works alone because or they dont do anything or they just give up
too much stress
teachers dont care so its on me
bruhhh π
my school has an older version of sql
do i update the database
ill need to somehow update the sql at school
but okay so
@pobiega do you have any site that I can share the codes
or can i send here? its rlly big and confusing
BlazeBin - tntkyzaunxrw
A tool for sharing your source code with the world!
omg
your teacher doesnt follow fucking naming conventions
what is that
!!!
what is this
private SqlConnection _SqlConn;
should be _sqlConn
private void abrirLigacao()
should be private void AbrirLigacao()
oh and in english
and ofc every method in "BLL" which is an actual class (lol) has a DAL dal = new DAL();
in it
okay so there is a BLL method called insertProduto
thats what you want to use, I guess
but yeah, I really dislike all the code in DAL/BLL
its very... bad practice getting even more confused
how so
you have a static method called
insertProduto
just call that in your button handler?insertproduto
WAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA my head
yk what
ill ask my teacher tomorrow
about the code and stuff
try to get an example and give more info
because this
is
BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADly confusing to me
how?
its as straightforward as it gets
you've been handed the readymade code that does all the hard stuff
you literally just need to call a method
a method
but the thing is
i need to change
the things in the code
and somehow do the admin thing
which i
dont know how because its different
i mean, there is already an "insert product" method in your BLL
so that doesnt need to be changed
yes
it inserts in the database
but how do I
make that work
"make that work"?
yes like
what code should i put into the button so that is saves everything in that form for that thing
its not just "insertProduct()"
and then load it into menu
Do you know how to read?
yes
static public int insertProduto(string nome, string tipo, string preço, bool ativo, byte[] imagem)
how many arguments does that take?huh????????????????????
look at the method signature I posted
thats the thing in the bll
yup.
its the method you should call
how many arguments does it take?
and how many arguments does
insertProduct()
provide?
directly quoted from your message above, btwwhat exactly do you mean by arguments
arguments/parameters
I cant be any more clear than that.
because thats the actual name
Can you see a difference between
static public int insertProduto(string nome, string tipo, string preço, bool ativo, byte[] imagem)
and static public int insertProduto()
its the same thing but one specifies the things?
the things being...?
the name etc of the product
<:picard_facepalm:616692703685509130>
hooooow
if its a string or not
are you doing winforms shit and dont know what a method parameter is
THE TEACHER DOESNT TEACH!!!!!
so those varialbles in the method signatures are what we call parameters, and is how you can pass arguments into a method
insertProduto()
doesnt work because there is no method with that name that takes 0 arguments
the one that exists takes 5 arguments
so you need to provide those 5 argumentshum
aight, so instead of saying that "it is confusing", you should tell us clearly what is confusing.
You two established that a call to
insertProduto()
magically saves a product in the database. Now the questions for you are
- What product? Where does it come from? (It clearly consists of information from your form)
- how does this magical construct insertProduto()
know about your product? Seems to have something to do with those "things" in parantheses (as you called them) after the method name
- how can you use this method to save your product to the database.
Right now it seems you need to read up on some basics. Here's the documentation about methods. Please read that carefully and you'll understand better, what Pobiega meant https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/methodsMethods - C# Programming Guide
A method in C# is a code block that contains a series of statements. A program runs the statements by calling the method and specifying arguments.
looks about right. I'd urge you to rename your controls thou
textBox1
is a terrible name
productNameTextBox
is a better name.i think its better if I let this in this way
it works
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.