public void Set_Save()
        {
            MessageBoxIcon msgIcon = MessageBoxIcon.Warning;
            try
            {
                if (!string.IsNullOrWhiteSpace(txtCOD_ALMA_RECE.Text))
                {
                    msgIcon = MessageBoxIcon.Warning;
                    throw new ArgumentException(WhMessage.MsgNotModyRegis);
                }
                var obrg = new BEReceivingGoods()
                {
                    COD_ALMA_TRAN = obtg.COD_ALMA_TRAN,
                    ALF_DOCU_REFE = txtALF_DOCU_REFE.Text.Trim(),
                    FEC_RECE = (DateTime?)dteFEC_RECE.EditValue,
                    FEC_REGI = (DateTime?)dteFEC_REGI.EditValue,
                    COD_ALMA = (int?)lkeCOD_ALMA.EditValue,
                    COD_SOCI_NEGO_RESP = (int?)lkeCOD_SOCI_NEGO_RESP.EditValue,
                    COD_MOTI = (int?)lkeCOD_MOTI.EditValue,
                    ALF_COME = memALF_COME.Text.Trim(),
                    COD_USUA_CREA = SESSION_USER,
                    COD_USUA_MODI = SESSION_USER,
                    COD_COMP = SESSION_COMP
                };

                var context = new ValidationContext(obrg, null, null);
                var errors = new List<ValidationResult>();
                if (!Validator.TryValidateObject(obrg, context, errors, true))
                {
                    foreach (ValidationResult result in errors)
                    {
                        msgIcon = MessageBoxIcon.Warning;
                        throw new ArgumentException(result.ErrorMessage);
                    }
                }

                gdvDetail.CloseEditor();
                gdvDetail.RefreshData();
                var olst = (List<BEReceivingGoodsDetail>)gdvDetail.DataSource;
                if (olst.Count == 0)
                {
                    msgIcon = MessageBoxIcon.Warning;
                    throw new ArgumentException(WhMessage.MsgManyRows);
                }

                var i = 1;
                olst.ForEach(item =>
                {
                    context = new ValidationContext(item, null, null);
                    errors = new List<ValidationResult>();
                    if (!Validator.TryValidateObject(item, context, errors, true))
                    {
                        foreach (ValidationResult result in errors)
                        {
                            msgIcon = MessageBoxIcon.Warning;
                            throw new ArgumentException(string.Format("{0}\nFila: {1}", result.ErrorMessage, i));
                        }
                    }
                    i++;
                });

                var manywh = olst.Select(item => item.COD_ALMA).Distinct().Count();
                if (manywh > 1)
                {
                    msgIcon = MessageBoxIcon.Warning;
                    throw new ArgumentException(WhMessage.MsgManyWhArt);
                }

                var obr = new BRReceivingGoods();
                obr.Set_PSGN_SPMT_SVTC_ALMA_RECE(obrg, olst);
                if (!string.IsNullOrWhiteSpace(obrg.MSG_MNTN))
                {
                    msgIcon = MessageBoxIcon.Error;
                    throw new ArgumentException(obrg.MSG_MNTN);
                }
                txtCOD_ALMA_RECE.Text = obrg.COD_ALMA_RECE.ToString();
                gdvDetail.RefreshData();
                StateControls(true);
                XtraMessageBox.Show(WhMessage.MsgSuccessfully, WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message,
                                    WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK,
                                    msgIcon);
            }
        }
        private void Search()
        {
            try
            {
                var opar = new BEReceivingGoods()
                {
                    COD_ALMA = (int?)lkeCOD_ALMA.EditValue,
                    COD_MOTI = (int?)lkeCOD_MOTI.EditValue,
                    FEC_RECE = (DateTime?)dteFEC_SALI.EditValue,
                    FEC_REGI = (DateTime?)dteFEC_REGI.EditValue,
                    ALF_DOCU_REFE = txtALF_DOCU_REFE.Text,
                    COD_COMP = xfMain.SgIns.SESSION_COMP
                };

                var obr = new BRReceivingGoods();
                var olst = obr.Get_PSGN_SPLS_SVTC_ALMA_RECE(opar);

                gdcSearch.DataSource = olst;
                gdvSearch.MoveFirst();
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, WhMessage.MsgInsCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void Set_ReceivingGoods(BEReceivingGoods row)
        {
            ClearControls();
            txtCOD_ALMA_RECE.Text = row.COD_ALMA_RECE.ToString();
            txtALF_DOCU_REFE.Text = row.ALF_DOCU_REFE;
            dteFEC_RECE.EditValue = row.FEC_RECE;
            dteFEC_REGI.EditValue = row.FEC_REGI;
            lkeCOD_ALMA.EditValue = row.COD_ALMA;
            lkeCOD_SOCI_NEGO_RESP.EditValue = row.COD_SOCI_NEGO_RESP;
            lkeCOD_MOTI.EditValue = row.COD_MOTI;
            memALF_COME.Text = row.ALF_COME;

            var obrg = new BEReceivingGoods() { COD_ALMA_RECE = row.COD_ALMA_RECE };
            var obr = new BRReceivingGoods();
            var olst = obr.Get_PSGN_SPLS_SVTD_ALMA_RECE(obrg);

            gdcDetail.DataSource = olst;
            gdvDetail.RefreshData();
        }