Ejemplo n.º 1
0
 private void setDataGrid(SQL_Structure ss)
 {
     dataGrid.ColumnCount     = 9;
     dataGrid.Columns[0].Name = "has stone";
     dataGrid.Columns[1].Name = "is ring";
     dataGrid.Columns[2].Name = "is couple";
     dataGrid.Columns[3].Name = "is pendant";
     dataGrid.Columns[4].Name = "is wristband";
     dataGrid.Columns[5].Name = "is bracelet";
     dataGrid.Columns[6].Name = "is earring";
     dataGrid.Columns[7].Name = "is necklace";
     dataGrid.Columns[8].Name = "is other";
     string[] row = new string[dataGrid.ColumnCount];
     row[0] = OorX(ss.has_stone);
     row[1] = OorX(ss.is_ring);
     row[2] = OorX(ss.is_couple);
     row[3] = OorX(ss.is_pendant);
     row[4] = OorX(ss.is_wristband);
     row[5] = OorX(ss.is_bracelet);
     row[6] = OorX(ss.is_earring);
     row[7] = OorX(ss.is_necklace);
     row[8] = OorX(ss.is_other);
     dataGrid.Rows.Clear();
     dataGrid.Rows.Add(row);
 }
Ejemplo n.º 2
0
 private void GetNext_Click(object sender, EventArgs e)
 {
     if (sql.checkConnection())
     {
         if (this.id.Text != string.Empty)
         {
             int           val = Convert.ToInt32(this.id.Text);
             SQL_Structure ss  = sql.Read(val);
             this.id.Text      = ss.id.ToString();
             this.modelID.Text = ss.modelID;
             this.gender.Text  = ss.gender;
             this.hasImg.Text  = ss.blobImg == null ? "None" : "Has";
             setDataGrid(ss);
             if (ss.blobImg != null)
             {
                 setImgBox(sql.BlobToImage(ss.blobImg));
             }
             else
             {
                 clearImgBox();
             }
         }
     }
     else
     {
         MessageBox.Show("Failed to connect to MYSQL server!");
     }
 }
Ejemplo n.º 3
0
        public SQL_Structure Read(int id)
        {
            SQL_Structure sql_struct = new SQL_Structure();

            conn.Open();
            if (conn.State != ConnectionState.Open)
            {
                conn.Close();
                return(sql_struct);
            }

            //add query
            command.CommandText = "select * from " + table + " where id = '" + id.ToString() + "'";
            adapter             = new MySqlDataAdapter(command);
            DataTable t = new DataTable();

            adapter.Fill(t);
            //fill structure
            sql_struct.id        = (int)t.Rows[0][0];
            sql_struct.modelID   = t.Rows[0][1].ToString();
            sql_struct.gender    = t.Rows[0][2].ToString();
            sql_struct.has_stone = (bool)t.Rows[0][3];
            sql_struct.is_ring   = (bool)t.Rows[0][4];
            Console.WriteLine("Bool:" + sql_struct.is_ring.ToString() + "  origin:" + t.Rows[0][4].ToString());
            sql_struct.is_couple    = (bool)t.Rows[0][5];
            sql_struct.is_pendant   = (bool)t.Rows[0][6];
            sql_struct.is_wristband = (bool)t.Rows[0][7];
            sql_struct.is_bracelet  = (bool)t.Rows[0][8];
            sql_struct.is_earring   = (bool)t.Rows[0][9];
            sql_struct.is_necklace  = (bool)t.Rows[0][10];
            sql_struct.is_other     = (bool)t.Rows[0][11];
            if (t.Rows[0][12] != System.DBNull.Value)
            {
                sql_struct.blobImg = (byte[])t.Rows[0][12];
            }
            //release memory use by adapter
            adapter.Dispose();
            conn.Close();
            return(sql_struct);
        }