Exemplo n.º 1
0
        public void loadSync(object element)
        {
            if (element != null)
            {
                COTIZACION poco = (COTIZACION)element;
                using (var entity = new TAE2Entities())
                {
                    var query = (from cust in entity.COTIZACIONs
                                 where poco.UNID_COTIZACION == cust.UNID_COTIZACION
                                 select cust).ToList();

                    //Actualización
                    if (query.Count > 0)
                    {
                        var aux = query.First();

                        if (aux.LAST_MODIFIED_DATE < poco.LAST_MODIFIED_DATE)
                        {
                            udpateElement((object)poco);
                        }
                    }
                    //Inserción
                    else
                    {
                        insertElementSync((object)poco);
                    }

                    var modifiedCotizacion = entity.COTIZACIONs.First(p => p.UNID_COTIZACION == poco.UNID_COTIZACION);
                    modifiedCotizacion.IS_MODIFIED = false;
                    entity.SaveChanges();
                }
            }
        }
Exemplo n.º 2
0
 public void udpateElement(object element)
 {
     if (element != null)
     {
         using (var entity = new TAE2Entities())
         {
             COTIZACION cotizacion         = (COTIZACION)element;
             var        modifiedCotizacion = entity.COTIZACIONs.First(p => p.UNID_COTIZACION == cotizacion.UNID_COTIZACION);
             modifiedCotizacion.OBSERVACIONES_COMPRAS = cotizacion.OBSERVACIONES_COMPRAS;
             modifiedCotizacion.MOTIVO_CANCELACION    = cotizacion.MOTIVO_CANCELACION;
             modifiedCotizacion.IS_ACTIVE             = cotizacion.IS_ACTIVE;
             modifiedCotizacion.ID_USER            = cotizacion.ID_USER;
             modifiedCotizacion.ID_TIPO_COTIZACION = cotizacion.ID_TIPO_COTIZACION;
             modifiedCotizacion.ID_STATUS          = cotizacion.ID_STATUS;
             modifiedCotizacion.ID_ROL             = cotizacion.ID_ROL;
             modifiedCotizacion.ID_PROYECTO        = cotizacion.ID_PROYECTO;
             modifiedCotizacion.ID_EMPRESA         = cotizacion.ID_EMPRESA;
             modifiedCotizacion.ID_CATEGORIA       = cotizacion.ID_CATEGORIA;
             modifiedCotizacion.FECHA_SOLICITUD    = cotizacion.FECHA_SOLICITUD;
             modifiedCotizacion.FECHA_REQUERIMENTO = cotizacion.FECHA_REQUERIMENTO;
             modifiedCotizacion.FECHA_COTIZACION   = cotizacion.FECHA_COTIZACION;
             modifiedCotizacion.DIAS_VIGENCIA      = cotizacion.DIAS_VIGENCIA;
             //Sync
             modifiedCotizacion.IS_MODIFIED        = true;
             modifiedCotizacion.LAST_MODIFIED_DATE = UNID.getNewUNID();
             var modifiedSync = entity.SYNCs.First(p => p.UNID_SYNC == 20120101000000000);
             modifiedSync.ACTUAL_DATE = UNID.getNewUNID();
             //
             entity.SaveChanges();
         }
     }
 }
Exemplo n.º 3
0
        public void insertElement(object element)
        {
            if (element != null)
            {
                using (var entity = new TAE2Entities())
                {
                    COTIZACION cotizacion = (COTIZACION)element;

                    var validacion = (from cust in entity.COTIZACIONs
                                      where cust.UNID_COTIZACION == cotizacion.UNID_COTIZACION
                                      select cust).ToList();

                    if (validacion.Count == 0)
                    {
                        cotizacion.UNID_COTIZACION = UNID.getNewUNID();
                        //Sync
                        cotizacion.IS_MODIFIED        = true;
                        cotizacion.LAST_MODIFIED_DATE = UNID.getNewUNID();
                        var modifiedSync = entity.SYNCs.First(p => p.UNID_SYNC == 20120101000000000);
                        modifiedSync.ACTUAL_DATE = UNID.getNewUNID();
                        entity.SaveChanges();
                        //
                        entity.COTIZACIONs.AddObject(cotizacion);
                        entity.SaveChanges();
                    }
                }
            }
        }
Exemplo n.º 4
0
            public static bool AgregarCotizacion(dbDataContext db, long idpaciente, long iddoctor, DateTime fecha_emision,
                                                 DateTime fecha_entrega, string nombres, string giro, string nit, string nrc, bool retencion,
                                                 bool CFiscal, decimal ptje_iva, decimal ptje_retencion, decimal monto_gravado, decimal monto_iva, decimal subtotal,
                                                 decimal monto_exento, decimal monto_retencion, decimal monto_total, List <COTIZACION_DETALLE> Detalle)
            {
                try
                {
                    var reg = new COTIZACION
                    {
                        ID_COTIZACION        = ((long?)db.COTIZACIONs.Select(c => (long?)c.ID_COTIZACION).Max() ?? 0) + 1,
                        ID_DOCTOR            = iddoctor,
                        ID_PACIENTE          = idpaciente,
                        ID_USUARIO_CREO      = CTRL.Datos.idusuario,
                        FECHA_EMISION        = fecha_emision,
                        FECHA_ENTREGA        = fecha_entrega,
                        NOMBRES              = nombres,
                        GIRO                 = giro,
                        NIT                  = nit,
                        NRC                  = nrc,
                        CREDITO_FISCAL       = CFiscal,
                        RETENCION            = retencion,
                        PORCENTAJE_IVA       = ptje_iva,
                        PORCENTAJE_RETENCION = ptje_retencion,
                        MONTO_GRAVADO        = monto_gravado,
                        MONTO_IVA            = monto_iva,
                        SUBTOTAL             = subtotal,
                        MONTO_EXENTO         = monto_exento,
                        MONTO_RETENCION      = monto_retencion,
                        TOTAL                = monto_total
                    };

                    //ASIGNANDO ID A DETALLE
                    foreach (COTIZACION_DETALLE item in Detalle)
                    {
                        item.ID_COTIZACION_DETALLE = reg.ID_COTIZACION + "-" + Detalle.IndexOf(item);
                    }

                    reg.COTIZACION_DETALLEs.AddRange(Detalle);

                    db.COTIZACIONs.InsertOnSubmit(reg);

                    db.SubmitChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error al agregar el registro.\n\n" + ex.Message, "SysLab", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return(false);
                }
            }
Exemplo n.º 5
0
        public void insertElementSync(object element)
        {
            if (element != null)
            {
                using (var entity = new TAE2Entities())
                {
                    COTIZACION cotizacion = (COTIZACION)element;

                    //Sync

                    var modifiedSync = entity.SYNCs.First(p => p.UNID_SYNC == 20120101000000000);
                    modifiedSync.ACTUAL_DATE = UNID.getNewUNID();
                    entity.SaveChanges();
                    //
                    entity.COTIZACIONs.AddObject(cotizacion);
                    entity.SaveChanges();
                }
            }
        }