Esempio n. 1
0
        void MoverDatos(BO.Models.Secuenciales MyComp)
        {
            //else if(ctr.Tag == MyComp.COM_DESCRIPCION)
            foreach (Control ctr in tabPage2.Controls)
            {
                if (ctr.Tag == null)
                {
                    continue;
                }


                switch (ctr.Tag.ToString())
                {
                case "ID":
                    ctr.Text = MyComp.SEC_ID.ToString();
                    break;

                case "TIPO_ID":
                    ctr.Text = MyComp.TIPO_ID.ToString();
                    break;

                case "VALOR":
                    ctr.Text = MyComp.VALOR.ToString();
                    break;
                }
            }
        }
Esempio n. 2
0
        bool SalvarDatos()
        {
            int  iId      = -1;
            bool bRetorno = false;

            //CompaniasRecord oCom = new CompaniasRecord();


            BO.Models.Secuenciales oCom;


            if (usrbntMant1.bAdiciona == false)
            {
                iId  = Convert.ToInt32(this.TextParametroId.Text);
                oCom = unitOfWork.SecuencialesRepository.GetByID(iId);
            }
            else
            {
                oCom = new BO.Models.Secuenciales();
            }

            oCom.TIPO_ID = Convert.ToInt32(TextTipoId.Text);
            oCom.VALOR   = Convert.ToInt32(this.txtValor1.Text.ToString());


            oCom.SUC_ID = Convert.ToInt32(cmbSucursal.SelectedValue);


            try
            {
                if (usrbntMant1.bAdiciona == false)
                {
                    unitOfWork.SecuencialesRepository.Update(oCom);
                }
                else
                {
                    unitOfWork.SecuencialesRepository.Insert(oCom);
                }

                unitOfWork.Save();
                bRetorno           = true;
                usrbntMant1.bExito = true;

                CargarDatosIniciales(iSucId);
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    string s = "";

                    /*
                     * Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                     *  eve.Entry.Entity.GetType().Name, eve.Entry.State);
                     */


                    foreach (var ve in eve.ValidationErrors)
                    {
                        s += ve.ErrorMessage + "\n";

                        /*Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                         *  ve.PropertyName, ve.ErrorMessage);*/
                    }
                    MessageBox.Show("Existen los siguientes errores:" + s, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //throw;
            }
            catch (DataException ex)
            {
                throw ex;
            }


            return(bRetorno);
        }