• Temir yo‘l kassasida, chipta sotish va bo‘sh o‘rinlar hisobi” dasturiy ta’minotini tuzish va amalda sinash.
  • Mavzu: Temir yo‘l kassasida, chipta sotish va bo‘sh o‘rinlar hisobi




    Download 1,93 Mb.
    bet12/13
    Sana06.02.2024
    Hajmi1,93 Mb.
    #151982
    1   ...   5   6   7   8   9   10   11   12   13
    Bog'liq
    Temir yo‘l kassasida,chipta sotish va bo‘sh o‘rinlar hisobi

    DriverManager.getConnection metodi ma’lumotlar bazasi ulanishini o‘rnatadi. Ushbu metod ma’lumotlar bazasi URL manzilini talab qiladi, bu sizning DBMSingizga qarab turlicha bo‘ladi. Quyida maʼlumotlar bazasi URL manzillarining baʼzi misollari keltirilgan:

    1. MySQL: jdbc:mysql://localhost:3306/, bu erda localhost ma’lumotlar bazasini joylashtiradigan server nomi va 3306 port raqami

    2. Java DB: jdbc:derby:testdb;create=true, bu erda testdb ulanish uchun ma’lumotlar bazasi nomi va create=true DBMSga ma’lumotlar bazasini yaratishni buyuradi.



      1. Temir yo‘l kassasida, chipta sotish va bo‘sh o‘rinlar hisobi” dasturiy ta’minotini tuzish va amalda sinash.

    Bu dasturimizni tuzishda java swing shuningdek MySQl tillaridan foydalaniladi.
    Kerakli kutubxonalarni import qilib olamiz.
    import java.awt.Desktop;
    import java.sql.*;
    import java.net.*;

    import javax.swing.JOptionPane;


    import javax.swing.table.DefaultTableModel;
    public class RailwayReservation extends javax.swing.JFrame {
    /**
    * Yangi birinchi oynani yaratish
    */
    public RailwayReservation() {
    initComponents();
    }
    * Ushbu metod oynani ishga tushirish uchun konstruktor ichidan chaqiriladi.
    * Ogohlantirish: Kodni ozgartirmang. Metod ichidagilar doim
    * Oyna muharriri tomonidan qayta tiklanadi.
    */
    JFrame - bu ekranda oynani ko‘rsatadigan Swingning yuqori darajali konteyneridir. Ramka - menyu paneli, panellar, teglar, matn maydonlari, tugmalar va boshqalar kabi boshqa komponentlar tayanadigan asosiy oyna. Deyarli har bir Swing ilovasi JFrame oynasidan boshlanadi. Quyida shular yaratilgan.

    private void initComponents() {


    NewAccountFrame = new javax.swing.JFrame();


    NewAccountMainPanel = new javax.swing.JPanel();
    SignupLBL1 = new javax.swing.JLabel();
    SignupLBL_PASSWORD1 = new javax.swing.JLabel();
    SignupLBL_PASSWORD2 = new javax.swing.JLabel();
    SignUpTF_Name = new javax.swing.JTextField();
    SignupPF_PASSWORD1 = new javax.swing.JPasswordField();
    SignupPF_PASSWORD2 = new javax.swing.JPasswordField();
    CREATESignupBTN = new javax.swing.JButton();
    NewAccountHeadingLBL = new javax.swing.JLabel();
    RailwayFrame = new javax.swing.JFrame();
    RainwayMainPanel = new javax.swing.JPanel();
    TitleLBL = new javax.swing.JLabel();
    IRCRCBTN = new javax.swing.JButton();
    TrainListBTN = new javax.swing.JButton();
    LogoutBTN = new javax.swing.JButton();
    AboutBTN = new javax.swing.JButton();
    ExitBTN = new javax.swing.JButton();
    ReservationBTN = new javax.swing.JButton();
    AboutFrame = new javax.swing.JFrame();
    AboutMainPanel = new javax.swing.JPanel();
    AboutLBL = new javax.swing.JLabel();
    TrainImgLBL = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    ReservationFrame = new javax.swing.JFrame();
    ReservationMainPanel = new javax.swing.JPanel();
    ReservationHeadingLBL = new javax.swing.JLabel();
    OriginLBL = new javax.swing.JLabel();
    DestinationLBL = new javax.swing.JLabel();
    OriginCB = new javax.swing.JComboBox<>();
    DestinationCB = new javax.swing.JComboBox<>();
    ReservationSearchBTN = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    ReservationTBL = new javax.swing.JTable();
    TrainlistFrame = new javax.swing.JFrame();
    TrainlistMainPanel = new javax.swing.JPanel();
    TrainlistHeadingLBL = new javax.swing.JLabel();
    jScrollPane2 = new javax.swing.JScrollPane();
    TrainlistTBL = new javax.swing.JTable();
    IRCTCFrame = new javax.swing.JFrame();
    IRCTCMainPanel = new javax.swing.JPanel();
    IRCTCHeadingPanel = new javax.swing.JPanel();
    TRCTCHeadingLBL = new javax.swing.JLabel();
    IRCTCLBL = new javax.swing.JLabel();
    MaharajaExpressLBL = new javax.swing.JLabel();
    ECateringLBL = new javax.swing.JLabel();
    IRCTCimgLBL = new javax.swing.JLabel();
    jLabel9 = new javax.swing.JLabel();
    jLabel11 = new javax.swing.JLabel();
    EditTrainFrame = new javax.swing.JFrame();
    EditTrainMainPanel = new javax.swing.JPanel();
    EditTrainHeadingLBL = new javax.swing.JLabel();
    MenuButtonLBL = new javax.swing.JLabel();
    AddRemStationPanel = new javax.swing.JPanel();
    AddRemStationHeadingLBL = new javax.swing.JLabel();
    AddStationLBL = new javax.swing.JLabel();
    AddStationTF = new javax.swing.JTextField();
    RemoveStationLBL = new javax.swing.JLabel();
    RemoveStationTF = new javax.swing.JTextField();
    AddStationBTN = new javax.swing.JButton();
    RemoveStationBTN = new javax.swing.JButton();
    NoteLBL = new javax.swing.JLabel();
    DeleteTrainPanel = new javax.swing.JPanel();
    DeleteTrainHeadingLBL = new javax.swing.JLabel();
    DeleteBTN = new javax.swing.JButton();
    DeleteTrainNoCB = new javax.swing.JCheckBox();
    DeleteTrainNameCB = new javax.swing.JCheckBox();
    DeleteStartingPointCB = new javax.swing.JCheckBox();
    DeleteDestinationCB = new javax.swing.JCheckBox();
    DeleteCodeCB = new javax.swing.JCheckBox();
    jSeparator1 = new javax.swing.JSeparator();
    DeleteTrainNoTF = new javax.swing.JTextField();
    DeleteTrainNameTF = new javax.swing.JTextField();
    DeleteStartingPointTF = new javax.swing.JTextField();
    DeleteDestinationTF = new javax.swing.JTextField();
    DeleteCodeTF = new javax.swing.JTextField();
    jLabel21 = new javax.swing.JLabel();
    UpdateTrainPanel = new javax.swing.JPanel();
    UpdateBTN = new javax.swing.JButton();
    UpdateTrainHeadingLBL = new javax.swing.JLabel();
    UpdateLBL1 = new javax.swing.JLabel();
    UpdateTrainNoTF = new javax.swing.JTextField();
    UpdateTrainNameTF = new javax.swing.JTextField();
    jLabel15 = new javax.swing.JLabel();
    UpdateShowBTN = new javax.swing.JButton();
    jLabel16 = new javax.swing.JLabel();
    jLabel17 = new javax.swing.JLabel();
    jLabel18 = new javax.swing.JLabel();
    jLabel19 = new javax.swing.JLabel();
    jLabel20 = new javax.swing.JLabel();
    UpdateStartingPointTF = new javax.swing.JTextField();
    UpdateDTimeTF = new javax.swing.JTextField();
    UpdateDestinationTF = new javax.swing.JTextField();
    UpdateATimeTF = new javax.swing.JTextField();
    UpdateSeatsTF = new javax.swing.JTextField();
    AddTrainPanel = new javax.swing.JPanel();
    AddTrainHeadingLBL = new javax.swing.JLabel();
    AddLBL = new javax.swing.JLabel();
    AddTrainNameTF = new javax.swing.JTextField();
    AddStartTF = new javax.swing.JTextField();
    AddDTimeTF = new javax.swing.JTextField();
    AddDestinationTF = new javax.swing.JTextField();
    AddATimeTF = new javax.swing.JTextField();
    AddSeatsTF = new javax.swing.JTextField();
    jLabel21A = new javax.swing.JLabel();
    jLabel22A = new javax.swing.JLabel();
    jLabel23A = new javax.swing.JLabel();
    jLabel24A = new javax.swing.JLabel();
    jLabel25A = new javax.swing.JLabel();
    jLabel26A = new javax.swing.JLabel();
    AddTrainNoTF = new javax.swing.JTextField();
    AddBTN = new javax.swing.JButton();
    EditTrainNavPanel = new javax.swing.JPanel();
    BackButtonLBL = new javax.swing.JLabel();
    AddTrainsLBL = new javax.swing.JLabel();
    UpdateTrainsLBL = new javax.swing.JLabel();
    DeleteTrainsLBL = new javax.swing.JLabel();
    AddRemStationLBL = new javax.swing.JLabel();
    TrainListLBL = new javax.swing.JLabel();
    WelcomeLBL = new javax.swing.JLabel();
    WelcomeImgLBL = new javax.swing.JLabel();
    TicketWindowFrame = new javax.swing.JFrame();
    TicketWindowMainPanel = new javax.swing.JPanel();
    TITrainNoLBL = new javax.swing.JLabel();
    TIHeadingLBL = new javax.swing.JLabel();
    jLabel1 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    TITrainNameTF = new javax.swing.JTextField();
    TIDestinationTF = new javax.swing.JTextField();
    TIStartingPointTF = new javax.swing.JTextField();
    TIArrivalTimeTF = new javax.swing.JTextField();
    TITrainNoTF = new javax.swing.JTextField();
    TIDepartureTimeTF = new javax.swing.JTextField();
    TINoofSeatsTF = new javax.swing.JTextField();
    TISeatsInputTF = new javax.swing.JTextField();
    BookTrainBTN = new javax.swing.JButton();
    DateCB = new javax.swing.JComboBox<>();
    MonthCB = new javax.swing.JComboBox<>();
    YearCB = new javax.swing.JComboBox<>();
    jSeparator2 = new javax.swing.JSeparator();
    Ticket = new javax.swing.JFrame();
    TicketMainPanel = new javax.swing.JPanel();
    TTrainNoLBL = new javax.swing.JLabel();
    TTrainNameLBL = new javax.swing.JLabel();
    TPlaceTimeLBL = new javax.swing.JLabel();
    TDateLBL1 = new javax.swing.JLabel();
    TDateLBL = new javax.swing.JLabel();
    TDestinationLBL = new javax.swing.JLabel();
    TSeatsLBL = new javax.swing.JLabel();
    TCostLBL = new javax.swing.JLabel();
    TicketCloseLBL = new javax.swing.JLabel();
    TicketBackground = new javax.swing.JLabel();
    buttonGroup1 = new javax.swing.ButtonGroup();
    LoginMainPanel = new javax.swing.JPanel();
    LoginInfoPanel = new javax.swing.JPanel();
    Title1LBL = new javax.swing.JLabel();
    Title2LBL = new javax.swing.JLabel();
    InfoLBL = new javax.swing.JLabel();
    ImageLBL = new javax.swing.JLabel();
    LoginSignupPanel = new javax.swing.JPanel();
    NameLBL = new javax.swing.JLabel();
    UserIDTF = new javax.swing.JTextField();
    PasswordLBL = new javax.swing.JLabel();
    PasswordPF = new javax.swing.JPasswordField();
    LoginBTN = new javax.swing.JButton();
    CreateNewAccountBTN = new javax.swing.JButton();
    LoginSignuoLBL = new javax.swing.JLabel();
    AdminLoginButtonLBL = new javax.swing.JLabel();
    BachgroundLBL = new javax.swing.JLabel();
    Akkount yaratish, Login oynasidagi labellarga malumotlarni kiritib, shriftlarini kiritib chiqamiz. Natija dastur kodi pastida
    NewAccountFrame.setTitle("Yangi akkount yaratish");
    NewAccountFrame.setFocusable(false);
    NewAccountFrame.setMinimumSize(new java.awt.Dimension(640, 480));
    NewAccountFrame.setResizable(false);
    NewAccountMainPanel.setBackground(new java.awt.Color(255, 255, 255));
    NewAccountMainPanel.setMinimumSize(new java.awt.Dimension(500, 300));
    SignupLBL1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    SignupLBL1.setText("Ismingizni kiriting :");
    SignupLBL_PASSWORD1.setFont(new java.awt.Font("Tahoma", 1, 12)); //
    SignupLBL_PASSWORD1.setText("Kirish kodi :");
    SignupLBL_PASSWORD2.setFont(new java.awt.Font("Tahoma", 1, 12)); //
    SignupLBL_PASSWORD2.setText("Kirish kodini tasdiqlang :");
    SignupPF_PASSWORD2.setNextFocusableComponent(SignupPF_PASSWORD2);
    CREATESignupBTN.setBackground(new java.awt.Color(69, 104, 220));
    CREATESignupBTN.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
    CREATESignupBTN.setForeground(new java.awt.Color(255, 255, 255));
    CREATESignupBTN.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/account.png"))); //
    CREATESignupBTN.setText("Akkount yaratish");
    CREATESignupBTN.setIconTextGap(6);
    CREATESignupBTN.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    CREATESignupBTNActionPerformed(evt);
    }
    });
    NewAccountHeadingLBL.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    NewAccountHeadingLBL.setForeground(new java.awt.Color(255, 255, 255));
    NewAccountHeadingLBL.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    NewAccountHeadingLBL.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Background.jpg"))); // NOI18N
    NewAccountHeadingLBL.setText("Yangi akkount yaratish");
    NewAccountHeadingLBL.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

    javax.swing.GroupLayout NewAccountMainPanelLayout = new javax.swing.GroupLayout(NewAccountMainPanel);


    NewAccountMainPanel.setLayout(NewAccountMainPanelLayout);
    NewAccountMainPanelLayout.setHorizontalGroup(
    NewAccountMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(NewAccountHeadingLBL, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addGroup(NewAccountMainPanelLayout.createSequentialGroup()
    .addGroup(NewAccountMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(NewAccountMainPanelLayout.createSequentialGroup()
    .addGap(120, 120, 120)
    .addGroup(NewAccountMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(NewAccountMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
    .addGroup(NewAccountMainPanelLayout.createSequentialGroup()
    .addComponent(SignupLBL1)
    .addGap(52, 52, 52))
    .addGroup(NewAccountMainPanelLayout.createSequentialGroup()
    .addComponent(SignupLBL_PASSWORD1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    .addGap(41, 41, 41)))
    .addGroup(NewAccountMainPanelLayout.createSequentialGroup()
    .addComponent(SignupLBL_PASSWORD2)
    .addGap(41, 41, 41)))
    .addGroup(NewAccountMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(SignupPF_PASSWORD2, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(SignUpTF_Name, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(SignupPF_PASSWORD1, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addGroup(NewAccountMainPanelLayout.createSequentialGroup()
    .addGap(225, 225, 225)
    .addComponent(CREATESignupBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE)))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    NewAccountMainPanelLayout.setVerticalGroup(
    NewAccountMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(NewAccountMainPanelLayout.createSequentialGroup()
    .addComponent(NewAccountHeadingLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
    .addGroup(NewAccountMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(SignUpTF_Name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(SignupLBL1))
    .addGap(18, 18, 18)
    .addGroup(NewAccountMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(SignupPF_PASSWORD1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(SignupLBL_PASSWORD1))
    .addGap(18, 18, 18)
    .addGroup(NewAccountMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(SignupLBL_PASSWORD2)
    .addComponent(SignupPF_PASSWORD2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(64, 64, 64)
    .addComponent(CREATESignupBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(93, 93, 93))
    );

    javax.swing.GroupLayout NewAccountFrameLayout = new javax.swing.GroupLayout(NewAccountFrame.getContentPane());


    NewAccountFrame.getContentPane().setLayout(NewAccountFrameLayout);
    NewAccountFrameLayout.setHorizontalGroup(
    NewAccountFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(NewAccountMainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );
    NewAccountFrameLayout.setVerticalGroup(
    NewAccountFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(NewAccountMainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );



    1
    4-rasm. Ro‘yxatdan o‘tish va Login formasi
    15-rasm. Ro‘yxatdan o‘tish oynasi

    Menyu oynasini va uning komponentlarini yaratib chiqish


    RailwayFrame.setTitle("Menyu");
    RailwayFrame.setBackground(new java.awt.Color(255, 255, 255));
    RailwayFrame.setMinimumSize(new java.awt.Dimension(640, 480));
    RailwayFrame.setResizable(false);

    RainwayMainPanel.setBackground(new java.awt.Color(255, 255, 255));


    RainwayMainPanel.setMinimumSize(new java.awt.Dimension(0, 0));
    RainwayMainPanel.setPreferredSize(new java.awt.Dimension(0, 0));

    TitleLBL.setBackground(new java.awt.Color(38, 50, 56));


    TitleLBL.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    TitleLBL.setForeground(new java.awt.Color(255, 255, 255));
    TitleLBL.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    TitleLBL.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Background.jpg"))); // NOI18N
    TitleLBL.setText("O‘zbekiston temir yo‘llar xizmati");
    TitleLBL.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    TitleLBL.setOpaque(true);

    IRCRCBTN.setBackground(new java.awt.Color(69, 104, 220));


    IRCRCBTN.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
    IRCRCBTN.setForeground(new java.awt.Color(255, 255, 255));
    IRCRCBTN.setText("UzRailway Portal");
    IRCRCBTN.setBorder(null);
    IRCRCBTN.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    IRCRCBTNActionPerformed(evt);
    }
    });

    TrainListBTN.setBackground(new java.awt.Color(69, 104, 220));


    TrainListBTN.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    TrainListBTN.setForeground(new java.awt.Color(255, 255, 255));
    TrainListBTN.setText("Poyezd ro‘yhati");
    TrainListBTN.setBorder(null);
    TrainListBTN.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    TrainListBTNActionPerformed(evt);
    }
    });

    LogoutBTN.setBackground(new java.awt.Color(69, 104, 220));


    LogoutBTN.setFont(new java.awt.Font("Tahoma", 1, 9)); // NOI18N
    LogoutBTN.setForeground(new java.awt.Color(255, 255, 255));
    LogoutBTN.setText("Akkountdan chiqish");
    LogoutBTN.setBorder(null);
    LogoutBTN.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    LogoutBTNActionPerformed(evt);
    }
    });

    AboutBTN.setBackground(new java.awt.Color(69, 104, 220));


    AboutBTN.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    AboutBTN.setForeground(new java.awt.Color(255, 255, 255));
    AboutBTN.setText("Biz haqimizda");
    AboutBTN.setBorder(null);
    AboutBTN.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    AboutBTNActionPerformed(evt);
    }
    });

    ExitBTN.setBackground(new java.awt.Color(69, 104, 220));


    ExitBTN.setFont(new java.awt.Font("Tahoma", 1, 9)); // NOI18N
    ExitBTN.setForeground(new java.awt.Color(255, 255, 255));
    ExitBTN.setText("Ilovadan Chiqish");
    ExitBTN.setBorder(null);
    ExitBTN.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    ExitBTNActionPerformed(evt);
    }
    });

    ReservationBTN.setBackground(new java.awt.Color(69, 104, 220));


    ReservationBTN.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
    ReservationBTN.setForeground(new java.awt.Color(255, 255, 255));
    ReservationBTN.setText("Chipta zakaz");
    ReservationBTN.setBorder(null);
    ReservationBTN.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    ReservationBTNActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout RainwayMainPanelLayout = new javax.swing.GroupLayout(RainwayMainPanel);


    RainwayMainPanel.setLayout(RainwayMainPanelLayout);
    RainwayMainPanelLayout.setHorizontalGroup(
    RainwayMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(RainwayMainPanelLayout.createSequentialGroup()
    .addGap(107, 107, 107)
    .addGroup(RainwayMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(ReservationBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(AboutBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(60, 60, 60)
    .addGroup(RainwayMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(TrainListBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(LogoutBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(58, 58, 58)
    .addGroup(RainwayMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(IRCRCBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(ExitBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    .addGroup(RainwayMainPanelLayout.createSequentialGroup()
    .addComponent(TitleLBL)
    .addGap(0, 0, Short.MAX_VALUE))
    );
    RainwayMainPanelLayout.setVerticalGroup(
    RainwayMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(RainwayMainPanelLayout.createSequentialGroup()
    .addComponent(TitleLBL, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addGap(61, 61, 61)
    .addGroup(RainwayMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(ReservationBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(TrainListBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(IRCRCBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addGap(34, 34, 34)
    .addGroup(RainwayMainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(ExitBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(LogoutBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(AboutBTN, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(85, Short.MAX_VALUE))
    );

    javax.swing.GroupLayout RailwayFrameLayout = new javax.swing.GroupLayout(RailwayFrame.getContentPane());


    RailwayFrame.getContentPane().setLayout(RailwayFrameLayout);
    RailwayFrameLayout.setHorizontalGroup(
    RailwayFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(RainwayMainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
    );
    RailwayFrameLayout.setVerticalGroup(
    RailwayFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(RainwayMainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
    );

    17-rasm. Menyu oynasi
    MySQL da dasturning ma’lumotlar bazasi yaartiladi va dastur bilan uni JDBC orqali bog‘laniladi:

    18-rasm. Dastur ma’lumotlar bazasi.
    Va uni bog‘lash kodi:
    try{
    Class.forName("java.sql.Driver");

    String userID = UserIDTF.getText();


    String password = new String (PasswordPF.getPassword());

    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/poyezd","root","opjs");


    stmt = con.createStatement();
    String query = "SELECT * from PASSWORD WHERE userID = '"+userID+"';";
    //Kiritilgan login va ism boyicha bazadan malumot qidirish
    rs = stmt.executeQuery(query);

    if(rs.next()){


    String password_stored = rs.getString("Password");
    if(password_stored.equals(password)){
    //parol togri yoki notoriligni tekshirish
    RailwayFrame.setVisible(true);
    }
    }
    else
    //parol togri kelmasa
    JOptionPane.showMessageDialog(null, "Xato Login yoki Parol");

    }
    catch(Exception e){


    JOptionPane.showMessageDialog(null, e.getMessage());
    }
    if(userID_NEW.equals("") && password_NEW1.equals("")){
    JOptionPane.showMessageDialog(null,"Iltimos, to‘g‘ri foydalanuvchi nomini kiriting.");
    }
    else{
    if(password_NEW1.equals(password_NEW2)){
    try{
    Class.forName("java.sql.Driver");

    con = DriverManager.getConnection("jdbc:mysql://localhost:3306/poyezd","root","opjs");


    stmt = con.createStatement();
    String query = "Insert into password values ('"+userID_NEW+"', '"+password_NEW1+"');";
    stmt.executeUpdate(query);
    JOptionPane.showMessageDialog(null,"Akkount muvaffaqiyatli yaratildi " + userID_NEW);
    stmt.close();
    con.close();
    }
    catch(Exception e){
    JOptionPane.showMessageDialog(null, "Bu Foydalanuvchi ID oldin kiritilgan.");
    }
    NewAccountFrame.setVisible(false);
    }
    else{
    JOptionPane.showMessageDialog(null,"Parol mos kelmadi !");
    }
    }

    private void ExitBTNActionPerformed(java.awt.event.ActionEvent evt)


    System.exit(0); //ilovanni yopish

    private void LogoutBTNActionPerformed(java.awt.event.ActionEvent evt)


    //
    RailwayFrame.setVisible(false);
    UserIDTF.setText("");
    PasswordPF.setText("");

    Dasturning kodlari ilova qilinadi.


    Dasturning real hayotga tadbiqi:

    18-rasm. Ro‘yhatdan o‘tish.

    19-rasm. Login parol bilan Menyuga kirish.

    20-rasm. Biz haqimizda oynasiga kirish.

    21-rasm. UzRailway oynasiga kirish.

    22-rasm. Poyezdlar ro‘yxati oynasiga kirish. Mavjud poyezdlar ko‘rinadi.

    23-rasm. Chipta zakaz qilish oynasiga kirish va manzillarni tanlash va poyezd qidirish tugmasini bosish.

    24-rasm. Chiqqan yo‘nalish natijasini bosish.

    25-rasm. Chipta oynasidan kerakli maydonlarni to‘ldirish va chiptani rasmiylashtirish.

    26-rasm. Rasmiylashtirilgan chipta

    27-rasm. Admin parol va login orqali Boshqaruv mamuryatiga kirish.


    28-rasm. Boshqaruv mamuryati oynasi

    29-rasm. Bu oynadan poyezd qo‘shish, poyezd ma’lumotlarini yangilash, bekatlarni qo‘shish, o‘chirish kabi amallar bajariladi.
    Xulosa
    Menga kurs ishi topshirig‘i sifatida “Temir yo‘l kassasida, chipta sotish va bo‘sh o‘rinlar hisobi” berildi. Ushbu kurs ishini bajarish davomida Temir yo‘l kassalarining tuzilishi, ularda foydalanuvchi mijozlarga chipta sotish tizimlariniing turlari bo‘yicha qator o‘rganishlar olib bordim.
    Bizga ma’lumki, bugungi kunda qaysi sohani qaramaylik dasturiy ta’minot muhim o‘rin kasb etmoqda. Shunday ekan dasturiy ta’minotga talab kundan-kunga ortib bormoqda. Kurs ishini bajarish davomida obyektga yo‘naltirilgan dasturlash tillari qatoriga kiruvchi Java dasturlash tilidagi Swing ktubxonalari haqida ham umumiy ma’lumotlar berdim. So‘ngra dasturiy ta’minotni yaratish texnologiyasi, dasturiy ta’minotni misollarda tekshirib ko‘rish bo‘limlariga alohida ahamiyat berdim.
    Bizga dasturash fanlaridan ma’lumki, qaysi bir soha bo‘lmasin uning hozirgi kunda zamon talablariga javob beruvchi, information texnologiyalar rivojlanayotgan bugungi zamonda avtomatlashtirish va optimallashtirish uchun dasturiy ta’minotini yaratish talab etiladi. Va tuzilgan dasturiy ta’minot temir yo‘l sohasida offlayn ishlarni onlayn holatga keltirishda sezirarli foyda beradi.
    Xulosam yakunida shuni aytishim mumkinki, kurs ishini bajarish davomida o‘z bilimlarimni mustahkamlab Java dasturlash tili va uning kutubxonalari, MySQL haqida chuqur bilimlarga va yana ko‘plab yangi tajribalarga ega bo‘ldim.


    Download 1,93 Mb.
    1   ...   5   6   7   8   9   10   11   12   13




    Download 1,93 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Mavzu: Temir yo‘l kassasida, chipta sotish va bo‘sh o‘rinlar hisobi

    Download 1,93 Mb.