7. Cafe Management System in java -View,Edit & Delete Product (JFrame, Mysql Database, Netbeans IDE)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
everyone welcome to my youtube channel in the previous video i just show you this new product part of our cafe management system project if you are not seen that video just go to the description and check out the link in this video i am going to create a new jframe for this view you read and delete product part so let us start with that let me exit this application and let me create a new jframe for that so right click on this new jframe form and here we have to write the name so view edit and after that we have to write delete product and after that we have to click on finish it will create a jframe you can see page has been created first thing is we have to make it as 1366 comma 768 screen size of that we have to save it now we have to insert a label first here and let's rename this view edit and delete product and after that we have to increase the size like we have to make it as bold 14 hold 14 okay and we also need to insert icon so let's select move here images and here we have to select view edit so we have a image with this name so let's check it out yeah so we have to select this name view edit read product dot png image and let's save this now that we have to insert a button to close this form so let's go to the properties and let's insert image in that first images and let's select that uh close dot png image after that we have to close this and let's read the sticks and remove this and let's decrease this to 30 and after that we have to place it the corner of this page and save this after doing this we have to move little bit down of this page okay let's check it out the screen size 136 768 it should 768 so it will cover my complete screen after that uh like we have to move little bit up below this we have to insert here a label and we have to rename this and here we have to write id so first level which we are going to display for the id after that the next level which we are going to display for name after the name next level which we are going to display for like a category so here we have to write category after category the next level which we are going to display that is for price so price okay after that uh like we have to insert one more label here actually or to display the id so let's place here to dash now let's write here zero so it could be visible after that uh we have to insert our fields according to that let's say first okay it's generated the event actually we clicked on that so not a problem we are going to use that event uh let's increase to 300 up that for next category we are using combo box so we have to select the combo box and we have to place it over here let's increase this to 300 after that we have to like uh need a text field text field and it should be 300 after that we have to insert buttons over here so let's place button one by one and uh let's say place last button so this button is for the clear so we are going to right here clear and we are going to insert the icon for this so let's uh select the images and after that we have to click on clear.png close this after that we have to write for delete so delete and after that we have to go to the properties and we have to select the image for this one also and let's select the delete dot png image okay close this after that we have to edit this text and we have to write here update and let's insert a image in this one also uh let's select uh images and here we have to click on move to the save this one save dot png okay close this you can see form has been created let me edit this text remove this by default text and you also need to remove this category items so let's go over here mod here create this all and click ok close this save this after that we have to select this all and we have to increase this to make it as bold 14 actually hold 14 okay just close this and move little bit left actually of this one let's increase the size of this one also what okay uh i think it's move little bit right yeah okay so let's increase by this side and decrease by this side it will fix it now after doing that we have to insert a table so let's uh insert a table here so let's place it over here and let's save this and let's minimize this one so that you can see at once complete form and after that uh i think it should be like it should be below this okay after that uh let's set the table content actually so we need here four columns so let's id here we have to write id after that the next one is for name and after that uh the next one is for category 3 and the last one we have here is price after that uh we have to close this and okay one more thing we forget here like we have to remove all the raw so just uh click on close after that we have to go to the properties of this and we are making it as bold 12 okay close this you can see our form has been created our gui is almost completed now let's change the layout to absolute layout actually after that uh let's uh insert a label here and let's go to the properties and after that we have to insert a image so this one is icon and we have to click on images and here we have to select for full page background on png image so this one click on ok close this let's place it completely on this page and let's move little bit right double click on this page you can see the label name is visible so delete that and save this page okay so you can see our gui is completed you can see the complete uh okay one more thing we forget here we have to change the like this one color to white actually so right click on this by selecting all this and after that we have to click on over here and we have to click on this and click on ok close this you can see color has been changed after that we have to save this so after doing these things uh first we have to like uh create few methods in product tau actually like whenever we click on update it should call that method whenever we delete it will call that meter and like we want to load the category we want to display the tables we everything we need to call methods so for category we already have a method so leave that for let's start with update and other stuff okay so let's move to the dow and in that we have a product.java class and here we have to create like a method which should return add a list so static array list this one so it should import from java util you can see it automatically imported that after that here we have to write actually product which we because we are going to import okay to automatically have that after that we have to write a get all records and after that we have to like uh it will show either because we did not return anything till now so we are going to create a list add a list with the like product type and in that we are going to set the values by extracting it from database so let list right here add a list equals a new array add a list and after that we have to like return right so let's write a return adding list you can see it has been removed but right now we did not connected like we did not getting it from database it should return null right so let's write code for that so i'm just writing here try catch block first catch block first and here we have to write exception e and here we have to write g option pan let me move a little bit down g option pan pan or this one dot show message dialog null and here we have to write e okay so after try in the try block we have to like call the result set okay so result set actually we have to import so it's all that option is not visible so we have to import java dot sql dot asterisk and let's get back over here result set you can see visible after that we have to write rs and here we have to call the dp operation db operation method and that we have a get data and in this we have to pass the queries so here we have to write select star from product and here we have to write while rs dot next and here we have to like uh call right here we have to create the object of product table product name new product and this one and after that we have to set the product details so product dot set id and here we have to write rs.get and so first we are going to get the id so here i'm just writing the id the name of data right so product dot set and after that we have to set the name so rs dot get a string and we have to get it like the name so i'm just writing a name product dot set category rs dot get category yeah okay so it should be sorry it should be a string and in between we have to write here category category after that at last i think we have to add product dot set price and here we have to write rs.kit a string string and here we have to write price and after that you can see we uh like we have to add like in the added list this product we have to pass that so here we have to write adding add a list dot add and we have to write here product you can see automatically taken that product so in this way we are going to add like uh like adding this in this add a list we are going to add the product object of that product so let's start so after that we have to create few more but right over here so let's create that like uh it will move to the view date so this that method which we are going to use to display the details related to product in this table after that we are going to write the code for update part after that we are going to write the code for delete so let let's start over here not over here actually uh we have to move to the product tao actually so here we are going to create public a static we don't need to return anything so we have to write here wide update update sorry update and here uh we are going to take a product type of okay input and in this uh we have to write create a query actually string query and here we have to write update product set name equals to single double plus plus product dot get name actually after that uh let's place the semi column at last after that let's copy this part and uh let's place the com comma here over here one and two after that let's check uh change that this one so first we have to change it to the category category category after that we have to check uh change this git category actually and let's move a little bit right also so after that category we have to write a price and we also need to change to get price and after that we have to write here after this we have to write like a real id is equals to single again same less plus and here we have to write here product product dot get id this one so let me show you the complete this one so you can see we have let me show you update product set name a product dot get name category dot uh like product dot get category price product dot get price where id product dot get id after that we have to pass this query to db operation set uh like method we have dot set data and this you can see we pass the query and we also need to pass the message so product updated success fully and save this let's copy this line of the code and let's play okay we don't need to copy completely actually so leave it static white and here we are going to write it for delete and let's uh right here we are going to take the id only to delete its right so i'm just writing a string id and here we have to write the query actually so string query single after that we have to write here uh delete from and product where id is equals single double plus plus and here we have to write id so after that we have to like again call the db operations this one dot set data and we pass the query and we have to pass the message to intervals we have to pass the product deleted success success fully and save this you can see we created here theme three methods uh let's close this and let's get back over here in the view read and delete order this one let's move to the design section and after it's uh first thing is we have to hide these two buttons update and delete not hide actually we have to disable this two buttons so let's move here and in in this place we have to write okay we also need to change like a variable name so let's change this one to btn and here we are going to write btn so update and after oh okay it should be actually uh txt name okay and uh let's uh we have only one combo box i'm going to leave this now as it is let's write here txt price okay let's change the variable name so btn dot update actually and btn btn delete okay let's uh change the variables for this one btn clear let's click on ok and one more variable we need to change it so lbl label and here i'm going to write id and we have to click on ok because we are going to set the id right so we change the name according for that actually so one more thing we forget over here like we did not remove mean max and close button from this form so open this navigator and we have to click on this one j frame actually after that we have to click on right click on that actually right click on this go to the properties and we have to click on this and recorded and we have to close this and save this page so it will remove mean max close button after that we here we have write btn update this one dot set enable and here we have to write false and after that we have to write btn delete actually and this one dot set enable and here we also need to write false after this like we have to validate the buttons so right according to text so in that case we have to create a method over here actually public void validate and here we have right field and after that here we have to like create a string string name txt name dot get text actually and after that we have to write here string and here we have to write price txt price dot get text this one after that we have to write a string category and here we are getting it value from combo box so i'm just going to write a string type j combo box dot get selected actually selected item this one and after that we have to write here if name dot equals is not equals actually or to this and and we are checking that condition and like price dot equals not equals and uh and category this one category is not equals to actually not equals to null in that case we are going to button update dot set enable actually and we are going to make it as true and an else condition we are going to make it as button update dot let me move a little bit like up set enable and we are making it as false okay let's save this after this we have we have to call this method so let's open this and let's generate event for this okay so this event should be not there actually so let's remove this event first because we white if uh we generated it okay so it should be event key released and it should be like event key released and we're going to call that method actually validate fields and here we are also going to call that validate fields method let's save this okay uh it get in like okay so after that like we have to write the code to like whenever we click on update it shouldn't call that uh like method which one method actually let's open this so it should call this update method and we are going to pass a product object so let's get back over here and let's generate event for this update button so you can see let's create a object first product product and here we are going to write new product actually and after that we have to go right like we have to get the very like id right so it should be id it should be inch type so we have to convert like uh text into integer type so integer dot parse and and here we have to pass the integers to lbl level id the variable we have dot get text actually so after that like uh we have to set here product dot set id so i'm just going to write here id you can see after the same we are going to set for others so set name and here we have to write dxt name dot get text actually and after that product dot set category actually and in this we are going to write a txt not dxj actually uh we have to like get it from combo box string j combo box one dot get selected item this one after that we have to write a product dot set price this one ext price dot get text this one after that we have to call that product uh like uh tau so we have to import it manually actually so here we have to write import import and here we have to actually write import dow dot product directly and let's uh move again back over here so product down product dao dot update and in this we have passed this object okay so after that we have to make a state visible hide this page and write here false and we have to make it as visible this page so view edit update this one set visible and here we have to write here true and you can see update part of this button is done so but uh like uh till now we did not uh loaded any reals in this after that we also did not generated the click event also so let's do one by one actually so let's uh like now we are going to write the code for this like we load this page right not load this page actually we are just adding the details for this table so let's uh let's generate an event for that actually so click on this and we have to click on jframe form event and we have to move to the component show you can see here you can see form component show event so in this like we have to import few things so default table model and uh okay so yeah default table model it should import you can see and it should import it from here import java x swing table default model and after that we have to write here dtm equals and here we have to write default actually default default model again and here we have to write j table one dot get model this one and after we have to create the area list actually add a list and this one and that should be a product type actually so product and here list equals to product dow dot get all products which we are going to call it and after that to extract the value from that we have to call the iterator so it will not import it uh yeah able to import it so let me show you from where we imported that java util iterator okay after that it should also a product type actually product let's write here idea iterator and list dot like here we have to write it this one and by iterator dot and here we have to write has next in that case it will uh the loop will work and iterative dot has next always return true false right so just check it out once yeah it's a boolean type so it will return true false okay so let's uh write here product and here we have to write our product object equals iterator dot next actually and let's save this and let's write here dtm dot add raw this one and here we have to write new object actually and remove this and we have to start the bracket and here we have to write product obj this one dot get id the same way we are going to import for others so get name name product obj dot like uh with the last afternoon we need for the category get category actually and at last product obj dot get price the last one so let me show you the complete line actually you can see this one after that let's move to the next line actually so here we have to write here okay it should be the complete line actually so in this way we are going to just like load the uh table details after that like whenever any mouse like uh clicked on a raw it should like uh set that value in this field so let's write code for that so first we need to generate event so mouse click even we have to generate this one mouse click the event and in this this event first we are going to get the index so in index j table one dot get selected raw actually and after here we have to write a table model this one table model and the important table model from you can see java x swing table table model let's get back over here and after that we have to write here model equals and j table 1 dot get model and after we have to like get the values so string id model dot get values and at index we have to leave it because we have a variable and in this position we have to write zero because at zero index we have a like ids of every right and it should return to be a string type that's why it's showing the error so the value of this we are going to set in the label id and then that check text and here i'm going to write id actually after that the next variable which we are going to set it so string and here we are going to write name pulse model dot git and here we have to write git values this one index and here this should be one dot to string type after we have to write it txt name dot set text and here we have to write name and after that the next is for the category actually so string category equals model model dot get values and it should be index and here we have to write here 2 dot 2 string and after t x okay we have to like uh we don't need to set it for now right now we will add it later actually uh let's write it for another variable let's go let's copy this line of the code let's paste it over here let's change to category to price actually let's change to this one to three and here we are going to set the for txt price dot set text and here i'm just going to write your price actually save this now now we have to like uh we have to enable two buttons actually whenever it click it should fill all these details right so it should be like button should be enabled so btn uh like uh we have to call the update button dot set enable actually and here we have to write true and after btn and we have to write delete actually dot set enable and here we have tried true let's move a little bit up actually after that the first thing is like whenever anyone click on any raw right so the categories will be set and when you click on another row it should like the category details should be changed right so in that case we have to like remove all the details from combo box so here dot remove all items you can see this one option we have to select that and after we have to write here add a list actually and we have to extract the values for the category okay this this one and it will import automatically the category category list equals to category tau actually we have to import it will import automatically get all records after that we are going to call the iterator iterator this one and that should be a category type it should be category type and here i'm going to write here category iterator equals category list actually list dot iterator and here why uh categorypitrator dot hash next in that case we have to loop value work and here we have to write actually category type of object we have to create actually so it should category and category equals okay it should be category object actually obj equals and here we have to write category iterator dot next this one and in this like we are going to match it like our the first like when we select any raw it should be some value here so we are going to add that value first after that we are going to add for others so let's write here first thing over here first j combo combobox dot add item this one and here we have to pass the category which variable which created over here so let's paste it over here so for the first item whatever the category actually have after we are going to match like the same category should not repeat so in that case we are going to ignore that category so i'm just writing a category obj dot git and it should not match with the category actually this category should not match the value of this one okay so in that case uh like we have to call the g combo box g combo box dot add item this one and here we have to pass the category obj dot get name and save this so in this way we are going to like whenever we click on any draw of the table we are going to display in the particular fields and here we are going to set the ids right so after this the next thing which we are going to do is like whenever we click on that delete button so we are going to write the code for that so just click on this delete button after that here we have to like hint okay first we have to create a variable here a string id so label dot our get text actually and after that end a equals to g option pan dot show confirm dialog this one and here first we have to pass the null and put the semi column at last and let's remove this and here we have to write here do you want to delete this product uh this pop-up message which you will be visible to the user select and here we have to set the option so here we have to write g option dot yes no okay it should be yes or no option this one select this and let me show you the complete line after that we have to check like whether the user selected yes or no so we have to check if he is equal equals to zero it means that user selected that yes so in that case we need to delete it right so we are going to call the product dow product dow and in that we are going to call the delete and we are passing the id and then to save the very well we are going to hide this page false and we are going to show the new page so let me write here view dot set visible and here i'm going to write here true okay so after this like we have to write the code for the killer so let me move a little bit up let me copy this line of these two lines of the code actually okay this two live on the code and paste it over here and let's format this so it will automatically take it off all the spaces we need to like enter after that one more thing we forget for this button so double click on this and here we just need to write set visible and here we have to write true sorry false we have to write here let's save this so we also need to connect this page with home page so let's move to the home page and design section let's move here and we have to double click on this view we delete product part and here we have to write new view this one dot set visible and here we have to write true actually so let's run this and let's check check it out it's working fine or we are getting any issue and let's run this let's click on view delete and uh product actually so we have only one product you can see that visible over here let's click on this you can see it's working fine actually you can see it's soup so the first option which we are seeing over here is so let's uh make it as 2000 actually let's try to upgrade this update products product updated successfully means that it will work you can see it's working let's add a new product here in d section so here let's add a black d let's make it as 20 and let's save this so product added successfully so here i'm going to move over here let's uh make it as a let's write here white tea actually and let's make it as soup and let's make it at 200 and let's try to update this product updated successfully so you can see it's working fine you can see uh let's check it out for clear you can see it is also working fine so let's check it out for like delete is working or not so just click on delete do you want to delete this product so let's click on yes you can see product deleted successfully message click on ok you can see that product has been removed so you can see if you like view edit and delete product part is working fine so this is all about this page i hope you guys like this video so please hit like and subscribe my channel thank you
Info
Channel: BTech Days
Views: 1,286
Rating: undefined out of 5
Keywords: java, jframe, swing, complete project, mysql, btechdays, final year project, java project, quick overview, netbeans, cafe management system introduction, signup in java, crud operation in java, projects, java projects, login in jframe, login in swing, dao porjects, create table in mysql, forgot password in java, management System, java (programming language), database connectivity in jframe, mysql database, home page, swing project, manage category, billing management system
Id: z9O0ozu-PfI
Channel Id: undefined
Length: 39min 51sec (2391 seconds)
Published: Thu Jul 08 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.