Ejemplo n.º 1
0
        private void FrmReleaseOrder_Load(object sender, EventArgs e)
        {
            //Traducciones
            SessionHelper.RegisterForTranslation(this, Codes.MNU_GE016);
            SessionHelper.RegisterForTranslation(cmdAccept, Codes.BTN_ACCEPT);
            SessionHelper.RegisterForTranslation(cmdClose, Codes.BTN_CLOSE);

            SessionHelper.RegisterForTranslation(lblBeneficiary, Codes.LBL_BENEFICIARY);
            SessionHelper.RegisterForTranslation(lblStock, Codes.LBL_STOCK);
            SessionHelper.RegisterForTranslation(lblQuantity, Codes.LBL_QUANTITY);
            SessionHelper.RegisterForTranslation(lblComment, Codes.LBL_OBSERVATION);

            try
            {
                BeneficiaryBLL beneficiaryBll    = new BeneficiaryBLL();
                ResultBM       beneficiaryResult = beneficiaryBll.GetBeneficiaries();
                cmbBeneficiary.DataSource    = beneficiaryResult.GetValue <List <BeneficiaryBM> >();
                cmbBeneficiary.DisplayMember = "FullName";

                StockBLL stockBll    = new StockBLL();
                ResultBM stockResult = stockBll.GetAvailableStocks();
                lstStock.DataSource    = stockResult.GetValue <List <StockBM> >();
                lstStock.DisplayMember = "Name";

                if (IsUpdate)
                {
                    bool found = false;

                    for (int i = 0; i < cmbBeneficiary.Items.Count && !found; ++i)
                    {
                        found = ((BeneficiaryBM)cmbBeneficiary.Items[i]).id == this.Entity.beneficiary.id;
                        if (found)
                        {
                            cmbBeneficiary.SelectedIndex = i;
                        }
                    }
                    lstAdded             = this.Entity.detail;
                    dgRelease.DataSource = lstAdded;
                    txtComment.Text      = this.Entity.Comment;
                }
                else
                {
                    entity = new ReleaseOrderBM();
                }
            }
            catch (Exception exception) {
                MessageBox.Show("Se ha producido el siguiente error: " + exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }