C
C#β€’2y ago
.ᐟ

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