Esempio n. 1
0
        public DialogProduk(String id_produk)
        {
            InitializeComponent();


            k.sql = "select *from tb_produk where id_produk ='" + id_produk + "'";
            k.setdt();
            Byte[] tmpfoto = new Byte[0];
            foreach (DataRow baris in k.dt.Rows)
            {
                txt_id.Text   = baris[0].ToString();
                txt_nama.Text = baris[1].ToString();
                if (baris[2].ToString() == "Makanan")
                {
                    rb_makanan.IsChecked = true;
                }
                else
                {
                    rb_minuman.IsChecked = true;
                }
                txt_detail.Text = baris[3].ToString();
                txt_harga.Text  = Convert.ToDecimal(baris[4].ToString()).ToString("c");

                tmpfoto         = (Byte[])baris[5];
                img_foto.Source = ByteImageConverter.ByteToImage(tmpfoto);
            }
        }
        private async void loadData()
        {
            await Task.Delay(300);

            try
            {
                k.sql = "select *from customer where id_customer ='" + idCustomer + "'";
                k.setdt();
                Byte[] tmpfoto = new Byte[0];
                foreach (DataRow baris in k.dt.Rows)
                {
                    txt_nik.Text  = baris[1].ToString();
                    txt_nama.Text = baris[2].ToString();
                    txt_telp.Text = baris[3].ToString();
                    if (baris[4].ToString() == "P")
                    {
                        rb_laki.IsChecked = true;
                    }
                    else
                    {
                        rb_perempuan.IsChecked = true;
                    }
                    String   tgllahir = baris[5].ToString();
                    DateTime dt       = Convert.ToDateTime(tgllahir);
                    tgl_lahir.SelectedDate = dt;
                    txt_asalkota.Text      = baris[6].ToString();
                    txt_alamat.Text        = baris[7].ToString();
                    cmb_pekerjaan.Text     = baris[8].ToString();
                    txt_instansi.Text      = baris[9].ToString();

                    if (!baris[10].Equals(null))
                    {
                        tmpfoto         = (Byte[])baris[10];
                        img_foto.Source = ByteImageConverter.ByteToImage(tmpfoto);
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show("error di open " + ex);
            }
        }