Beispiel #1
0
        public Boolean altadeRegistro()
        {
            if (!validarEntradadeDatos())
            {
                return(false);
            }


            List <TB_PresentacionesCAIDetalle> lista = new List <TB_PresentacionesCAIDetalle>();

            /*  validar a nivel de Items*/
            foreach (DataGridViewRow item in dataGridView1.Rows)
            {
                TB_PresentacionesCAIDetalle un_TB_PresentacionesCAIDetalle = new TB_PresentacionesCAIDetalle();
                un_TB_PresentacionesCAIDetalle.nrCAI = item.Cells["CAI"].EditedFormattedValue.ToString();
                un_TB_PresentacionesCAIDetalle.PDV   = item.Cells["PDV"].EditedFormattedValue.ToString();
                un_TB_PresentacionesCAIDetalle.Letra = item.Cells["Letra"].EditedFormattedValue.ToString();
                un_TB_PresentacionesCAIDetalle.nrUltNroComprobante = int.Parse(item.Cells["UltNroComprobante"].EditedFormattedValue.ToString());
                un_TB_PresentacionesCAIDetalle.dtInsercion         = DateTime.Today;
                un_TB_PresentacionesCAIDetalle.tpComprobante       = item.Cells["DOC"].EditedFormattedValue.ToString();
                lista.Add(un_TB_PresentacionesCAIDetalle);
            }

            if ((lista.Count() == 0))
            {
                MessageBox.Show("Debe poseer la informacion de la a presentar.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                dataGridView1.Focus();
                return(false);
            }

            TB_PresentacionesCAI una_presentacion = new TB_PresentacionesCAI();

            una_presentacion.nrAnio         = int.Parse(this.txtnrAnio.Text);
            una_presentacion.nrMes          = int.Parse(this.cbnrMes.Text);
            una_presentacion.dtPresentacion = this.cbdtPresentacion.Value.Date;
            una_presentacion.flestado       = "A";
            una_presentacion.dsUsuario      = serviceModel.Usuario;
            una_presentacion.dtModificacion = DateTime.Now;
            una_presentacion.TB_PresentacionesCAIDetalle = lista;
            //serviceModel.agregarPresentacionCAI(una_presentacion, lista);
            serviceModel.AgregarRegistro(una_presentacion);
            una_presentacion_actual = una_presentacion;
            return(true);
        }
Beispiel #2
0
 public void agregarPresentacionCAI(TB_PresentacionesCAI objPresentacion, IEnumerable <TB_PresentacionesCAIDetalle> objPresentacionDetalle)
 {
     Trace.TraceInformation("ingresando a agregarPresentacionCAI");
     using (var context = new dbSG2000Entities())
     {
         using (TransactionScope transaction = new TransactionScope())
         {
             TB_PresentacionesCAIDetalle detalleConciliacion = new TB_PresentacionesCAIDetalle();
             foreach (var item in objPresentacionDetalle)
             {
                 context.TB_PresentacionesCAIDetalle.Add(new TB_PresentacionesCAIDetalle {
                     TB_PresentacionesCAI = objPresentacion,
                     nrCAI               = item.nrCAI,
                     dtInsercion         = DateTime.Now,
                     nrUltNroComprobante = item.nrUltNroComprobante
                 });
             }
             context.TB_PresentacionesCAI.Add(objPresentacion);
             context.SaveChanges();
             transaction.Complete();
             return;
         }
     }
 } // cierre agregarPresentacionCAI