void OnAddtoListClick(object sender, EventArgs e) { if (_validateForm(this) == false) { MessageBox.Show(Resources.frmCostingRates_OnAddtoListClick_Incomplete_information_provided_, Constants.ALERTMESSAGEHEADER); return; } ItemDetail transactionDetails; if (!_validateDataGrid(dgCostingFormat, out transactionDetails)) { return; } // Create a local collection of costing rates DataGridViewRow row = dgCostingFormat.Rows[0]; // make a list of purchaseJewelsRequest and save it to database. var item = new JewelTransaction { JewelItemCategory = ItemCategory, CostingDetail = new CostingDetail { Properties = CostingRate }, TransactionType = TransactionType.PurchaseTransaction, KT = row.GetCellValue(_columnmetaltype), CertificateNumber = row.GetCellValue(_columncerno), DesignCode = row.GetCellValue(_columndesignno), StonePcs = JewelHasStone ? row.GetParsedCellValue <int>(_columndiapcs) : 0, StoneWeight = JewelHasStone ? row.GetParsedCellValue <decimal>(_columndiawt) : 0, CStonePcs = JewelHasStone ? row.GetParsedCellValue <int>(_columncstonepcs) : 0, CStoneWeight = JewelHasStone ? row.GetParsedCellValue <decimal>(_columncstonewt) : 0, JewelType = row.GetCellValue(_columntype), TotalWeight = Convert.ToDecimal(row.GetCellValue(_columngrwt)), MetalWeight = Convert.ToDecimal(row.GetCellValue(_columnntwt)), MetalColor = row.GetCellValue(_columnmetalcolor), Properties = new TransactionDetails { ItemDetails = transactionDetails }, TransactionPartyRef = ((Supplier)cboCustomer.SelectedItem).SupplierCode, TransactionDate = dtCosting.Value, JewelTransactionRowId = Guid.NewGuid(), }; PurchaseTransactionItems.Add(item); _addtoPanel(item); ResetDataGridView(dgCostingFormat); }
void _itemremovefromPanel(object sender, EventArgs e) { var mnuItem = sender as MenuItem; if (mnuItem == null) { return; } var panel = mnuItem.GetContextMenu().SourceControl; //get a item var item = PurchaseTransactionItems.SingleOrDefault(x => x.JewelTransactionRowId == (Guid)panel.Tag); if (item != null) { PurchaseTransactionItems.Remove(item); flowLayout.Controls.Remove(panel); flowLayout.PerformLayout(); } }
void onSaveClick(object sender, EventArgs e) { if (_validateForm(this) == false) { MessageBox.Show(Resources.frmCostingRates_onSaveClick_Incomplete_information_provided_, Constants.ALERTMESSAGEHEADER); return; } if (PurchaseTransactionItems.Any()) { _jewelCalculation.Calculate(CostingRate, PurchaseTransactionItems); var lookup = new TransactionLookup { ContactName = txtContactName.Text, DocNumber = txtDocNo.Text, Remarks = txtRemarks.Text, TransactionDate = dtCosting.Value, TransactionPartyRef = ((Supplier)cboCustomer.SelectedItem).SupplierCode, TransactionType = TransactionType.PurchaseTransaction, JewelTransactions = PurchaseTransactionItems }; var request = new JewelTransactionRequest { TransactionLookup = lookup, }; var response = _transactionService.CreateJewelTransaction(request); if (response.IsValid == false) { MessageBox.Show(response.AllErrors.ErrorMessageString(), Constants.ALERTMESSAGEHEADER); return; } Close(); ShowManagedModalForm <frmCostingConfirmation>(Owner as frmCostingBase, response.TransactionLookup); } }
void JewelItemClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } var panel = sender as Panel; if (panel == null) { return; } var item = PurchaseTransactionItems.SingleOrDefault(x => x.JewelTransactionRowId == (Guid)panel.Tag); if (item != null) { var frm = new frmItemDetail(); frm.BindForm(item.Properties.ItemDetails); frm.Show(); } }