hello everyone welcome to my YouTube channel in the previous video we have completed home part of inventory management system project if you are not seen that video just go to the description and check out the link so in this video we are going to work on user part so let us start with that let me close this application and here we have to create a new jframe form so here click on new jframe form and here we are going to write manage user and then we have to click on finish finish it will create a new jframe for us then we have to close this one and then we are going to increase the size to 850 comma 600 and then we have to click okay so it will increase the form size and then we have to uh like uh go to the property of this one and we have to remove mean Max close button from here so we just need to click on this one and click on close after that we have to generate a events so this event event component component show so this event will be triggered whenever this page going to be open okay so after that we have to just close this one and get back to this design section and then we have to put a uh label over here at the center uh okay and here we have to write manage user and here we have to write manage user and then we have to go to the properties of this one and we have to select over here make it as bold 36 and then here we have to just click I so impact this one we need to select and we have to put it the center of the page after that here we need to place a table if you scroll little bit you can see in the swing controller there's a option of table you have to just click on it and drag and place it over here and uh just drag till the almost last line over till this point and after that we need to change the content so go to the table content and click on columns and uh and we first we let's remove the raw so just C remove this all the RWS and after that here we need to change this one for ID the First Column is for the ID this next column will be for name and after name the next will be for mobile number Mobile number and after that uh email and then we have to insert two more columns over here so the next will be for uh next will be for address and at last we have a status then we have to just close it after that you can see the labels name has been changed and let me decrease the size of this one little bit and after that here we need to put uh create the form so let me here right side uh we just need to place a label name so first so I'm going to put a label over here after that here we going to put a text field and let me rename this one as a name and uh one by one we are going to place the multiple uh labels and all so mobile number and after that here put a button uh sorry text field text [Music] field and one more label over here and this label is for email and uh so for this one we also need text field and after that we need one more label and here this will for address here just rename to the address and after that uh it will need text field so place it over here after add address the next field will be for status so just put and write here status and here we need uh like combo box as we need to show the two options one active or inactive after that here we need to place few buttons and let me check the screens forms size okay it's 850 600 correct and uh in this status column we just need to change the value so click on over here in the properties you can see the model option is there from this we can put all the values which is want to display in that particular uh combo box so here we have to write inactive or active and we have to click on okay and close this after that we have to just select all these fields and go to the properties and we are going to okay we are not getting options to change it so just select first label name and go to the properties and let's make it as a bold 12 okay and close this and after that we are going to select the text field and uh then we are going to properties of this one and then we are also going to select bold for uh 12 okay and close this after that we are going to remove the default text uh which it have and let me increase the size of this one here so let decrease a little bit let make it as a 338 and let's remove this one Ed text remove this one the same way we have to increase the size of this one also remove this text field value and and same way remove the text okay okay here we have missed one field that we also need here and that field will be for the password so here so uh let's uh let here change this one as a password and let's drag this one little bit down and then we are going to put a uh text field so just place it over here then going to remove the text from here and we're going to increase the size of this one and here we are going to go to the properties uh let's make it as bold or 12 okay and close this and then we have to put one more label over here so just let me scroll a little bit this one then we have to place it over here and this one will be for status and then let me scroll a bit uh okay drag and drop it and after that we have to also make it as bold 12 okay and close this after that here we need few buttons so let me place it one by one so here this is will the first button and this button will for save so just changes to save and then we need one more button and this will be for update wa put it over here then we need one more button that will for reset this form so reset and the last button which will be for uh close this form so I'm just writing a close and save this let me drag a little bit and make it at Center okay just increase the size of this one okay and just save this after that uh okay this is little bit up okay and then we have to just save this and we after that we have to change the layout to Absolute layout can see and save this now we have to put a label over here and then we are going to set a background image so I'm just going to and here you can see all page background PNG image then close it you can see after drag and drop in the perfectly on this Frame and double click on this label particular label and here you can see the label name is there so just remove those text and save this our form has been created and one more thing is there so we just need to make it as a bold 12 so select these buttons and let's make it as a bold 12 okay and just close this and save this okay and how form has been created now we have to go to the source of this form and then we have to go to the top of over here and then we have to uh make set Loc location location relative to and here we have to just pass the null so that it will open in the center of the page and here we have to create a variable in app user and PK so to store the PK we are going to use it and after that we have to go to the form component show which we have generated few minutes ago and here we have to write default table table model this one we need to import and we are going to import it from here and here we are going to access the table and we're going to set the values in it so that purpose we need this one and default table model and then we have to call the table which we have created in the UI so the table name is j table so we can also change the name so change variable name here just write table and here we can write here uh user table user click on okay and the same way we also need to change this one so txt name and here we have to just write txt mobile number and txt email and txt address so txt address and txt password so txt password click on okay and uh change the variable name and here combo box combo box uh status click on okay and save this and we also going to change the buttons name so BTN and save BTN update update and uh BTN reset and BTN close BTN close click on okay and save this now get back over to the source and here table user you can see automatically get changed after that we have to get the model and put semic colum let me scroll this one little bit and then as we are going to connect with the database and get the data so try and catch is required to writing those okay so here we have to just uh there's a chance that exception going to be generated so to catch and uh show to the user we are going to use this one G option pan. show message dialog null and here we just need to pass whatever the message or error we get after that in the tri block we have to create the connection so connection and we need to import the connection from uh SQL so go over here and import import java.sql Dost to import all the uh files all the files related to this one class okay and let's get back over here so connection will be from here and con equals to connection provider class which we have Creator created earlier provider this one from Dow Dot and it it having a St static method in it after that here the same way we have to create the statement and to execute the statement so con. create the statement and after that results set to store the results and st. execute our query this one and then we have to write here select star from app user where a user rule is equals to single codes and here we have to just write admin so all the users which having a rule is admin we are going to return over here and after that here we have to use while loop and rs. next to get fish all the values and here we have to write model and then we have to add the uh like add the raw in particular models so after that we have to write this like this and then we have to write here new object and object type will be like this and we are going to import it from okay and after that here we have to put the curly bracket and inside this one we have to pass the value so get string and in this way actually we are going to access the column value so rs. G is string and here we have to pass the first uh the column name so app user andore PK so primary key we need and after that we have to put column after parenthesis then we have to write here get a string and then we have to write name so Aris doget string and the next will be for mobile number number R.G string and here after mobile number the email email is there and rs. git string sorry get string here right so get string and then we have to pass address address and adds doget string sorry get string here and here we have to pass the status so let me show you the complete so app user for key PK primary key we need to pass after the name mobile number email address and Status so these are the fields which we want to show in our table here you can see and uh so just uh close this after that uh just save this and let's try to run this file only and if I run this you can see it's completely blank because in the current our database we have only super admin till now we don't have added any admin user so let me close it and let me okay from here we need to close it because we did not write the code to close the form and uh after that here one more thing is there so whenever page load right so uh it should be like save button should be enabled update button should be disabled because all the fields will be blank and in that case the save button means new item only going to be add so that's the reason here after this form we need to disable a button so BTN update button so do set enable and here we just need to pass the false and save this after that here this one we have to scroll up and here after the Constructor this Constructor uh below the man uh this one and here we have to create a private method so private buoen it should be a Bullen type and that will be for validate field fields and here we have to write string form and we also get want to know that what type of form we are validating so it could be add or it could be edit so in the both cases we want to uh do some different validations so let's say if it is edit in that case we don't want to uh validate the password field and if it is ADD then we want to validate all the fields so those purposes we have created this particular variable okay so here we have to write here if form type type do equals and equals to and it should be edit in that case and name okay txt txt name do get text so in this way we access the values and Dot equals to uh equals to if txt value is not equals to this U my means null or blank in that case we are going to return false okay so just in the same way we have to add for the other fields so I'm just going to copy paste this part of the code or this part of the code that will be also good so just remove this one paste it over here and then we have to change this one to uh mobile number so just change this one for mobile number and after mobile number the next will be for email address so I just paste it over here and txt email address after email address the next will for address it over here and txt address okay so these are the full fields we want to validate uh okay so name mobile number email address and uh email or address these are the F field we want to validate whenever edit form is going to be in use okay so just uh create a curly bracket inside that one and press enter and here we have to just return okay let me decrease the size of this one as we don't need it so here you can see the all the code at once okay after that here we have write we have to return false so this will going to be disable or enable the buttons on uh sorry it will show show the message as per this true and false after that if condition the next will be for else if else if okay so then we are going to copy paste this all same line of the codes uh till this parenthesis last parenthesis okay and paste it over inside this one parenthesis and uh one more column here we want to add is that will be for uh here to add uh change txt password field okay and here we need to change this one for add here we have to not add new just write new and then put curly bracket press enter and uh we need to go to the next line okay over here and then we have to just return false put semic column and in else condition we are going to uh return true okay and after that let's format this code and save this okay so currently we are not using it so that's why it's showing as alert uh valid valid Fields is never used okay after that we have to go to design and we have to double click on this save button to generate the event for that and inside this one we have to get all the fields values so here we have to write one by one so string name dxt name doget text string mobile number and here txt mobile number doget text string email txt email doget text after that the next will be for password and txt password doget text and uh after that uh next will be for address so string address txt uh sorry txt address do get text after that here for a string status so this one we are getting from combo box so here first we to change this one to string type and then we have to write txt do status okay so sorry combo box here so combo box status dog selected item we need to uh go with selected item after that here we need to write validate the fields so validate field we are going to call this one method which we have created earlier and in this one we have to pass the new and if uh like validations returns true in that case we need to display G option pan do show message dialogue and here we have to pass the null and here we need to show the message so here we have to write all fields are required so this ER message will be visible and in else condition we are going to write the code to insert the data so here we have to write here try catch block so try and catch and here we are expecting to catch the exception and uh and G option pan to display the message error message and here we have to just write e and ins inside Tri block here we have to write first to create the connection so connection con and equals to connection provider do gcon method and then we have to prepare the statement okay so prepared the statement PS it's the same as uh uh create a statement but in this one we are updating the values dynamically Okay so a prepared statement so just go with this one here just select this one and inside this one we have to just write the query so insert into app user and then we have to select one by one which columns values user Rule and then we have to pass the values and then here so first value for app user rule will be by default it sh to the admin okay after after that the next will be for name mobile number and email password and uh after password the next will be for address then we want to pass the status and here uh let me put a semic column to remove the error and then we have to put uh question mark over here till 1 2 3 4 5 6 six Time 1 2 2 3 4 5 6 so we are going to pass this values so just go to the next line of this code and here then we are going to set the values so PS do set string so set a string and here or with which position we want to send the value so first question mark from here we are going to set the value that will be name so here we have to write one and here we have to pass the name in the same way we are going to copy paste this one 1 2 3 4 5 and we're going to rename this one 2 3 4 5 and six and then one by one after name the next will be for mobile number and after mobile number the next will be for email after email the next will be for password after that address and then we have to pass the status status and then we have to execute this statement so ps. execute update and then we are going to show the G option pan. show message okay and the message will be here like uh user added successfully then we want to refresh the page so for that set visible and we're going to make it as false and the new visible will be the same page so manage user do set visible and here we're going to write a true so let's try this one uh so let me run this file directly from here and let me try here so here I'm going to write a test user uh let's say right here one and I'm going to enter the contact number 200 or one one let's write here and after that here I'm going to write here test user one at the rate test email.com and address I'm going to also write here test and the password I'm going to write 1 2 3 and the status I'm going to say as active and I'm going to click on this save button and here you can see the update button is not there right it is disabled state so let me click on Save user added successfully if I click on okay you can see the values here over here you can see all the user details here so you can see the ID you can see the name you can see the mobile number you can see the email address so all these informations you can see over here so let me close this one and until this point whatever we have coded it's work working fine as expected so now we have to right click on this table and then we have to go to the mouse click event so go to the mouse clicked event so whenever anyone click on particular raw of the table we need to get the data and we have to populate those data in this particular Fields so for that purpose we need to write the code now so here first we need to get the index so here we have to get the index and then we have to pass the table so table user dog selected our raw which raw we are then we have to get the table model so table model and we are going to import the table model from here uh let's get back over here T model and the model equals to and then table user dog model and then we have to first get the value so string ID and then after that model.kit value and then we have to pass the index from where we want to get the value and the second position which column uh you want so as a zero index our ID is going to be stored so we have to pass here zero index sorry zero column and we also need to convert this one is to a string because it is object type so it will convert to the string and then we're going to store in the ID after that app user PK which we have created and we have to just uh like a store this value so integer as that one is a integer type and currently we are accessing as a string type so we need to convert that so Java has provided par in so we can convert the string values into ins and after that we are going to store in app user this variable we have created in the starting video you can see this one okay and uh here we have to just assign that value inside this one and after that the same way string name and model model. git value this one and index and then s first first position and that uh need to get and then we have to just set this value so txt name do Set uh like text and we have to set the text and whatever the value we are going to get we are going to set in uh name field okay the same way we have to copy paste this one so this one will be for mobile number mobile number and index 2 here we needed and here txt mobile number just format this one okay and okay so here we also need to pass the mobile number and after mobile number the next field will be for uh email address so string email model. git value and here we have to pass the index and then we have to pass the third position of column and that contains our email address and then txt email. set text and and then you have to pass the email and after email the next will be for address so model doget values index fourth position uh do2 string and txt address do set address and here we have to pass the address okay after that the next will be for uh status status is equals to model doget values at index and uh from fifth column to string and then here we don't need to right assign to this one okay so we need to do little manipulations over here so if the status value is active if is equals uh sorry status. equals equals is active in that case we need to actually add like this and first we also want to remove the item so basically whenever you start the simplication you rightly see the active or inactive values right so that need to be changed as per whenever we click on status should be whatever the value is there first it need to be show let's say if any raw contains inactive so in the status first inactive should be visible then active should be visible so for that case we need to write here first we need to remove the items so txt status or sorry uh combo box sorry combo box box status dot remove all items first do this and then we have to check if status is active then we have have to add the value dynamically and then we have to add item item here and then first we have to write active and then just copy this one and paste it over here and here just change this to in active and here just copy these two lines and here just need to paste it to else condition and paste it over here and format this and here we need to swipe this one options and paste it over here let me format this one and save this let me run this one let me show you what I was trying to say So currently if I click on this one you can see this values has been changed okay so here one more thing we left to do and here we need to change the color of this one password as well as we also need to enable or disable this button so that need to be done because that is required and important so here txt password field. set editable and we also want to set this one as a editable as a false so that no one can put any text and then password do set background here so background it going to be import from this one uh color we need to import a background this things let get back over here okay so by default it s the color so just we want to set the colors dark gray so this one we need to pass and then we have to button save button we want to disable the save button now and we want to enable Okay so set enable false and BTN update do set enable true okay then save this now let me run this file and here you can see if I click on this one it will go going to populate all the information let me try to add one more user here let user to and here I'm going to put the contact number just randomly okay just test user to at theate test email.com T address and let's write a 1 2 3 and here I'm going to change to inactive I'm going to click on Save user added successfully if I click on this one you can see reset so currently you can see all the fields is blank if I click on this one you can see all the values has been set to particular respective fields and here you can the status is also active first is showing as active here you can see after that it's showing inactive but in the ID three you can see the in status is inactive if I click on this one you can see it first show The inactive user uh status and then it's showing the active because let's say some user have updated when they want to update the name and he by mistake updated the status like inactive or change that so it will cause issue so that purpose we have changing this values okay and after that we have to just close this one and now we have to go to the uh update button code okay so double click on update button and here the most of the things will be same other than updating the stuff so I'm going to uh this uh button save button I'm going to copy exactly same code it from here because the values we are going to get it will be almost same so I'm going to copy paste over here and after that let me format this one and save this and first we need to remove the password field as it is not required and here we just need to change this one to edit as this will going to be called the edate and after that we also need to update this one query so I'm going to remove this complete query which we have written earlier let me scroll this one and here we have to write update app user set name question mark and mobile number question mark email the symbol address and then status where app user underscore PK and then we have to pass this one and put semic column in the same way can see the complete query after that here one by one we have to change the value so first we need to pass the name then mobile number email and then we want to pass the address so just change this one address after address the next will be for status and at last we want to pass the ad app user PK which we have set it from here so this value going to pick and this value we are going to pass it over here and here we have to just change this one to set int as this is int so we have to set the int and here we have to change the message so updated successfully and uh here uh other things will be almost same yeah it will be same actually so after that let me also few line of the code is left so just write it and then we going to do the final testing and here we have to set visible false so this will be for resetting the form so manage sorry yeah manage user do set visible and here we have to write true and then go to design in the close also do set visible and Mark as false save this now we need to connect this manage user with the homepage so just go to the homepage I'm going to design section and I'm going to double click on this user can see event has been generated then here we have to write new manage user. set visible and here we have to just write uh true save this now going to restart the application from here and if I click on user if form has been open currently you can see so here you can see the form and uh so first we're going to tightly save it so all the fields are required and you can see the ER message is there if I write most of the values so let's write as test user three and here I'm going to enter the contact number 00 0 0 0 let's write like this test user 3 atate test email.com here I'm also going to write test and if I try to save this it will still throw the same mirror here we have to enter the password to save it and after that if you click on save it will going to be add user added successfully after that let's click on this one and let's try to update this one okay so let me change this one as a four and here I'm going to change it to one here I'm also going to change this for four and test four we are going to return over here let's change this inactive click on update user updated successfully if I click on okay you can see here the values over here so let me decrease the size of this one you can see test user 4 is there mobile number 001 is there test user 4 address test user 4 inactive and if I uh you can see update is working fine as expected now we are going to try the reset you can see it's also working let's write something try to reset it you can see it gets removed if I click on close it will close the form okay so everything is working fine and this is all related to manage user or user part of Inventory management system project I hope you guys like this video so please hit like And subscribe my channel