Beispiel #1
0
        public static bool Delete(string path, Cdata box)
        {
            try
            {
                MySqlConnection sqlCon = new MySqlConnection(path);
                sqlCon.Open();
                MySqlCommand sqlcmd = sqlCon.CreateCommand();

                sqlcmd.CommandText = "DELETE FROM `bsdata` WHERE `DAY`=@DAY OR `BOXSN`=@BOXSN OR `TYPE`=@TYPE OR `PSN`=@PSN OR `MSSN`=@MSSN";
                sqlcmd.Parameters.AddWithValue("DAY", box.DAY);
                sqlcmd.Parameters.AddWithValue("BOXSN", box.BOXSN);
                sqlcmd.Parameters.AddWithValue("TYPE", box.TYPE);
                sqlcmd.Parameters.AddWithValue("PSN", box.PSN);
                sqlcmd.Parameters.AddWithValue("MSSN", box.MSSN);
                int i = sqlcmd.ExecuteNonQuery();

                return(i == 1);
            }
            catch (Exception)
            {
                //Do any logging operation here if necessary
                return(false);
            }
        }
Beispiel #2
0
        public static bool Insert(string path, Cdata box)
        {
            try
            {
                MySqlConnection sqlCon = new MySqlConnection(path);
                sqlCon.Open();
                MySqlCommand sqlcmd = sqlCon.CreateCommand();

                sqlcmd.CommandText = "INSERT INTO bsdata(ID,BOXSN,TYPE,DAY,PSN,MSSN) VALUES(uuid(),@BOXSN,@TYPE,@DAY,@PSN,@MSSN);";
                sqlcmd.Parameters.Add(new MySqlParameter("BOXSN", box.BOXSN));
                sqlcmd.Parameters.Add(new MySqlParameter("TYPE", box.TYPE));
                sqlcmd.Parameters.Add(new MySqlParameter("DAY", box.DAY));
                sqlcmd.Parameters.Add(new MySqlParameter("PSN", box.PSN));
                sqlcmd.Parameters.Add(new MySqlParameter("MSSN", box.MSSN));
                int i = sqlcmd.ExecuteNonQuery();

                return(i == 1);
            }
            catch (Exception)
            {
                //Do any logging operation here if necessary
                return(false);
            }
        }
Beispiel #3
0
        public static bool Update(string path, Cdata box)
        {
            try
            {
                MySqlConnection sqlCon = new MySqlConnection(path);
                sqlCon.Open();
                MySqlCommand sqlcmd = sqlCon.CreateCommand();

                sqlcmd.CommandText = "UPDATE bsdata SET BOXSN=@BOXSN,TYPE=@TYPE,DAY=@DAY,MSSN=@MSSN where PSN=@PSN;";
                sqlcmd.Parameters.Add(new MySqlParameter("BOXSN", box.BOXSN));
                sqlcmd.Parameters.Add(new MySqlParameter("TYPE", box.TYPE));
                sqlcmd.Parameters.Add(new MySqlParameter("DAY", box.DAY));
                sqlcmd.Parameters.Add(new MySqlParameter("PSN", box.PSN));
                sqlcmd.Parameters.Add(new MySqlParameter("MSSN", box.MSSN));
                int i = sqlcmd.ExecuteNonQuery();

                return(i == 1);
            }
            catch (Exception)
            {
                //Do any logging operation here if necessary
                return(false);
            }
        }
Beispiel #4
0
        public static Cdata Getdata(string path, Cdata box)
        {
            try
            {
                MySqlConnection sqlCon = new MySqlConnection(path);
                sqlCon.Open();
                MySqlCommand sqlcmd = sqlCon.CreateCommand();

                sqlcmd.CommandText = "SELECT  `DAY`, `BOXSN` , `TYPE` , `PSN` , `MSSN`, `UPDATETIME` FROM `bsdata` WHERE `DAY`=@DAY OR `BOXSN`=@BOXSN OR `TYPE`=@TYPE OR `PSN`=@PSN OR `MSSN`=@MSSN";
                sqlcmd.Parameters.AddWithValue("DAY", box.DAY);
                sqlcmd.Parameters.AddWithValue("BOXSN", box.BOXSN);
                sqlcmd.Parameters.AddWithValue("TYPE", box.TYPE);
                sqlcmd.Parameters.AddWithValue("PSN", box.PSN);
                sqlcmd.Parameters.AddWithValue("MSSN", box.MSSN);
                MySqlDataReader sdr = sqlcmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                if (sdr.Read())
                {
                    box.DAY        = sdr.GetString(0);
                    box.BOXSN      = sdr.GetString(1);
                    box.TYPE       = sdr.GetString(2);
                    box.PSN        = sdr.GetString(3);
                    box.MSSN       = sdr.GetString(4);
                    box.UPDATETIME = sdr.GetString(5);
                    return(box);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                //Do any logging operation here if necessary
                return(null);
            }
        }