public async Task <ActionResult <StockColor> > PostStockColor(StockColor stockColor) { _context.StockColors.Add(stockColor); await _context.SaveChangesAsync(); return(CreatedAtAction("GetStockColors", new { id = stockColor.Id }, stockColor)); }
public void InsertIntoDataBase(IEnumerable <CreateProductsModel> list) { var repository = new ProductsRepository(); foreach (var item in list) { var productlist = new Products(); productlist.Category = item.Category; productlist.ProductName = item.ProductName; productlist.UnitPrice = item.Price; var _productID = repository.CreateProductDetail(productlist); var sizelist = new Size(); //productID sizelist.SizeType = item.Size; sizelist.ProductID = _productID; var _sizeID = repository.CreateProductSize(sizelist); var StockColor = new StockColor(); StockColor.Color = item.Color; StockColor.Stock = item.Stock; StockColor.SizeID = _sizeID; repository.CreateStockColor(StockColor); } }
//新增顏色、存貨 public bool CreateStockColor(StockColor model) { SqlConnection connection = new SqlConnection(source.connectcloud); connection.Execute("INSERT INTO StockColor(SizeID , Color , Stock) Values(@SizeID , @Color , @Stock)", new { model.SizeID, model.Color, model.Stock }); var result = connection.Query("SELECT SizeID ,Color ,Stock From StockColor Where SizeID = @SizeID and Color = @Color and Stock = @Stock ", new { model.SizeID, model.Color, model.Stock }); if (result.Count() > 0) { return(true); } else { return(false); } }
public void Delete(StockColor model) { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "Delete FROM Products WHERE ColorID = @colorid"; SqlCommand command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@colorid", model.ColorID); connection.Open(); command.ExecuteNonQuery(); connection.Close(); }
public void Update(StockColor model) { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "UPDATE StockColor SET ColorID = @colorid, SizeID=@sizeid, Color=@color,Stock=@stock"; SqlCommand command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@colorid", model.ColorID); command.Parameters.AddWithValue("@sizeid", model.SizeID); command.Parameters.AddWithValue("@color", model.Color); command.Parameters.AddWithValue("@stock", model.Stock); connection.Open(); command.ExecuteNonQuery(); connection.Close(); }
public void Create(StockColor model) { SqlConnection connection = new SqlConnection(source.connectcloud); var sql = "INSERT INTO StockColor VALUES (@colorid, @sizeid,@color,@stock)"; SqlCommand command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@colorid", model.ColorID); command.Parameters.AddWithValue("@sizeid", model.SizeID); command.Parameters.AddWithValue("@color", model.Color); command.Parameters.AddWithValue("@stock", model.Stock); connection.Open(); command.ExecuteNonQuery(); connection.Close(); }
private void UpdateStatus(string text, StockColor color = StockColor.Disabled) { switch (color) { case StockColor.Green: labelForStatus.ForeColor = Color.FromArgb(0, 255, 0); break; case StockColor.Red: labelForStatus.ForeColor = Color.Red; break; case StockColor.Disabled: labelForStatus.ForeColor = Color.White; labelForStatus.Tag = null; break; } labelForStatus.Text = text; }
private void UpdateStatus(string text, StockColor color = StockColor.Disabled) { switch (color) { case StockColor.Green: //labelForStatus.ForeColor = Color.FromArgb(128, 0, 0xCC, 0x99); labelForStatus.ForeColor = Color.White; break; case StockColor.Red: //labelForStatus.ForeColor = Color.FromArgb(128, 0xcc, 0x33, 0); labelForStatus.ForeColor = Color.White; break; case StockColor.Disabled: labelForStatus.ForeColor = Color.White; labelForStatus.Tag = null; break; } labelForStatus.Text = text; }