Ejemplo n.º 1
0
        void OnSaveClick(object sender, EventArgs e)
        {
            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 = _costingServices.CreateJewelTransaction(request);

                if (response.IsValid == false)
                {
                    MessageBox.Show(AllErrors.ErrorMessageString(), Constants.ALERTMESSAGEHEADER);
                    return;
                }

                ShowManagedModalForm <frmCostingConfirmation>(Owner as frmCostingBase, response.TransactionLookup);
                Close();
            }
        }
Ejemplo n.º 2
0
        void Calculate(DataGridView mapGrid, CostingRates costingRates, out List <JewelTransaction> jewelTransaction)
        {
            jewelTransaction = new List <JewelTransaction>();
            var tranLookupKey = Guid.NewGuid();

            foreach (var item in mapGrid.Rows)
            {
                var row     = (DataGridViewRow)item;
                var jewelNo = row.GetCellValue(_columnjewelnumber);

                var tranDetails = _transactionServices.GetJewelTransactionsByJewelNo(jewelNo);
                var tran        = new JewelTransaction
                {
                    JewelTransactionRowId = tranLookupKey,
                    TransactionType       = ApprovalSelection ? TransactionType.ApprovalTransaction : TransactionType.MarketingTransaction,
                    CostingDetail         = new CostingDetail {
                        Properties = costingRates
                    },
                    CertificateNumber  = tranDetails.CertificateNumber,
                    CStonePcs          = tranDetails.CStonePcs,
                    CStoneWeight       = tranDetails.CStoneWeight,
                    DesignCode         = tranDetails.DesignCode,
                    JewelNumber        = tranDetails.JewelNumber,
                    JewelTransactionId = tranDetails.JewelTransactionId,
                    JewelType          = tranDetails.JewelType,
                    KT                  = tranDetails.KT,
                    MetalColor          = tranDetails.MetalColor,
                    JewelItemCategory   = tranDetails.JewelItemCategory,
                    MetalWeight         = tranDetails.MetalWeight,
                    Properties          = tranDetails.Properties,
                    StonePcs            = tranDetails.StonePcs,
                    StoneWeight         = tranDetails.StoneWeight,
                    TotalAmount         = tranDetails.TotalAmount,
                    TotalWeight         = tranDetails.TotalWeight,
                    TransactionDate     = dtCosting.Value,
                    TransactionPartyRef = ((Customer)cboCustomer.SelectedItem).CustomersCode,
                };

                jewelTransaction.Add(tran);
            }
            _jewelCalculation.Calculate(costingRates, jewelTransaction);
        }