public Proforma SelectObject(Proforma objekat)
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         Proforma proforma = _broker.SelectObjectJoin(objekat) as Proforma;
         proforma.Stavke = _broker.ReturnByCriteriaJoin($"WHERE sp.SifraProforme={proforma.Id}", new StavkaProforme()).OfType <StavkaProforme>().ToList();
         _broker.Commit();
         return(proforma);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,UserID,Price,ProductoID")] Proforma proforma)
        {
            if (id != proforma.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(proforma);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProformaExists(proforma.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductoID"] = new SelectList(_context.Producto, "ID", "ID", proforma.ProductoID);
            return(View(proforma));
        }
Example #3
0
        public int Agregar(Proforma proforma)
        {
            var comando = BaseDatos.GetStoredProcCommand("[inmueble].[usp_ProformaInsert]");

            BaseDatos.AddOutParameter(comando, "IdProforma", DbType.Int32, 4);
            BaseDatos.AddInParameter(comando, "Fecproforma", DbType.DateTime, proforma.Fecproforma);
            BaseDatos.AddInParameter(comando, "Cliente", DbType.String, proforma.Cliente);
            BaseDatos.AddInParameter(comando, "Cantidad", DbType.Int32, proforma.Cantidad);
            BaseDatos.AddInParameter(comando, "Idmoneda", DbType.Int32, proforma.idmoneda);
            BaseDatos.AddInParameter(comando, "Subtotal", DbType.Decimal, proforma.Subotal);
            BaseDatos.AddInParameter(comando, "Igv", DbType.Decimal, proforma.Igv);
            BaseDatos.AddInParameter(comando, "Total", DbType.Decimal, proforma.Total);
            BaseDatos.AddInParameter(comando, "Idunidadinmobiliaria", DbType.Int32, proforma.Idunidadinmobiliaria);

            var resultado = BaseDatos.ExecuteNonQuery(comando);

            if (resultado == 0)
            {
                throw new Exception("No se pudo insertar el registro en la base de datos.");
            }

            var valor = (int)BaseDatos.GetParameterValue(comando, "IdProforma");

            comando.Dispose();

            return(valor);
        }
        protected void DownloadPdf_Click(object sender, EventArgs e)
        {
            StringWriter sw = new StringWriter();

            sw.Write("");
            HtmlTextWriter hw = new HtmlTextWriter(sw);

            Proforma.RenderControl(hw);
            StringReader sr = new StringReader(sw.ToString());


            Document pdfDoc = new Document(PageSize.A3, 10f, 10f, 10f, 10f);

            //  HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
            pdfDoc.SetPageSize(PageSize.A3);
            PdfWriter writer = PdfWriter.GetInstance(pdfDoc, new FileStream(Server.MapPath("~/PDFDoc/user.pdf"), FileMode.Create));



            pdfDoc.Open();
            XMLWorkerHelper.GetInstance().ParseXHtml(
                writer, pdfDoc, sr
                );
            //FontFactory.GetFont("Times New Roman", 14);

            // htmlparser.Parse(sr);
            pdfDoc.Close();

            Response.ContentType = "application/octect-stream";
            Response.AppendHeader("content-disposition", "filename=user.pdf");
            Response.TransmitFile(Server.MapPath("~/PDFDoc/user.pdf"));
            Response.End();
        }
Example #5
0
        //---------------------------------
        // Buscar Persona para ser atendida
        //---------------------------------
        public DataTable Android_Get_Persona_by_nPerIdeTipo_cPerIdeNumero(Proforma Objeto)
        {
            DataTable dt = new DataTable();

            try
            {
                clsConection Obj    = new clsConection();
                string       Cadena = Obj.GetConexionString("Naylamp");

                using (SqlConnection cn = new SqlConnection(Cadena))
                {
                    cn.Open();

                    using (SqlCommand cm = new SqlCommand())
                    {
                        cm.CommandText = "[Android].[usp_Android_Get_Persona_by_nPerIdeTipo_cPerIdeNumero]";
                        cm.CommandType = CommandType.StoredProcedure;
                        cm.Parameters.AddWithValue("nPerIdeTipo", Objeto.nPerIdeTipo);
                        cm.Parameters.AddWithValue("cPerIdeNumero", Objeto.cPerIdeNumero);

                        cm.Connection = cn;

                        using (SqlDataReader dr = cm.ExecuteReader())
                            dt.Load(dr);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(dt);
        }
        public void AddProforma(Proforma proforma)
        {
            var newProforma = new Proforma();

            newProforma.ClienteId = proforma.ClienteId;

            // newVenta.Cliente = venta.Cliente;
            newProforma.Fecha = proforma.Fecha;
            newProforma.total = proforma.total;

            //newVenta.TipoDocumento = venta.TipoDocumento;

            foreach (var item in proforma.detalleproforma)
            {
                var detalle = new DetalleProforma();
                detalle.Cantidad   = item.Cantidad;
                detalle.ProductoId = item.ProductoId;

                detalle.Precio = item.Precio;
                //TIPO DOC

                newProforma.detalleproforma.Add(detalle);
            }


            _context.Proformas.Add(newProforma);
            _context.SaveChanges();
        }
Example #7
0
        public List <Proforma> GetAllProformas()
        {
            string consulta =
                " select pf.id," +
                " upper(concat(pf.anio, ' | ', tp.nombre, ' | ', tc.clave, ' | ', '(', e.desc_id, ')', e.nombre, ' | '," +
                "    un.descripcion, ' | ', '(', cc.desc_id, ')', cc.nombre)) as nombre_proforma," +
                " pf.anio," +
                " pf.modelo_negocio_id," +
                " pf.tipo_captura_id," +
                " pf.tipo_proforma_id," +
                " pf.centro_costo_id," +
                " pf.activo," +
                " pf.usuario," +
                " pf.fecha_captura," +
                " pf.fecha_actualizacion" +
                "    from proforma pf" +
                " join unidad_negocio un on pf.unidad_id = un.id" +
                " join empresa e on pf.empresa_id = e.id" +
                " inner join modelo_negocio mn on mn.id = pf.modelo_negocio_id" +
                " inner join centro_costo cc on cc.id = pf.centro_costo_id" +
                " inner join proyecto pr on pr.id = cc.proyecto_id" +
                " inner join tipo_proforma tp on pf.tipo_proforma_id = tp.id" +
                " join tipo_captura tc on tc.id = pf.tipo_captura_id" +
                " where pf.activo = 'true' order by pf.fecha_captura desc,pf.fecha_actualizacion desc";

            try
            {
                List <Proforma> lstProforma = new List <Proforma>();
                con.Open();

                NpgsqlCommand    cmd = new NpgsqlCommand(consulta.Trim(), con);
                NpgsqlDataReader rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    Proforma proforma = new Proforma();
                    proforma.id = Convert.ToInt64(rdr["id"]);
                    proforma.modelo_negocio_id = Convert.ToInt64(rdr["modelo_negocio_id"]);
                    proforma.tipo_captura_id   = Convert.ToInt64(rdr["tipo_captura_id"]);
                    proforma.tipo_proforma_id  = Convert.ToInt64(rdr["tipo_proforma_id"]);
                    proforma.centro_costo_id   = Convert.ToInt64(rdr["centro_costo_id"]);
                    proforma.activo            = Convert.ToBoolean(rdr["activo"]);
                    proforma.usuario           = Convert.ToInt64(rdr["usuario"]);
                    proforma.fecha_captura     = Convert.ToDateTime(rdr["fecha_captura"]);
                    if (rdr["fecha_actualizacion"] != DBNull.Value)
                    {
                        proforma.fecha_actualizacion = Convert.ToDateTime(rdr["fecha_actualizacion"]);
                    }

                    proforma.nombre_proforma = Convert.ToString(rdr["nombre_proforma"]);
                    lstProforma.Add(proforma);
                }

                return(lstProforma);
            }
            finally
            {
                con.Close();
            }
        }
Example #8
0
        public async Task <IActionResult> Add(int?id)
        {
            var userID = _userManager.GetUserName(User);

            if (userID == null)
            {
                ViewData["Message"] = "Por favor debe loguearse antes de agregar un producto";
                List <Producto> productos = new List <Producto>();
                return(View("Index", productos));
            }
            else
            {
                var producto = await _context.DataProductos.FindAsync(id);

                Proforma proforma = new Proforma();
                proforma.Producto = producto;
                proforma.Price    = producto.Price;
                proforma.Quantity = 1;
                proforma.UserID   = userID;
                _context.Add(proforma);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
        }
Example #9
0
        // Metodo para almacenar una proforma
        public int GuardaProforma(List <ProformaDetalle> detalles)
        {
            Proforma proforma  = new Proforma();
            DateTime fechaProc = DateTime.Now;

            proforma.activo            = true;
            proforma.anio              = detalles[0].anio;
            proforma.usuario           = detalles[0].usuario;
            proforma.modelo_negocio_id = detalles[0].modelo_negocio_id;
            proforma.tipo_proforma_id  = detalles[0].tipo_proforma_id;
            proforma.tipo_captura_id   = detalles[0].tipo_captura_id;
            proforma.centro_costo_id   = detalles[0].centro_costo_id;
            proforma.unidad_id         = detalles[0].unidad_id;
            proforma.empresa_id        = detalles[0].empresa_id;
            proforma.fecha_captura     = fechaProc;
            validadNoDuplicateProforms(proforma);
            _profHelper.setMotoRealesAndProform(detalles);
            AddProforma(proforma);
            detalles.ForEach(detalle =>
            {
                detalle.id_proforma = proforma.id;
                detalle.activo      = true;
                new ProformaDetalleDataAccessLayer().AddProformaDetalle(detalle);
            });

            return(0);
        }
 public List <Proforma> SelectAll(Proforma objekat)
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         List <Proforma> list = _broker.SelectAllJoin(objekat).OfType <Proforma>().ToList();
         _broker.Commit();
         return(list);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
Example #11
0
        /// <summary>
        /// Constructor
        /// </summary>
        public ConceptoProformaLibreAddForm(Form parent, Proforma Proforma, SerieInfo serie, ClienteInfo cliente)
            : base(parent, Proforma, serie, cliente)
        {
            InitializeComponent();

            // Va aquí porque si no peta en el padre porque _entity es nulo
            _entity.PropertyChanged += new PropertyChangedEventHandler(Entity_PropertyChanged);
        }
Example #12
0
        public Task <Planilla> ObtenerTrama(Trama trama)
        {
            Planilla planilla = new Planilla();
            Proforma proforma;

            planilla.ListaProforma = new List <Proforma>();

            List <OracleParameter> parameters  = new List <OracleParameter>();
            CultureInfo            cultureInfo = new CultureInfo("es-PE");

            parameters.Add(new OracleParameter("P_NIDBANK", OracleDbType.Int32, trama.IdBanco, ParameterDirection.Input));
            parameters.Add(new OracleParameter("P_NPRODUCT", OracleDbType.Int32, trama.IdProducto, ParameterDirection.Input));
            parameters.Add(new OracleParameter("P_DFECHAINI", OracleDbType.Date, DateTime.Parse(trama.FechaInicial, cultureInfo), ParameterDirection.Input));
            parameters.Add(new OracleParameter("P_DFECHAFIN", OracleDbType.Date, DateTime.Parse(trama.FechaFinal, cultureInfo), ParameterDirection.Input));
            parameters.Add(new OracleParameter("P_NUSERCODE", OracleDbType.Int32, trama.CodigoUsuario, ParameterDirection.Input));

            //Parámetro de Salida
            var pValid = new OracleParameter("P_NCODE", OracleDbType.Int32, ParameterDirection.Output);
            var pRuta  = new OracleParameter("P_SRUTA", OracleDbType.NVarchar2, ParameterDirection.Output);

            pRuta.Size = 2500;


            // var pRuta = new OracleParameter("P_SRUTA", OracleDbType.Varchar2,4000, ParameterDirection.Output);
            var pMensaje = new OracleParameter("P_SMESSAGE", OracleDbType.Varchar2, 4000, ParameterDirection.Output);

            parameters.Add(pRuta);
            parameters.Add(new OracleParameter("LISTA", OracleDbType.RefCursor, ParameterDirection.Output));
            parameters.Add(pValid);
            parameters.Add(pMensaje);

            using (OracleDataReader dr = (OracleDataReader)_connectionBase.ExecuteByStoredProcedure("PKG_SCTR_COBRANZAS.SPS_TRAMA_ENVIO_BANCO", parameters, ConnectionBase.enuTypeDataBase.OracleConciliacion))
            {
                while (dr.Read())
                {
                    proforma = new Proforma();
                    //  proforma.NumeroCuenta = dr["NRECEIPT"] == DBNull.Value ? string.Empty : dr["NRECEIPT"].ToString();
                    proforma.NombreContratante = dr["SCLIENAME"] == DBNull.Value ? string.Empty : dr["SCLIENAME"].ToString();
                    proforma.Documento         = dr["SIDDOC"] == DBNull.Value ? string.Empty : dr["SIDDOC"].ToString();
                    proforma.DescTipoDoc       = dr["DESC_TIPODOC"] == DBNull.Value ? string.Empty : dr["DESC_TIPODOC"].ToString();
                    proforma.CodigoProforma    = dr["SPROFORMA"] == DBNull.Value ? string.Empty : dr["SPROFORMA"].ToString();
                    proforma.NumeroRecibo      = dr["NRECEIPT"] == DBNull.Value ? string.Empty : dr["NRECEIPT"].ToString();
                    proforma.FechaEmision      = dr["FE_EMISION"] == DBNull.Value ? string.Empty : Convert.ToDateTime(dr["FE_EMISION"].ToString()).ToString("dd/MM/yyyy");
                    proforma.FechaVencimiento  = dr["FE_VENCIMIENTO"] == DBNull.Value ? string.Empty : Convert.ToDateTime(dr["FE_VENCIMIENTO"].ToString()).ToString("dd/MM/yyyy");
                    proforma.Importe           = dr["NPREMIUM"] == DBNull.Value ? "0.00" : Convert.ToDouble(dr["NPREMIUM"].ToString()).ToString("N2");
                    //  proforma.ImporteMora = dr["MORA"] == DBNull.Value ? "0.00" : Convert.ToDouble(dr["MORA"].ToString()).ToString("N2");
                    //  proforma.ImporteMontoMinimo = dr["MONTO_MINIMO"] == DBNull.Value ? "0.00" : Convert.ToDouble(dr["MONTO_MINIMO"].ToString()).ToString("N2");

                    planilla.ListaProforma.Add(proforma);
                }
                planilla.Resultado    = int.Parse(pValid.Value.ToString()) == 0 ? true : false;
                planilla.MensajeError = pMensaje.Value.ToString();
                planilla.RutaTrama    = pRuta.Value.ToString();
            }
            return(Task.FromResult <Planilla>(planilla));
        }
        public ConceptoProformaUIForm(Form parent, Proforma proforma, SerieInfo serie, ClienteInfo cliente)
            : base(true, parent)
        {
            InitializeComponent();

            _proforma = proforma;
            _serie    = serie;
            _cliente  = cliente;
            SetFormData();
        }
Example #14
0
        public async Task <IActionResult> Create([Bind("ID,UserID,Quantity,Price")] Proforma proforma)
        {
            if (ModelState.IsValid)
            {
                _context.Add(proforma);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(proforma));
        }
Example #15
0
 public int Agregar(Proforma proforma)
 {
     try
     {
         return(datProforma.Instancia.Agregar(proforma));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Example #16
0
 public IActionResult EditarProforma(Proforma p)
 {
     if (ModelState.IsValid)
     {
         var proforma = _context.DataProforma.Find(p.Id);
         proforma.Cantidad = p.Cantidad;
         proforma.SubTotal = p.Cantidad * proforma.Precio;
         _context.SaveChanges();
         return(RedirectToAction("Proforma"));
     }
     return(View(p));
 }
        public ConceptoProformaLibreEditForm(Form parent, Proforma proforma, SerieInfo serie, ClienteInfo cliente, ConceptoProforma concepto)
            : base(parent, proforma, serie, cliente)
        {
            InitializeComponent();

            _entity = concepto;

            RefreshMainData();

            // Va aquí porque si no peta en el padre porque _entity es nulo
            _entity.PropertyChanged += new PropertyChangedEventHandler(Entity_PropertyChanged);
        }
Example #18
0
        public async Task <IActionResult> Create([Bind("ID,UserID,Price,ProductoID")] Proforma proforma)
        {
            if (ModelState.IsValid)
            {
                _context.Add(proforma);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductoID"] = new SelectList(_context.Producto, "ID", "ID", proforma.ProductoID);
            return(View(proforma));
        }
        public ConceptoProformaAddForm(Form parent, Proforma proforma, SerieInfo serie, ClienteInfo cliente)
            : base(parent, proforma, serie, cliente)
        {
            InitializeComponent();

            this.MdiParent = parent;

            this.Text = Resources.Labels.CONCEPTO_NEW_TITLE;

            // Va aquí porque si no peta en el padre porque _entity es nulo
            _entity.PropertyChanged += new PropertyChangedEventHandler(Entity_PropertyChanged);
        }
Example #20
0
 public List <ProformaDetalle> GetProforma([FromBody] Proforma proforma)
 {
     try
     {
         return(new ProformaHelper().getAjustes(proforma.centro_costo_id, proforma.anio,
                                                proforma.tipo_captura_id));
     }
     catch (Exception e)
     {
         logger.Error(e, "error en ajustes");
         throw e;
     }
 }
Example #21
0
 public Dictionary <string, double> getFactoresTipoCambioGia([FromBody] Proforma proforma)
 {
     try
     {
         return(new TipoCambioHelper().getTiposCambio(proforma.centro_costo_id, proforma.anio,
                                                      proforma.tipo_captura_id));
     }
     catch (Exception e)
     {
         logger.Error(e, "error en tipoCambio");
         throw e;
     }
 }
 public ActionResult Delete(int id, Proforma objekat)
 {
     try
     {
         return(RedirectToAction(nameof(Index), "Proforma"));
     }
     catch (Exception ex)
     {
         return(View("Error", new Error()
         {
             Greska = ex.Message
         }));
     }
 }
        public void BindProforma(Proforma proforma)
        {
            proforma.total = proforma.detalleproforma.Sum(i => i.Monto);
            lvDetalleProforma.DataSource = proforma.detalleproforma;
            lvProformas.DataBind();
            lvDetalleProforma.DataBind();

            if (proforma.detalleproforma.Count > 0)
            {
                var lblTotal = lvDetalleProforma.FindControl("lblTotalproforma") as Label;
                lblTotal.Text = proforma.total.ToString();
            }
            Cache.Insert(KEYPROFORMA, proforma);
        }
Example #24
0
        public ConceptoProformaEditForm(Form parent, Proforma proforma, SerieInfo serie, ClienteInfo cliente, ConceptoProforma concepto)
            : base(parent, proforma, serie, cliente)
        {
            InitializeComponent();

            this.Text = Resources.Labels.CONCEPTO_EDIT_TITLE;

            _entity = concepto;

            RefreshMainData();

            // Va aquí porque si no peta en el padre porque _entity es nulo
            _entity.PropertyChanged += new PropertyChangedEventHandler(Entity_PropertyChanged);
        }
 public ActionResult Edit(int id, Proforma objekat)
 {
     try
     {
         _logic.UpdateObject(objekat);
         return(RedirectToAction(nameof(Index), "Proforma"));
     }
     catch (Exception ex)
     {
         return(View("Error", new Error()
         {
             Greska = ex.Message
         }));
     }
 }
Example #26
0
 public JsonResult SaveProforma(int req, int patientId, string productIds)
 {
     try
     {
         var usr         = (Pharmacies)Session["user"];
         var product_ids = productIds.Split(',').ToList();
         var details     = new List <ProformaDetails>();
         var request     = client.GetRequestById(req);
         foreach (var s in _proforma)
         {
             details.Add(new ProformaDetails
             {
                 Product    = s.Product,
                 Unit       = s.Unit,
                 UnitPrice  = s.UnitPrice,
                 Quantity   = s.Quantity,
                 ProductId  = s.ProductId,
                 Equivalent = s.Equivalent
             });
         }
         Instant now    = SystemClock.Instance.GetCurrentInstant();
         var     utcNow = now.InZone(DateTimeZoneProviders.Tzdb[usr.TimeZone]).ToDateTimeUtc();
         var     profo  = new Proforma
         {
             Amount       = details.Sum(x => (x.UnitPrice * x.Quantity)),
             Currency     = usr.Currency, // la proforma est faite sen la devise de la pharmacie.
             PatientId    = patientId,
             PharmacyId   = usr.Id,
             OrdonnanceId = request.OrdonnanceId,
             DateCreated  = utcNow,
             Status       = 0
         };
         client.CreateProforma(profo, details.ToArray());
         _proforma = null;
         return(Json(new { success = true }));
     }
     catch (FaultException ex)
     {
         return(Json(new { success = false, message = ex.Message }));
     }
     catch (Exception ex)
     {
         return(Json(new { success = false, message = ex.Message }));
     }
 }
 public bool UpdateObject(Proforma objekat)
 {
     try
     {
         _broker.OpenConnection();
         _broker.BeginTransaction();
         Proforma fromDb = _broker.SelectObjectJoin(objekat) as Proforma;
         if (fromDb.UkupnaCena != objekat.UkupnaCena)
         {
             if (!_broker.UpdateSpecific(objekat, $" UkupnaCena={objekat.UkupnaCena}"))
             {
                 throw new Exception();
             }
         }
         else if (objekat.Popust == null)
         {
             if (!_broker.UpdateSpecific(objekat, $"Datum='{objekat.Datum}',SifraZaposlenog={objekat.Zaposleni.Id},SifraPorudzbine={objekat.Porudzbina.Id},SifraBanke={objekat.Racun.Banka.Id},SifraRacuna={objekat.Racun.Id},SifraIsporuke={objekat.NacinIsporuke.Id}"))
             {
                 throw new Exception();
             }
         }
         else if (!_broker.UpdateObject(objekat))
         {
             throw new Exception();
         }
         _broker.Commit();
         return(true);
     }
     catch (SqlException ex)
     {
         Debug.Write(">>>>>>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(">>>> " + ex.Message);
         _broker.Rollback();
         throw new Exception(ex.Message);
     }
     finally
     {
         _broker.CloseConnection();
     }
 }
Example #28
0
        public async Task <HttpResponseMessage> PostAsync([FromBody] Proforma proforma)
        {
            var transaccion = db.Database.BeginTransaction();

            try
            {
                EncProforma Consulta = db.EncProforma.Where(a => a.NumProforma == proforma.encProforma.NumProforma).FirstOrDefault();

                if (Consulta == null)
                {
                    proforma.encProforma.FecFactura = DateTime.Now;

                    db.EncProforma.Add(proforma.encProforma);

                    await db.SaveChangesAsync();

                    foreach (var det in proforma.detProforma)
                    {
                        det.NumProforma = proforma.encProforma.NumProforma;
                        det.Nompro      = det.Nompro; //db.Productos.Where(a => a.Codpro == det.Codpro).Select(u => u.Nompro).FirstOrDefault();
                        db.DetProforma.Add(det);
                        db.SaveChanges();
                    }
                    transaccion.Commit();

                    resp = new
                    {
                        Success = true
                    };

                    return(Request.CreateResponse(HttpStatusCode.OK, resp));
                }
                else
                {
                    throw new Exception("Producto ya existe");
                }
            }
            catch (Exception ex)
            {
                transaccion.Rollback();
                // EncuestasRegistroController.GuardarBitacoraTxt(ex.Message);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Example #29
0
        //-------------------
        // INSERT Proforma
        //-------------------
        public bool Android_Insert_Proforma(Proforma Objeto)
        {
            bool exito = false;

            try
            {
                clsConection Obj = new clsConection();
                //string Cadena = Obj.GetConexionString("Naylamp");
                string Cadena = "Server=10.0.0.10\\SRVDATOSMED; DataBase = BDDatos; Uid = android; Pwd =C2879442C28147B;Integrated Security=False; Pooling = False";

                using (SqlConnection cn = new SqlConnection(Cadena))
                {
                    cn.Open();

                    using (SqlCommand cm = new SqlCommand())
                    {
                        cm.CommandText = "[Android].[usp_Android_Insert_Proforma]";
                        cm.CommandType = CommandType.StoredProcedure;
                        cm.Parameters.AddWithValue("nCorrelativo", Objeto.nCorrelativo);
                        cm.Parameters.AddWithValue("nPerIdeTipo", Objeto.nPerIdeTipo);
                        cm.Parameters.AddWithValue("cPerIdeNumero", Objeto.cPerIdeNumero);
                        cm.Parameters.AddWithValue("ListMuestras", Objeto.ListMuestras);
                        //cm.Parameters.AddWithValue("nIntJerarquia", Objeto.nIntJerarquia);
                        //cm.Parameters.AddWithValue("nPrecio", Objeto.nPrecio);
                        cm.Connection = cn;

                        if (cm.ExecuteNonQuery() > 0)
                        {
                            exito = true;
                        }
                        else
                        {
                            throw new ApplicationException("se ha producido un error procedimiento almacenado: [Android].[usp_Android_Insert_Proforma]; Consulte al administrador del sistema");
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(exito);
        }
Example #30
0
        public void validadNoDuplicateProforms(Proforma proforma)
        {
            var res = _queryExecuter.ExecuteQueryUniqueresult(
                "select count(1) as numexist " +
                " from proforma where activo=true " +
                " and anio=@anio and tipo_proforma_id=@tipo_proforma_id " +
                " and tipo_captura_id=@tipo_captura_id and empresa_id=@empresa_id  " +
                " and centro_costo_id=@centro_costo_id",
                new NpgsqlParameter("@anio", proforma.anio),
                new NpgsqlParameter("@tipo_proforma_id", proforma.tipo_proforma_id),
                new NpgsqlParameter("@tipo_captura_id", proforma.tipo_captura_id),
                new NpgsqlParameter("@empresa_id", proforma.empresa_id),
                new NpgsqlParameter("@centro_costo_id", proforma.centro_costo_id));

            if (Convert.ToInt16(res["numexist"]) > 0)
            {
                throw new DataException("Ya existe la proforma, si desea modificarla, vaya al menu, consultela y editela  ");
            }
        }