Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hai guys, i create a winform like this image. the time at start session is run using timer. now i need a method or sample to improve my winform.

the thing i need is:

situation a: user can pick any station (station 1 to station 20), user add hour. as an example, if the user start session 3.45 pm and add hour. So the end session will be 4.45pm and the app will notify the user.

problem is: how about if the station run at same time (different hour), and the program will notify user.

- im new in this winform

What I have tried:

<pre>using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SessionManager__Demo
{
    public partial class Dashboard : Form
    {
        public Dashboard()
        {
            InitializeComponent();
            timer_St1.Start();
        }

        private void bunifuFlatButton1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }


        private void Dashboard_Load(object sender, EventArgs e)
        {
        }

        private void Start_Session_Click(object sender, EventArgs e)
        {
            try
            {

                int cb_hour = int.Parse(comboBox2.SelectedItem.ToString()); // covert String combobox to integer


                /*******************************************
                 *             Yes & No
                 *******************************************/

                DialogResult dialogResult = MessageBox.Show("Do you want to add the Station ?", "PS4 Station", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {

                    // ADD Time
                    DateTime addHour = DateTime.Now.AddHours(cb_hour);
                    string expSessionTime = addHour.ToString("hh:mm:ss:tt");

                    label27.Text = expSessionTime;

                    //latest session
                    latestSession();

                    //compare date





                }
                else if (dialogResult == DialogResult.No)
                {
                    MessageBox.Show("Session is Cancel", "Warning");

                    label27.Text ="00 : 00 : 00";
                }


            }
            catch (Exception ex)
            {
                MessageBox.Show("Please insert the session Hour value","Warning",MessageBoxButtons.YesNo,MessageBoxIcon.Warning);

            }
        }




        private void timer1_Tick_st1(object sender, EventArgs e)
        {
            /*******************************************
             *          Display Current Time
             *******************************************/
            DateTime time = DateTime.Now;
            label26.Text = time.ToString("hh:mm:ss:tt");
        }




        /*******************************************
         *          Latest Station
         *******************************************/
         private void latestSession()
        {
            label33.Text = comboBox1.Text.ToString();
            label34.Text = comboBox2.Text.ToString();
            label35.Text = label26.Text;
            label36.Text = label27.Text;

        }



        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }


    }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900