示例#1
0
文件: Disk.cs 项目: drme/disks-db
 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;
 }
示例#2
0
        public FormNewDisk(DisksDB.DataBase.DataBase db, DataBase.Box box)
        {
            this.box = box;

            InitializeComponent();

            FillDrives();
            this.comboBoxDiskType.DataSource = db.DiskTypes;
            this.controlNewCover1.FillImages(db.DiskImages);
            this.textBoxName.Text = box.Name;
            this.diskType = (DiskType)db.DiskTypes[0];

            try
            {
                this.Icon = new System.Drawing.Icon(MyResources.GetStream("dvdbox.ico"));
                this.pictureBox1.Image = new System.Drawing.Bitmap(MyResources.GetStream("wellcomeImage.png"));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
            }
        }
示例#3
0
 private void DiskTypeSelectedIndexChanged(object sender, EventArgs e)
 {
     this.diskType = (DiskType)this.comboBoxDiskType.SelectedItem;
 }
示例#4
0
文件: Box.cs 项目: drme/disks-db
        public Disk AddDisk(String name, DiskType type, Image image, string driveLetter, IAddDiskProgress prog, bool addFiles)
        {
            CheckDeleted();

            Disk d = this.idb.AddDisk(name, type, image, this, driveLetter, prog, addFiles);

            if (d != null)
            {
                OnChildAdded(d);
            }

            return d;
        }
示例#5
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});
 }
示例#6
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;
        }