예제 #1
0
        // POST: api/MuestrasObservaciones
        public Respuesta Post([FromBody] MuestraObs value)
        {
            Respuesta resp = new Respuesta()
            {
                Error = false, Msg = ""
            };

            string WObservacion = value.Observacion.ToString();

            try
            {
                if (WObservacion.Length > 200)
                {
                    WObservacion = WObservacion.Substring(0, 200);
                }

                using (SqlConnection cn = new SqlConnection("workstation id=SurfactanSa.mssql.somee.com;packet size=4096;user id=fergthh_SQLLogin_1;pwd=nppge4uooo;data source=SurfactanSa.mssql.somee.com;persist security info=False;initial catalog=SurfactanSa"))
                {
                    cn.ConnectionString = ConfigurationManager.AppSettings["CS"];
                    cn.Open();

                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = cn;
                        cmd.CommandText = "SELECT Clave FROM MuestrasObservaciones WHERE Pedido = '" + value.Pedido + "' AND Producto = '" + value.Producto + "'";

                        using (SqlDataReader dr = cmd.ExecuteReader())
                        {
                            if (dr.HasRows)
                            {
                                cmd.CommandText = "UPDATE MuestrasObservaciones SET Observacion = '" + WObservacion + "' WHERE Pedido = '" + value.Pedido + "' AND Producto = '" + value.Producto + "'";
                            }
                            else
                            {
                                string WClave = value.Pedido.ToString() + value.Producto.ToString().Trim();

                                cmd.CommandText = "INSERT INTO MuestrasObservaciones (Clave, Pedido, Observacion, Producto) VALUES ('" + WClave + "', '" + value.Pedido + "', '" + WObservacion + "', '" + value.Producto + "')";
                            }

                            if (!dr.IsClosed)
                            {
                                dr.Close();
                            }

                            cmd.ExecuteNonQuery();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                resp.Error = true;
                resp.Msg   = ex.Message;
            }

            return(resp);
        }
예제 #2
0
        // GET: api/MuestrasObservaciones/Pedido/Producto
        public MuestraObs Get(string param, string param2)
        {
            MuestraObs m = new MuestraObs()
            {
                Producto = "", Observacion = "", Pedido = 0
            };

            try
            {
                using (SqlConnection cn = new SqlConnection("workstation id=SurfactanSa.mssql.somee.com;packet size=4096;user id=fergthh_SQLLogin_1;pwd=nppge4uooo;data source=SurfactanSa.mssql.somee.com;persist security info=False;initial catalog=SurfactanSa"))
                {
                    cn.ConnectionString = ConfigurationManager.AppSettings["CS"];
                    cn.Open();

                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = cn;
                        cmd.CommandText = "SELECT Pedido, Observacion, Producto FROM MuestrasObservaciones WHERE Pedido = '" + param + "' AND Producto = '" + param2 + "'";

                        using (SqlDataReader dr = cmd.ExecuteReader())
                        {
                            if (dr.HasRows)
                            {
                                dr.Read();

                                m.Pedido      = int.Parse(dr["Pedido"].ToString());
                                m.Observacion = dr["Observacion"].ToString();
                                m.Producto    = dr["Producto"].ToString();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(m);
        }
예제 #3
0
 // POST: api/Muestras
 public void Post(MuestraObs value)
 {
 }