Exemplo n.º 1
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            UseWaitCursor = true;
            string    sql    = "SELECT * FROM tblTemp WHERE DATE(date_Temp) = CURDATE()";
            var       manage = new db_manage();
            DataTable dt     = manage.getData(sql);

            this.chartTemp.Series["Temperature"].Points.AddXY(convertDate(dt), dt.Rows.Count == 0 ? 0 : dt.Rows[0][1]);

            sql = "SELECT * FROM tblDamp WHERE DATE(date_Damp) = CURDATE()";
            dt  = manage.getData(sql);
            this.chartTemp.Series["Humidity"].Points.AddXY(convertDate(dt), dt.Rows.Count == 0 ? 0 : dt.Rows[0][1]);

            sql = "SELECT * FROM tblTemp WHERE DATE(date_Temp) = CURDATE() - 1";
            dt  = manage.getData(sql);
            this.chartTemp.Series["Temperature"].Points.AddXY(convertDate(dt), dt.Rows.Count == 0 ? 0 : dt.Rows[0][1]);

            sql = "SELECT * FROM tblDamp WHERE DATE(date_Damp) = CURDATE() - 1";
            dt  = manage.getData(sql);
            this.chartTemp.Series["Humidity"].Points.AddXY(convertDate(dt), dt.Rows.Count == 0 ? 0 : dt.Rows[0][1]);

            sql = "SELECT * FROM tblTemp WHERE DATE(date_Temp) = CURDATE() - 2";
            dt  = manage.getData(sql);
            this.chartTemp.Series["Temperature"].Points.AddXY(convertDate(dt), dt.Rows.Count == 0 ? 0 : dt.Rows[0][1]);

            sql = "SELECT * FROM tblDamp WHERE DATE(date_Damp) = CURDATE() - 2";
            dt  = manage.getData(sql);
            this.chartTemp.Series["Humidity"].Points.AddXY(convertDate(dt), dt.Rows.Count == 0 ? 0 : dt.Rows[0][1]);

            picEmp.Image   = imgEmp;
            lblNmeEmp.Text = nameEmp;

            var db_conn = new db_connect();

            if (db_conn.OpenConnection())
            {
                lblDBName.Text      = db_conn.connection.Database;
                lblDataSrc.Text     = db_conn.connection.DataSource;
                lblIP.Text          = Program.GetIP();
                lblServThread.Text  = db_conn.connection.ServerThread.ToString();
                lblServVersion.Text = db_conn.connection.ServerVersion;
                lblServState.Text   = db_conn.connection.State.ToString();
                lblHosting.Text     = "www.ppakorni.info";
                db_conn.CloseConnection();
            }
            else
            {
                lblDBName.Text      = $"Unknown";
                lblDataSrc.Text     = $"Unknown";
                lblIP.Text          = Program.GetIP();
                lblServThread.Text  = $"Unknown";
                lblServVersion.Text = $"Unknown";
                lblServState.Text   = $"Unknown";
                lblHosting.Text     = $"Unknown";
            }
            UseWaitCursor = false;
        }
Exemplo n.º 2
0
        private void frmImg_Load(object sender, EventArgs e)
        {
            string sql = "SELECT date_Img,img_Name FROM tblObjectImg WHERE id_obj = '" + barCode + "' " +
                         "and date_Img IN (SELECT MAX(date_Img) FROM tblObjectImg) GROUP BY img_Name";
            var    manage = new db_manage();
            string url    = manage.lastImg(sql);

            if (url == "")
            {
                return;
            }

            pictureBox1.Load("http://www.ppakorn.info/siam_summaryDoc/img/coding2/" + url);
        }
Exemplo n.º 3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string sql = string.Format("SELECT User_Emp,Pass_Emp,Name_Emp,img_Emp FROM tblEmployees WHERE " +
                                       "User_Emp = '{0}' and Pass_Emp = '{1}'",
                                       txtUser.Text.Trim(), txtPass.Text.Trim());

            var manage = new db_manage();
            var emp    = manage.chkUser(sql);

            if (emp.Rows.Count > 0)
            {
                this.Hide();
                var f = new frmMain();
                f.nameEmp = emp.Rows[0][2].ToString();

                byte[]       bits = (byte[])emp.Rows[0][3];
                MemoryStream mem  = new MemoryStream(bits);
                f.imgEmp = Image.FromStream(mem);

                emp.Dispose();
                f.ShowDialog();
                this.Close();
            }
        }
Exemplo n.º 4
0
 public frmManage()
 {
     InitializeComponent();
     this.ActiveControl = txtBarCode;
     manage             = new db_manage();
 }
Exemplo n.º 5
0
        private async void insertOfDay()
        {
            lblStatus.Text = "Checking...";
            var manage = new db_manage();

            List <DataTable> dts;

            dts = manage.getLastData();

            for (int i = 0; i < dts.Count; i++)
            {
                if (dts[i].Rows.Count > 0)
                {
                    //ถ้าความชื้นยังไม่ได้บันทึก
                    if ((dts[i].TableName == "tblTemp") && (dts.Count == 1))
                    {
                        lblStatus.Text = "Saving...";
                        await Task.Delay(2000);

                        manage.insertDamp(damp);
                    }

                    //ถ้าอุณหภูมิยังไม่ได้บันทึก
                    else if ((dts[i].TableName == "tblDamp") && (dts.Count == 1))
                    {
                        lblStatus.Text = "Saving...";
                        await Task.Delay(2000);

                        manage.insertTemp(temp);
                    }

                    DateTime date = Convert.ToDateTime(dts[i].Rows[0][0].ToString());

                    //ถ้ายังไม่ได้บันทึกข้อมูลในวันนี้
                    if (date.Date != DateTime.Now.Date)
                    {
                        if (dts[i].TableName == "tblTemp")
                        {
                            lblStatus.Text = "Saving...";
                            await Task.Delay(2000);

                            manage.insertTemp(temp);
                        }
                        else if (dts[i].TableName == "tblDamp")
                        {
                            lblStatus.Text = "Saving...";
                            await Task.Delay(2000);

                            manage.insertDamp(damp);
                        }
                    }
                }
            }

            if (dts.Count == 1)
            {
                //ถ้าไม่ได้เชื่อมต่ออินเทอร์เน็ต
                if (dts[0].TableName == "No table")
                {
                    lblStatus.Text = "Connect to Internet for save today.";
                }
                else
                {
                    lblStatus.Text = "";
                    lblStatus.Hide();
                }
            }

            //ยังไม่มีข้อมูลอะไรเลย
            else if (dts.Count == 0)
            {
                lblStatus.Text = "Saving...";
                await Task.Delay(2000);

                manage.insertDamp(damp);
                manage.insertTemp(temp);
                lblStatus.Text = "";
                lblStatus.Hide();
            }
            else
            {
                lblStatus.Text = "";
                lblStatus.Hide();
            }
        }