Esempio n. 1
0
        public Boolean ModificarDB(com_cotizacion_compra_Info info, ref string msg)
        {
            try
            {
                using (EntitiesCompras Context = new EntitiesCompras())
                {
                    var contact = Context.com_cotizacion_compra.FirstOrDefault(A => A.IdEmpresa == info.IdEmpresa && A.IdCotizacion == info.IdCotizacion);

                    if (contact != null)
                    {
                        contact.Observacion     = info.Observacion;
                        contact.Fecha_UltMod    = DateTime.Now;
                        contact.IdProveedor     = info.IdProveedor;
                        contact.IdUsuarioUltAnu = info.IdUsuarioUltMod;
                        Context.SaveChanges();

                        //Eliminar detalle
                        com_cotizacion_compra_det_Data odata = new com_cotizacion_compra_det_Data();
                        if (odata.EliminarDB(Convert.ToInt32(info.IdEmpresa), Convert.ToDecimal(info.IdCotizacion), ref msg))
                        {
                            //grabo nuevo detalle

                            foreach (var item in info.Detalle)
                            {
                                item.IdEmpresa    = info.IdEmpresa;
                                item.IdCotizacion = info.IdCotizacion;
                            }

                            if (odata.GuardarDB(info.Detalle, ref msg))
                            {
                                msg = "Actualización exitosa..";
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                msg = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref msg);
                throw new Exception(ex.ToString());
            }
        }
Esempio n. 2
0
        public Boolean GuardarDB(com_cotizacion_compra_Info info, ref string msg)
        {
            try
            {
                decimal idcotiza = 0;
                using (EntitiesCompras Context = new EntitiesCompras())
                {
                    var Address = new com_cotizacion_compra();

                    Address.IdEmpresa     = info.IdEmpresa;
                    Address.IdCotizacion  = idcotiza = GetId(info.IdEmpresa);
                    Address.Fecha         = DateTime.Now;
                    Address.IdSucursal    = info.IdSucursal;
                    Address.Observacion   = info.Observacion;
                    Address.Estado        = Convert.ToString(info.estado);
                    Address.IdProveedor   = info.IdProveedor;
                    Address.Fecha_Transac = info.Fecha_Transac;
                    Context.com_cotizacion_compra.Add(Address);

                    Context.SaveChanges();

                    //grabar detalle
                    com_cotizacion_compra_det_Data odata = new com_cotizacion_compra_det_Data();

                    if (odata.GuardarDB(info.Detalle, ref msg))
                    {
                        msg = "Grabación exitosa..";
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                msg = ex.InnerException + " " + ex.Message;
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref msg);
                throw new Exception(ex.ToString());
            }
        }