Beispiel #1
0
        void cmdInsertImage_Click(object sender, EventArgs e)
        {
            SelectImageForm f = new SelectImageForm();

            try
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    int Identifier = 0;
                    var fileBytes  = System.IO.File.ReadAllBytes(f.FileName);
                    if (ops.InsertImage(fileBytes, f.Description, ref Identifier) == Success.Okay)
                    {
                        ((DataTable)bs.DataSource).Rows.Add(new object[] { Identifier, fileBytes, f.Description });
                        var index = bs.Find("ImageId", Identifier);
                        if (index > -1)
                        {
                            bs.Position = index;
                        }
                    }
                }
            }
            finally
            {
                f.Dispose();
            }
        }
Beispiel #2
0
        void InsertImageButton_Click(object sender, EventArgs e)
        {
            var f = new SelectImageForm();

            try
            {
                if (f.ShowDialog() == DialogResult.OK)
                {
                    int Identifier = 0;
                    var fileBytes  = File.ReadAllBytes(f.FileName);

                    if (_databaseImageOperations.InsertImage(fileBytes, f.Description, ref Identifier) == Success.Okay)
                    {
                        ((DataTable)_bindingSource.DataSource).Rows.Add(Identifier, fileBytes, f.Description);

                        var index = _bindingSource.Find("ImageId", Identifier);

                        if (index > -1)
                        {
                            _bindingSource.Position = index;
                        }
                    }
                }
            }
            finally
            {
                f.Dispose();
            }
        }