Ejemplo n.º 1
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            try
            {
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                    ofd.Filter           = "Png Files|*.png|Jpeg Files|*.jpeg|Jpg Files|*.jpg";
                    ofd.Multiselect      = false;
                    DialogResult dr = ofd.ShowDialog();

                    if (dr == System.Windows.Forms.DialogResult.OK)
                    {
                        im_bytes        = File.ReadAllBytes(ofd.FileName);
                        pcbxImage.Image = ImageByteConverter.byteArrayToImage(im_bytes);
                        AddChange("Resim", im_bytes);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally { }
        }
Ejemplo n.º 2
0
        private void FormLoad()
        {
            try
            {
                is_formload = false;

                if (p_id > 0)
                {
                    List <YasoParameter> h = new List <YasoParameter>();
                    h.Add(new YasoParameter {
                        Name = "Id", Value = p_id
                    });
                    DataTable dt = dtMan.GetResultSetOfQuery("Select * From Person Where Id=?", h).Tables[0];
                    AddChange("Id", p_id);
                    foreach (DataRow row in dt.Rows)
                    {
                        txtAd.Text    = string.Format("{0}", row["Ad"]);
                        txtSoyad.Text = string.Format("{0}", row["Soyad"]);
                        if (row["Resim"] != null && row["Resim"] != DBNull.Value)
                        {
                            im_bytes = (byte[])row["Resim"];
                            if (im_bytes.Length > 0)
                            {
                                pcbxImage.Image = ImageByteConverter.byteArrayToImage(im_bytes);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                error_fired = true;
                MessageBox.Show(ex.Message);
            }
            finally
            {
                is_formload = true;
            }
        }