C
C#13mo ago
hinky

✅ 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
hinky
hinky13mo ago
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
HimmDawg
HimmDawg13mo ago
So what is it exactly, what you need help with? We cannot write the app for you fluffyFoxLurk . 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
hinky
hinky13mo ago
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
HimmDawg
HimmDawg13mo ago
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?
hinky
hinky13mo ago
more or less like the food in the menu ignore it
hinky
hinky13mo ago
i need to be able to put the food by the admin form
hinky
hinky13mo ago
for example i put the name, price, etc foto and it needs to appear in the menu
HimmDawg
HimmDawg13mo ago
Ah, so if you are an admin, you can add new food
hinky
hinky13mo ago
yesss
HimmDawg
HimmDawg13mo ago
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)
hinky
hinky13mo ago
hmmm
HimmDawg
HimmDawg13mo ago
Is there anything that is unclear?
hinky
hinky13mo ago
im confused where should I do that exactly
HimmDawg
HimmDawg13mo ago
Do what?
hinky
hinky13mo ago
the code itself into the add button? or outside it grief
HimmDawg
HimmDawg13mo ago
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.
hinky
hinky13mo ago
it has nothing in the admin form 😭
hinky
hinky13mo ago
HimmDawg
HimmDawg13mo ago
But you know how to add an event to a button?
hinky
hinky13mo ago
just this
HimmDawg
HimmDawg13mo ago
Right
hinky
hinky13mo ago
im guessing double click if not idk
HimmDawg
HimmDawg13mo ago
Nay
HimmDawg
HimmDawg13mo ago
Button2 is this?
Pobiega
Pobiega13mo ago
technically doubleclick would work, but it might be an idea to learn how to use the Properties window 🙂
hinky
hinky13mo ago
button2
HimmDawg
HimmDawg13mo ago
Yes, button2. I'm just blind lol
hinky
hinky13mo ago
idek where the button1 is
HimmDawg
HimmDawg13mo ago
The code would go in that button2_Clickevent
hinky
hinky13mo ago
ooooh right
HimmDawg
HimmDawg13mo ago
button1 might be your red arrow thing. Not sure
hinky
hinky13mo ago
its a picture box
HimmDawg
HimmDawg13mo ago
ah
hinky
hinky13mo ago
i think i deleted the button1
HimmDawg
HimmDawg13mo ago
then you can also search for it in the properties window, as pobiega said ^^
hinky
hinky13mo ago
deleted it yea no button 1
HimmDawg
HimmDawg13mo ago
Aight. Anyway, the code will go in that button2_Click event
hinky
hinky13mo ago
aight and i create a function and then an object
HimmDawg
HimmDawg13mo ago
Try it out. If you are stuck, ask again 🙂
hinky
hinky13mo ago
ill try @pobiega
Pobiega
Pobiega13mo ago
Oh it's this thread
hinky
hinky13mo ago
yea suffering still
Pobiega
Pobiega13mo ago
So, where are you stuck?
hinky
hinky13mo ago
in the same place idek how to create a function at this grief
Pobiega
Pobiega13mo ago
What
hinky
hinky13mo ago
its supposed to create a function right
Pobiega
Pobiega13mo ago
If you don't know what a method is, you're in over your head
hinky
hinky13mo ago
a method
Pobiega
Pobiega13mo ago
"it"?
hinky
hinky13mo ago
it?
Pobiega
Pobiega13mo ago
hinky
hinky13mo ago
wait huh oh wait so method and function are the same thing
Pobiega
Pobiega13mo ago
Yup In C# we call them methods
hinky
hinky13mo ago
i thought it was like something (something){ something }
Pobiega
Pobiega13mo ago
But they are used fairly interchangeable Sure, that's roughly the syntax
hinky
hinky13mo ago
is it the thing is idek what to put in there im completely noob
Pobiega
Pobiega13mo ago
Then you need to figure that iut
hinky
hinky13mo ago
add(string something){ something idk } if its not that then idk at all
Pobiega
Pobiega13mo ago
What exactly are you working on right now? The add product button?
hinky
hinky13mo ago
yes save the info into the database and load it into the menu form instead of the things in the menu already
Pobiega
Pobiega13mo ago
So, tell me what you want to happen when that button is clicked
hinky
hinky13mo ago
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
Pobiega
Pobiega13mo ago
Okay. Do you currently have a database or similar ?
hinky
hinky13mo ago
yes the database is made with the tables and needed columns
Pobiega
Pobiega13mo ago
Okay
hinky
hinky13mo ago
just the regist and login works
Pobiega
Pobiega13mo ago
So, write some code in the add button handler to add a new row to your products table
hinky
hinky13mo ago
what grief think its better if i go get my work and database and screenshot it
HimmDawg
HimmDawg13mo ago
$code
MODiX
MODiX13mo ago
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/
HimmDawg
HimmDawg13mo ago
Use this if there's code to show 🙂
Pobiega
Pobiega13mo ago
I don't know what database you use, or how you connect to it
hinky
hinky13mo ago
ikik we use the sql inside the visual basic
Pobiega
Pobiega13mo ago
What
hinky
hinky13mo ago
we connect via dal
Pobiega
Pobiega13mo ago
What
hinky
hinky13mo ago
and do something in grief
Pobiega
Pobiega13mo ago
Stop using onion terms
hinky
hinky13mo ago
its the name of the things 😭
Pobiega
Pobiega13mo ago
It's not.
hinky
hinky13mo ago
what is the name of it then dal and bll omg its better if i send it all
Pobiega
Pobiega13mo ago
Dal is just a piece of your code that is responsible for database work. That doesn't tell me anything at sll
hinky
hinky13mo ago
huh
Pobiega
Pobiega13mo ago
Is it ado.net? Ef core? Dapper?
hinky
hinky13mo ago
none of that? IDKKK
Pobiega
Pobiega13mo ago
Then find out
hinky
hinky13mo ago
we just click in add database inside visual studio and use the sql inside it
HimmDawg
HimmDawg13mo ago
Asking the other way around: How do you register new users? How are those saved in your database?
Pobiega
Pobiega13mo ago
You can't just "add an item to a database".
HimmDawg
HimmDawg13mo ago
You said registering is working
hinky
hinky13mo ago
via code
HimmDawg
HimmDawg13mo ago
Show code
hinky
hinky13mo ago
omg im confused now i cant rn im at the cafe ill show everything as soon as I can
Pobiega
Pobiega13mo ago
You will likely need to add some methods to your "Dal" so it can add new products Then call that method from your form
hinky
hinky13mo ago
we do that in bll
Pobiega
Pobiega13mo ago
Okay. Then do that?
hinky
hinky13mo ago
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
Pobiega
Pobiega13mo ago
I'm calling a strict no spoonfeeding on this thread.
hinky
hinky13mo ago
dal and bll are codes pre made that our teacher gave us and make us work with that
Pobiega
Pobiega13mo ago
I see. That would have been good to start with Since its critical to your issue
hinky
hinky13mo ago
i didnt know im so sorry
Pobiega
Pobiega13mo ago
Go get your code.
hinky
hinky13mo ago
i thought it was all this way
Pobiega
Pobiega13mo ago
We can't do anything until you do
hinky
hinky13mo ago
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
HimmDawg
HimmDawg13mo ago
You said you still have 2 weeks. So stay calm, grab your code when you can, and then we'll see
hinky
hinky13mo ago
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
HimmDawg
HimmDawg13mo ago
Did something prevent you?
hinky
hinky13mo ago
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
HimmDawg
HimmDawg13mo ago
Does your teacher know about it?
hinky
hinky13mo ago
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
hinky
hinky13mo ago
bruhhh 😭
hinky
hinky13mo ago
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
hinky
hinky13mo ago
BlazeBin - tntkyzaunxrw
A tool for sharing your source code with the world!
Pobiega
Pobiega13mo ago
omg your teacher doesnt follow fucking naming conventions
hinky
hinky13mo ago
what is that !!! what is this
Pobiega
Pobiega13mo ago
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
hinky
hinky13mo ago
grief getting even more confused
Pobiega
Pobiega13mo ago
how so you have a static method called insertProduto just call that in your button handler?
hinky
hinky13mo ago
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
Pobiega
Pobiega13mo ago
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
hinky
hinky13mo ago
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
Pobiega
Pobiega13mo ago
i mean, there is already an "insert product" method in your BLL so that doesnt need to be changed
hinky
hinky13mo ago
yes it inserts in the database but how do I make that work
Pobiega
Pobiega13mo ago
"make that work"?
hinky
hinky13mo ago
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
Pobiega
Pobiega13mo ago
Do you know how to read?
hinky
hinky13mo ago
yes
Pobiega
Pobiega13mo ago
static public int insertProduto(string nome, string tipo, string preço, bool ativo, byte[] imagem) how many arguments does that take?
hinky
hinky13mo ago
huh????????????????????
Pobiega
Pobiega13mo ago
look at the method signature I posted
hinky
hinky13mo ago
thats the thing in the bll
Pobiega
Pobiega13mo ago
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, btw
hinky
hinky13mo ago
what exactly do you mean by arguments
Pobiega
Pobiega13mo ago
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()
hinky
hinky13mo ago
its the same thing but one specifies the things?
Pobiega
Pobiega13mo ago
the things being...?
hinky
hinky13mo ago
the name etc of the product
Pobiega
Pobiega13mo ago
<:picard_facepalm:616692703685509130> hooooow
hinky
hinky13mo ago
if its a string or not
Pobiega
Pobiega13mo ago
are you doing winforms shit and dont know what a method parameter is
hinky
hinky13mo ago
THE TEACHER DOESNT TEACH!!!!!
Pobiega
Pobiega13mo ago
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 arguments
hinky
hinky13mo ago
hum
HimmDawg
HimmDawg13mo ago
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/methods
Methods - 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.
hinky
hinky13mo ago
byte[] imagem = imageToByteArray(pictureBox1.Image);
int x = BLL.produto.insertProduto(textBox1.Text, comboBox1.Text, textBox3.Text, checkBox1.Checked, imagem);
byte[] imagem = imageToByteArray(pictureBox1.Image);
int x = BLL.produto.insertProduto(textBox1.Text, comboBox1.Text, textBox3.Text, checkBox1.Checked, imagem);
Pobiega
Pobiega13mo ago
looks about right. I'd urge you to rename your controls thou textBox1 is a terrible name productNameTextBox is a better name.
hinky
hinky13mo ago
i think its better if I let this in this way it works
Accord
Accord13mo ago
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.