Ejemplo n.º 1
0
        private void Run()
        {
            while (true)
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new Action(delegate()
                    {
                        string sql               = "SELECT * FROM cart";
                        DataTable dt             = db.GetDBTable(sql);
                        dataGridView1.DataSource = dt;

                        this.Refresh();
                    }));
                    Thread.Sleep(1);
                }
            }
        }
Ejemplo n.º 2
0
        private void Main_Load(object sender, EventArgs e)
        {
            Checkit();
            VisibleFalseLabel();
            LblCart.Visible         = true;
            LblCartInfo.Visible     = true;
            LblLiveInfo.Visible     = true;
            LblUsingUser.Visible    = true;
            picBoxCheck1.Visible    = true;
            picBoxCheck2.Visible    = true;
            btnCart.BackgroundImage = Image.FromFile("menuCart2.jpg");
            pictureBox2.BackColor   = Color.FromArgb(234, 234, 234);

            //로그인 창 띄우기
            loginForm = new Login();
            loginForm.loginEventHandler += new EventHandler(LoginSuccess);
            switch (loginForm.ShowDialog())
            {
            case DialogResult.OK:
                loginForm.Close();
                break;

            case DialogResult.Cancel:
                Dispose();
                break;
            }

            //DataGridView1에 Cart 실시간 현황 테이블 생성
            string    sql = "SELECT * FROM `cart`";
            DataTable dt  = db.GetDBTable(sql);

            dataGridView1.DataSource = dt;
        }
Ejemplo n.º 3
0
        private void Main_Load(object sender, EventArgs e)
        {
            Checkit();
            VisibleFalseLabel();
            LblCart.Visible      = true;
            LblCartInfo.Visible  = true;
            LblLiveInfo.Visible  = true;
            LblUsingUser.Visible = true;
            picBoxCheck1.Visible = true;
            //picBoxCheck2.Visible = true;
            dataGridView1.Visible   = true;
            btnCart.BackgroundImage = Image.FromFile("menuCart2.jpg");
            pictureBox2.BackColor   = Color.FromArgb(234, 234, 234);

            dataGridView1.RowHeadersVisible = false;
            dataGridView2.RowHeadersVisible = false;
            dataGridView3.RowHeadersVisible = false;


            //오늘 날짜
            int    nowYear   = DateTime.Now.Year;               //오늘 년
            int    nowMonth  = DateTime.Now.Month;              //오늘 월
            string nowWeek   = DTPlast1.Value.ToString("dddd"); //오늘 요일
            int    nowHour   = DateTime.Now.Hour;               //오늘 시
            int    nowMinute = DateTime.Now.Minute;             //오늘 분
            int    firstDay  = DateTime.Now.Day - 7;            //일주일 전 날짜
            int    lastDay   = DateTime.Now.Day;                //오늘 날짜

            //총매출액 그래프 날짜
            DTPfirst1.Value = new DateTime(nowYear, nowMonth, firstDay);
            DTPlast1.Value  = new DateTime(nowYear, nowMonth, lastDay);
            //상품별 매출액 그래프 날짜
            DTPfirst2.Value = new DateTime(nowYear, nowMonth, firstDay);
            DTPlast2.Value  = new DateTime(nowYear, nowMonth, lastDay);

            int firstyear  = DTPfirst1.Value.Year;
            int firstmonth = DTPfirst1.Value.Month;
            int firstday   = DTPfirst1.Value.Day;
            int lastyear   = DTPlast1.Value.Year;
            int lastmonth  = DTPlast1.Value.Month;
            int lastday    = DTPlast1.Value.Day;

            //총매출액 그래프
            string          Querysale = "  select date_format(buydate, '%m-%d') as date, sum(price) from `order` where buydate between date('" + firstyear + "-" + firstmonth + "-" + firstday + "') AND date('" + lastyear + "-" + lastmonth + "-" + lastday + "') group by buydate";
            string          constring = "server=localhost; database=smartcart; uid=root; password=apmsetup;";
            MySqlConnection consaleDB = new MySqlConnection(constring);
            MySqlCommand    cmdsaleDB = new MySqlCommand(Querysale, consaleDB);
            MySqlDataReader myreadersale;

            consaleDB.Open();
            myreadersale = cmdsaleDB.ExecuteReader();
            chartSum.Series.Clear();
            Series series = chartSum.Series.Add("price");

            try
            {
                while (myreadersale.Read())
                {
                    string date = myreadersale.GetString("date");
                    chartSum.Series["price"].Points.AddXY(date, myreadersale.GetString("sum(price)"));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            consaleDB.Close();

            //실시간 시간
            LblNowDate.Text = "" + nowYear + "년 " + nowMonth + "월 " + lastDay + "일 " + nowWeek + " " + nowHour + "시 " + nowMinute + "분";

            //로그인 창 띄우기
            loginForm = new Login();
            loginForm.loginEventHandler += new EventHandler(LoginSuccess);
            switch (loginForm.ShowDialog())
            {
            case DialogResult.OK:
                loginForm.Close();
                break;

            case DialogResult.Cancel:
                Dispose();
                break;
            }

            //DataGridView1에 Cart 실시간 현황 테이블 생성
            string    sql = "SELECT * FROM `cart`";
            DataTable dt  = db.GetDBTable(sql);

            dataGridView1.DataSource = dt;

            dataGridView1.Columns["cartNumber"].HeaderText = "카트 번호";
            dataGridView1.Columns["cartName"].HeaderText   = "카트 이름";
            dataGridView1.Columns["usingName"].HeaderText  = "사용자 정보";

            dataGridView1.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView2.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            dataGridView3.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;

            //db 행 색깔,폰트 색깔
            dataGridView1.EnableHeadersVisualStyles = false;
            dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.CornflowerBlue;
            dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
            dataGridView2.EnableHeadersVisualStyles = false;
            dataGridView2.ColumnHeadersDefaultCellStyle.BackColor = Color.CornflowerBlue;
            dataGridView2.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
            dataGridView3.EnableHeadersVisualStyles = false;
            dataGridView3.ColumnHeadersDefaultCellStyle.BackColor = Color.CornflowerBlue;
            dataGridView3.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;

            // dataGridView1.ColumnHeadersDefaultCellStyle.Font = new Font("나눔스퀘어라운드", 13, FontStyle.Bold);
            //dataGridView2.ColumnHeadersDefaultCellStyle.Font = new Font("나눔스퀘어라운드", 13, FontStyle.Bold);
            //dataGridView3.ColumnHeadersDefaultCellStyle.Font = new Font("나눔스퀘어라운드", 13, FontStyle.Bold);

            //  dataGridView1.Select = false;
        }
Ejemplo n.º 4
0
        //스레드 함수
        private void Run()
        {
            try
            {
                while (true)
                {
                    if (this.InvokeRequired)
                    {
                        this.Invoke(new Action(delegate()
                        {
                            int nowYear    = DateTime.Now.Year;               //오늘 년
                            int nowMonth   = DateTime.Now.Month;              //오늘 월
                            string nowWeek = DTPlast1.Value.ToString("dddd"); //오늘 요일
                            int nowHour    = DateTime.Now.Hour;               //오늘 시
                            int nowMinute  = DateTime.Now.Minute;             //오늘 분
                            int lastDay    = DateTime.Now.Day;                //오늘 날짜
                            //실시간 시간
                            LblNowDate.Text = "" + nowYear + "년 " + nowMonth + "월 " + lastDay + "일 " + nowWeek + " " + nowHour + "시 " + nowMinute + "분";

                            string sql               = "SELECT * FROM cart";
                            DataTable dt             = db.GetDBTable(sql);
                            dataGridView1.DataSource = dt;

                            this.Refresh();
                        }));
                        Thread.Sleep(1000);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }