示例#1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            cardFiche           = ficheBindTool.DataObject;
            creditLine          = creditLineBindTool.DataObject;
            debitLine           = debitLineBindTool.DataObject;
            creditLine.SignType = -1;
            debitLine.SignType  = 1;
            cardFiche.Lines     = new List <CardFicheLine> {
                creditLine, debitLine
            };
            Operation <CardFiche> postedCashTransaction = OperationHandler.PostCardFiche(cardFiche);

            if (postedCashTransaction.Successful)
            {
                this.Close();
            }
            SetError(postedCashTransaction.Fail, false);
        }
示例#2
0
        private void Manp_CardTransaction_Shown(object sender, EventArgs e)
        {
            if (!IsEditMode)
            {
                foreach (Control c in grpCenter.Controls)
                {
                    c.Enabled = false;
                }
                btnOk.Enabled = false;
            }
            List <IBaseOperation> loadOperations = new List <IBaseOperation>();

            IBaseOperation baseOperation = dataHolder.LoadEnumData();

            loadOperations.Add(baseOperation);

            Operation <List <CardView> > op_CardMaster = OperationHandler.GetCardsByUserId(StaticData.CurrentUserId);

            loadOperations.Add(op_CardMaster);

            if (Id != 0)
            {
                Operation <CardFiche> op_ExistingCardFiche = OperationHandler.GetCardFicheById(Id);
                loadOperations.Add(op_ExistingCardFiche);
                cardFiche  = op_ExistingCardFiche.Value;
                creditLine = cardFiche.Lines.Where(x => x.SignType < 0).FirstOrDefault();
                debitLine  = cardFiche.Lines.Where(x => x.SignType > 0).FirstOrDefault();
            }
            else
            {
                cardFiche             = new CardFiche();
                cardFiche.CreatedDate = DateTime.Now;
                cardFiche.CreatedBy   = StaticData.CurrentUserId;
                cardFiche.StatusId    = 11;
            }

            foreach (IBaseOperation ibop in loadOperations)
            {
                if (!ibop.Successful)
                {
                    SetError(ibop.Fail);
                    return;
                }
            }

            Cards     = op_CardMaster.Value;
            CashTypes = dataHolder.CashTypes;
            lookUpCashType.Properties.DataSource         = CashTypes;
            searchLookUpSourceCard.Properties.DataSource = Cards;
            searchLookUpDestCard.Properties.DataSource   = Cards;


            ficheBindTool.BindControl(lookUpCashType, nameof(cardFiche.CashTypeId));
            ficheBindTool.BindControl(txtNote, nameof(cardFiche.Note));
            ficheBindTool.BindControl(txtFicheno, nameof(cardFiche.Ficheno));

            if (creditLine == null)
            {
                creditLine = new CardFicheLine();
            }
            creditLineBindTool.BindControl(searchLookUpSourceCard, nameof(creditLine.CardId));
            creditLineBindTool.BindControl(sourceCurrencyRate, nameof(creditLine.CurrencyRate));
            creditLineBindTool.BindControl(sourceAmount, nameof(creditLine.Total));

            if (debitLine == null)
            {
                debitLine = new CardFicheLine();
            }
            debitLineBindTool.BindControl(searchLookUpDestCard, nameof(debitLine.CardId));
            debitLineBindTool.BindControl(destCurrencyRate, nameof(debitLine.CurrencyRate));
            debitLineBindTool.BindControl(destAmount, nameof(debitLine.Total));

            ficheBindTool.DataObject      = cardFiche;
            creditLineBindTool.DataObject = creditLine;
            debitLineBindTool.DataObject  = debitLine;

            txtDate.Text = cardFiche.CreatedDate.ToString(StaticData.DateTimeFromatStr);

            ControlCurrencies();
            //if (injected)
            //{


            //    //CardView sourceCard = Cards.Where(x => x.Id == sourceCardId).FirstOrDefault();
            //    //lookUpCurrency.EditValue = sourceCard?.CurrencyId;
            //    //searchLookUpSourceCard.EditValue = sourceCard?.Id;
            //    //searchLookUpDestCard.EditValue = destCardId;
            //    //sourceAmount.EditValue = amount;
            //    //txtNote.Text = note;
            //    ////lookUpCurrency.ReadOnly = true;
            //    //cashTransaction.ConnectedFicheId = connectedInvoiceId;
            //}
        }