Пример #1
0
        private void On_BTN_ChangeIcon_Click(object sender, RoutedEventArgs e)
        {
            GirlInfoVM vm = CMB_Girls.SelectedItem as GirlInfoVM;

            using (System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog())
            {
                dlg.Title  = "Open Image";
                dlg.Filter = "Image files (*.BMP;*.JPG;*.PNG)|*.BMP;*.JPG;*.Png|All files (*.*)|*.*";

                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    vm.ImgBase64 = GirlInfo.ImgFileToBase64(dlg.FileName);
                }
            }
        }
Пример #2
0
        public List <GirlInfo> LoadData()
        {
            List <GirlInfo> ret     = new List <GirlInfo>();
            String          cmdText = "SELECT * FROM " + TABLE_NAME_BASIC_INFO;

            using (SQLiteCommand cmd = new SQLiteCommand(cmdText, _dbConnection))
            {
                SQLiteDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    GirlInfo info = ParseData(rdr);

                    ret.Add(info);
                }
            }
            return(ret);
        }
Пример #3
0
        private static GirlInfo ParseData(SQLiteDataReader rdr)
        {
            GirlInfo info = new GirlInfo();

            info.ID        = Convert.ToInt32(rdr[COLUMN_NAME_ID]);
            info.ImgBase64 = Convert.ToString(rdr[COLUMN_NAME_IMG_BASE64]);
            //info.ImageSrc = GirlInfo.Base642Image(info.ImgBase64);
            info.Names       = Convert.ToString(rdr[COLUMN_NAME_NAMES]);
            info.NamesJPN    = Convert.ToString(rdr[COLUMN_NAME_NAMES_JPN]);
            info.NamesCHT    = Convert.ToString(rdr[COLUMN_NAME_NAMES_CHT]);
            info.NamesCHS    = Convert.ToString(rdr[COLUMN_NAME_NAMES_CHS]);
            info.NamesENU    = Convert.ToString(rdr[COLUMN_NAME_NAMES_ENU]);
            info.Rare        = Convert.ToInt32(rdr[COLUMN_NAME_RARE]);
            info.Type        = (GirlInfoEnum.Types)Convert.ToInt32(rdr[COLUMN_NAME_TYPE]);
            info.Nationality = (GirlInfoEnum.Nationalities)Convert.ToInt32(rdr[COLUMN_NAME_NATIONALITY]);
            info.Note        = Convert.ToString(rdr[COLUMN_NAME_NOTE]);
            int variable = 0;

            int.TryParse(Convert.ToString(rdr[COLUMN_NAME_FKG_ID]), out variable);
            info.FKGID = variable;
            return(info);
        }
Пример #4
0
        public List <GirlInfo> SearchData(String keyword, GirlInfoEnum.Types type, GirlInfoEnum.Nationalities nationality, int rare)
        {
            List <GirlInfo> ret       = new List <GirlInfo>();
            String          condition = "";

            if (keyword != "")
            {
                condition += "( ";
                condition += COLUMN_NAME_NAMES_JPN + String.Format(" LIKE '%{0}%' OR ", keyword);
                condition += COLUMN_NAME_NAMES_CHT + String.Format(" LIKE '%{0}%' OR ", keyword);
                condition += COLUMN_NAME_NAMES_CHS + String.Format(" LIKE '%{0}%' OR ", keyword);
                condition += COLUMN_NAME_NAMES_ENU + String.Format(" LIKE '%{0}%' OR ", keyword);
                condition += COLUMN_NAME_NOTE + String.Format(" LIKE '%{0}%'", keyword);
                condition += " )";
            }

            if (type != GirlInfoEnum.Types.NotCare)
            {
                int itype = (int)type;
                if (condition != "")
                {
                    condition += " AND ";
                }
                condition += String.Format("{0} == {1}", COLUMN_NAME_TYPE, itype);
            }

            if (nationality != GirlInfoEnum.Nationalities.NotCare)
            {
                int inational = (int)nationality;
                if (condition != "")
                {
                    condition += " AND ";
                }
                condition += String.Format("{0} == {1}", COLUMN_NAME_NATIONALITY, inational);
            }

            if (rare > 0)
            {
                if (condition != "")
                {
                    condition += " AND ";
                }
                condition += String.Format("{0} == {1}", COLUMN_NAME_RARE, rare);
            }

            if (condition != "")
            {
                condition = " WHERE " + condition;
            }

            String cmdText = "SELECT * FROM " + TABLE_NAME_BASIC_INFO + condition;

            using (SQLiteCommand cmd = new SQLiteCommand(cmdText, _dbConnection))
            {
                try
                {
                    SQLiteDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        GirlInfo info = ParseData(rdr);
                        ret.Add(info);
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine($"[SQLiteCtrl] SearchData error:{e.Message}");
                }
            }
            return(ret);
        }
Пример #5
0
        public void InsertData(GirlInfo data)
        {
            /*
             * INSERT OR REPLACE INTO BasicInformation
             * (
             * ID,
             * ImgBase64,
             * Names,
             * NamesJPN,
             * NamesCHT,
             * NamesCHS,
             * NamesENU,
             * Rare,
             * Type,
             * Nationality
             * ) VALUES (
             * 1,
             * xxxxxxxxxxxxxxx...,
             * names,
             * jpn names,
             * cht names,
             * chs names,
             * enu names,
             * 2,
             * 1,
             * 1,
             * 123456
             * )
             */

            String cmdText = "INSERT OR REPLACE INTO " + TABLE_NAME_BASIC_INFO
                             + "("
                             + COLUMN_NAME_ID + ", "
                             + COLUMN_NAME_IMG_BASE64 + ", "
                             + COLUMN_NAME_NAMES + ", "
                             + COLUMN_NAME_NAMES_JPN + ", "
                             + COLUMN_NAME_NAMES_CHT + ", "
                             + COLUMN_NAME_NAMES_CHS + ", "
                             + COLUMN_NAME_NAMES_ENU + ", "
                             + COLUMN_NAME_RARE + ", "
                             + COLUMN_NAME_TYPE + ", "
                             + COLUMN_NAME_NATIONALITY + ", "
                             + COLUMN_NAME_NOTE + ", "
                             + COLUMN_NAME_FKG_ID
                             + ") VALUES ("
                             + data.ID + ", "
                             + String.Format("\"{0}\", ", data.ImgBase64)
                             + String.Format("\"{0}\", ", data.Names)
                             + String.Format("\"{0}\", ", data.NamesJPN)
                             + String.Format("\"{0}\", ", data.NamesCHT)
                             + String.Format("\"{0}\", ", data.NamesCHS)
                             + String.Format("\"{0}\", ", data.NamesENU)
                             + (int)data.Rare + ", "
                             + (int)data.Type + ", "
                             + (int)data.Nationality + ", "
                             + String.Format("\"{0}\"", data.Note) + ", "
                             + data.FKGID
                             + ")";

            using (SQLiteCommand cmd = new SQLiteCommand(cmdText, _dbConnection))
            {
                cmd.ExecuteNonQuery();
            }
        }
Пример #6
0
 public GirlInfoVM(GirlInfo info)
 {
     _info = info;
 }