Beispiel #1
0
        public FormPropertiesBox(DisksDB.DataBase.DataBase db, Box box)
        {
            this.db = db;
            this.box = box;

            InitializeComponent();

            this.textBoxTitle.Text = this.box.Name;
            this.textBoxDescription.Text = this.box.Description;

            foreach (Object o in db.BoxTypes)
            {
                this.comboBoxBoxType.Items.Add(o);
            }

            for (int i = 0; i < this.comboBoxBoxType.Items.Count; i++)
            {
                if (((BoxType)this.comboBoxBoxType.Items[i]).Id == box.Type.Id)
                {
                    this.comboBoxBoxType.SelectedIndex = i;
                }
            }

            this.imagePanelFront.ImgFact = db.FrontImages;
            this.imagePanelBack.ImgFact = db.BackImages;
            this.imagePanelInlay.ImgFact = db.InlayImages;
            this.imagePanelBack.ShowImage(box.BackCover);
            this.imagePanelFront.ShowImage(box.FrontCover);
            this.imagePanelInlay.ShowImage(box.InlayCover);

            var lst = this.db.BoxTypes;
            this.comboBox1.DataSource = lst;
            this.Text = box.Name + " - Properties";
        }
Beispiel #2
0
 public Disk(IDBLayer idb, long id, string name, Image image, DiskType type, Box box)
     : base(idb, id)
 {
     this.name = name;
     this.image = image;
     this.type = type;
     this.box = box;
 }
Beispiel #3
0
 public SearchResultRow(string fileName, int fileSize, int fileType, DateTime fileDate, Disk disk, Box box, Category category, string diskName, string boxName, string categoryName)
     : base(fileName)
 {
     this.fileName = fileName;
     this.fileSize = fileSize;
     this.fileType = fileType;
     this.fileDate = fileDate;
     this.disk = disk;
     this.box = box;
     this.category = category;
     this.diskName = diskName;
     this.boxName = boxName;
     this.categoryName = categoryName;
 }
Beispiel #4
0
 public void UpdateDisk(Disk disk, String name, DiskType type, Image image, Box box)
 {
     DBUtils.UpdateSQL(this.DBConString, "UPDATE [Disks] SET [DiskImage] = ?, [Name] = ?, [Type] = ?, [CDBox] = ?, [LastUpdate] = NOW() WHERE [id] = ?", new object[] {image.Id, name, type.Id, box.Id, disk.Id});
 }
Beispiel #5
0
 public void UpdateCDBox(Box box, String newName, String newDescription, Image newBack, Image newFront, Image newInlay, BoxType newType, Category newParent)
 {
     DBUtils.UpdateSQL(this.DBConString, "UPDATE [CDBoxes] SET [Description] = ?, [Name] = ?, [BackImage] = ?, [InlayImage] = ?, [Type] = ?,  [FrontImage] = ?, [Category]	= ?, [LastUpdate] = NOW() WHERE [id] = ?", new object[] {newDescription, newName, newBack.Id, newInlay.Id, newType.Id, newFront.Id, newParent.Id, box.Id});
 }
Beispiel #6
0
        public List<Disk> GetDisks(Box box)
        {
            using (OleDbDataReader myReader = DBUtils.ExecSQL(this.DBConString, "SELECT [id], [DiskImage], [CDBox], [Name], [Type] FROM [Disks] WHERE [CDBox] = ? ORDER BY [Name]", new object[] { box.Id }))
            {
                List<Disk> lst = new List<Disk>();

                while (true == myReader.Read())
                {
                    lst.Add(new Disk(this, (int)(myReader[0]), (string)(myReader[3]), db.DiskImages.GetImage((int)myReader[1]), GetDiskType((int)myReader[4]), box));
                }

                return lst;
            }
        }
Beispiel #7
0
        public List<Box> GetChildCDBoxes(Category parentCat)
        {
            using (OleDbDataReader myReader = DBUtils.ExecSQL(this.DBConString, "SELECT [id], [Description], [Name], [BackImage], [InlayImage], [Type], [FrontImage] FROM [CDBoxes] WHERE [Category] = ? ORDER BY [Name]", new object[] { parentCat.Id }))
            {
                List<Box> lst = new List<Box>();

                while (true == myReader.Read())
                {
                    Box box = new Box((string)(myReader["Name"]), (string)(myReader["Description"]),
                                      (int)(myReader["id"]),
                                      db.BackImages.GetImage((int)myReader["BackImage"]),
                                      db.InlayImages.GetImage((int)myReader["InlayImage"]),
                                      GetCDBoxType((int)myReader["Type"]),
                                      db.FrontImages.GetImage((int)myReader["FrontImage"]),
                                      this, parentCat);
                    lst.Add(box);
                }

                return lst;
            }
        }
Beispiel #8
0
 public void DeleteCDBox(Box box)
 {
     DBUtils.DeleteSQL(this.DBConString, "DELETE FROM [CDBoxes] WHERE [id] = ?", new object[] {box.Id});
 }
Beispiel #9
0
        public Disk AddDisk(String name, DiskType type, Image image, Box box, String driveLetter, IAddDiskProgress prog, bool addFiles)
        {
            try
            {
                long files = 0;

                if (true == addFiles)
                {
                    AddFolder(driveLetter, prog, true, ref files, true, null, 0, 0);
                }

                prog.Total(files);

                using (OleDbConnection sqlCon = new OleDbConnection(this.DBConString))
                {
                    sqlCon.Open();
                    OleDbTransaction sqlTran = sqlCon.BeginTransaction();

                    OleDbCommand sqlCmd = new OleDbCommand("INSERT INTO [Disks] ([DiskImage], [CDBox], [Name], [Type], [Description]) VALUES(?, ?, ?, ?, ?)", sqlCon, sqlTran);

                    sqlCmd.Parameters.AddWithValue("@image", image.Id);
                    sqlCmd.Parameters.AddWithValue("@box", box.Id);
                    sqlCmd.Parameters.AddWithValue("@name", name);
                    sqlCmd.Parameters.AddWithValue("@type", type.Id);
                    sqlCmd.Parameters.AddWithValue("@desc", "/* TBD */");

                    sqlCmd.ExecuteNonQuery();

                    OleDbCommand oleCmdIdentity = new OleDbCommand("SELECT @@IDENTITY", sqlCon, sqlTran);

                    int rez = (int)oleCmdIdentity.ExecuteScalar();

                    if (true == addFiles)
                    {
                        long diskId = rez;

                        files = 0;

                        prog.Started();

                        AddFolder(driveLetter, prog, true, ref files, false, sqlTran, -1, diskId);
                    }

                    sqlTran.Commit();
                    prog.Finished();

                    return new Disk(this, rez, name, image, type, box);
                }
            }
            catch (Exception ex)
            {
                prog.Failed(ex.Message);
            }

            return null;
        }