private void FrmAdminInterface_Load(object sender, EventArgs e) { try { this.lblAdmin.Text = admin.Nama; this.pictureBox1.Image = new ImageConverter().ConvertFrom(admin.Pict) as Image; using (var dao = new BarangDAO(Setting.GetConnectionString())) { this.dgvDataBarang.DataSource = null; this.dgvDataBarang.DataSource = dao.GetAllDataBarang(); this.dgvDataBarang.Columns[0].DataPropertyName = nameof(Barang.Kode); this.dgvDataBarang.Columns[1].DataPropertyName = nameof(Barang.Nama); this.dgvDataBarang.Columns[2].DataPropertyName = nameof(Barang.Jumlah); this.dgvDataBarang.Columns[2].DefaultCellStyle.Format = "n0"; this.dgvDataBarang.Columns[3].DataPropertyName = nameof(Barang.Harga); this.dgvDataBarang.Columns[3].DefaultCellStyle.Format = "c0"; } using (var dao = new AkunDAO(Setting.GetConnectionString())) { this.dgvDataMember.DataSource = null; this.dgvDataMember.DataSource = dao.GetAllDataAccount(); this.dgvDataMember.Columns[0].DataPropertyName = nameof(Akun.Username); this.dgvDataMember.Columns[1].DataPropertyName = nameof(Akun.Nama); this.dgvDataMember.Columns[2].DataPropertyName = nameof(Akun.Total); this.dgvDataMember.Columns[2].DefaultCellStyle.Format = "c0"; } using (var dao = new PenjualanDAO(Setting.GetConnectionString())) { this.dgvDataOrder.DataSource = null; listData = dao.SejarahPenjualan(null, Setting.GetConnectionString()); foreach (Penjualan jual in listData) { this.dgvDataOrder.Rows.Add(new string[] { jual.NoOrder.ToString(), jual.Tanggal.ToShortDateString(), jual.DataBarang.Kode, jual.DataBarang.Nama, jual.DataAkun.Nama, jual.DataBarang.Harga.ToString("c0"), jual.Quantity.ToString("n0"), jual.Total.ToString("c0") }); } } } catch (Exception ex) { MessageBox.Show(ex.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void txtDataMember_Leave(object sender, EventArgs e) { this.dgvDataMember.DataSource = null; using (var dao = new AkunDAO(Setting.GetConnectionString())) { this.dgvDataMember.DataSource = dao.GetAllDataAccount(new Akun { Nama = this.txtNamaUser.Text.Trim(), Username = this.txtUsername.Text.Trim(), Password = null, Pict = null, Total = 0 }); this.dgvDataMember.Columns[0].DataPropertyName = nameof(Akun.Username); this.dgvDataMember.Columns[1].DataPropertyName = nameof(Akun.Nama); this.dgvDataMember.Columns[2].DataPropertyName = nameof(Akun.Total); } }