private void PopulateBillReceiptItem(BillReceiptItem billReceiptItem) { var item = new ListViewItem(billReceiptItem.SalesId.ToString()); item.SubItems.Add(billReceiptItem.Sales.Date.ToString("dd/MM/yyyy")); item.SubItems.Add(billReceiptItem.Sales.Code); item.SubItems.Add(billReceiptItem.Sales.Customer.Name); item.SubItems.Add(billReceiptItem.Sales.Salesman.Name); item.SubItems.Add(billReceiptItem.Total.ToString("N0").Replace(",", ".")); lvwBillReceipt.Items.Add(item); }
public void Delete(IEntityManager em, Transaction tx, BillReceiptItem billReceiptItem) { try { string[] columns = { "Total" }; object[] values = { 0 }; var q = new Query().Select(columns).From(tableName).Update(values) .Where("BillReceiptId").Equal("{" + billReceiptItem.BillReceiptId + "}"); em.ExecuteNonQuery(q.ToSql(), tx); } catch (Exception ex) { throw ex; } }
public void Save(IEntityManager em, Transaction tx, BillReceiptItem billReceiptItem) { try { string[] columns = { "ID", "BillReceiptId", "SalesId", "Total", "Notes" }; object[] values = { Guid.NewGuid(), billReceiptItem.BillReceiptId, billReceiptItem.SalesId, billReceiptItem.Total, billReceiptItem.Notes }; var q = new Query().Select(columns).From(tableName).Insert(values); em.ExecuteNonQuery(q.ToSql(), tx); } catch (Exception ex) { throw ex; } }
private void SaveBillReceipt() { if (dtpDate.Value.Month != Store.ActiveMonth || dtpDate.Value.Year != Store.ActiveYear) { MessageBox.Show("Tanggal diluar periode aktif", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (txtSalesmanName.Text == "") { MessageBox.Show("Salesman tidak boleh kosong", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); btnBrowseSalesman.Focus(); } else if (lvwBillReceipt.Items.Count == 0) { MessageBox.Show("Detail tidak boleh kosong", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var billReceipt = new BillReceipt(); billReceipt.Code = lblCode.Text; billReceipt.BillReceiptDate = dtpDate.Value; billReceipt.Notes = txtNotes.Text; billReceipt.SalesmanId = new Guid(txtSalesmanId.Text); billReceipt.GrandTotal = decimal.Parse(lblTotal.Text.Replace(".", "")); var billReceiptItems = new List <BillReceiptItem>(); foreach (ListViewItem item in lvwBillReceipt.Items) { string salesId = item.SubItems[0].Text; string total = item.SubItems[5].Text; BillReceiptItem si = new BillReceiptItem(); if (si.Sales == null) { si.Sales = new Sales(); } si.Sales.Code = item.SubItems[2].Text; si.SalesId = new Guid(salesId); si.Notes = ""; si.Total = decimal.Parse(total.Replace(".", "")); billReceiptItems.Add(si); } billReceipt.BillReceiptItems = billReceiptItems; if (formMode == FormMode.Add) { billReceiptRepository.Save(billReceipt); ShowBillReceiptReport(); GetLastBillReceipt(); } else if (formMode == FormMode.Edit) { billReceipt.ID = new Guid(txtID.Text); billReceipt.GrandTotal = decimal.Parse(lblTotal.Text.Replace(".", "")); billReceiptRepository.Update(billReceipt); ShowBillReceiptReport(); } LoadBillReceiptItems(new Guid(txtID.Text)); DisableForm(); formMode = FormMode.View; FillCode(); this.Text = "TTNT"; } }