コード例 #1
0
 public static int InsertProduct(Product p , IEnumerable<Claim> claims)
 {
     string sql = "INSERT INTO Product VALUES(@ProductName,@Price)";
     DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@ProductName", p.ProductName);
     DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@Price", p.Price);
     return Database.InsertData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2);
 }
コード例 #2
0
        public HttpResponseMessage Put(Product pr)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;
            ProductsDA.UpdateProduct(pr, p.Claims);

            return new HttpResponseMessage(HttpStatusCode.OK);
        }
コード例 #3
0
 public static int UpdateProduct(Product p, IEnumerable<Claim> claims)
 {
     string sql = "UPDATE Product SET ProductName=@ProductName, Price=@Price WHERE ID=@ID";
     DbParameter par1 = Database.AddParameter(Database.ADMIN_DB, "@ProductName", p.ProductName);
     DbParameter par2 = Database.AddParameter(Database.ADMIN_DB, "@Price", p.Price);
     DbParameter par3 = Database.AddParameter(Database.ADMIN_DB, "@ID", p.ID);
     return Database.ModifyData(Database.GetConnection(CreateConnectionString(claims)), sql, par1, par2, par3);
 }
コード例 #4
0
        public HttpResponseMessage Post(Product pr)
        {
            ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal;
            int id = ProductsDA.InsertProduct(pr, p.Claims);

            HttpResponseMessage message = new HttpResponseMessage(HttpStatusCode.OK);
            message.Content = new StringContent(id.ToString());
            return message;
        }
コード例 #5
0
 public static List<Sale> GetSalesByProductID(Product p, IEnumerable<Claim> claims)
 {
     List<Sale> list = new List<Sale>();
     string sql = "SELECT * FROM Sale WHERE ProductID=@ID";
     DbParameter parID = Database.AddParameter(Database.ADMIN_DB, "@ID", p.ID);
     DbDataReader reader = Database.GetData(Database.GetConnection(CreateConnectionString(claims)), sql, parID);
     while (reader.Read())
     {
         list.Add(Create(reader));
     }
     reader.Close();
     return list;
 }
コード例 #6
0
 public static List<Sale> GetSalesByCustRegProdID(Customer c, Register r, Product p, IEnumerable<Claim> claims)
 {
     List<Sale> list = new List<Sale>();
     string sql = "SELECT * FROM Sale WHERE CustomerID=@CID And RegisterID=@RID And ProductID=@PID";
     DbParameter parCID = Database.AddParameter(Database.ADMIN_DB, "@CID", c.ID);
     DbParameter parRID = Database.AddParameter(Database.ADMIN_DB, "@RID", r.ID);
     DbParameter parPID = Database.AddParameter(Database.ADMIN_DB, "@PID", p.ID);
     DbDataReader reader = Database.GetData(Database.GetConnection(CreateConnectionString(claims)), sql, parCID, parRID, parPID);
     while (reader.Read())
     {
         list.Add(Create(reader));
     }
     reader.Close();
     return list;
 }
コード例 #7
0
 private void NewProduct()
 {
     Product p = new Product();
     Products.Add(p);
     SelectedProduct = p;
 }