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 btnLogIn_Click(object sender, EventArgs e) { try { using (var daoAkun = new AkunDAO(Setting.GetConnectionString())) { Akun temp = daoAkun.GetDataCustomerByUsername(txtUsername.Text); if (temp.Password.Equals(txtPassword.Text)) { if (temp.Username.ToLower().Equals("admin")) { FrmAdminInterface frm = new FrmAdminInterface(temp); this.Hide(); frm.ShowDialog(); FrmLogInMember_Load(null, null); this.Show(); } else { FrmUserInterface frm = new FrmUserInterface(temp); this.Hide(); frm.ShowDialog(); FrmLogInMember_Load(null, null); this.Show(); } } else { throw new Exception(); } } } catch (Exception) { this.lblAccountError.Visible = true; this.txtUsername.Text = ""; this.txtPassword.Text = ""; this.txtUsername.Focus(); } }
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); } }
private void btnOrder_Click(object sender, EventArgs e) { DSPenjualan ds = new DSPenjualan(); if (MessageBox.Show("Apakah anda yakin membeli barang ini ?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { foreach (Penjualan jual in listPenjualan) { var row = ds.Penjualan.NewPenjualanRow(); row.NoOrder = jual.NoOrder; row.NamaBarang = jual.DataBarang.Nama; row.NamaCustomer = jual.DataAkun.Nama; row.Quantity = jual.Quantity.ToString(); row.Tanggal = jual.Tanggal.ToShortDateString(); row.SubTotal = jual.Total.ToString("n0"); row.Total = $"Rp. {tempTotalHrg.ToString("n0")}"; ds.Penjualan.AddPenjualanRow(row); _result = new PenjualanDAO(Setting.GetConnectionString()).AddPenjualan(jual) > 0; using (var dao = new BarangDAO(Setting.GetConnectionString())) { dao.UpdateQuantity(jual.DataBarang, jual.Quantity); } using (var dao = new AkunDAO(Setting.GetConnectionString())) { dao.UpdateTotal(jual.DataAkun, jual.Total); } } FrmReceipt frmReceipt = new FrmReceipt(ds); frmReceipt.ShowDialog(); MessageBox.Show("Order telah diproses.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { this.Close(); } }