示例#1
0
        public int updateCost(Batch batch)
        {
            SSGetService getService = new SSGetService();
            SSAddService addService = new SSAddService();

            Batch existingBatch = getService.getBatchByName(batch.name);

            if (existingBatch.name != null)
            {
                using (SqlCommand command = new SqlCommand("UPDATE ss_stocks SET cost=@cost WHERE bid=" + existingBatch.id + ""))
                {
                    command.Parameters.AddWithValue("@cost", batch.cost);
                    int response = service.execute(command);
                    if (response > 0)
                    {
                        addService.addLog(new Log()
                        {
                            type        = "Updated Cost",
                            statement   = command.CommandText,
                            description = "Updated [" + existingBatch.id + "] Batch",
                        });
                    }
                    return(response);
                }
            }
            else
            {
                return(-404);
            }
        }